Help is deeply appreciated as I have been trying to solve this problem for a couple of days now but still unable to figure out the problem.
All the code below use to work perfectly, until recently, the list stops updating like it use to until I hot restart it.
The below two functions are getting my map list and my note list respectively
Future<List<Map<String, dynamic>>> getNoteListMap() async {
Database db = await this.database;
var result = await db.query(noteTable);
return result;
}
Future<List<Note>> getNoteList() async {
var noteMapList = await getNoteListMap();
int count = noteMapList.length;
//list of notes, each note consist of their own independent variables
List<Note> noteList = new List<Note>();
for (int i = 0; i < count; i++) {
noteList.add(Note.fromMapObject(noteMapList[i]));
}
return noteList;
}
This is my main function , which creates a list using FutureBuilder. However the list doesnt get updates, and only does after I hot restart everytime.
FutureBuilder<List<Note>>(
future: _databaseHelper.getNoteList(),
builder: (BuildContext context, AsyncSnapshot<List<Note>> snapshot) {
if (snapshot.hasData) {
return ListView.builder(
physics: TargetPlatform.iOS!=null? BouncingScrollPhysics() : ClampingScrollPhysics(),
itemCount: snapshot.data.length,
itemBuilder: (BuildContext context, int position) {
Note note = snapshot.data[position];
return Card(
color: Colors.white,
elevation: 2.0,
child: new ListTile(
title: new Text(note.title?? ''),
subtitle: new Text(note.bodyText ?? ''),
onTap: () => _navigateToTaskByDatePage(date),
),
);
}
);
} else if (snapshot.hasError) {
return Container(
child: Center(
child: new Text('Error: ${snapshot.error}'),
),
);
} else {
return Container(
width: 0,
height: 0,
);
}
},
),