Showing
1 changed file
with
77 additions
and
76 deletions
| @@ -33,8 +33,8 @@ Somando a isso, quando uma rota é enviada, o `MaterialApp` inteiro pode ser rec | @@ -33,8 +33,8 @@ Somando a isso, quando uma rota é enviada, o `MaterialApp` inteiro pode ser rec | ||
| 33 | Essa biblioteca vai mudar a forma que você trabalha com o Framework e salvar seu código dos boilerplates, aumentando sua produtividade, e eliminando os bugs de reconstrução da sua aplicação. | 33 | Essa biblioteca vai mudar a forma que você trabalha com o Framework e salvar seu código dos boilerplates, aumentando sua produtividade, e eliminando os bugs de reconstrução da sua aplicação. |
| 34 | 34 | ||
| 35 | 35 | ||
| 36 | -- **[How to use?](#how-to-use)** | ||
| 37 | -- **[Navigating without named routes](#Navigating-without-named-routes)** | 36 | +- **[Como usar?](#como-usar)** |
| 37 | +- **[Navegação sem rotas nomeadas](#navegação-sem-rotas-nomeadas)** | ||
| 38 | - **[SnackBars](#SnackBars)** | 38 | - **[SnackBars](#SnackBars)** |
| 39 | - **[Dialogs](#Dialogs)** | 39 | - **[Dialogs](#Dialogs)** |
| 40 | - **[BottomSheets](#BottomSheets)** | 40 | - **[BottomSheets](#BottomSheets)** |
| @@ -59,131 +59,132 @@ Essa biblioteca vai mudar a forma que você trabalha com o Framework e salvar se | @@ -59,131 +59,132 @@ Essa biblioteca vai mudar a forma que você trabalha com o Framework e salvar se | ||
| 59 | 59 | ||
| 60 | Any contribution is welcome! | 60 | Any contribution is welcome! |
| 61 | 61 | ||
| 62 | -## How to use? | 62 | +## Como usar? |
| 63 | 63 | ||
| 64 | <!-- - Flutter Master/Dev/Beta: version 2.0.x-dev | 64 | <!-- - Flutter Master/Dev/Beta: version 2.0.x-dev |
| 65 | - Flutter Stable branch: version 2.0.x | 65 | - Flutter Stable branch: version 2.0.x |
| 66 | -(look for latest version on pub.dev) --> | 66 | +(procure pela versão mais recente em pub.dev) --> |
| 67 | 67 | ||
| 68 | -Add Get to your pubspec.yaml file | 68 | +Adicione Get ao seu arquivo pubspec.yaml |
| 69 | <!-- according to the version of Flutter you are using. --> | 69 | <!-- according to the version of Flutter you are using. --> |
| 70 | 70 | ||
| 71 | -Exchange your MaterialApp for GetMaterialApp and enjoy! | 71 | +Troque seu `MaterialApp` por `GetMaterialApp` e aproveite! |
| 72 | ```dart | 72 | ```dart |
| 73 | import 'package:get/get.dart'; | 73 | import 'package:get/get.dart'; |
| 74 | + | ||
| 74 | GetMaterialApp( // Before: MaterialApp( | 75 | GetMaterialApp( // Before: MaterialApp( |
| 75 | home: MyHome(), | 76 | home: MyHome(), |
| 76 | ) | 77 | ) |
| 77 | ``` | 78 | ``` |
| 78 | -## Navigating without named routes | ||
| 79 | -To navigate to a new screen: | 79 | + |
| 80 | +## Navegação sem rotas nomeadas | ||
| 81 | +Para navegar para uma próxima tela: | ||
| 80 | 82 | ||
| 81 | ```dart | 83 | ```dart |
| 82 | -Get.to(NextScreen()); | 84 | +Get.to(ProximaTela()); |
| 83 | ``` | 85 | ``` |
| 84 | 86 | ||
| 85 | -To return to previous screen | 87 | +Para retornar para a tela anterior: |
| 86 | 88 | ||
| 87 | ```dart | 89 | ```dart |
| 88 | Get.back(); | 90 | Get.back(); |
| 89 | ``` | 91 | ``` |
| 90 | 92 | ||
| 91 | -To go to the next screen and no option to go back to the previous screen (for use in SplashScreens, login screens and etc.) | 93 | +Para ir para a próxima tela e NÃO deixar opção para voltar para a tela anterior (bom para SplashScreens, telas de login e etc.): |
| 92 | 94 | ||
| 93 | ```dart | 95 | ```dart |
| 94 | -Get.off(NextScreen()); | 96 | +Get.off(ProximaTela()); |
| 95 | ``` | 97 | ``` |
| 96 | 98 | ||
| 97 | -To go to the next screen and cancel all previous routes (useful in shopping carts, polls, and tests) | 99 | +Para ir para a próxima tela e cancelar todas as rotas anteriores (útil em telas de carrinho, votações e testes): |
| 98 | 100 | ||
| 99 | ```dart | 101 | ```dart |
| 100 | -Get.offAll(NextScreen()); | 102 | +Get.offAll(ProximaTela()); |
| 101 | ``` | 103 | ``` |
| 102 | 104 | ||
| 103 | -To navigate to the next route, and receive or update data as soon as you return from it: | 105 | +Para navegar para a próxima rota, e recebar ou atualizar dados assim que retornar da rota: |
| 104 | ```dart | 106 | ```dart |
| 105 | -var data = await Get.to(Payment()); | 107 | +var dados = await Get.to(Pagamento()); |
| 106 | ``` | 108 | ``` |
| 107 | -on other screen, send a data for previous route: | 109 | +Na outra tela, envie os dados para a rota anterior: |
| 108 | 110 | ||
| 109 | ```dart | 111 | ```dart |
| 110 | -Get.back(result: 'sucess'); | 112 | +Get.back(result: 'sucesso'); |
| 111 | ``` | 113 | ``` |
| 112 | -And use it: | 114 | +E use-os: |
| 113 | 115 | ||
| 114 | -ex: | ||
| 115 | ```dart | 116 | ```dart |
| 116 | -if(data == 'sucess') madeAnything(); | 117 | +if (dados == 'sucesso') fazerQualquerCoisa(); |
| 117 | ``` | 118 | ``` |
| 118 | 119 | ||
| 119 | -Don't you want to learn our syntax? | ||
| 120 | -Just change the Navigator (uppercase) to navigator (lowercase), and you will have all the functions of the standard navigation, without having to use context | ||
| 121 | -Example: | 120 | +Não quer aprender nossa sintaxe? |
| 121 | +Apenas mude o `Navigator` (letra maiúscula) para `navigator` (letra minúscula), e você terá todas as funcionalidades da navigation padrão, sem precisar usar `context` | ||
| 122 | 122 | ||
| 123 | -```dart | 123 | +Exemplo: |
| 124 | 124 | ||
| 125 | -// Default Flutter navigator | 125 | +```dart |
| 126 | +// Navigator padrão do Flutter | ||
| 126 | Navigator.of(context).push( | 127 | Navigator.of(context).push( |
| 127 | - context, | ||
| 128 | - MaterialPageRoute( | ||
| 129 | - builder: (BuildContext context) { | ||
| 130 | - return HomePage(); | ||
| 131 | - }, | ||
| 132 | - ), | ||
| 133 | - ); | 128 | + context, |
| 129 | + MaterialPageRoute( | ||
| 130 | + builder: (BuildContext context) { | ||
| 131 | + return HomePage(); | ||
| 132 | + }, | ||
| 133 | + ), | ||
| 134 | +); | ||
| 134 | 135 | ||
| 135 | -// Get using Flutter syntax without needing context | 136 | +// Get usando a sintaxe Flutter sem precisar do context |
| 136 | navigator.push( | 137 | navigator.push( |
| 137 | - MaterialPageRoute( | ||
| 138 | - builder: (_) { | ||
| 139 | - return HomePage(); | ||
| 140 | - }, | ||
| 141 | - ), | ||
| 142 | - ); | 138 | + MaterialPageRoute( |
| 139 | + builder: (_) { | ||
| 140 | + return HomePage(); | ||
| 141 | + }, | ||
| 142 | + ), | ||
| 143 | +); | ||
| 143 | 144 | ||
| 144 | -// Get syntax (It is much better, but you have the right to disagree) | 145 | +// Sintaxe do Get (é bem melhor, mas você tem o direito de discordar) |
| 145 | Get.to(HomePage()); | 146 | Get.to(HomePage()); |
| 146 | - | ||
| 147 | - | ||
| 148 | ``` | 147 | ``` |
| 149 | 148 | ||
| 150 | ### SnackBars | 149 | ### SnackBars |
| 151 | 150 | ||
| 152 | -To have a simple SnackBar with Flutter, you must get the context of Scaffold, or you must use a GlobalKey attached to your Scaffold, | 151 | +Para ter um `SnackBar` simples no Flutter, você precisa pegar o `context` do Scaffold, ou você precisa de uma `GlobalKey` atrelada ao seu Scaffold |
| 153 | ```dart | 152 | ```dart |
| 154 | final snackBar = SnackBar( | 153 | final snackBar = SnackBar( |
| 155 | - content: Text('Hi!'), | ||
| 156 | - action: SnackBarAction( | ||
| 157 | - label: 'I am a old and ugly snackbar :(', | ||
| 158 | - onPressed: (){} | ||
| 159 | - ), | ||
| 160 | - // Find the Scaffold in the widget tree and use | ||
| 161 | - // it to show a SnackBar. | ||
| 162 | - Scaffold.of(context).showSnackBar(snackBar); | 154 | + content: Text('Olá!'), |
| 155 | + action: SnackBarAction( | ||
| 156 | + label: 'Eu sou uma SnackBar velha e feia :(', | ||
| 157 | + onPressed: (){} | ||
| 158 | + ), | ||
| 159 | +); | ||
| 160 | +// Encontra o Scaffold na árvore de Widgets e | ||
| 161 | +// o usa para mostrar o SnackBar | ||
| 162 | +Scaffold.of(context).showSnackBar(snackBar); | ||
| 163 | ``` | 163 | ``` |
| 164 | 164 | ||
| 165 | -With Get: | 165 | +Com o Get: |
| 166 | 166 | ||
| 167 | ```dart | 167 | ```dart |
| 168 | -Get.snackbar('Hi', 'i am a modern snackbar'); | 168 | +Get.snackbar('Olá', 'eu sou uma SnackBar moderna e linda!'); |
| 169 | ``` | 169 | ``` |
| 170 | 170 | ||
| 171 | -With Get, all you have to do is call your Get.snackbar from anywhere in your code or customize it however you want! | 171 | +Com Get, tudo que você precisa fazer é chamar `Get.snackbar` de qualquer lugar no seu código, ou custumizá-lo da forma que quiser! |
| 172 | 172 | ||
| 173 | ```dart | 173 | ```dart |
| 174 | - Get.snackbar( | ||
| 175 | - "Hey i'm a Get SnackBar!", // title | ||
| 176 | - "It's unbelievable! I'm using SnackBar without context, without boilerplate, without Scaffold, it is something truly amazing!", // message | ||
| 177 | - icon: Icon(Icons.alarm), | ||
| 178 | - shouldIconPulse: true, | ||
| 179 | - onTap:(){}, | ||
| 180 | - barBlur: 20, | ||
| 181 | - isDismissible: true, | ||
| 182 | - duration: Duration(seconds: 3), | ||
| 183 | - ); | 174 | +Get.snackbar( |
| 175 | + "Ei, eu sou uma SnackBar Get!", // título | ||
| 176 | + "É inacreditável! Eu estou usando uma SnackBar sem context, sem " + | ||
| 177 | + "boilerplate, sem Scaffold, é algo realmente maravilhoso!", // mensagem | ||
| 178 | + icon: Icon(Icons.alarm), | ||
| 179 | + shouldIconPulse: true, | ||
| 180 | + onTap:(){}, | ||
| 181 | + barBlur: 20, | ||
| 182 | + isDismissible: true, | ||
| 183 | + duration: Duration(seconds: 3), | ||
| 184 | +); | ||
| 184 | 185 | ||
| 185 | 186 | ||
| 186 | - ////////// ALL FEATURES ////////// | 187 | + ////////// TODOS OS RECURSOS ////////// |
| 187 | // Color colorText, | 188 | // Color colorText, |
| 188 | // Duration duration, | 189 | // Duration duration, |
| 189 | // SnackPosition snackPosition, | 190 | // SnackPosition snackPosition, |
| @@ -219,27 +220,27 @@ With Get, all you have to do is call your Get.snackbar from anywhere in your cod | @@ -219,27 +220,27 @@ With Get, all you have to do is call your Get.snackbar from anywhere in your cod | ||
| 219 | // Form userInputForm | 220 | // Form userInputForm |
| 220 | /////////////////////////////////// | 221 | /////////////////////////////////// |
| 221 | ``` | 222 | ``` |
| 222 | -If you prefer the traditional snackbar, or want to customize it from scratch, including adding just one line (Get.snackbar makes use of a mandatory title and message), you can use | ||
| 223 | -`Get.rawSnackbar();` which provides the RAW API on which Get.snackbar was built. | 223 | +Se você prefere a SnackBar tradicional, ou quer customizar por completo, incluindo até adicionar apenas uma linha (Get.snackbar usa um `title` e `message` obrigatórios), você pode usar `Get.rawSnackbar();` que fornece a RAW API na qual Get.snackbar foi contruído. |
| 224 | 224 | ||
| 225 | ### Dialogs | 225 | ### Dialogs |
| 226 | 226 | ||
| 227 | -To open dialog: | 227 | +Para abrir um dialog: |
| 228 | 228 | ||
| 229 | ```dart | 229 | ```dart |
| 230 | -Get.dialog(YourDialogWidget()); | 230 | +Get.dialog(SeuDialogWidget()); |
| 231 | ``` | 231 | ``` |
| 232 | 232 | ||
| 233 | -To open default dialog: | 233 | +Para abrir um dialog padrão: |
| 234 | 234 | ||
| 235 | ```dart | 235 | ```dart |
| 236 | - Get.defaultDialog( | ||
| 237 | - onConfirm: () => print("Ok"), | ||
| 238 | - middleText: "Dialog made in 3 lines of code"); | 236 | +Get.defaultDialog( |
| 237 | + onConfirm: () => print("Ok"), | ||
| 238 | + middleText: "Dialog made in 3 lines of code", | ||
| 239 | +); | ||
| 239 | ``` | 240 | ``` |
| 240 | -You can also use Get.generalDialog instead of showGeneralDialog. | 241 | +Você também pode usar `Get.generalDialog` em vez de `showGeneralDialog`. |
| 241 | 242 | ||
| 242 | -For all other Flutter dialog widgets, including cupertinos, you can use Get.overlayContext instead of context, and open it anywhere in your code. | 243 | +Para todos os outros Widgets dialog do Flutter, incluindo os do Cupertino, você pode usar `Get.overlayContext` em vez do `context`, e abrir em qualquer lugar do seu código. |
| 243 | For widgets that don't use Overlay, you can use Get.context. | 244 | For widgets that don't use Overlay, you can use Get.context. |
| 244 | These two contexts will work in 99% of cases to replace the context of your UI, except for cases where inheritedWidget is used without a navigation context. | 245 | These two contexts will work in 99% of cases to replace the context of your UI, except for cases where inheritedWidget is used without a navigation context. |
| 245 | 246 |
-
Please register or login to post a comment