我正在嘗試通過迭代串列來創建 ListView,但出現此錯誤:
package:flutter/src/material/list_tile.dart': 失敗的斷言: line 1002 pos 12: 'color != null || 背景關系 != null': 不是真的。
我該如何解決這個問題?這是我的代碼:
ListView(
children: ListTile.divideTiles(
tiles: _people.map((item) => ListTile(
leading: CircleAvatar(
backgroundColor: Colors.amber,
child: Text(item['id'].toString()),
),
title: Text(item['name']),
subtitle: Text(item['descrip']),
trailing: IconButton(
icon: Icon(Icons.delete),
onPressed: () {},
),
))).toList()));
uj5u.com熱心網友回復:
正如上面的答案所指出的,您不能將兩個引數都保留為空
ListView(
children: ListTile.divideTiles(
color: Colors.red,
context: context,
tiles: _people.map(
(item) => ListTile(
leading: CircleAvatar(
backgroundColor: Colors.amber,
child: Text(item['id'].toString()),
),
title: Text(item['name']),
subtitle: Text(item['descrip']),
trailing: IconButton(
icon: Icon(Icons.delete),
onPressed: () {},
),
),
),
).toList())
這必須作業
uj5u.com熱心網友回復:
ListTile.divideTiles 需要顏色引數:

在 中指定顏色ListTile.divideTiles,你會沒事的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/374042.html
