Skip to content

Commit a9bdfc1

Browse files
committed
Fix dart format
1 parent f5a397a commit a9bdfc1

File tree

9 files changed

+68
-98
lines changed

9 files changed

+68
-98
lines changed

lib/game/dino.dart

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@ import '/game/audio_manager.dart';
99
import '/models/player_data.dart';
1010

1111
/// This enum represents the animation states of [Dino].
12-
enum DinoAnimationStates {
13-
idle,
14-
run,
15-
kick,
16-
hit,
17-
sprint,
18-
}
12+
enum DinoAnimationStates { idle, run, kick, hit, sprint }
1913

2014
// This represents the dino character of this game.
2115
class Dino extends SpriteAnimationGroupComponent<DinoAnimationStates>
@@ -70,7 +64,7 @@ class Dino extends SpriteAnimationGroupComponent<DinoAnimationStates>
7064
bool isHit = false;
7165

7266
Dino(Image image, this.playerData)
73-
: super.fromFrameData(image, _animationMap);
67+
: super.fromFrameData(image, _animationMap);
7468

7569
@override
7670
void onMount() {

lib/game/dino_run.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ class DinoRun extends FlameGame with TapDetector, HasCollisionDetection {
143143

144144
/// This method reads [PlayerData] from the hive box.
145145
Future<PlayerData> _readPlayerData() async {
146-
final playerDataBox =
147-
await Hive.openBox<PlayerData>('DinoRun.PlayerDataBox');
146+
final playerDataBox = await Hive.openBox<PlayerData>(
147+
'DinoRun.PlayerDataBox',
148+
);
148149
final playerData = playerDataBox.get('DinoRun.PlayerData');
149150

150151
// If data is null, this is probably a fresh launch of the game.
@@ -165,10 +166,7 @@ class DinoRun extends FlameGame with TapDetector, HasCollisionDetection {
165166
// If data is null, this is probably a fresh launch of the game.
166167
if (settings == null) {
167168
// In such cases store default values in hive.
168-
await settingsBox.put(
169-
'DinoRun.Settings',
170-
Settings(bgm: true, sfx: true),
171-
);
169+
await settingsBox.put('DinoRun.Settings', Settings(bgm: true, sfx: true));
172170
}
173171

174172
// Now it is safe to return the stored value.

lib/game/enemy_manager.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ class EnemyManager extends Component with HasGameReference<DinoRun> {
3131

3232
// Help in setting all enemies on ground.
3333
enemy.anchor = Anchor.bottomLeft;
34-
enemy.position = Vector2(
35-
game.virtualSize.x + 32,
36-
game.virtualSize.y - 24,
37-
);
34+
enemy.position = Vector2(game.virtualSize.x + 32, game.virtualSize.y - 24);
3835

3936
// If this enemy can fly, set its y position randomly.
4037
if (enemyData.canFly) {

lib/main.dart

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,10 @@ class DinoRunApp extends StatelessWidget {
6363
body: GameWidget<DinoRun>.controlled(
6464
// This will dislpay a loading bar until [DinoRun] completes
6565
// its onLoad method.
66-
loadingBuilder: (conetxt) => const Center(
67-
child: SizedBox(
68-
width: 200,
69-
child: LinearProgressIndicator(),
70-
),
71-
),
66+
loadingBuilder:
67+
(conetxt) => const Center(
68+
child: SizedBox(width: 200, child: LinearProgressIndicator()),
69+
),
7270
// Register all the overlays that will be used by this game.
7371
overlayBuilderMap: {
7472
MainMenu.id: (_, game) => MainMenu(game),
@@ -79,14 +77,15 @@ class DinoRunApp extends StatelessWidget {
7977
},
8078
// By default MainMenu overlay will be active.
8179
initialActiveOverlays: const [MainMenu.id],
82-
gameFactory: () => DinoRun(
83-
// Use a fixed resolution camera to avoid manually
84-
// scaling and handling different screen sizes.
85-
camera: CameraComponent.withFixedResolution(
86-
width: 360,
87-
height: 180,
88-
),
89-
),
80+
gameFactory:
81+
() => DinoRun(
82+
// Use a fixed resolution camera to avoid manually
83+
// scaling and handling different screen sizes.
84+
camera: CameraComponent.withFixedResolution(
85+
width: 360,
86+
height: 180,
87+
),
88+
),
9089
),
9190
),
9291
);

lib/widgets/game_over_menu.dart

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,17 @@ class GameOverMenu extends StatelessWidget {
2828
child: BackdropFilter(
2929
filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
3030
child: Card(
31-
shape:
32-
RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
31+
shape: RoundedRectangleBorder(
32+
borderRadius: BorderRadius.circular(20),
33+
),
3334
color: Colors.black.withAlpha(100),
3435
child: FittedBox(
3536
fit: BoxFit.scaleDown,
3637
child: Padding(
37-
padding:
38-
const EdgeInsets.symmetric(vertical: 20, horizontal: 100),
38+
padding: const EdgeInsets.symmetric(
39+
vertical: 20,
40+
horizontal: 100,
41+
),
3942
child: Wrap(
4043
direction: Axis.vertical,
4144
crossAxisAlignment: WrapCrossAlignment.center,
@@ -51,16 +54,16 @@ class GameOverMenu extends StatelessWidget {
5154
return Text(
5255
'You Score: $score',
5356
style: const TextStyle(
54-
fontSize: 40, color: Colors.white),
57+
fontSize: 40,
58+
color: Colors.white,
59+
),
5560
);
5661
},
5762
),
5863
ElevatedButton(
5964
child: const Text(
6065
'Restart',
61-
style: TextStyle(
62-
fontSize: 30,
63-
),
66+
style: TextStyle(fontSize: 30),
6467
),
6568
onPressed: () {
6669
game.overlays.remove(GameOverMenu.id);
@@ -72,12 +75,7 @@ class GameOverMenu extends StatelessWidget {
7275
},
7376
),
7477
ElevatedButton(
75-
child: const Text(
76-
'Exit',
77-
style: TextStyle(
78-
fontSize: 30,
79-
),
80-
),
78+
child: const Text('Exit', style: TextStyle(fontSize: 30)),
8179
onPressed: () {
8280
game.overlays.remove(GameOverMenu.id);
8381
game.overlays.add(MainMenu.id);

lib/widgets/hud.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,7 @@ class Hud extends StatelessWidget {
6565
return Row(
6666
children: List.generate(5, (index) {
6767
if (index < lives) {
68-
return const Icon(
69-
Icons.favorite,
70-
color: Colors.red,
71-
);
68+
return const Icon(Icons.favorite, color: Colors.red);
7269
} else {
7370
return const Icon(
7471
Icons.favorite_border,
@@ -78,7 +75,7 @@ class Hud extends StatelessWidget {
7875
}),
7976
);
8077
},
81-
)
78+
),
8279
],
8380
),
8481
),

lib/widgets/main_menu.dart

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,33 @@ class MainMenu extends StatelessWidget {
2222
child: BackdropFilter(
2323
filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
2424
child: Card(
25-
shape:
26-
RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
25+
shape: RoundedRectangleBorder(
26+
borderRadius: BorderRadius.circular(20),
27+
),
2728
color: Colors.black.withAlpha(100),
2829
child: FittedBox(
2930
fit: BoxFit.scaleDown,
3031
child: Padding(
31-
padding:
32-
const EdgeInsets.symmetric(vertical: 20, horizontal: 100),
32+
padding: const EdgeInsets.symmetric(
33+
vertical: 20,
34+
horizontal: 100,
35+
),
3336
child: Wrap(
3437
direction: Axis.vertical,
3538
crossAxisAlignment: WrapCrossAlignment.center,
3639
spacing: 10,
3740
children: [
3841
const Text(
3942
'Dino Run',
40-
style: TextStyle(
41-
fontSize: 50,
42-
color: Colors.white,
43-
),
43+
style: TextStyle(fontSize: 50, color: Colors.white),
4444
),
4545
ElevatedButton(
4646
onPressed: () {
4747
game.startGamePlay();
4848
game.overlays.remove(MainMenu.id);
4949
game.overlays.add(Hud.id);
5050
},
51-
child: const Text(
52-
'Play',
53-
style: TextStyle(
54-
fontSize: 30,
55-
),
56-
),
51+
child: const Text('Play', style: TextStyle(fontSize: 30)),
5752
),
5853
ElevatedButton(
5954
onPressed: () {
@@ -62,9 +57,7 @@ class MainMenu extends StatelessWidget {
6257
},
6358
child: const Text(
6459
'Settings',
65-
style: TextStyle(
66-
fontSize: 30,
67-
),
60+
style: TextStyle(fontSize: 30),
6861
),
6962
),
7063
],

lib/widgets/pause_menu.dart

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,17 @@ class PauseMenu extends StatelessWidget {
2727
child: BackdropFilter(
2828
filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
2929
child: Card(
30-
shape:
31-
RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
30+
shape: RoundedRectangleBorder(
31+
borderRadius: BorderRadius.circular(20),
32+
),
3233
color: Colors.black.withAlpha(100),
3334
child: FittedBox(
3435
fit: BoxFit.scaleDown,
3536
child: Padding(
36-
padding:
37-
const EdgeInsets.symmetric(vertical: 20, horizontal: 100),
37+
padding: const EdgeInsets.symmetric(
38+
vertical: 20,
39+
horizontal: 100,
40+
),
3841
child: Wrap(
3942
direction: Axis.vertical,
4043
crossAxisAlignment: WrapCrossAlignment.center,
@@ -48,7 +51,9 @@ class PauseMenu extends StatelessWidget {
4851
return Text(
4952
'Score: $score',
5053
style: const TextStyle(
51-
fontSize: 40, color: Colors.white),
54+
fontSize: 40,
55+
color: Colors.white,
56+
),
5257
);
5358
},
5459
),
@@ -62,9 +67,7 @@ class PauseMenu extends StatelessWidget {
6267
},
6368
child: const Text(
6469
'Resume',
65-
style: TextStyle(
66-
fontSize: 30,
67-
),
70+
style: TextStyle(fontSize: 30),
6871
),
6972
),
7073
ElevatedButton(
@@ -78,9 +81,7 @@ class PauseMenu extends StatelessWidget {
7881
},
7982
child: const Text(
8083
'Restart',
81-
style: TextStyle(
82-
fontSize: 30,
83-
),
84+
style: TextStyle(fontSize: 30),
8485
),
8586
),
8687
ElevatedButton(
@@ -91,12 +92,7 @@ class PauseMenu extends StatelessWidget {
9192
game.reset();
9293
AudioManager.instance.resumeBgm();
9394
},
94-
child: const Text(
95-
'Exit',
96-
style: TextStyle(
97-
fontSize: 30,
98-
),
99-
),
95+
child: const Text('Exit', style: TextStyle(fontSize: 30)),
10096
),
10197
],
10298
),

lib/widgets/settings_menu.dart

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@ class SettingsMenu extends StatelessWidget {
3030
height: MediaQuery.of(context).size.height * 0.8,
3131
child: Card(
3232
shape: RoundedRectangleBorder(
33-
borderRadius: BorderRadius.circular(20)),
33+
borderRadius: BorderRadius.circular(20),
34+
),
3435
color: Colors.black.withAlpha(100),
3536
child: Padding(
36-
padding:
37-
const EdgeInsets.symmetric(vertical: 20, horizontal: 100),
37+
padding: const EdgeInsets.symmetric(
38+
vertical: 20,
39+
horizontal: 100,
40+
),
3841
child: Column(
3942
mainAxisAlignment: MainAxisAlignment.center,
4043
children: [
@@ -44,18 +47,16 @@ class SettingsMenu extends StatelessWidget {
4447
return SwitchListTile(
4548
title: const Text(
4649
'Music',
47-
style: TextStyle(
48-
fontSize: 30,
49-
color: Colors.white,
50-
),
50+
style: TextStyle(fontSize: 30, color: Colors.white),
5151
),
5252
value: bgm,
5353
onChanged: (bool value) {
5454
Provider.of<Settings>(context, listen: false).bgm =
5555
value;
5656
if (value) {
57-
AudioManager.instance
58-
.startBgm('8BitPlatformerLoop.wav');
57+
AudioManager.instance.startBgm(
58+
'8BitPlatformerLoop.wav',
59+
);
5960
} else {
6061
AudioManager.instance.stopBgm();
6162
}
@@ -69,10 +70,7 @@ class SettingsMenu extends StatelessWidget {
6970
return SwitchListTile(
7071
title: const Text(
7172
'Effects',
72-
style: TextStyle(
73-
fontSize: 30,
74-
color: Colors.white,
75-
),
73+
style: TextStyle(fontSize: 30, color: Colors.white),
7674
),
7775
value: sfx,
7876
onChanged: (bool value) {

0 commit comments

Comments
 (0)