Skip to content

Commit b124ae8

Browse files
committed
Use more dot-shorthands
1 parent 579c9c3 commit b124ae8

1 file changed

Lines changed: 33 additions & 37 deletions

File tree

lib/main_menu/projects/project_tile.dart

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class _OpeningStateNotifier extends Notifier<_OpeningStep?> {
4444

4545
@override
4646
_OpeningStep build() {
47-
return _OpeningStep.nothing;
47+
return .nothing;
4848
}
4949

5050
void set(_OpeningStep newState) {
@@ -227,23 +227,21 @@ It will only be removed from the list.""",
227227

228228
// == Check if project directory exists ==
229229
if (!projectDirectory.existsSync()) {
230-
ref
231-
.read(_openingStateProvider.notifier)
232-
.error(error: _OpenError.directoryNotFound);
230+
ref.read(_openingStateProvider.notifier).error(error: .directoryNotFound);
233231
setState(() => projectDirectoryExists = false); //to update the subtitle
234232
return;
235233
}
236234

237235
// == Checking for BlueMap CLI JAR ==
238-
ref.read(_openingStateProvider.notifier).set(_OpeningStep.checking);
236+
ref.read(_openingStateProvider.notifier).set(.checking);
239237
final File potentialBlueMapJar = getBlueMapJarFile(projectDirectory);
240238

241239
final File bluemapJar;
242240
// == If needed, download BlueMap CLI JAR ==
243241
if (potentialBlueMapJar.existsSync()) {
244242
bluemapJar = potentialBlueMapJar;
245243
} else {
246-
ref.read(_openingStateProvider.notifier).set(_OpeningStep.downloading);
244+
ref.read(_openingStateProvider.notifier).set(.downloading);
247245
final NonHashedFile susBlueMapJar;
248246
try {
249247
susBlueMapJar = await downloadFile(
@@ -257,28 +255,28 @@ It will only be removed from the list.""",
257255
} on IOException catch (e) {
258256
ref
259257
.read(_openingStateProvider.notifier)
260-
.error(error: _OpenError.downloadFailed, details: e.toString());
258+
.error(error: .downloadFailed, details: e.toString());
261259
return;
262260
}
263261

264262
// == Verify BlueMap CLI JAR hash ==
265-
ref.read(_openingStateProvider.notifier).set(_OpeningStep.hashing);
263+
ref.read(_openingStateProvider.notifier).set(.hashing);
266264
final File? hashedBlueMapJar = await susBlueMapJar.hashFile(blueMapCliJarHash);
267265
if (hashedBlueMapJar == null) {
268-
ref.read(_openingStateProvider.notifier).error(error: _OpenError.wrongHash);
266+
ref.read(_openingStateProvider.notifier).error(error: .wrongHash);
269267
return;
270268
}
271269
bluemapJar = hashedBlueMapJar;
272270
}
273271

274272
// == Run BlueMap CLI JAR to generate default configs ==
275-
ref.read(_openingStateProvider.notifier).set(_OpeningStep.running);
273+
ref.read(_openingStateProvider.notifier).set(.running);
276274

277275
final JavaPath? javaPath = ref.read(javaPathProvider);
278276
if (javaPath == null) {
279277
ref
280278
.read(_openingStateProvider.notifier)
281-
.error(error: _OpenError.runFail, details: "Java Path was null");
279+
.error(error: .runFail, details: "Java Path was null");
282280
return;
283281
}
284282

@@ -287,7 +285,7 @@ It will only be removed from the list.""",
287285
} on JavaVersionCheckException catch (e) {
288286
ref
289287
.read(_openingStateProvider.notifier)
290-
.error(error: _OpenError.runFail, details: e.message);
288+
.error(error: .runFail, details: e.message);
291289
return;
292290
}
293291

@@ -315,7 +313,7 @@ It will only be removed from the list.""",
315313
} on ProcessException catch (e) {
316314
ref
317315
.read(_openingStateProvider.notifier)
318-
.error(error: _OpenError.runFail, details: e.toString());
316+
.error(error: .runFail, details: e.toString());
319317
return;
320318
}
321319
final String stdout = run.stdout.toString();
@@ -334,14 +332,14 @@ It will only be removed from the list.""",
334332
ref
335333
.read(_openingStateProvider.notifier)
336334
.error(
337-
error: _OpenError.runFail,
335+
error: .runFail,
338336
details: combined.isNotEmpty ? combined : "<no output>",
339337
);
340338
return;
341339
}
342340

343341
// == Turn default maps directory into templates directory ==
344-
ref.read(_openingStateProvider.notifier).set(_OpeningStep.mapping);
342+
ref.read(_openingStateProvider.notifier).set(.mapping);
345343
//Check if we are currently upgrading an outdated project
346344
if (tempMapsDir == null) {
347345
//We are not currently upgrading an outdated project
@@ -365,7 +363,7 @@ It will only be removed from the list.""",
365363
}
366364

