0
Good morning, I am updating to sqlite with Flutter and am having the following error:
NoSuchMethodError: The method 'update' was called on null.
I built the code according to the documentation where I receive a Model and make a map of the appropriate fields.
Future<void> updateCategoria(CategoriasModel categoriasModels) async {
try {
await db.update('categoria', categoriasModels.toMap(),
where: "id = ?", whereArgs: [categoriasModels.id]);
} catch (error) {
print(error.toString());
}
}
and the model:
class CategoriasModel with ChangeNotifier {
final int id;
final String descricao;
final int isReceita;
CategoriasModel({
this.id,
this.descricao,
this.isReceita,
});
Map<String, dynamic> toMap() {
return {'id': id, 'descricao': descricao, 'isReceita': isReceita};
}
}
other CRUD function are working normally.
By the message the error is in your database instance. At what point do you initialize it? It is null and calling the method "update".
– Leonardo Paim
I really forgot to boot. Thanks my friend.
– Ronaldo Lopes
I will post as reply to leave registered for other dev’s
– Leonardo Paim