Showing
6 changed files
with
90 additions
and
0 deletions
@@ -907,6 +907,7 @@ Any contribution is welcome! | @@ -907,6 +907,7 @@ Any contribution is welcome! | ||
907 | - [Firestore User with GetX | Todo App](https://www.youtube.com/watch?v=BiV0DcXgk58) - Video by Amateur Coder. | 907 | - [Firestore User with GetX | Todo App](https://www.youtube.com/watch?v=BiV0DcXgk58) - Video by Amateur Coder. |
908 | - [Firebase Auth with GetX | Todo App](https://www.youtube.com/watch?v=-H-T_BSgfOE) - Video by Amateur Coder. | 908 | - [Firebase Auth with GetX | Todo App](https://www.youtube.com/watch?v=-H-T_BSgfOE) - Video by Amateur Coder. |
909 | - [The Flutter GetX™ Ecosystem ~ State Management](https://medium.com/flutter-community/the-flutter-getx-ecosystem-state-management-881c7235511d) - State management by [Aachman Garg](https://github.com/imaachman). | 909 | - [The Flutter GetX™ Ecosystem ~ State Management](https://medium.com/flutter-community/the-flutter-getx-ecosystem-state-management-881c7235511d) - State management by [Aachman Garg](https://github.com/imaachman). |
910 | +- [The Flutter GetX™ Ecosystem ~ Dependency Injection](https://medium.com/flutter-community/the-flutter-getx-ecosystem-dependency-injection-8e763d0ec6b9) - Dependency Injection by [Aachman Garg](https://github.com/imaachman). | ||
910 | - [GetX, the all-in-one Flutter package](https://www.youtube.com/watch?v=IYQgtu9TM74) - A brief tutorial covering State Management and Navigation by Thad Carnevalli. | 911 | - [GetX, the all-in-one Flutter package](https://www.youtube.com/watch?v=IYQgtu9TM74) - A brief tutorial covering State Management and Navigation by Thad Carnevalli. |
911 | - [Build a To-do List App from scratch using Flutter and GetX](https://www.youtube.com/watch?v=EcnqFasHf18) - UI + State Management + Storage video by Thad Carnevalli. | 912 | - [Build a To-do List App from scratch using Flutter and GetX](https://www.youtube.com/watch?v=EcnqFasHf18) - UI + State Management + Storage video by Thad Carnevalli. |
912 | - [GetX Flutter Firebase Auth Example](https://medium.com/@jeffmcmorris/getx-flutter-firebase-auth-example-b383c1dd1de2) - Article by Jeff McMorris. | 913 | - [GetX Flutter Firebase Auth Example](https://medium.com/@jeffmcmorris/getx-flutter-firebase-auth-example-b383c1dd1de2) - Article by Jeff McMorris. |
@@ -152,6 +152,23 @@ void main() { | @@ -152,6 +152,23 @@ void main() { | ||
152 | } | 152 | } |
153 | ``` | 153 | ``` |
154 | 154 | ||
155 | +To handle navigation to non-defined routes (404 error), you can define an unknownRoute page in GetMaterialApp. | ||
156 | + | ||
157 | +```dart | ||
158 | +void main() { | ||
159 | + runApp( | ||
160 | + GetMaterialApp( | ||
161 | + unknownRoute: GetPage(name: '/notfound', page: () => UnknownRoutePage()), | ||
162 | + initialRoute: '/', | ||
163 | + getPages: [ | ||
164 | + GetPage(name: '/', page: () => MyHomePage()), | ||
165 | + GetPage(name: '/second', page: () => Second()), | ||
166 | + ], | ||
167 | + ) | ||
168 | + ); | ||
169 | +} | ||
170 | +``` | ||
171 | + | ||
155 | ### Send data to named Routes | 172 | ### Send data to named Routes |
156 | 173 | ||
157 | Just send what you want for arguments. Get accepts anything here, whether it is a String, a Map, a List, or even a class instance. | 174 | Just send what you want for arguments. Get accepts anything here, whether it is a String, a Map, a List, or even a class instance. |
@@ -151,6 +151,23 @@ void main() { | @@ -151,6 +151,23 @@ void main() { | ||
151 | } | 151 | } |
152 | ``` | 152 | ``` |
153 | 153 | ||
154 | +Para manejar la navegación a rutas no definidas (error 404), puede definir una página de ruta desconocida en GetMaterialApp. | ||
155 | + | ||
156 | +```dart | ||
157 | +void main() { | ||
158 | + runApp( | ||
159 | + GetMaterialApp( | ||
160 | + unknownRoute: GetPage(name: '/notfound', page: () => UnknownRoutePage()), | ||
161 | + initialRoute: '/', | ||
162 | + getPages: [ | ||
163 | + GetPage(name: '/', page: () => MyHomePage()), | ||
164 | + GetPage(name: '/second', page: () => Second()), | ||
165 | + ], | ||
166 | + ) | ||
167 | + ); | ||
168 | +} | ||
169 | +``` | ||
170 | + | ||
154 | ### Enviar datos a rutas nombradas | 171 | ### Enviar datos a rutas nombradas |
155 | 172 | ||
156 | Envía lo que quieras usando el parámetro arguments. GetX acepta cualquier cosa aquí, ya sea un String, Map, List o incluso una instancia de clase. | 173 | Envía lo que quieras usando el parámetro arguments. GetX acepta cualquier cosa aquí, ya sea un String, Map, List o incluso una instancia de clase. |
@@ -247,6 +247,23 @@ void main() { | @@ -247,6 +247,23 @@ void main() { | ||
247 | } | 247 | } |
248 | ``` | 248 | ``` |
249 | 249 | ||
250 | +Para lidar com a navegação para rotas não definidas (erro 404), você pode definir uma página unknownRoute em GetMaterialApp. | ||
251 | + | ||
252 | +```dart | ||
253 | +void main() { | ||
254 | + runApp( | ||
255 | + GetMaterialApp( | ||
256 | + unknownRoute: GetPage(name: '/notfound', page: () => UnknownRoutePage()), | ||
257 | + initialRoute: '/', | ||
258 | + getPages: [ | ||
259 | + GetPage(name: '/', page: () => MyHomePage()), | ||
260 | + GetPage(name: '/second', page: () => Second()), | ||
261 | + ], | ||
262 | + ) | ||
263 | + ); | ||
264 | +} | ||
265 | +``` | ||
266 | + | ||
250 | ### Enviar dados para rotas nomeadas | 267 | ### Enviar dados para rotas nomeadas |
251 | 268 | ||
252 | Apenas envie o que você quiser no parâmetro `arguments`. Get aceita qualquer coisa aqui, seja String, Map, List, ou até a instância de uma classe. | 269 | Apenas envie o que você quiser no parâmetro `arguments`. Get aceita qualquer coisa aqui, seja String, Map, List, ou até a instância de uma classe. |
@@ -149,6 +149,23 @@ void main() { | @@ -149,6 +149,23 @@ void main() { | ||
149 | } | 149 | } |
150 | ``` | 150 | ``` |
151 | 151 | ||
152 | +要处理到未定义路线的导航(404错误),可以在GetMaterialApp中定义unknownRoute页面。 | ||
153 | + | ||
154 | +```dart | ||
155 | +void main() { | ||
156 | + runApp( | ||
157 | + GetMaterialApp( | ||
158 | + unknownRoute: GetPage(name: '/notfound', page: () => UnknownRoutePage()), | ||
159 | + initialRoute: '/', | ||
160 | + getPages: [ | ||
161 | + GetPage(name: '/', page: () => MyHomePage()), | ||
162 | + GetPage(name: '/second', page: () => Second()), | ||
163 | + ], | ||
164 | + ) | ||
165 | + ); | ||
166 | +} | ||
167 | +``` | ||
168 | + | ||
152 | ### 发送数据到别名路由 | 169 | ### 发送数据到别名路由 |
153 | 170 | ||
154 | 只要发送你想要的参数即可。Get在这里接受任何东西,无论是一个字符串,一个Map,一个List,甚至一个类的实例。 | 171 | 只要发送你想要的参数即可。Get在这里接受任何东西,无论是一个字符串,一个Map,一个List,甚至一个类的实例。 |
@@ -161,6 +161,27 @@ class GetMaterialApp extends StatelessWidget { | @@ -161,6 +161,27 @@ class GetMaterialApp extends StatelessWidget { | ||
161 | final match = Get.routeTree.matchRoute(name); | 161 | final match = Get.routeTree.matchRoute(name); |
162 | Get.parameters = match?.parameters; | 162 | Get.parameters = match?.parameters; |
163 | 163 | ||
164 | + //Route can be nullable, just pass the unknown route | ||
165 | + if (match?.route == null) { | ||
166 | + return [ | ||
167 | + GetPageRoute( | ||
168 | + page: unknownRoute.page, | ||
169 | + parameter: unknownRoute.parameter, | ||
170 | + settings: RouteSettings(name: name, arguments: null), | ||
171 | + curve: unknownRoute.curve, | ||
172 | + opaque: unknownRoute.opaque, | ||
173 | + customTransition: unknownRoute.customTransition, | ||
174 | + binding: unknownRoute.binding, | ||
175 | + bindings: unknownRoute.bindings, | ||
176 | + transitionDuration: (unknownRoute.transitionDuration ?? | ||
177 | + Get.defaultTransitionDuration), | ||
178 | + transition: unknownRoute.transition, | ||
179 | + popGesture: unknownRoute.popGesture, | ||
180 | + fullscreenDialog: unknownRoute.fullscreenDialog, | ||
181 | + ) | ||
182 | + ]; | ||
183 | + } | ||
184 | + | ||
164 | return [ | 185 | return [ |
165 | GetPageRoute( | 186 | GetPageRoute( |
166 | page: match.route.page, | 187 | page: match.route.page, |
-
Please register or login to post a comment