|
8 | 8 |  |
9 | 9 | <br> |
10 | 10 |
|
11 | | - |
| 11 | + |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +### 💾 The Flutter Micro App package provides a Flutter DevTools Extension, so you can inspect the app event handlers, inspect the routes in Widget Tree through the Flutter Widget Inspector, dispatch events to control the app from outside, search for routes and export all routes to an Excel file (.xlsx) |
| 16 | + |
| 17 | +<img width="1674" alt="image" src="https://github.com/user-attachments/assets/7f9dcca9-1085-401c-9096-fc03e7ed5563"> |
12 | 18 |
|
13 | 19 | --- |
14 | 20 |
|
|
43 | 49 | ); |
44 | 50 | ``` |
45 | 51 |
|
46 | | -### 💾 Flutter DevTools: Inspect the app, search for routes and export all routes to an Excel file (.xlsx) |
47 | | -- Use Flutter Devtools in order to inspect the whole application structure and export all routes to an excel file. |
48 | | - |
49 | | -<img width="1674" alt="image" src="https://github.com/user-attachments/assets/7f9dcca9-1085-401c-9096-fc03e7ed5563"> |
50 | | - |
51 | | - |
52 | | -```dart |
53 | | -
|
54 | | -// In order to use GoRouter, you need to add package https://pub.dev/packages/fma_go_router |
55 | | - FmaGoRoute( |
56 | | - description: 'This is a example of GoRouter page', |
57 | | - path: 'page_with_id/:id', |
58 | | - parameters: ExamplePageA.new, // If using `.new`, the parameters will be passed automatically, but you can use a String if you want to pass manually |
59 | | - builder: (context, state) { |
60 | | - return ExamplePageA(state.pathParameters['id']); |
61 | | - }, |
62 | | -), |
63 | | -
|
64 | | -or |
65 | | -
|
66 | | -MicroAppPage( |
67 | | - route: '/page2', |
68 | | - parameters: Page2.new, |
69 | | - pageBuilder: PageBuilder( |
70 | | - widgetBuilder: (_, settings) => |
71 | | - Page2(title: settings.arguments as String?)), |
72 | | -), |
73 | | -``` |
74 | | - |
75 | 52 | --- |
76 | 53 |
|
77 | 54 | ### 🚀 Initialize the micro host, registering all micro apps |
@@ -123,6 +100,31 @@ class MyApp extends MicroHostStatelessWidget { // Use MicroHostStatelessWidget o |
123 | 100 | } |
124 | 101 | ``` |
125 | 102 |
|
| 103 | +The example above shows how to use a classic routing strategy, but you can use GoRouter to leverage an advanced routing system. |
| 104 | + |
| 105 | +```dart |
| 106 | +// Register routes using classic routing or GoRouter |
| 107 | +// In order to use GoRouter, you need to add package https://pub.dev/packages/fma_go_router |
| 108 | +// IMPORTANT: See example code, in order to understand how GoRouter integration works |
| 109 | + FmaGoRoute( |
| 110 | + description: 'This is a example of GoRouter page', |
| 111 | + path: 'page_with_id/:id', |
| 112 | + parameters: ExamplePageA.new, // If using `.new`, the parameters will be passed automatically, but you can use a String if you want to pass manually |
| 113 | + builder: (context, state) { |
| 114 | + return ExamplePageA(state.pathParameters['id']); |
| 115 | + }, |
| 116 | +), |
| 117 | +
|
| 118 | +// or use classic routing |
| 119 | +MicroAppPage( |
| 120 | + route: '/page2', |
| 121 | + parameters: Page2.new, |
| 122 | + pageBuilder: PageBuilder( |
| 123 | + widgetBuilder: (_, settings) => |
| 124 | + Page2(title: settings.arguments as String?)), |
| 125 | +), |
| 126 | +``` |
| 127 | + |
126 | 128 | ### You can structure your application in many ways, this is one of the ways I usually use it in my projects. |
127 | 129 |
|
128 | 130 |  |
|
0 commit comments