Expanded(
child: FutureBuilder(
future: employees,
builder: (context, snapshot) {
if (snapshot.hasData) {
return generateList(List<Employee>.from(snapshot.data));
}
if (snapshot.data == null || !snapshot.hasData) {
return Text('No Employee Found');
}
return CircularProgressIndicator();
},
),
),
],
),
);
}
SingleChildScrollView generateList(List<Employee> employees) {
return SingleChildScrollView(
scrollDirection: Axis.vertical,
child: SizedBox(
width: MediaQuery.of(context).size.width,
child: DataTable(
columns: [
DataColumn(
出现错误返回 generateList(snapshot.data); ********************************** 如果更改为返回 generateList(List.from(snapshot.data));
答案 0 :(得分:0)
您是否尝试将 snapshot.data
转换为 Iterable<dynamic>
类型?
return generateList(List<Employee>.from(snapshot.data as Iterable<dynamic>));