Showing
2 changed files
with
34 additions
and
6 deletions
| @@ -29,7 +29,7 @@ Add this to your package's pubspec.yaml file: | @@ -29,7 +29,7 @@ Add this to your package's pubspec.yaml file: | ||
| 29 | 29 | ||
| 30 | ``` | 30 | ``` |
| 31 | dependencies: | 31 | dependencies: |
| 32 | - get: ^1.17.2 // ^1.20.0-dev on beta/dev/master | 32 | + get: ^1.17.3 // ^1.20.0-dev on beta/dev/master |
| 33 | ``` | 33 | ``` |
| 34 | 34 | ||
| 35 | And import it: | 35 | And import it: |
| @@ -262,10 +262,11 @@ So you can use your controller (or class Bloc) normally | @@ -262,10 +262,11 @@ So you can use your controller (or class Bloc) normally | ||
| 262 | controller.fetchApi();// Rather Controller controller = Controller(); | 262 | controller.fetchApi();// Rather Controller controller = Controller(); |
| 263 | ``` | 263 | ``` |
| 264 | 264 | ||
| 265 | -Imagine that you have navigated through numerous routes, and you need a data that was left behind in your controller, you would need a state manager combined with the Provider or Get_it, correct? Not with Get. You just need to ask Get to "search" for your controller, you don't need any additional dependencies: | 265 | +Imagine that you have navigated through numerous routes, and you need a data that was left behind in your controller, you would need a state manager combined with the Provider or Get_it, correct? Not with Get. You just need to ask Get to "find" for your controller, you don't need any additional dependencies: |
| 266 | 266 | ||
| 267 | ```dart | 267 | ```dart |
| 268 | -Controller controller = Get.find(Controller()); | 268 | +Controller controller = Get.find(); |
| 269 | +//Yes, it looks like Magic, Get will find your controller, and will deliver it to you. You can have 1 million controllers instantiated, Get will always give you the right controller. | ||
| 269 | ``` | 270 | ``` |
| 270 | And then you will be able to recover your controller data that was obtained back there: | 271 | And then you will be able to recover your controller data that was obtained back there: |
| 271 | 272 | ||
| @@ -275,7 +276,7 @@ Text(controller.textFromApi); | @@ -275,7 +276,7 @@ Text(controller.textFromApi); | ||
| 275 | 276 | ||
| 276 | To remove a instance of Get: | 277 | To remove a instance of Get: |
| 277 | ```dart | 278 | ```dart |
| 278 | -Controller controller = Get.delete(Controller()); | 279 | +Get.delete(Controller()); |
| 279 | ``` | 280 | ``` |
| 280 | 281 | ||
| 281 | 282 | ||
| @@ -295,6 +296,19 @@ To navigate and remove all previous screens from the tree. | @@ -295,6 +296,19 @@ To navigate and remove all previous screens from the tree. | ||
| 295 | Get.offAllNamed("/NextScreen"); | 296 | Get.offAllNamed("/NextScreen"); |
| 296 | ``` | 297 | ``` |
| 297 | 298 | ||
| 299 | +### Send data to named Routes: | ||
| 300 | + | ||
| 301 | +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. | ||
| 302 | +```dart | ||
| 303 | +Get.toNamed("/NextScreen", arguments: 'Get is the best'); | ||
| 304 | +``` | ||
| 305 | +on your class or controller: | ||
| 306 | + | ||
| 307 | +```dart | ||
| 308 | +print(Get.arguments); | ||
| 309 | +//print out: Get is the best | ||
| 310 | +``` | ||
| 311 | + | ||
| 298 | ## Configure the Named Routes and And offering full flutter_web support to friendly urls: | 312 | ## Configure the Named Routes and And offering full flutter_web support to friendly urls: |
| 299 | 313 | ||
| 300 | ### If you have not yet added "navigatorKey: Get.key," to your MaterialApp, do it now. Take the opportunity to add an "initialRoute" and your "onGenerateRoute". | 314 | ### If you have not yet added "navigatorKey: Get.key," to your MaterialApp, do it now. Take the opportunity to add an "initialRoute" and your "onGenerateRoute". |
| @@ -34,7 +34,7 @@ Adicione esse pacote ao seu arquivo pubspec.yaml: | @@ -34,7 +34,7 @@ Adicione esse pacote ao seu arquivo pubspec.yaml: | ||
| 34 | 34 | ||
| 35 | ``` | 35 | ``` |
| 36 | dependencies: | 36 | dependencies: |
| 37 | - get: ^1.17.1s // ^1.20.0-dev on beta/dev/master | 37 | + get: ^1.17.3 // ^1.20.0-dev on beta/dev/master |
| 38 | ``` | 38 | ``` |
| 39 | 39 | ||
| 40 | Importe ele se seu IDE não fizer isso de forma automática: | 40 | Importe ele se seu IDE não fizer isso de forma automática: |
| @@ -269,7 +269,8 @@ controller.fetchApi();// Rather Controller controller = Controller(); | @@ -269,7 +269,8 @@ controller.fetchApi();// Rather Controller controller = Controller(); | ||
| 269 | Agora, imagine que você navegou por inúmeras rotas e precisa de dados que foram deixados para trás em seu controlador; você precisaria de um gerenciador de estado combinado com o Provider ou Get_it, correto? Não com Get. Você só precisa pedir ao Get para "procurar" pelo seu controlador, você não precisa de nenhuma dependência adicional para isso: | 269 | Agora, imagine que você navegou por inúmeras rotas e precisa de dados que foram deixados para trás em seu controlador; você precisaria de um gerenciador de estado combinado com o Provider ou Get_it, correto? Não com Get. Você só precisa pedir ao Get para "procurar" pelo seu controlador, você não precisa de nenhuma dependência adicional para isso: |
| 270 | 270 | ||
| 271 | ```dart | 271 | ```dart |
| 272 | -Controller controller = Get.find(Controller()); | 272 | +Controller controller = Get.find(); |
| 273 | +// Sim, parece Magia, o Get irá descobrir qual é seu controller, e irá te entregar. Você pode ter 1 milhão de controllers instanciados, o Get sempre te entregará o controller correto. Apenas se lembre de Tipar seu controller, final controller = Get.find(); por exemplo, não irá funcionar. | ||
| 273 | ``` | 274 | ``` |
| 274 | E então você poderá recuperar os dados do seu controlador obtidos lá: | 275 | E então você poderá recuperar os dados do seu controlador obtidos lá: |
| 275 | 276 | ||
| @@ -300,6 +301,19 @@ Para navegar para uma nova tela e remover todas rotas anteriores da stack | @@ -300,6 +301,19 @@ Para navegar para uma nova tela e remover todas rotas anteriores da stack | ||
| 300 | Get.offAllNamed("/NextScreen"); | 301 | Get.offAllNamed("/NextScreen"); |
| 301 | ``` | 302 | ``` |
| 302 | 303 | ||
| 304 | +### Enviando dados por rotas nomeadas: | ||
| 305 | + | ||
| 306 | +Apenas envie o que você quiser por argumentos. Get aceita qualquer coisa aqui, não importa se é uma String, um Map, uma List, int ou até uma instancia de classe. | ||
| 307 | +```dart | ||
| 308 | +Get.toNamed("/NextScreen", arguments: 'Get is the best'); | ||
| 309 | +``` | ||
| 310 | +Agora você pode recuperar em sua classe ou em seu controller: | ||
| 311 | + | ||
| 312 | +```dart | ||
| 313 | +print(Get.arguments); | ||
| 314 | +//print out: Get is the best | ||
| 315 | +``` | ||
| 316 | + | ||
| 303 | ## Configurando rotas nomeadas e adicionando suporte completo à urls amigáveis do Flutter Web | 317 | ## Configurando rotas nomeadas e adicionando suporte completo à urls amigáveis do Flutter Web |
| 304 | 318 | ||
| 305 | ### Se você ainda não adicionou " navigatorKey: Get.key," ao seu MaterialApp, faça agora. aproveite para adicionar uma "initialRoute" e o seu "onGenerateRoute". | 319 | ### Se você ainda não adicionou " navigatorKey: Get.key," ao seu MaterialApp, faça agora. aproveite para adicionar uma "initialRoute" e o seu "onGenerateRoute". |
-
Please register or login to post a comment