I try to load specific data from my Sembast database to the view on init and add it to an existing list. Why this code does not work?
The data exists, but could it be that my code will never called? I´ve edited the code with print. print("3") does not fire.
bool _checkConfiguration() => true;
@override
void initState() {
_currentDate = widget._currentDate;
_markedDateMap = widget._markedDateMap;
if (_checkConfiguration()) {
print("1"); // FIRES
Future.delayed(Duration(seconds: 2), () {
final calendarEntriesDataInitial =
Provider.of<CalendarEntries>(context, listen: false);
print("2"); // FIRES
FutureBuilder<List<CalendarEntry>>(
future: calendarEntriesDataInitial.getAll(),
builder: (BuildContext context,
AsyncSnapshot<List<CalendarEntry>> snapshot) {
print("3"); // NOT FIRES. HERE´S A PROBLEM!
if (snapshot.hasData &&
snapshot.connectionState != ConnectionState.waiting) {
for (final entry in snapshot.data) {
setState(() {
_markedDateMap.add(
new DateTime(entry.dateTime),
new Event(
date: new DateTime(entry.dateTime),
title: 'Event 5',
icon: _eventIcon,
));
});
}
}
});
});
}
super.initState();
}