Created
April 19, 2021 22:02
-
-
Save guilhermecarvalhocarneiro/8fb79ebb7a7bf0cc684c6606c6ff0fad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/cupertino.dart'; | |
| /// Arquivo gerado via manager do Django para controlar as rotas nomeadas | |
| /// da aplicação. | |
| /// | |
| /// Caso uma nova app seja adicionada no projeto siga os passos abaixo: | |
| /// 1. Adicionar as constantes nas páginas: | |
| /// 1.1 Index -> static const routeNameIndexPage = "/xptoIndex"; | |
| /// 1.2 List -> static const routeNameListPage = "/xptoListPage"; | |
| /// 1.3 Create -> static const routeNameAddPage = "/xptoAddPage"; | |
| /// 1.4 Detail -> static const routeNameDetailPage = "/xptoDetailPage"; | |
| /// 1.5 Update -> static const routeNameUpdatePage = "/xptoUpdate"; | |
| /// | |
| /// 2. Adicionar no Switch da classe RouteGenerator o apontamento para as rotas. | |
| /// | |
| /// [Travar o arquivo] | |
| /// Caso deseje "travar" o arquivo para não ser parseado novamente | |
| /// pelo manage do Django adicione um # antes da palavra abaixo | |
| /// #FileLocked | |
| import 'package:flutter/material.dart'; | |
| import './apps/usuario/usuario/pages/create.dart'; | |
| import './apps/usuario/usuario/pages/detail.dart'; | |
| import './apps/usuario/usuario/pages/index.dart'; | |
| import './apps/usuario/usuario/pages/list.dart'; | |
| import './apps/usuario/usuario/pages/update.dart'; | |
| class RouteGenerator { | |
| static Route<dynamic> generateRoute(RouteSettings settings) { | |
| /// Recuperando os agumentos passados como parâmetro | |
| final args =settings.arguments; | |
| /// Switch para identificar qual rota está sendo invocada | |
| switch (settings.name) { | |
| case UsuarioIndexPage.routeName: | |
| return CupertinoPageRoute(builder: (_) => UsuarioIndexPage()); | |
| break; | |
| case UsuarioDetailPage.routeName: | |
| return CupertinoPageRoute(builder: (_) => UsuarioDetailPage()); | |
| break; | |
| case UsuarioListPage.routeName: | |
| return CupertinoPageRoute(builder: (_) => UsuarioListPage()); | |
| break; | |
| case UsuarioUpdatePage.routeName: | |
| return CupertinoPageRoute(builder: (_) => UsuarioUpdatePage()); | |
| break; | |
| case UsuarioAddPage.routeName: | |
| return CupertinoPageRoute(builder: (_) => UsuarioAddPage()); | |
| break; | |
| default: | |
| /// Caso a rota invocada não exista será mostrado o views de erro. | |
| return _errorRoute(); | |
| } | |
| } | |
| // Retornando a tela de rota não encontrada. Caso deseje configurar a tela de erro basta editar o código desse método | |
| static Route<dynamic> _errorRoute() { | |
| return MaterialPageRoute(builder: (_) { | |
| return Scaffold( | |
| appBar: AppBar( | |
| title: Text('Error'), | |
| ), | |
| body: Center( | |
| child: Text('ERROR'), | |
| ), | |
| ); | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment