From 92e554f411f87f812e9a1762985ffffb244f6062 Mon Sep 17 00:00:00 2001 From: alestiago Date: Wed, 2 Mar 2022 13:58:56 +0000 Subject: [PATCH] refactor: changed factory constructor for named constructor --- lib/game/bloc/game_bloc.dart | 2 +- lib/game/bloc/game_state.dart | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/game/bloc/game_bloc.dart b/lib/game/bloc/game_bloc.dart index dbcb8f24..71c527a8 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(GameState.initial()) { + GameBloc() : super(const GameState.initial()) { on(_onBallLost); on(_onScored); } diff --git a/lib/game/bloc/game_state.dart b/lib/game/bloc/game_state.dart index 8db1df7f..235e264d 100644 --- a/lib/game/bloc/game_state.dart +++ b/lib/game/bloc/game_state.dart @@ -11,10 +11,9 @@ 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, - ); + const GameState.initial() + : score = 0, + balls = 3; /// The current score of the game. final int score;