I am new to Flutter development. I just started to make Note app with Provider pattern, but when I update note, It won't update and It just create a new note in list. But when I minimize and return back list is updated. when I click on the item, it shows old data. Help me
sqlite_helper.dart
import 'package:sqflite/sqflite.dart' as sql;
import 'package:path/path.dart' as path;
import 'package:sqflite/sqlite_api.dart';
class DBHelper {
static Future<Database> database() async {
final dbPath = await sql.getDatabasesPath();
return sql.openDatabase(path.join(dbPath, 'mydatabase.db'),
onCreate: (db, version) {
return db.execute(
'CREATE TABLE notes(id TEXT PRIMARY KEY, title TEXT, content TEXT)');
}, version: 1);
}
static Future<void> insert(String table, Map<String, Object> data) async {
final db = await DBHelper.database();
db.insert(
table,
data,
conflictAlgorithm: ConflictAlgorithm.replace,
);
}
}