ndk
This commit is contained in:
25
lib/controllers/game_controller.dart
Normal file
25
lib/controllers/game_controller.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
import 'dart:async';
|
||||
import '../models/game_model.dart';
|
||||
|
||||
class GameController {
|
||||
final List<Game> _games = [];
|
||||
final _gameStreamController = StreamController<List<Game>>.broadcast();
|
||||
|
||||
Stream<List<Game>> get gamesStream => _gameStreamController.stream;
|
||||
|
||||
void addGame(String myTeam, String opponent, String season) {
|
||||
final newGame = Game(
|
||||
id: DateTime.now().toString(),
|
||||
myTeam: myTeam,
|
||||
opponentTeam: opponent,
|
||||
season: season,
|
||||
date: DateTime.now(),
|
||||
);
|
||||
_games.insert(0, newGame); // Adiciona ao topo da lista
|
||||
_gameStreamController.add(List.unmodifiable(_games));
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
_gameStreamController.close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user