Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
feat: display score in ScorePage
Browse files Browse the repository at this point in the history
  • Loading branch information
alestiago committed Feb 17, 2024
1 parent 04897db commit 13768c4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
5 changes: 4 additions & 1 deletion packages/trashy_road/lib/src/game/view/game_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ class _GameView extends StatelessWidget {
score: state.score,
),
);
Navigator.pushReplacement(context, ScorePage.route());
Navigator.pushReplacement(
context,
ScorePage.route(score: state.score),
);
},
child: Stack(
children: [
Expand Down
19 changes: 14 additions & 5 deletions packages/trashy_road/lib/src/score/view/score_page.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import 'package:flutter/material.dart';

class ScorePage extends StatelessWidget {
const ScorePage({super.key});
const ScorePage({
required int score,
super.key,
}) : _score = score;

static Route<void> route() {
return MaterialPageRoute<void>(builder: (_) => const ScorePage());
final int _score;

static Route<void> route({
required int score,
}) {
return MaterialPageRoute<void>(
builder: (_) => ScorePage(score: score),
);
}

@override
Expand All @@ -13,8 +22,8 @@ class ScorePage extends StatelessWidget {
appBar: AppBar(
title: const Text('Score'),
),
body: const Center(
child: Text('Score Page'),
body: Center(
child: Text('Score: $_score'),
),
);
}
Expand Down

0 comments on commit 13768c4

Please sign in to comment.