refactor: changed factory constructor for named constructor

pull/3/head
alestiago 4 years ago
parent 3e318d3c0d
commit 92e554f411

@ -6,7 +6,7 @@ part 'game_event.dart';
part 'game_state.dart';
class GameBloc extends Bloc<GameEvent, GameState> {
GameBloc() : super(GameState.initial()) {
GameBloc() : super(const GameState.initial()) {
on<BallLost>(_onBallLost);
on<Scored>(_onScored);
}

@ -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;

Loading…
Cancel
Save