Skip to content

Commit 4339ba7

Browse files
committed
refactor: Format code and simplify widget constructors
This commit applies extensive code formatting across the project, primarily by converting multi-line widget and list declarations into single, chained statements. This improves code conciseness and readability. Key changes include: - Simplified widget constructor calls and list initializations by removing unnecessary line breaks. - Refactored `column` and `row` extensions to be more compact. - Updated `json_serializable` generated files (`.g.dart`) to use the new concise conditional syntax for JSON serialization. - Removed an unused image asset directory (`assets/img/`). - Added a build and format command to `README.md`.
1 parent 65fa32b commit 4339ba7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+711
-1416
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
[![Button Discord]][Discord]
66
[![Buttons Download]][Download]
77

8+
```shell
9+
dart run build_runner build --delete-conflicting-outputs && dart format . -l 120
10+
```
11+
812
#### *A multi-platform text-based game powered by Flutter*
913

1014
### [Play This Online][Online Demo]

lib/app.dart

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -38,45 +38,27 @@ class _EscapeWildAppState extends State<EscapeWildApp> {
3838
localizationsDelegates: context.localizationDelegates,
3939
supportedLocales: context.supportedLocales,
4040
locale: context.locale,
41-
theme: buildTheme(ThemeData(
42-
brightness: .light,
43-
colorSchemeSeed: Colors.yellow,
44-
)),
45-
darkTheme: buildTheme(ThemeData(
46-
brightness: .dark,
47-
colorSchemeSeed: Colors.green,
48-
)),
49-
builder: (ctx, child) => _PostServiceRunner(
50-
child: child ?? const SizedBox.shrink(),
51-
),
41+
theme: buildTheme(ThemeData(brightness: .light, colorSchemeSeed: Colors.yellow)),
42+
darkTheme: buildTheme(ThemeData(brightness: .dark, colorSchemeSeed: Colors.green)),
43+
builder: (ctx, child) => _PostServiceRunner(child: child ?? const SizedBox.shrink()),
5244
),
5345
);
5446
}
5547

5648
ThemeData buildTheme(ThemeData raw) {
5749
return raw.copyWith(
58-
cardTheme: raw.cardTheme.copyWith(
59-
shape: const RoundedRectangleBorder(
60-
borderRadius: .all(.circular(14)),
61-
),
62-
),
63-
navigationBarTheme: raw.navigationBarTheme.copyWith(
64-
height: 68,
65-
),
50+
cardTheme: raw.cardTheme.copyWith(shape: const RoundedRectangleBorder(borderRadius: .all(.circular(14)))),
51+
navigationBarTheme: raw.navigationBarTheme.copyWith(height: 68),
6652
splashFactory: InkSparkle.splashFactory,
67-
pageTransitionsTheme: const PageTransitionsTheme(builders: {
68-
TargetPlatform.android: SharedAxisPageTransitionsBuilder(
69-
transitionType: SharedAxisTransitionType.horizontal,
70-
),
71-
TargetPlatform.windows: SharedAxisPageTransitionsBuilder(
72-
transitionType: SharedAxisTransitionType.horizontal,
73-
),
74-
TargetPlatform.linux: SharedAxisPageTransitionsBuilder(
75-
transitionType: SharedAxisTransitionType.horizontal,
76-
),
77-
TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
78-
TargetPlatform.macOS: CupertinoPageTransitionsBuilder(),
79-
}),
53+
pageTransitionsTheme: const PageTransitionsTheme(
54+
builders: {
55+
TargetPlatform.android: SharedAxisPageTransitionsBuilder(transitionType: SharedAxisTransitionType.horizontal),
56+
TargetPlatform.windows: SharedAxisPageTransitionsBuilder(transitionType: SharedAxisTransitionType.horizontal),
57+
TargetPlatform.linux: SharedAxisPageTransitionsBuilder(transitionType: SharedAxisTransitionType.horizontal),
58+
TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
59+
TargetPlatform.macOS: CupertinoPageTransitionsBuilder(),
60+
},
61+
),
8062
);
8163
}
8264

