Estou com o seguinte erro: [VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: DatabaseException(Error Domain=FMDatabase Code=1 "no such table: contacts" UserInfo={NSLocalizedDescription=no such table: contacts}) sql 'INSERT INTO contacts (id, tarefas) VALUES (?, ?)' args [0, rafa]}
main:
void main() {
runApp(MyApp());
save(Tarefas(0, 'rafa')).then((id) {
findAll().then((tarefas) => debugPrint(tarefas.toString()));
});
}
classe:
class Tarefas{
final int id;
final String tarefa;
Tarefas(this.id, this.tarefa);
@override
String toString(){
return tarefa;
}
}
database:
import 'package:mkneumorphicflutter/models/Tarefas.dart';
import 'package:path/path.dart';
import 'package:sqflite/sqflite.dart';
Future<Database> createDatabase(){
return getDatabasesPath().then((dbPath) {
final String path = join(dbPath, 'markTime.db');
// deleteDatabase(path);
return openDatabase(path, onCreate: (db, version){
db.execute('CREATE TABLE contacts('
'id INTEGER PRIMARY KEY, '
'tarefas TEXT, ');
}, version: 1);
});
}
Future<int> save(Tarefas contact) {
return createDatabase().then((db) {
final Map<String, dynamic> contactMap = Map();
contactMap['id'] = contact.id;
contactMap['tarefas'] = contact.tarefa;
return db.insert('contacts', contactMap);
});
}
Future<List<Tarefas>> findAll() {
return createDatabase().then((db) {
return db.query('contacts').then((maps) {
final List<Tarefas> contacts = List();
for (Map<String, dynamic> map in maps) {
final Tarefas contact = Tarefas(
map['id'],
map['tarefas']
);
contacts.add(contact);
}
return contacts;
});
});
}