Já realizei o Flutter Clean e o erro persiste, alguém poderia me ajudar, quero dar continuidade no curso.
Restarted application in 5.751ms.
E/SQLiteLog(13008): (1) no such table: contacts in "INSERT INTO contacts (id, name, account_number) VALUES (?, ?, ?)"
E/flutter (13008): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: DatabaseException(no such table: contacts (code 1 SQLITE_ERROR): , while compiling: INSERT INTO contacts (id, name, account_number) VALUES (?, ?, ?)) sql 'INSERT INTO contacts (id, name, account_number) VALUES (?, ?, ?)' args [0, Taka, 1055]}
E/flutter (13008): #0 wrapDatabaseException (package:sqflite/src/exception_impl.dart:11:7)
E/flutter (13008): <asynchronous suspension>
E/flutter (13008): #1 SqfliteDatabaseMixin.txnRawInsert.<anonymous closure> (package:sqflite_common/src/database_mixin.dart:394:14)
E/flutter (13008): <asynchronous suspension>
E/flutter (13008): #2 BasicLock.synchronized (package:synchronized/src/basic_lock.dart:33:16)
E/flutter (13008): <asynchronous suspension>
E/flutter (13008): #3 SqfliteDatabaseMixin.txnSynchronized (package:sqflite_common/src/database_mixin.dart:346:14)
E/flutter (13008): <asynchronous suspension>
E/flutter (13008): #4 main.<anonymous closure> (package:bytebank/main.dart)
E/flutter (13008): <asynchronous suspension>
E/flutter (13008):
import 'package:bytebank/models/contact.dart';
import 'package:path/path.dart';
import 'package:sqflite/sqflite.dart';
Future<Database> createDatabase() {
return getDatabasesPath().then((dbPath) {
final String path = join(dbPath, 'bytebank.db');
return openDatabase(path, onCreate: (db, version) {
db.execute('CREATE TABLE contacts('
'id INTEGER PRIMARY KEY, '
'name TEXT, '
'account_number INTEGER');
}, version: 1);
});
}
Future<int> save(Contact contact) {
return createDatabase().then((db) {
final Map<String, dynamic> contactMap = Map();
contactMap['id'] = contact.id;
contactMap['name'] = contact.name;
contactMap['account_number'] = contact.accountNumber;
return db.insert('contacts', contactMap);
});
}
Future<List<Contact>> findAll() {
return createDatabase().then((db) {
return db.query('contacts').then((maps) {
final List<Contact> contacts = [];
for (Map<String, dynamic> map in maps) {
final Contact contact = Contact(
map['id'],
map['name'],
map['account_number'],
);
contacts.add(contact);
}
return contacts;
});
});
}