[英]add 3 text in ListTile, change background color for each column, and add search in this list
请问如何在下面的列表视图中添加搜索如果可以,是否可以在我的 ListTile 中添加 3 个文本,我该怎么做。 以及如何在我的列表中更改背景 colors 一次蓝色和第二次绿色等......谢谢您的帮助
body: StreamBuilder<List>(
stream: _streamController.stream,
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.hasData)
return ListView(
children: [
for (Map document in snapshot.data)
Card(
elevation: 10.6,
color: Colors.blue,
child: new ListTile(
title: Text(document['title1'], textScaleFactor: 1.2, style: TextStyle(color:Colors.white),),
subtitle: Text(document['title2'], textScaleFactor: 1.2, style: TextStyle(color:Colors.white),),
leading: new IconButton(
icon: Icon(Icons.headset, color: Colors.white),
onPressed: () {
//***//
},
),
),
),
],
);
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CircularProgressIndicator()
],
),
);
},
),
要开始在 ListView 中搜索,您可以查看: https://blog.usejournal.com/flutter-search-in-listview-1ffa40956685
或使用SearchDelegate
https://api.flutter.dev/flutter/material/SearchDelegate-class.html
ListTiles 只是将小部件作为前导、标题、副标题和尾随。 所以你可以放任何你想要的东西!
ListTile(
title: Column(
children: [
Text('abc'),
Text('def'),
//etc,
],
),
subtitle: Column(
children: [
Text('123'),
Text('456'),
//etc,
],
),
),
Listview.builder
。 它使用一个IndexWidgetBuilder
提供一个索引,您可以使用索引来检查它是否均匀或不均匀以设置首选颜色。 https://api.flutter.dev/flutter/widgets/ListView/ListView.builder.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.