@@ -94,9 +76,7 @@ class _EscapeWildAppState extends State<EscapeWildApp> {
9476
class _PostServiceRunner extends StatefulWidget {
9577
final Widget child;
9678

97-
const _PostServiceRunner({
98-
required this.child,
99-
});
79+
const _PostServiceRunner({required this.child});
10080

10181
@override
10282
State<_PostServiceRunner> createState() => _PostServiceRunnerState();

lib/core/action/action.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class UserAction with Moddable {
1616

1717
// Move
1818
static final //
19-
move = UserAction("move"),
19+
move = UserAction("move"),
2020
explore = UserAction("explore"),
2121
gather = UserAction("gather"),
2222
getWood = UserAction("get-wood"),
@@ -29,15 +29,15 @@ class UserAction with Moddable {
2929

3030
static final
3131
// Win the game
32-
escapeWild = UserAction("escape-wild"),
32+
escapeWild = UserAction(
33+
"escape-wild",
34+
),
3335
// Lose the game
34-
stopHeartbeat = UserAction("stop-heartbeat");
36+
stopHeartbeat = UserAction(
37+
"stop-heartbeat",
38+
);
3539

36-
static final List<UserAction> defaultActions = [
37-
move,
38-
explore,
39-
shelter,
40-
];
40+
static final List<UserAction> defaultActions = [move, explore, shelter];
4141

4242
@override
4343
bool operator ==(Object other) {

lib/core/attribute/attribute.g.dart

Lines changed: 13 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/core/backpack/backpack.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,7 @@ extension BackpackX on Backpack {
174174
}
175175

176176
/// Separate the [items] into matched and unmatched.
177-
MapEntry<List<ItemStack>, List<ItemStack>> separateMatchedFromUnmatched(
178-
bool Function(ItemStack stack) matcher,
179-
) {
177+
MapEntry<List<ItemStack>, List<ItemStack>> separateMatchedFromUnmatched(bool Function(ItemStack stack) matcher) {
180178
final matched = <ItemStack>[];
181179
final unmatched = <ItemStack>[];
182180
for (final item in items) {

lib/core/backpack/backpack.g.dart

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/core/campfire/campfire.dart

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ class FireState {
1414
final double fuel;
1515
static const maxVisualFuel = 500.0;
1616

17-
FireState({
18-
double ember = 0.0,
19-
double fuel = 0.0,
20-
}) : ember = max(0, ember),
21-
fuel = max(0, fuel);
17+
FireState({double ember = 0.0, double fuel = 0.0}) : ember = max(0, ember), fuel = max(0, fuel);
2218

2319
bool get active => fuel > 0 || ember > 0;
2420
bool get isOff => fuel <= 0 && ember <= 0;
@@ -29,14 +25,7 @@ class FireState {
2925

3026
static final FireState off = FireState();
3127

32-
FireState copyWith({
33-
double? ember,
34-
double? fuel,
35-
}) =>
36-
FireState(
37-
ember: ember ?? this.ember,
38-
fuel: fuel ?? this.fuel,
39-
);
28+
FireState copyWith({double? ember, double? fuel}) => FireState(ember: ember ?? this.ember, fuel: fuel ?? this.fuel);
4029
}
4130

4231
abstract class CampfirePlaceProtocol extends PlaceProtocol with ChangeNotifier {
@@ -172,10 +161,7 @@ mixin CampfireCookingMixin on CampfirePlaceProtocol {
172161
const _emberCostFactor = 5;
173162

174163
// TODO: Better formula
175-
FireState _burningFuel(
176-
FireState former,
177-
double cost,
178-
) {
164+
FireState _burningFuel(FireState former, double cost) {
179165
final curFuel = former.fuel;
180166
var resFuel = curFuel;
181167
var resEmber = former.ember;

lib/core/campfire/campfire.g.dart

Lines changed: 5 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/core/cook/container.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@ class ContainerCookRecipe extends CookRecipeProtocol implements JConvertibleProt
1717
}
1818

1919
@override
20-
bool updateCooking(
21-
List<ItemStack> inputs,
22-
List<ItemStack> outputs,
23-
Ts totalTimePassed,
24-
Ts delta,
25-
) {
20+
bool updateCooking(List<ItemStack> inputs, List<ItemStack> outputs, Ts totalTimePassed, Ts delta) {
2621
throw UnimplementedError();
2722
}
2823

lib/core/cook/continuous.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,7 @@ class ContinuousCookRecipe extends CookRecipeProtocol implements JConvertiblePro
5555
}
5656

5757
@override
58-
bool updateCooking(
59-
List<ItemStack> inputs,
60-
List<ItemStack> outputs,
61-
Ts totalTimePassed,
62-
Ts delta,
63-
) {
58+
bool updateCooking(List<ItemStack> inputs, List<ItemStack> outputs, Ts totalTimePassed, Ts delta) {
6459
if (inputs.length != 1) return false;
6560
final input = inputs.first;
6661
if (!input.meta.mergeable) return false;

0 commit comments

Comments
 (0)