Problem: The method 'query' can't be unconditionally invoked because the receiver can be 'null'.
1 - I already checked that the _database is not null. How do I get around this?
2 - I'm not sure how to add my returned Rung object to mylist.
Future<Object?> get database async {
if (_database != null) {
dev.log('1 My db is NOT null: $_database', name: 'db_helper.dart');
final List<Map<String, dynamic>> maps = await _database.query('dbtable');
return List.generate(maps.length, (i) {
return Rung(
rungId: maps[i]['colId'],
name: maps[i]['colTask'] ?? 'unknown',
done: maps[i]['colDone'] ?? 'false',
boldTitle: maps[i]['colBold'] ?? 'false',
info: maps[i]['colInfo'] ?? '',
);
});
// Rung rung = Rung(rungId: colId, name: colTask, done: colDone.toLowerCase()=='true', boldTitle: colBold.toLowerCase()=='true', info: colInfo);
//Rung.myList.add(rung);