futurebuilder 在颤振中没有实例

时间:2021-01-12 13:51:50

标签: linux flutter flutter-futurebuilder

body: FutureBuilder(
    future: taskList,
    builder: (context, snapshot) {
      if (!snapshot.hasData) {
        return Center(
          child: CircularProgressIndicator(),
        );
      }

      final int completedTaskCount = snapshot.data
          .where((Task task) => task.status == 1)
          .toList()
          .length;
      return ListView.builder(
          padding: EdgeInsets.symmetric(vertical: 50.0),
          itemCount: 1 + snapshot.data.length,
          itemBuilder: (BuildContext context, int index) {
            if (index == 0) {
              return Padding(
                padding: const EdgeInsets.symmetric(
                    horizontal: 40.0, vertical: 20.0),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      'My Tasks',
                      style: TextStyle(
                          color: Colors.black,
                          fontSize: 40,
                          fontWeight: FontWeight.bold),
                    ),
                    SizedBox(
                      height: 10,
                    ),
                    Text(
                      '$completedTaskCount of ${snapshot.data.length}',
                      style: TextStyle(
                          color: Colors.grey,
                          fontSize: 20,
                          fontWeight: FontWeight.w600),
                    ),
                  ],
                ),
              );
            }
            return _buildTask(snapshot.data(index - 1));
          });
    },
  ),

这是我得到的错误:

Class 'List<Task>' has no instance method 'call'.
Receiver: Instance(length:2) of '_GrowableList'
Tried calling: call(0)

0 个答案:

没有答案