367365
// == Copy BlueMap GUI Configs ==
368-
ref.read(_openingStateProvider.notifier).set(_OpeningStep.copying);
366+
ref.read(_openingStateProvider.notifier).set(.copying);
369367
final File startupConfigFile = File(
370368
p.join(projectDirectory.path, "config", "startup.conf"),
371369
);
@@ -380,20 +378,20 @@ It will only be removed from the list.""",
380378
} on FileSystemException catch (e) {
381379
ref
382380
.read(_openingStateProvider.notifier)
383-
.error(error: _OpenError.copyFail, details: e.toString());
381+
.error(error: .copyFail, details: e.toString());
384382
return;
385383
}
386384
}
387385

388386
// == Open project ==
389-
ref.read(_openingStateProvider.notifier).set(_OpeningStep.opening);
387+
ref.read(_openingStateProvider.notifier).set(.opening);
390388

391389
try {
392390
await ref.read(projectProviderNotifier).openProject(projectDirectory);
393391
} on FatalConfigFileLoadException catch (e) {
394392
ref
395393
.read(_openingStateProvider.notifier)
396-
.error(error: _OpenError.openFail, details: e.getDetails());
394+
.error(error: .openFail, details: e.getDetails());
397395
return;
398396
}
399397

@@ -450,34 +448,32 @@ class _OpenProjectDialog extends ConsumerWidget {
450448
style: TextStyle(color: Colors.red),
451449
)
452450
: switch (pickingStep) {
453-
_OpeningStep.nothing => const Text("Preparing to open the project..."),
454-
_OpeningStep.checking => const Text(
451+
.nothing => const Text("Preparing to open the project..."),
452+
.checking => const Text(
455453
"Checking if BlueMap CLI JAR has already been downloaded...",
456454
),
457-
_OpeningStep.downloading => const Text("Downloading BlueMap CLI JAR..."),
458-
_OpeningStep.hashing => const Text("Verifying BlueMap CLI JAR hash..."),
459-
_OpeningStep.running => const Text(
455+
.downloading => const Text("Downloading BlueMap CLI JAR..."),
456+
.hashing => const Text("Verifying BlueMap CLI JAR hash..."),
457+
.running => const Text(
460458
"Running BlueMap CLI to generate default configs...",
461459
),
462-
_OpeningStep.mapping => const Text(
460+
.mapping => const Text(
463461
"Turning BlueMap's default map configs into templates...",
464462
),
465-
_OpeningStep.copying => const Text(
466-
"Copying BlueMap GUI configs into the project...",
467-
),
468-
_OpeningStep.opening => const Text("Opening project..."),
463+
.copying => const Text("Copying BlueMap GUI configs into the project..."),
464+
.opening => const Text("Opening project..."),
469465
},
470466
content: isError && openError != null
471467
? Column(
472-
mainAxisSize: MainAxisSize.min,
473-
crossAxisAlignment: CrossAxisAlignment.start,
468+
mainAxisSize: .min,
469+
crossAxisAlignment: .start,
474470
children: switch (openError) {
475-
_OpenError.directoryNotFound => [
471+
.directoryNotFound => [
476472
const Text("The project directory could not be found!"),
477473
const SizedBox(height: 8),
478474
const Text("Try removing it from the list and recreating it."),
479475
],
480-
_OpenError.downloadFailed => [
476+
.downloadFailed => [
481477
const Text(
482478
"""
483479
Failed to download BlueMap CLI JAR.
@@ -487,7 +483,7 @@ Check your internet connection and try again.
487483
const SizedBox(height: 8),
488484
?ref.read(_openingStateProvider.notifier).getErrorDetails(context),
489485
],
490-
_OpenError.wrongHash => [
486+
.wrongHash => [
491487
const Text(
492488
"""
493489
Could not verify the downloaded BlueMap CLI JAR's integrity!
@@ -496,7 +492,7 @@ The hash of the downloaded file does not match the expected hash.""",
496492
const SizedBox(height: 8),
497493
const Text("Please try again later or download the file manually."),
498494
],
499-
_OpenError.runFail => [
495+
.runFail => [
500496
const Text(
501497
"""
502498
Failed to run the CLI to generate default BlueMap configs!
@@ -505,12 +501,12 @@ Please check your Java settings and try again.""",
505501
const SizedBox(height: 8),
506502
?ref.read(_openingStateProvider.notifier).getErrorDetails(context),
507503
],
508-
_OpenError.copyFail => [
504+
.copyFail => [
509505
const Text("Failed to copy BlueMap GUI config into the project!"),
510506
const SizedBox(height: 8),
511507
?ref.read(_openingStateProvider.notifier).getErrorDetails(context),
512508
],
513-
_OpenError.openFail => [
509+
.openFail => [
514510
const Text(
515511
"A fatal exception occurred when trying to open the project!",
516512
),

0 commit comments

Comments
 (0)