Added provider for games

This commit is contained in:
SomnusVeritas
2023-10-21 11:14:28 +02:00
parent 781c92faf0
commit f2e0ce1694
6 changed files with 83 additions and 21 deletions

View File

@@ -0,0 +1,19 @@
import 'package:flutter/material.dart';
import 'package:maggs_victory_voyage/services/db_helper.dart';
import '../models/game.dart';
class Games extends ChangeNotifier {
final List<Game> _games = [];
List<Game> get games {
if (_games.isEmpty) {
DbHelper.fetchGames().then((value) {
_games.clear();
_games.addAll(value);
notifyListeners();
});
}
return _games;
}
}