chore: major changes
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:sqflite_common/sqflite.dart';
|
||||
import '../models/pokemon.dart';
|
||||
|
||||
// Permet de gérer la base de données
|
||||
class PokedexDatabase {
|
||||
static Database? database;
|
||||
static final ValueNotifier<int> onDatabaseUpdate = ValueNotifier(0);
|
||||
|
||||
static Future<void> initDatabase() async {
|
||||
database = await openDatabase(
|
||||
"pokedex.db", // Nom de la base de données
|
||||
@@ -37,6 +40,7 @@ class PokedexDatabase {
|
||||
pokemon.toJson(),
|
||||
conflictAlgorithm: ConflictAlgorithm.replace,
|
||||
);
|
||||
onDatabaseUpdate.value++;
|
||||
}
|
||||
|
||||
// Méthode qui permet de récupérer la liste des pokémons dans la base de données
|
||||
@@ -62,6 +66,7 @@ class PokedexDatabase {
|
||||
static Future<void> updatePokemon(Pokemon pokemon) async {
|
||||
Database database = await getDatabase();
|
||||
await database.update("pokemon", pokemon.toJson(), where: "id = ?", whereArgs: [pokemon.id]);
|
||||
onDatabaseUpdate.value++;
|
||||
}
|
||||
|
||||
// Méthode qui permet de récupérer un Pokémon dans la base de données à partir de son ID
|
||||
|
||||
Reference in New Issue
Block a user