参数类型“对象?”不能分配给参数类型“Iterable<dynamic>”

时间:2021-06-15 18:24:01

标签: flutter sqlite

          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));

1 个答案:

答案 0 :(得分:0)

您是否尝试将 snapshot.data 转换为 Iterable<dynamic> 类型?

return generateList(List<Employee>.from(snapshot.data as Iterable<dynamic>));