diff --git a/lib/game/bloc/game_bloc.dart b/lib/game/bloc/game_bloc.dart index 048d9bb4..dbcb8f24 100644 --- a/lib/game/bloc/game_bloc.dart +++ b/lib/game/bloc/game_bloc.dart @@ -6,7 +6,7 @@ part 'game_event.dart'; part 'game_state.dart'; class GameBloc extends Bloc { - GameBloc() : super(const GameState(score: 0, balls: 3)) { + GameBloc() : super(GameState.initial()) { on(_onBallLost); on(_onScored); } diff --git a/lib/game/bloc/game_state.dart b/lib/game/bloc/game_state.dart index 7058c0b6..8db1df7f 100644 --- a/lib/game/bloc/game_state.dart +++ b/lib/game/bloc/game_state.dart @@ -11,6 +11,11 @@ class GameState extends Equatable { }) : assert(score >= 0, "Score can't be negative"), assert(balls >= 0, "Number of balls can't be negative"); + factory GameState.initial() => const GameState( + score: 0, + balls: 3, + ); + /// The current score of the game. final int score;