Skip to content

Commit bbe8528

Browse files
chore: Refactor example app (#404)
1 parent 575e59c commit bbe8528

Some content is hidden

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

58 files changed

+975
-648
lines changed

.vscode/launch.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
"type": "dart",
3333
"cwd": "example",
3434
"request": "launch",
35+
"program": "lib/embedded.dart",
36+
"deviceId": "chrome",
3537
"toolArgs": ["--dart-define=EMBEDDED=true"]
3638
}
3739
]

example/.metadata

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# This file should be version controlled and should not be manually edited.
55

66
version:
7-
revision: "603104015dd692ea3403755b55d07813d5cf8965"
7+
revision: "ac4e799d237041cf905519190471f657b657155a"
88
channel: "stable"
99

1010
project_type: app
@@ -13,11 +13,11 @@ project_type: app
1313
migration:
1414
platforms:
1515
- platform: root
16-
create_revision: 603104015dd692ea3403755b55d07813d5cf8965
17-
base_revision: 603104015dd692ea3403755b55d07813d5cf8965
18-
- platform: android
19-
create_revision: 603104015dd692ea3403755b55d07813d5cf8965
20-
base_revision: 603104015dd692ea3403755b55d07813d5cf8965
16+
create_revision: ac4e799d237041cf905519190471f657b657155a
17+
base_revision: ac4e799d237041cf905519190471f657b657155a
18+
- platform: web
19+
create_revision: ac4e799d237041cf905519190471f657b657155a
20+
base_revision: ac4e799d237041cf905519190471f657b657155a
2121

2222
# User provided section
2323

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:go_router/go_router.dart';
3+
import 'package:zeta_example/config/components_config.dart' show ExampleWrap;
4+
import 'package:zeta_example/pages/assets/illustrations_example.dart' deferred as illustrations_example;
5+
import 'package:zeta_example/pages/assets/icons_example.dart' deferred as icons_example;
6+
7+
const String iconsRoute = 'Icons';
8+
const String illustrationsRoute = 'Illustrations';
9+
10+
final Map<String, ExampleWrap> assetExampleNames = {
11+
iconsRoute: ExampleWrap(
12+
pageBuilder: (context) => icons_example.IconsExample(),
13+
loader: icons_example.loadLibrary,
14+
),
15+
illustrationsRoute: ExampleWrap(
16+
pageBuilder: (context) => illustrations_example.IllustrationsExample(),
17+
loader: illustrations_example.loadLibrary,
18+
),
19+
};
20+
21+
final assetRoutes = assetExampleNames.entries.map(
22+
(e) => GoRoute(
23+
path: e.key,
24+
builder: (_, __) => FutureBuilder(
25+
future: e.value.loader(),
26+
builder: (context, asyncSnapshot) {
27+
if (asyncSnapshot.connectionState == ConnectionState.waiting) {
28+
return Center(child: CircularProgressIndicator());
29+
}
30+
31+
if (asyncSnapshot.hasError) {
32+
print('Error loading ${e.key}: ${asyncSnapshot.error}');
33+
return Center(
34+
child: Column(
35+
mainAxisAlignment: MainAxisAlignment.center,
36+
children: [
37+
Icon(Icons.error, size: 48, color: Colors.red),
38+
SizedBox(height: 16),
39+
Text('Failed to load ${e.value}'),
40+
SizedBox(height: 8),
41+
Text('${asyncSnapshot.error}',
42+
textAlign: TextAlign.center, style: TextStyle(fontSize: 12, color: Colors.grey)),
43+
],
44+
),
45+
);
46+
}
47+
48+
if (asyncSnapshot.connectionState == ConnectionState.done) {
49+
return e.value.pageBuilder.call(_);
50+
}
51+
52+
return Center(child: CircularProgressIndicator());
53+
}),
54+
),
55+
);

0 commit comments

Comments
 (0)