So i have a problem with the futurebuilder. first here is my code:
FutureBuilder(
future: DBProvider.db.getAllTasks(),
builder:(BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.connectionState ==
ConnectionState.waiting) {
return Center(
child: Text("Loading..."),
);
} else if (snapshot.hasData) {
print(snapshot.data);
return Column(
children: List.generate(snapshot.data.length,
(index) {
return Text(snapshot.data[index].title); // the problem is here
}),
);
} else {
return Center(
child: CircularProgressIndicator());
}
}),
I fetch data with DBProvider.db.getAllTasks() that will return a list, then i use the builder to render this data, the snapshot.data is not equal to null because when i printed the snapshot.data it shows that there is an instance of each item in the list. The problem is when i try to display the list, it gives me this error: A non-null String must be provided to a Text widget. 'package:flutter/src/widgets/text.dart': Failed assertion: line 360 pos 10: 'data != null'
and this error is because of the text widget. How can i resolve this problem ? Thanks in advance.