[英]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.