Showing
1 changed file
with
43 additions
and
42 deletions
@@ -720,17 +720,17 @@ Get.delete<Controller>(); | @@ -720,17 +720,17 @@ Get.delete<Controller>(); | ||
720 | 720 | ||
721 | Para navegar para uma nova tela | 721 | Para navegar para uma nova tela |
722 | ```dart | 722 | ```dart |
723 | -Get.toNamed("/NextScreen"); | 723 | +Get.toNamed("/ProximaTela"); |
724 | ``` | 724 | ``` |
725 | 725 | ||
726 | Para navegar para uma tela sem a opção de voltar para a rota atual. | 726 | Para navegar para uma tela sem a opção de voltar para a rota atual. |
727 | ```dart | 727 | ```dart |
728 | -Get.offNamed("/NextScreen"); | 728 | +Get.offNamed("/ProximaTela"); |
729 | ``` | 729 | ``` |
730 | 730 | ||
731 | Para navegar para uma nova tela e remover todas rotas anteriores da stack | 731 | Para navegar para uma nova tela e remover todas rotas anteriores da stack |
732 | ```dart | 732 | ```dart |
733 | -Get.offAllNamed("/NextScreen"); | 733 | +Get.offAllNamed("/ProximaTela"); |
734 | ``` | 734 | ``` |
735 | 735 | ||
736 | Para definir rotas, use o `GetMaterialApp`: | 736 | Para definir rotas, use o `GetMaterialApp`: |
@@ -781,18 +781,18 @@ void main() => runApp( | @@ -781,18 +781,18 @@ void main() => runApp( | ||
781 | namedRoutes: { | 781 | namedRoutes: { |
782 | '/': GetRoute(page: MyHomePage()), | 782 | '/': GetRoute(page: MyHomePage()), |
783 | /// Importante! :user não é uma nova rota, é somente uma | 783 | /// Importante! :user não é uma nova rota, é somente uma |
784 | - /// especificação do parâmentro. Não use '/second/:user/' e '/second' | 784 | + /// especificação do parâmentro. Não use '/segunda/:user/' e '/segunda' |
785 | /// se você precisa de uma nova rota para o user, então | 785 | /// se você precisa de uma nova rota para o user, então |
786 | - /// use '/second/user/:user' se '/second' for uma rota | ||
787 | - '/second/:user': GetRoute(page: Second()), // recebe a ID | ||
788 | - '/third': GetRoute(page: Third(),transition: Transition.cupertino); | 786 | + /// use '/segunda/user/:user' se '/segunda' for uma rota |
787 | + '/segunda/:user': GetRoute(page: Segunda()), // recebe a ID | ||
788 | + '/terceira': GetRoute(page: Terceira(),transition: Transition.cupertino); | ||
789 | }, | 789 | }, |
790 | ), | 790 | ), |
791 | ); | 791 | ); |
792 | ``` | 792 | ``` |
793 | Envie dados na rota nomeada | 793 | Envie dados na rota nomeada |
794 | ```dart | 794 | ```dart |
795 | -Get.toNamed("/second/34954"); | 795 | +Get.toNamed("/segunda/34954"); |
796 | ``` | 796 | ``` |
797 | 797 | ||
798 | Na segunda tela receba os dados usando `Get.parameters[]` | 798 | Na segunda tela receba os dados usando `Get.parameters[]` |
@@ -800,57 +800,58 @@ Na segunda tela receba os dados usando `Get.parameters[]` | @@ -800,57 +800,58 @@ Na segunda tela receba os dados usando `Get.parameters[]` | ||
800 | print(Get.parameters['user']); // valor: 34954 | 800 | print(Get.parameters['user']); // valor: 34954 |
801 | ``` | 801 | ``` |
802 | 802 | ||
803 | -E agora, tudo que você precisa fazer é usar `Get.toNamed)` para navegar por suas rotas nomeadas, sem nenhum `context` (você pode chamar suas rotas diretamente do seu BLoc ou do Controller), e quando seu aplicativo é compilado para a web, suas rotas vão aparecer na url :heart: | ||
804 | - | ||
805 | -And now, all you need to do is use Get.toNamed() to navigate your named routes, without any context (you can call your routes directly from your BLoC or Controller class), and when your app is compiled to the web, your routes will appear in the url <3 | 803 | +E agora, tudo que você precisa fazer é usar `Get.toNamed)` para navegar por suas rotas nomeadas, sem nenhum `context` (você pode chamar suas rotas diretamente do seu BLoc ou do Controller), e quando seu aplicativo é compilado para a web, suas rotas vão aparecer na url ❤ |
806 | 804 | ||
807 | 805 | ||
808 | #### Middleware | 806 | #### Middleware |
809 | -If you want listen Get events to trigger actions, you can to use routingCallback to it | 807 | + |
808 | +Se você quer escutar eventos do Get para ativar ações, você pode usar `routingCallback` para isso | ||
810 | ```dart | 809 | ```dart |
811 | GetMaterialApp( | 810 | GetMaterialApp( |
812 | routingCallback: (route){ | 811 | routingCallback: (route){ |
813 | - if(routing.current == '/second'){ | 812 | + if(routing.current == '/segunda'){ |
814 | openAds(); | 813 | openAds(); |
815 | } | 814 | } |
816 | } | 815 | } |
817 | - ``` | ||
818 | -If you are not using GetMaterialApp, you can use the manual API to attach Middleware observer. | ||
819 | - | 816 | +) |
817 | +``` | ||
820 | 818 | ||
819 | +Se você não estiver usando o `GetMaterialApp`, você pode usar a API manual para anexar um observer Middleware. | ||
821 | ```dart | 820 | ```dart |
822 | void main() { | 821 | void main() { |
823 | - runApp(MaterialApp( | 822 | + runApp( |
823 | + MaterialApp( | ||
824 | onGenerateRoute: Router.generateRoute, | 824 | onGenerateRoute: Router.generateRoute, |
825 | initialRoute: "/", | 825 | initialRoute: "/", |
826 | navigatorKey: Get.key, | 826 | navigatorKey: Get.key, |
827 | navigatorObservers: [ | 827 | navigatorObservers: [ |
828 | - GetObserver(MiddleWare.observer), // HERE !!! | 828 | + GetObserver(MiddleWare.observer), // AQUI !!! |
829 | ], | 829 | ], |
830 | - )); | 830 | + ) |
831 | + ); | ||
831 | } | 832 | } |
832 | ``` | 833 | ``` |
833 | -Create a MiddleWare class | ||
834 | 834 | ||
835 | +Criar uma classe MiddleWare | ||
835 | ```dart | 836 | ```dart |
836 | class MiddleWare { | 837 | class MiddleWare { |
837 | static observer(Routing routing) { | 838 | static observer(Routing routing) { |
838 | - /// You can listen in addition to the routes, the snackbars, dialogs and bottomsheets on each screen. | ||
839 | - ///If you need to enter any of these 3 events directly here, | ||
840 | - ///you must specify that the event is != Than you are trying to do. | ||
841 | - if (routing.current == '/second' && !routing.isSnackbar) { | ||
842 | - Get.snackbar("Hi", "You are on second route"); | ||
843 | - } else if (routing.current =='/third'){ | ||
844 | - print('last route called'); | 839 | + /// Você pode escutar junto com as rotas, snackbars, dialogs |
840 | + /// e bottomsheets em cada tela. | ||
841 | + /// Se você precisar entrar em algum um desses 3 eventos aqui diretamente, | ||
842 | + /// você precisa especificar que o evento é != do que você está tentando fazer | ||
843 | + if (routing.current == '/segunda' && !routing.isSnackbar) { | ||
844 | + Get.snackbar("Olá", "Você está na segunda rota"); | ||
845 | + } else if (routing.current =='/terceira'){ | ||
846 | + print('última rota chamada'); | ||
845 | } | 847 | } |
846 | } | 848 | } |
847 | } | 849 | } |
848 | ``` | 850 | ``` |
849 | 851 | ||
850 | -Now, use Get on your code: | ||
851 | - | 852 | +Agora, use Get no seu código: |
852 | ```dart | 853 | ```dart |
853 | -class First extends StatelessWidget { | 854 | +class Primeira extends StatelessWidget { |
854 | @override | 855 | @override |
855 | Widget build(BuildContext context) { | 856 | Widget build(BuildContext context) { |
856 | return Scaffold( | 857 | return Scaffold( |
@@ -858,16 +859,16 @@ class First extends StatelessWidget { | @@ -858,16 +859,16 @@ class First extends StatelessWidget { | ||
858 | leading: IconButton( | 859 | leading: IconButton( |
859 | icon: Icon(Icons.add), | 860 | icon: Icon(Icons.add), |
860 | onPressed: () { | 861 | onPressed: () { |
861 | - Get.snackbar("hi", "i am a modern snackbar"); | 862 | + Get.snackbar("Oi", "eu sou uma snackbar moderna"); |
862 | }, | 863 | }, |
863 | ), | 864 | ), |
864 | - title: Text('First Route'), | 865 | + title: Text('Primeira rota'), |
865 | ), | 866 | ), |
866 | body: Center( | 867 | body: Center( |
867 | child: RaisedButton( | 868 | child: RaisedButton( |
868 | - child: Text('Open route'), | 869 | + child: Text('Abrir rota'), |
869 | onPressed: () { | 870 | onPressed: () { |
870 | - Get.toNamed("/second"); | 871 | + Get.toNamed("/segunda"); |
871 | }, | 872 | }, |
872 | ), | 873 | ), |
873 | ), | 874 | ), |
@@ -875,7 +876,7 @@ class First extends StatelessWidget { | @@ -875,7 +876,7 @@ class First extends StatelessWidget { | ||
875 | } | 876 | } |
876 | } | 877 | } |
877 | 878 | ||
878 | -class Second extends StatelessWidget { | 879 | +class Segunda extends StatelessWidget { |
879 | @override | 880 | @override |
880 | Widget build(BuildContext context) { | 881 | Widget build(BuildContext context) { |
881 | return Scaffold( | 882 | return Scaffold( |
@@ -883,16 +884,16 @@ class Second extends StatelessWidget { | @@ -883,16 +884,16 @@ class Second extends StatelessWidget { | ||
883 | leading: IconButton( | 884 | leading: IconButton( |
884 | icon: Icon(Icons.add), | 885 | icon: Icon(Icons.add), |
885 | onPressed: () { | 886 | onPressed: () { |
886 | - Get.snackbar("hi", "i am a modern snackbar"); | 887 | + Get.snackbar("Oi", "eu sou uma snackbar moderna"); |
887 | }, | 888 | }, |
888 | ), | 889 | ), |
889 | - title: Text('second Route'), | 890 | + title: Text('Segunda rota'), |
890 | ), | 891 | ), |
891 | body: Center( | 892 | body: Center( |
892 | child: RaisedButton( | 893 | child: RaisedButton( |
893 | - child: Text('Open route'), | 894 | + child: Text('Abrir rota'), |
894 | onPressed: () { | 895 | onPressed: () { |
895 | - Get.toNamed("/third"); | 896 | + Get.toNamed("/terceira"); |
896 | }, | 897 | }, |
897 | ), | 898 | ), |
898 | ), | 899 | ), |
@@ -900,19 +901,19 @@ class Second extends StatelessWidget { | @@ -900,19 +901,19 @@ class Second extends StatelessWidget { | ||
900 | } | 901 | } |
901 | } | 902 | } |
902 | 903 | ||
903 | -class Third extends StatelessWidget { | 904 | +class Terceira extends StatelessWidget { |
904 | @override | 905 | @override |
905 | Widget build(BuildContext context) { | 906 | Widget build(BuildContext context) { |
906 | return Scaffold( | 907 | return Scaffold( |
907 | appBar: AppBar( | 908 | appBar: AppBar( |
908 | - title: Text("Third Route"), | 909 | + title: Text("Terceira Rota"), |
909 | ), | 910 | ), |
910 | body: Center( | 911 | body: Center( |
911 | child: RaisedButton( | 912 | child: RaisedButton( |
912 | onPressed: () { | 913 | onPressed: () { |
913 | Get.back(); | 914 | Get.back(); |
914 | }, | 915 | }, |
915 | - child: Text('Go back!'), | 916 | + child: Text('Voltar!'), |
916 | ), | 917 | ), |
917 | ), | 918 | ), |
918 | ); | 919 | ); |
-
Please register or login to post a comment