flutter 如何在listview中获取文本下的一行

fdx2calv  于 2023-04-22  发布在  Flutter
关注(0)|答案(1)|浏览(138)

enter image description here
像这样的东西
SizedBox(高度:30,child:Row(children:[展开(子:填充(填充:const EdgeInsets.only(top:13,左:25),孩子:ListView(scrollDirection:轴水平,子项:[墨水池(onTap:(){},子项:const Text('Arts',style:文本样式(颜色:Color.fromARGB(255,151,151,151)),),),const SizedBox(width:10)、InkWell(onTap:(){},子项:const Text('Biography',style:文本样式(颜色:Color.fromARGB(255,151,151,151)),),),const SizedBox(width:10)、InkWell(onTap:(){},子项:const Text('Romance',style:文本样式(颜色:Color.fromARGB(255,151,151,151)),),),const SizedBox(width:10)、InkWell(onTap:(){},子项:const Text(“Thriller”,style:文本样式(颜色:Color.fromARGB(255,151,151,151)),),),const SizedBox(width:10)、InkWell(onTap:(){},子项:const Text(“Fiction”,style:文本样式(颜色:Color.fromARGB(255,151,151,151)),),),const SizedBox(width:10)、InkWell(onTap:(){},子项:const Text(“Crime”,style:文本样式(颜色:Color.fromARGB(255,151,151,151)),),),const SizedBox(width:10)、InkWell(onTap:(){},子项:const Text(“Movies”,style:文本样式(颜色:Color.fromARGB(255,151,151,151)),),),const SizedBox(width:10)、InkWell(onTap:(){},子项:const Text(“Religious”,style:文本样式(颜色:Color.fromARGB(255,151,151,151)),),),const SizedBox(width:10)、InkWell(onTap:(){},子项:const Text(“Philosophy”,style:文本样式(颜色:Color.fromARGB(255,151,151,151),),),),),),),),),),),),

yduiuuwa

yduiuuwa1#

使用TabBar代替

import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  static const String _title = 'Flutter Code Sample';

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: _title,
      home: MyStatelessWidget(),
    );
  }
}

class MyStatelessWidget extends StatelessWidget {
  const MyStatelessWidget({super.key});

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      initialIndex: 1,
      length: 3,
      child: Scaffold(
        appBar: AppBar(
          title: const Text('TabBar Widget'),
          bottom: const TabBar(
            tabs: <Widget>[
              Tab(
                
                text: 'Tab 1'
              ),
              Tab(
                text: 'Tab 2'
              ),
              Tab(
                 text: 'Tab 3',
              ),
            ],
          ),
        ),
        body: const TabBarView(
          children: <Widget>[
            Center(
              child: Text("It's cloudy here"),
            ),
            Center(
              child: Text("It's rainy here"),
            ),
            Center(
              child: Text("It's sunny here"),
            ),
          ],
        ),
      ),
    );
  }
}

相关问题