Renat Fakhrutdinov
Committed by GitHub

Merge pull request #3 from jonataslaw/master

update
Showing 53 changed files with 1139 additions and 660 deletions
  1 +## [3.5.1]
  2 +- Remove unnecessary whitespaces
  3 +
  4 +## [3.5.0]
  5 +- Added logwritter (@stefandevo)
  6 +- Added responsiveValue (@juanjoseleca)
  7 +- Fixed ghost url for snackbar, bottomsheets, and dialogs and unnamed navigation.
  8 +
1 ## [3.4.6] 9 ## [3.4.6]
2 - Fix TextField dispose throw on last Flutter hotfix 10 - Fix TextField dispose throw on last Flutter hotfix
3 11
@@ -6,7 +14,8 @@ @@ -6,7 +14,8 @@
6 - Remove initialization console print 14 - Remove initialization console print
7 15
8 ## [3.4.4] 16 ## [3.4.4]
9 -- Fix exception 'isInit called null' when tags are used in conjunction with dependencies. (@djade007) 17 +- Fix exception 'isInit called null' when tags are used in conjunction with dependencies. (@djade007)
  18 +- Fix typos (@tiagocpeixoto)
10 19
11 ## [3.4.3] 20 ## [3.4.3]
12 - Fix onInit fired only first time 21 - Fix onInit fired only first time
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 4
5 [![pub package](https://img.shields.io/pub/v/get.svg?label=get&color=blue)](https://pub.dev/packages/get) 5 [![pub package](https://img.shields.io/pub/v/get.svg?label=get&color=blue)](https://pub.dev/packages/get)
6 ![building](https://github.com/jonataslaw/get/workflows/build/badge.svg) 6 ![building](https://github.com/jonataslaw/get/workflows/build/badge.svg)
7 -[![Gitter](https://badges.gitter.im/flutter_get/community.svg)](https://gitter.im/flutter_get/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) 7 +[![Discord Shield](https://discordapp.com/api/guilds/722900883784073290/widget.png?style=shield)](https://discord.com/invite/9Hpt99N)
8 <a href="https://github.com/Solido/awesome-flutter"> 8 <a href="https://github.com/Solido/awesome-flutter">
9 <img alt="Awesome Flutter" src="https://img.shields.io/badge/Awesome-Flutter-blue.svg?longCache=true&style=flat-square" /> 9 <img alt="Awesome Flutter" src="https://img.shields.io/badge/Awesome-Flutter-blue.svg?longCache=true&style=flat-square" />
10 </a> 10 </a>
@@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
40 40
41 [**Slack (English)**](https://communityinviter.com/apps/getxworkspace/getx) 41 [**Slack (English)**](https://communityinviter.com/apps/getxworkspace/getx)
42 42
43 -[**Discord (English and Portuguese)**](https://discord.com/invite/9Hpt99N) 43 +[**Discord (English, Spanish and Portuguese)**](https://discord.com/invite/9Hpt99N)
44 44
45 [**Telegram (Portuguese)**](https://t.me/joinchat/PhdbJRmsZNpAqSLJL6bH7g) 45 [**Telegram (Portuguese)**](https://t.me/joinchat/PhdbJRmsZNpAqSLJL6bH7g)
46 46
@@ -431,6 +431,14 @@ context.isLargeTablet() @@ -431,6 +431,14 @@ context.isLargeTablet()
431 431
432 /// True if the current device is Tablet 432 /// True if the current device is Tablet
433 context.isTablet() 433 context.isTablet()
  434 +
  435 +/// Returns a value according to the screen size
  436 +/// can give value for
  437 +/// swatch: if the shortestSide is smaller than 300
  438 +/// mobile: if the shortestSide is smaller than 600
  439 +/// tablet: if the shortestSide is smaller than 1200
  440 +/// desktop: if width is largest than 1200
  441 +context.responsiveValue<T>()
434 ``` 442 ```
435 443
436 ### Optional Global Settings and Manual configurations 444 ### Optional Global Settings and Manual configurations
@@ -474,6 +482,22 @@ Get.config( @@ -474,6 +482,22 @@ Get.config(
474 ) 482 )
475 ``` 483 ```
476 484
  485 +You can optionally redirect all the logging messages from Get. If you want to use your own favourite logging package and want to capture the logs there.
  486 +
  487 +```dart
  488 +GetMaterialApp(
  489 + enableLog: true,
  490 + logWriterCallback: localLogWriter,
  491 +);
  492 +
  493 +void localLogWriter(String text, {bool isError = false}) {
  494 + // pass the message to your favourite logging package here
  495 + // please note that even if enableLog: false log messages will be pushed in this callback
  496 + // you get check the flag if you want through GetConfig.isLogEnable
  497 +}
  498 +
  499 +```
  500 +
477 ## Video explanation of Other GetX Features 501 ## Video explanation of Other GetX Features
478 502
479 503
@@ -473,6 +473,22 @@ Get.config( @@ -473,6 +473,22 @@ Get.config(
473 ) 473 )
474 ``` 474 ```
475 475
  476 +É possível redirecionar todas as mensagens de log do GetX. Útil quando se tem um package de logging e vc quer que ele lide com todos os logs
  477 +
  478 +```dart
  479 +GetMaterialApp(
  480 + enableLog: true,
  481 + logWriterCallback: localLogWriter,
  482 +);
  483 +
  484 +void localLogWriter(String text, {bool isError = false}) {
  485 + // passage a mensagem para seu package de logging favorito aqui
  486 + // Obs: mesmo que as mensagens de log estejam desativadas
  487 + // com o comando "enableLog: false", as mensagens ainda vão passar por aqui
  488 + // Você precisa checar essa config manualmente aqui se quiser respeitá-la
  489 +}
  490 +```
  491 +
476 ## Video explanation of Other GetX Features 492 ## Video explanation of Other GetX Features
477 493
478 494
@@ -15,6 +15,13 @@ packages: @@ -15,6 +15,13 @@ packages:
15 url: "https://pub.dartlang.org" 15 url: "https://pub.dartlang.org"
16 source: hosted 16 source: hosted
17 version: "0.39.10" 17 version: "0.39.10"
  18 + archive:
  19 + dependency: transitive
  20 + description:
  21 + name: archive
  22 + url: "https://pub.dartlang.org"
  23 + source: hosted
  24 + version: "2.0.13"
18 args: 25 args:
19 dependency: transitive 26 dependency: transitive
20 description: 27 description:
@@ -28,7 +35,7 @@ packages: @@ -28,7 +35,7 @@ packages:
28 name: async 35 name: async
29 url: "https://pub.dartlang.org" 36 url: "https://pub.dartlang.org"
30 source: hosted 37 source: hosted
31 - version: "2.4.2" 38 + version: "2.5.0-nullsafety"
32 bloc: 39 bloc:
33 dependency: "direct main" 40 dependency: "direct main"
34 description: 41 description:
@@ -42,7 +49,7 @@ packages: @@ -42,7 +49,7 @@ packages:
42 name: boolean_selector 49 name: boolean_selector
43 url: "https://pub.dartlang.org" 50 url: "https://pub.dartlang.org"
44 source: hosted 51 source: hosted
45 - version: "2.0.0" 52 + version: "2.1.0-nullsafety"
46 build: 53 build:
47 dependency: transitive 54 dependency: transitive
48 description: 55 description:
@@ -105,14 +112,14 @@ packages: @@ -105,14 +112,14 @@ packages:
105 name: characters 112 name: characters
106 url: "https://pub.dartlang.org" 113 url: "https://pub.dartlang.org"
107 source: hosted 114 source: hosted
108 - version: "1.1.0-nullsafety" 115 + version: "1.1.0-nullsafety.2"
109 charcode: 116 charcode:
110 dependency: transitive 117 dependency: transitive
111 description: 118 description:
112 name: charcode 119 name: charcode
113 url: "https://pub.dartlang.org" 120 url: "https://pub.dartlang.org"
114 source: hosted 121 source: hosted
115 - version: "1.1.3" 122 + version: "1.2.0-nullsafety"
116 checked_yaml: 123 checked_yaml:
117 dependency: transitive 124 dependency: transitive
118 description: 125 description:
@@ -126,7 +133,7 @@ packages: @@ -126,7 +133,7 @@ packages:
126 name: clock 133 name: clock
127 url: "https://pub.dartlang.org" 134 url: "https://pub.dartlang.org"
128 source: hosted 135 source: hosted
129 - version: "1.0.1" 136 + version: "1.1.0-nullsafety"
130 code_builder: 137 code_builder:
131 dependency: transitive 138 dependency: transitive
132 description: 139 description:
@@ -140,7 +147,7 @@ packages: @@ -140,7 +147,7 @@ packages:
140 name: collection 147 name: collection
141 url: "https://pub.dartlang.org" 148 url: "https://pub.dartlang.org"
142 source: hosted 149 source: hosted
143 - version: "1.15.0-nullsafety" 150 + version: "1.15.0-nullsafety.2"
144 convert: 151 convert:
145 dependency: transitive 152 dependency: transitive
146 description: 153 description:
@@ -154,7 +161,7 @@ packages: @@ -154,7 +161,7 @@ packages:
154 name: crypto 161 name: crypto
155 url: "https://pub.dartlang.org" 162 url: "https://pub.dartlang.org"
156 source: hosted 163 source: hosted
157 - version: "2.1.5" 164 + version: "2.1.4"
158 csslib: 165 csslib:
159 dependency: transitive 166 dependency: transitive
160 description: 167 description:
@@ -189,7 +196,7 @@ packages: @@ -189,7 +196,7 @@ packages:
189 name: fake_async 196 name: fake_async
190 url: "https://pub.dartlang.org" 197 url: "https://pub.dartlang.org"
191 source: hosted 198 source: hosted
192 - version: "1.1.0" 199 + version: "1.1.0-nullsafety"
193 fixnum: 200 fixnum:
194 dependency: transitive 201 dependency: transitive
195 description: 202 description:
@@ -270,6 +277,13 @@ packages: @@ -270,6 +277,13 @@ packages:
270 url: "https://pub.dartlang.org" 277 url: "https://pub.dartlang.org"
271 source: hosted 278 source: hosted
272 version: "3.1.4" 279 version: "3.1.4"
  280 + image:
  281 + dependency: transitive
  282 + description:
  283 + name: image
  284 + url: "https://pub.dartlang.org"
  285 + source: hosted
  286 + version: "2.1.12"
273 io: 287 io:
274 dependency: transitive 288 dependency: transitive
275 description: 289 description:
@@ -304,14 +318,14 @@ packages: @@ -304,14 +318,14 @@ packages:
304 name: matcher 318 name: matcher
305 url: "https://pub.dartlang.org" 319 url: "https://pub.dartlang.org"
306 source: hosted 320 source: hosted
307 - version: "0.12.8" 321 + version: "0.12.10-nullsafety"
308 meta: 322 meta:
309 dependency: "direct main" 323 dependency: "direct main"
310 description: 324 description:
311 name: meta 325 name: meta
312 url: "https://pub.dartlang.org" 326 url: "https://pub.dartlang.org"
313 source: hosted 327 source: hosted
314 - version: "1.3.0-nullsafety" 328 + version: "1.3.0-nullsafety.2"
315 mime: 329 mime:
316 dependency: transitive 330 dependency: transitive
317 description: 331 description:
@@ -367,7 +381,7 @@ packages: @@ -367,7 +381,7 @@ packages:
367 name: path 381 name: path
368 url: "https://pub.dartlang.org" 382 url: "https://pub.dartlang.org"
369 source: hosted 383 source: hosted
370 - version: "1.7.0" 384 + version: "1.8.0-nullsafety"
371 pedantic: 385 pedantic:
372 dependency: transitive 386 dependency: transitive
373 description: 387 description:
@@ -375,6 +389,13 @@ packages: @@ -375,6 +389,13 @@ packages:
375 url: "https://pub.dartlang.org" 389 url: "https://pub.dartlang.org"
376 source: hosted 390 source: hosted
377 version: "1.9.0" 391 version: "1.9.0"
  392 + petitparser:
  393 + dependency: transitive
  394 + description:
  395 + name: petitparser
  396 + url: "https://pub.dartlang.org"
  397 + source: hosted
  398 + version: "2.4.0"
378 pool: 399 pool:
379 dependency: transitive 400 dependency: transitive
380 description: 401 description:
@@ -456,21 +477,21 @@ packages: @@ -456,21 +477,21 @@ packages:
456 name: source_span 477 name: source_span
457 url: "https://pub.dartlang.org" 478 url: "https://pub.dartlang.org"
458 source: hosted 479 source: hosted
459 - version: "1.7.0" 480 + version: "1.8.0-nullsafety"
460 stack_trace: 481 stack_trace:
461 dependency: transitive 482 dependency: transitive
462 description: 483 description:
463 name: stack_trace 484 name: stack_trace
464 url: "https://pub.dartlang.org" 485 url: "https://pub.dartlang.org"
465 source: hosted 486 source: hosted
466 - version: "1.9.5" 487 + version: "1.10.0-nullsafety"
467 stream_channel: 488 stream_channel:
468 dependency: transitive 489 dependency: transitive
469 description: 490 description:
470 name: stream_channel 491 name: stream_channel
471 url: "https://pub.dartlang.org" 492 url: "https://pub.dartlang.org"
472 source: hosted 493 source: hosted
473 - version: "2.0.0" 494 + version: "2.1.0-nullsafety"
474 stream_transform: 495 stream_transform:
475 dependency: transitive 496 dependency: transitive
476 description: 497 description:
@@ -484,21 +505,21 @@ packages: @@ -484,21 +505,21 @@ packages:
484 name: string_scanner 505 name: string_scanner
485 url: "https://pub.dartlang.org" 506 url: "https://pub.dartlang.org"
486 source: hosted 507 source: hosted
487 - version: "1.0.5" 508 + version: "1.1.0-nullsafety"
488 term_glyph: 509 term_glyph:
489 dependency: transitive 510 dependency: transitive
490 description: 511 description:
491 name: term_glyph 512 name: term_glyph
492 url: "https://pub.dartlang.org" 513 url: "https://pub.dartlang.org"
493 source: hosted 514 source: hosted
494 - version: "1.1.0" 515 + version: "1.2.0-nullsafety"
495 test_api: 516 test_api:
496 dependency: transitive 517 dependency: transitive
497 description: 518 description:
498 name: test_api 519 name: test_api
499 url: "https://pub.dartlang.org" 520 url: "https://pub.dartlang.org"
500 source: hosted 521 source: hosted
501 - version: "0.2.17" 522 + version: "0.2.19-nullsafety"
502 timing: 523 timing:
503 dependency: transitive 524 dependency: transitive
504 description: 525 description:
@@ -512,7 +533,7 @@ packages: @@ -512,7 +533,7 @@ packages:
512 name: typed_data 533 name: typed_data
513 url: "https://pub.dartlang.org" 534 url: "https://pub.dartlang.org"
514 source: hosted 535 source: hosted
515 - version: "1.3.0-nullsafety" 536 + version: "1.3.0-nullsafety.2"
516 uuid: 537 uuid:
517 dependency: "direct main" 538 dependency: "direct main"
518 description: 539 description:
@@ -526,7 +547,7 @@ packages: @@ -526,7 +547,7 @@ packages:
526 name: vector_math 547 name: vector_math
527 url: "https://pub.dartlang.org" 548 url: "https://pub.dartlang.org"
528 source: hosted 549 source: hosted
529 - version: "2.1.0-nullsafety" 550 + version: "2.1.0-nullsafety.2"
530 watcher: 551 watcher:
531 dependency: transitive 552 dependency: transitive
532 description: 553 description:
@@ -541,6 +562,13 @@ packages: @@ -541,6 +562,13 @@ packages:
541 url: "https://pub.dartlang.org" 562 url: "https://pub.dartlang.org"
542 source: hosted 563 source: hosted
543 version: "1.1.0" 564 version: "1.1.0"
  565 + xml:
  566 + dependency: transitive
  567 + description:
  568 + name: xml
  569 + url: "https://pub.dartlang.org"
  570 + source: hosted
  571 + version: "3.6.1"
544 yaml: 572 yaml:
545 dependency: transitive 573 dependency: transitive
546 description: 574 description:
@@ -549,5 +577,5 @@ packages: @@ -549,5 +577,5 @@ packages:
549 source: hosted 577 source: hosted
550 version: "2.2.1" 578 version: "2.2.1"
551 sdks: 579 sdks:
552 - dart: ">=2.9.0-18.0 <2.9.0" 580 + dart: ">=2.10.0-0.0.dev <2.10.0"
553 flutter: ">=1.16.0" 581 flutter: ">=1.16.0"
@@ -476,7 +476,7 @@ Get.bottomSheet( @@ -476,7 +476,7 @@ Get.bottomSheet(
476 ), 476 ),
477 ], 477 ],
478 ), 478 ),
479 - ); 479 + )
480 ); 480 );
481 ``` 481 ```
482 482
@@ -476,7 +476,7 @@ Get.bottomSheet( @@ -476,7 +476,7 @@ Get.bottomSheet(
476 ), 476 ),
477 ], 477 ],
478 ), 478 ),
479 - ); 479 + )
480 ); 480 );
481 ``` 481 ```
482 482
@@ -20,7 +20,7 @@ Em vez de instanciar sua classe dentro da classe que você está usando, você e @@ -20,7 +20,7 @@ Em vez de instanciar sua classe dentro da classe que você está usando, você e
20 20
21 Para que então você possa usar seu controller (ou uma classe Bloc) normalmente 21 Para que então você possa usar seu controller (ou uma classe Bloc) normalmente
22 22
23 -**Tip:** O gerenciamento de dependência do get é desaclpado de outras partes do package, então se por exemplo seu aplicativo já está usando um outro gerenciador de estado (qualquer um, não importa), você não precisa de reescrever tudo, pode simplesmente usar só a injeção de dependência sem problemas 23 +**Tip:** O gerenciamento de dependência do get é desacoplado de outras partes do package, então se por exemplo seu aplicativo já está usando um outro gerenciador de estado (qualquer um, não importa), você não precisa de reescrever tudo, pode simplesmente usar só a injeção de dependência sem problemas
24 24
25 ```dart 25 ```dart
26 controller.fetchApi(); 26 controller.fetchApi();
@@ -71,11 +71,11 @@ Para remover a instância do Get: @@ -71,11 +71,11 @@ Para remover a instância do Get:
71 Get.delete<Controller>(); 71 Get.delete<Controller>();
72 ``` 72 ```
73 73
74 -## Opções 74 +## Métodos de instanciamento.
75 75
76 -Quando você usa Get.put, lazyPut e putAsync, existe algumas opções que você pode alterar se quiser 76 +Apesar do Get já entregar configurações muito boas para uso, é possível refiná-las ainda mais para que sejam de utilidade ainda maior para você programador. Os métodos e seus parâmetros configuráveis são:
77 77
78 -- No Get.put(): 78 +- Get.put():
79 79
80 ```dart 80 ```dart
81 Get.put<S>( 81 Get.put<S>(
@@ -95,17 +95,12 @@ Get.put<S>( @@ -95,17 +95,12 @@ Get.put<S>(
95 // padrão: false 95 // padrão: false
96 bool permanent = false, 96 bool permanent = false,
97 97
98 - // opcional: permite que depois de usar uma classe abstrata num teste,  
99 - // trocar por outra e continuar com o teste  
100 - // padrão: false  
101 - bool overrideAbstract = false,  
102 -  
103 // opcional: permite criar a dependência usando uma função em vez da dependênia em si 98 // opcional: permite criar a dependência usando uma função em vez da dependênia em si
104 FcBuilderFunc<S> builder, 99 FcBuilderFunc<S> builder,
105 ) 100 )
106 ``` 101 ```
107 102
108 -- No Get.lazyPut: 103 +- Get.lazyPut:
109 104
110 ```dart 105 ```dart
111 Get.lazyPut<S>( 106 Get.lazyPut<S>(
@@ -126,7 +121,7 @@ Get.lazyPut<S>( @@ -126,7 +121,7 @@ Get.lazyPut<S>(
126 ) 121 )
127 ``` 122 ```
128 123
129 -- No Get.putAsync: 124 +- Get.putAsync:
130 125
131 ```dart 126 ```dart
132 Get.putAsync<S>( 127 Get.putAsync<S>(
@@ -143,6 +138,44 @@ Get.putAsync<S>( @@ -143,6 +138,44 @@ Get.putAsync<S>(
143 bool permanent = false 138 bool permanent = false
144 ``` 139 ```
145 140
  141 +- Get.create:
  142 +
  143 +```dart
  144 +Get.create<S>(
  145 + // Obrigatório: Uma função que retorna uma classe que será "fabricada" toda vez que Get.find() for chamado
  146 + // Exemplo: Get.create<YourClass>(() => YourClass())
  147 + FcBuilderFunc<S> builder,
  148 +
  149 + // opcional: igual ao Get.put(), mas é usado quando você precisa de múltiplas instâncias de uma mesma classe.
  150 + // Útil caso você tenha uma lista em que cada item precise de um controller próprio
  151 + // precisa ser uma string única. Apenas mudou o nome de tag para name.
  152 + String name,
  153 +
  154 + // opcional: igual ao Get.put(), usado quando você precisa manter a instância ativa no app inteiro. A diferença
  155 + // é que com Get.create o permanent está habilitado por padrão
  156 + bool permanent = true
  157 +```
  158 +
  159 +### Diferenças entre os métodos:
  160 +
  161 +Primeiramente, vamos falar das variáveis `_factory` e `_singl`. Ambas são essenciais no processo de criação e uso de suas dependências, pois é através delas que podemos armazenar, apagar, recriar nossas instâncias.
  162 +
  163 +Primeiro, vamos falar do `fenix` do Get.lazyPut e o `permanent` dos outros métodos.
  164 +
  165 +- O `fenix` diz respeito ao armazenamento da instância. Quando você manipula os parâmetros `fenix` ou `smartManagement` para não perder as instâncias da sua dependência, elas serão salvas na para serem chamadas posteriormente.
  166 +
  167 +- O `permanent` diz respeito ao uso. Se a instância permanece ativa, ou se é apagada, quando não está em uso na tela.
  168 +
  169 +A diferença fundamental entre `permanent` e `fenix` está em como você quer armazenar as suas instâncias. Reforçando: por padrão, o Get apaga as instâncias quando elas não estão em uso (Digamos que a tela 1 tenha o controlador A e tela 2, controlador B. Ao mover-se de 1 para 2, o controlador A perde o uso e portanto é apagado), mas se você optar por algo `permanent: true`, então ela não se perde nessa transição - o que é muito útil para serviços que você quer manter rodando na aplicação inteira. Já o `fenix`, é para serviços que você não se preocupa em perder por uma tela ou outra, mas quando você precisar chamar o serviço, você espera que ele "retorne das cinzas" (`fenix: true`), criando uma nova instância.
  170 +
  171 +Prosseguindo com as diferenças entre os métodos:
  172 +
  173 +- Get.put e Get.putAsync seguem a mesma ordem de criação, com a diferença que o Async opta por aplicar um método assíncrono: Esses dois métodos criam e já inicializam a instância. Esta é inserida diretamente na memória, através do método interno `insert` com os parâmetros `permanent: false` e `isSingleton: true` (esse parâmetro `isSingleton` serve apenas para dizer se é para utilizar a dependência colocada em `dependency`, ou se é para usar a dependência colocada no `FcBuilderFunc`). Depois disso, é chamado o `Get.find` que imediatamente inicializa as instâncias que estão na memória.
  174 +
  175 +- Get.create: Como o nome indica, você vai "criar" a sua dependência! Similar ao `Get.put`, ela também chama o método interno `insert` para instanciamento. Contudo, `permanent` e `isSingleton` passam a ser `true` e `false` (Como estamos "criando" a nossa dependência, não tem como ela ser um Singleton de algo, logo, `false`). E por ser `permanent: true`, temos por padrão o benefício de não se perder entre telas! Além disso, não é chamado o `Get.find`, logo ela fica esperando ser chamada para ser usada. Ele é criado dessa forma para aproveitar o uso do parâmetro `permanent`, já que, vale ressaltar, o Get.create foi criado com o objetivo de criar instâncias não compartilhadas, mas que não se perdem, como por exemplo um botão em um listView, que você quer uma instância única para aquela lista - por conta disso, o Get.create deve ser usado em conjunto com o GetWidget.
  176 +
  177 +- Get.lazyPut: Como o nome dá a entender, é um processo preguiçoso (lazy). A instância é criada, mas ela não é chamada para uso logo em seguida, ela fica aguardando ser chamada. Diferente dos outros métodos, o `insert` não é chamado. Ao invés disso, a instância é inserida em outra parte na memória, uma parte responsável por dizer se a instância pode ser recriada ou não, vamos chamá-la de "fábrica". Se queremos criar algo para ser chamado só depois, não vamos misturá-lo com as coisas que estão sendo usadas agora. E é aqui que entra a mágica do `fenix`. Se você optou por deixar `fenix: false`, e seu `smartManagement` não for `keepFactory`, então ao usar o `Get.find` a instância passa da "fábrica" para a área comum das instância. Em seguinda, por padrão é removida da "fábrica". Agora, se você optou por `fenix: true`, a instância continua a existir nessa parte dedicada, mesmo indo para a área comum, para ser chamada futuramente caso precise.
  178 +
146 ## Bindings 179 ## Bindings
147 180
148 Um dos grandes diferenciais desse package, talvez, seja a possibilidade de integração total com rotas, gerenciador de estado e gerenciador de dependências. 181 Um dos grandes diferenciais desse package, talvez, seja a possibilidade de integração total com rotas, gerenciador de estado e gerenciador de dependências.
  1 +# Miscellaneous
  2 +*.class
  3 +*.log
  4 +*.pyc
  5 +*.swp
  6 +.DS_Store
  7 +.atom/
  8 +.buildlog/
  9 +.history
  10 +.svn/
  11 +
  12 +# IntelliJ related
  13 +*.iml
  14 +*.ipr
  15 +*.iws
  16 +.idea/
  17 +
  18 +# The .vscode folder contains launch configuration and tasks you configure in
  19 +# VS Code which you may wish to be included in version control, so this line
  20 +# is commented out by default.
  21 +#.vscode/
  22 +
  23 +# Flutter/Dart/Pub related
  24 +**/doc/api/
  25 +**/ios/Flutter/.last_build_id
  26 +.dart_tool/
  27 +.flutter-plugins
  28 +.flutter-plugins-dependencies
  29 +.packages
  30 +.pub-cache/
  31 +.pub/
  32 +/build/
  33 +
  34 +# Web related
  35 +lib/generated_plugin_registrant.dart
  36 +
  37 +# Symbolication related
  38 +app.*.symbols
  39 +
  40 +# Obfuscation related
  41 +app.*.map.json
  1 +# This file tracks properties of this Flutter project.
  2 +# Used by Flutter tool to assess capabilities and perform upgrades etc.
  3 +#
  4 +# This file should be version controlled and should not be manually edited.
  5 +
  6 +version:
  7 + revision: 7c6f9dd2396dfe7deb6fd11edc12c10786490083
  8 + channel: dev
  9 +
  10 +project_type: app
  1 +# example
  2 +
  3 +A new Flutter project.
  4 +
  5 +## Getting Started
  6 +
  7 +This project is a starting point for a Flutter application.
  8 +
  9 +A few resources to get you started if this is your first Flutter project:
  10 +
  11 +- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
  12 +- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
  13 +
  14 +For help getting started with Flutter, view our
  15 +[online documentation](https://flutter.dev/docs), which offers tutorials,
  16 +samples, guidance on mobile development, and a full API reference.
1 -include app_configuration.mk  
2 -  
3 -# Default build type.  
4 -BUILD=debug  
5 -  
6 -FLUTTER_MANAGED_DIR=flutter  
7 -FLUTTER_EPHEMERAL_DIR=$(FLUTTER_MANAGED_DIR)/ephemeral  
8 -  
9 -# Configuration provided via flutter tool.  
10 -FLUTTER_CONFIG_FILE=$(FLUTTER_EPHEMERAL_DIR)/generated_config.mk  
11 -include $(FLUTTER_CONFIG_FILE)  
12 -  
13 -# Dependency locations  
14 -FLUTTER_APP_DIR=$(CURDIR)/..  
15 -FLUTTER_APP_BUILD_DIR=$(FLUTTER_APP_DIR)/build  
16 -  
17 -OUT_DIR=$(FLUTTER_APP_BUILD_DIR)/linux  
18 -OBJ_DIR=$(OUT_DIR)/obj/$(BUILD)  
19 -  
20 -# Libraries  
21 -FLUTTER_LIB_NAME=flutter_linux_glfw  
22 -FLUTTER_LIB=$(FLUTTER_EPHEMERAL_DIR)/lib$(FLUTTER_LIB_NAME).so  
23 -  
24 -# Tools  
25 -FLUTTER_BIN=$(FLUTTER_ROOT)/bin/flutter  
26 -LINUX_BUILD=$(FLUTTER_ROOT)/packages/flutter_tools/bin/tool_backend.sh  
27 -  
28 -# Resources  
29 -ICU_DATA_NAME=icudtl.dat  
30 -ICU_DATA_SOURCE=$(FLUTTER_EPHEMERAL_DIR)/$(ICU_DATA_NAME)  
31 -FLUTTER_ASSETS_NAME=flutter_assets  
32 -FLUTTER_ASSETS_SOURCE=$(FLUTTER_APP_BUILD_DIR)/$(FLUTTER_ASSETS_NAME)  
33 -  
34 -# Bundle structure  
35 -BUNDLE_OUT_DIR=$(OUT_DIR)/$(BUILD)  
36 -BUNDLE_DATA_DIR=$(BUNDLE_OUT_DIR)/data  
37 -BUNDLE_LIB_DIR=$(BUNDLE_OUT_DIR)/lib  
38 -  
39 -BIN_OUT=$(BUNDLE_OUT_DIR)/$(BINARY_NAME)  
40 -ICU_DATA_OUT=$(BUNDLE_DATA_DIR)/$(ICU_DATA_NAME)  
41 -FLUTTER_LIB_OUT=$(BUNDLE_LIB_DIR)/$(notdir $(FLUTTER_LIB))  
42 -ALL_LIBS_OUT=$(FLUTTER_LIB_OUT) \  
43 - $(foreach lib,$(EXTRA_BUNDLED_LIBRARIES),$(BUNDLE_LIB_DIR)/$(notdir $(lib)))  
44 -  
45 -# Add relevant code from the wrapper library, which is intended to be statically  
46 -# built into the client.  
47 -# Use abspath for the wrapper root, which can contain relative paths; the  
48 -# intermediate build files will be based on the source path, which will cause  
49 -# issues if they start with one or more '../'s.  
50 -WRAPPER_ROOT=$(abspath $(FLUTTER_EPHEMERAL_DIR)/cpp_client_wrapper_glfw)  
51 -WRAPPER_SOURCES= \  
52 - $(WRAPPER_ROOT)/flutter_window_controller.cc \  
53 - $(WRAPPER_ROOT)/plugin_registrar.cc \  
54 - $(WRAPPER_ROOT)/engine_method_result.cc  
55 -  
56 -# Use abspath for extra sources, which may also contain relative paths (see  
57 -# note above about WRAPPER_ROOT).  
58 -SOURCES=main.cc window_configuration.cc \  
59 - flutter/generated_plugin_registrant.cc \  
60 - $(WRAPPER_SOURCES) $(abspath $(EXTRA_SOURCES))  
61 -  
62 -# Headers  
63 -WRAPPER_INCLUDE_DIR=$(WRAPPER_ROOT)/include  
64 -INCLUDE_DIRS=$(FLUTTER_EPHEMERAL_DIR) $(WRAPPER_INCLUDE_DIR)  
65 -  
66 -# Build settings  
67 -ifneq ($(strip $(SYSTEM_LIBRARIES)),)  
68 -EXTRA_CPPFLAGS+=$(patsubst -I%,-isystem%,$(shell pkg-config --cflags $(SYSTEM_LIBRARIES)))  
69 -EXTRA_LDFLAGS+=$(shell pkg-config --libs $(SYSTEM_LIBRARIES))  
70 -endif  
71 -CXX=clang++  
72 -CPPFLAGS.release=-DNDEBUG  
73 -CPPFLAGS.profile=$(CPPFLAGS.release)  
74 -CXXFLAGS.release=-O2  
75 -CXXFLAGS.profile=$(CXXFLAGS.release)  
76 -CXXFLAGS=-std=c++14 -Wall -Werror $(CXXFLAGS.$(BUILD)) $(EXTRA_CXXFLAGS)  
77 -CPPFLAGS=$(patsubst %,-I%,$(INCLUDE_DIRS)) \  
78 - $(CPPFLAGS.$(BUILD)) $(EXTRA_CPPFLAGS)  
79 -LDFLAGS=-L$(BUNDLE_LIB_DIR) \  
80 - -l$(FLUTTER_LIB_NAME) \  
81 - $(EXTRA_LDFLAGS) \  
82 - -Wl,-rpath=\$$ORIGIN/lib  
83 -  
84 -# Intermediate files.  
85 -OBJ_FILES=$(SOURCES:%.cc=$(OBJ_DIR)/%.o)  
86 -DEPENDENCY_FILES=$(OBJ_FILES:%.o=%.d)  
87 -  
88 -# Targets  
89 -  
90 -.PHONY: all  
91 -all: $(BIN_OUT) bundle  
92 -  
93 -# Add the plugin targets, and their associated settings.  
94 -include $(FLUTTER_MANAGED_DIR)/generated_plugins.mk  
95 -EXTRA_BUNDLED_LIBRARIES+=$(PLUGIN_LIBRARIES)  
96 -EXTRA_LDFLAGS+=$(PLUGIN_LDFLAGS)  
97 -EXTRA_CPPFLAGS+=$(PLUGIN_CPPFLAGS)  
98 -  
99 -# This is a phony target because the flutter tool cannot describe  
100 -# its inputs and outputs yet.  
101 -.PHONY: sync  
102 -sync: $(FLUTTER_CONFIG_FILE)  
103 - $(LINUX_BUILD) linux-x64 $(BUILD)  
104 -  
105 -.PHONY: bundle  
106 -bundle: $(ICU_DATA_OUT) $(ALL_LIBS_OUT) bundleflutterassets  
107 -  
108 -$(BIN_OUT): $(OBJ_FILES) $(ALL_LIBS_OUT)  
109 - mkdir -p $(@D)  
110 - $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OBJ_FILES) $(LDFLAGS) -o $@  
111 -  
112 -$(WRAPPER_SOURCES) $(FLUTTER_LIB) $(ICU_DATA_SOURCE) $(FLUTTER_ASSETS_SOURCE) \  
113 - $(PLUGIN_TARGETS): | sync  
114 -  
115 -# Plugin library bundling pattern.  
116 -$(BUNDLE_LIB_DIR)/%: $(OUT_DIR)/%  
117 - mkdir -p $(BUNDLE_LIB_DIR)  
118 - cp $< $@  
119 -  
120 -$(FLUTTER_LIB_OUT): $(FLUTTER_LIB)  
121 - mkdir -p $(@D)  
122 - cp $< $@  
123 -  
124 -$(ICU_DATA_OUT): $(ICU_DATA_SOURCE)  
125 - mkdir -p $(@D)  
126 - cp $< $@  
127 -  
128 --include $(DEPENDENCY_FILES)  
129 -  
130 -$(OBJ_DIR)/%.o : %.cc | sync  
131 - mkdir -p $(@D)  
132 - $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -c $< -o $@  
133 -  
134 -# Fully re-copy the assets directory on each build to avoid having to keep a  
135 -# comprehensive list of all asset files here, which would be fragile to changes  
136 -# in other files (e.g., adding a new font to pubspec.yaml).  
137 -.PHONY: bundleflutterassets  
138 -bundleflutterassets: $(FLUTTER_ASSETS_SOURCE)  
139 - mkdir -p $(BUNDLE_DATA_DIR)  
140 - rsync -rpu --delete $(FLUTTER_ASSETS_SOURCE) $(BUNDLE_DATA_DIR)  
141 -  
142 -.PHONY: clean  
143 -clean:  
144 - rm -rf $(OUT_DIR); \  
145 - cd $(FLUTTER_APP_DIR); \  
146 - $(FLUTTER_BIN) clean  
1 -# This file contains variables that applications are likely to need to  
2 -# change, to isolate them from the main Makefile where the build rules are still  
3 -# in flux. This should simplify re-creating the runner while preserving local  
4 -# changes.  
5 -  
6 -# Executable name.  
7 -BINARY_NAME=get_state  
8 -# Any extra source files to build.  
9 -EXTRA_SOURCES=  
10 -# Paths of any additional libraries to be bundled in the output directory.  
11 -EXTRA_BUNDLED_LIBRARIES=  
12 -# Extra flags (e.g., for library dependencies).  
13 -SYSTEM_LIBRARIES=  
14 -EXTRA_CXXFLAGS=  
15 -EXTRA_CPPFLAGS=  
16 -EXTRA_LDFLAGS=  
1 -//  
2 -// Generated file. Do not edit.  
3 -//  
4 -  
5 -#include "generated_plugin_registrant.h"  
6 -  
7 -  
8 -void fl_register_plugins(FlPluginRegistry* registry) {  
9 -}  
1 -//  
2 -// Generated file. Do not edit.  
3 -//  
4 -  
5 -#ifndef GENERATED_PLUGIN_REGISTRANT_  
6 -#define GENERATED_PLUGIN_REGISTRANT_  
7 -  
8 -#include <flutter_linux/flutter_linux.h>  
9 -  
10 -// Registers Flutter plugins.  
11 -void fl_register_plugins(FlPluginRegistry* registry);  
12 -  
13 -#endif // GENERATED_PLUGIN_REGISTRANT_  
1 -#  
2 -# Generated file, do not edit.  
3 -#  
4 -  
5 -list(APPEND FLUTTER_PLUGIN_LIST  
6 -)  
7 -  
8 -set(PLUGIN_BUNDLED_LIBRARIES)  
9 -  
10 -foreach(plugin ${FLUTTER_PLUGIN_LIST})  
11 - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})  
12 - target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)  
13 - list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)  
14 - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})  
15 -endforeach(plugin)  
1 -# Plugins to include in the build.  
2 -GENERATED_PLUGINS=\  
3 -  
4 -GENERATED_PLUGINS_DIR=flutter/ephemeral/.plugin_symlinks  
5 -# A plugin library name plugin name with _plugin appended.  
6 -GENERATED_PLUGIN_LIB_NAMES=$(foreach plugin,$(GENERATED_PLUGINS),$(plugin)_plugin)  
7 -  
8 -# Variables for use in the enclosing Makefile. Changes to these names are  
9 -# breaking changes.  
10 -PLUGIN_TARGETS=$(GENERATED_PLUGINS)  
11 -PLUGIN_LIBRARIES=$(foreach plugin,$(GENERATED_PLUGIN_LIB_NAMES),\  
12 - $(OUT_DIR)/lib$(plugin).so)  
13 -PLUGIN_LDFLAGS=$(patsubst %,-l%,$(GENERATED_PLUGIN_LIB_NAMES))  
14 -PLUGIN_CPPFLAGS=$(foreach plugin,$(GENERATED_PLUGINS),\  
15 - -I$(GENERATED_PLUGINS_DIR)/$(plugin)/linux)  
16 -  
17 -# Targets  
18 -  
19 -# Implicit rules don't match phony targets, so list plugin builds explicitly.  
20 -  
21 -.PHONY: $(GENERATED_PLUGINS)  
22 -$(GENERATED_PLUGINS):  
23 - make -C $(GENERATED_PLUGINS_DIR)/$@/linux \  
24 - OUT_DIR=$(OUT_DIR) \  
25 - FLUTTER_EPHEMERAL_DIR="$(abspath flutter/ephemeral)"  
1 -#include <flutter/flutter_window_controller.h>  
2 -#include <linux/limits.h>  
3 -#include <unistd.h>  
4 -  
5 -#include <cstdlib>  
6 -#include <iostream>  
7 -#include <memory>  
8 -#include <vector>  
9 -  
10 -#include "flutter/generated_plugin_registrant.h"  
11 -#include "window_configuration.h"  
12 -  
13 -namespace {  
14 -  
15 -// Returns the path of the directory containing this executable, or an empty  
16 -// string if the directory cannot be found.  
17 -std::string GetExecutableDirectory() {  
18 - char buffer[PATH_MAX + 1];  
19 - ssize_t length = readlink("/proc/self/exe", buffer, sizeof(buffer));  
20 - if (length > PATH_MAX) {  
21 - std::cerr << "Couldn't locate executable" << std::endl;  
22 - return "";  
23 - }  
24 - std::string executable_path(buffer, length);  
25 - size_t last_separator_position = executable_path.find_last_of('/');  
26 - if (last_separator_position == std::string::npos) {  
27 - std::cerr << "Unabled to find parent directory of " << executable_path  
28 - << std::endl;  
29 - return "";  
30 - }  
31 - return executable_path.substr(0, last_separator_position);  
32 -}  
33 -  
34 -} // namespace  
35 -  
36 -int main(int argc, char **argv) {  
37 - // Resources are located relative to the executable.  
38 - std::string base_directory = GetExecutableDirectory();  
39 - if (base_directory.empty()) {  
40 - base_directory = ".";  
41 - }  
42 - std::string data_directory = base_directory + "/data";  
43 - std::string assets_path = data_directory + "/flutter_assets";  
44 - std::string icu_data_path = data_directory + "/icudtl.dat";  
45 -  
46 - // Arguments for the Flutter Engine.  
47 - std::vector<std::string> arguments;  
48 -  
49 - flutter::FlutterWindowController flutter_controller(icu_data_path);  
50 - flutter::WindowProperties window_properties = {};  
51 - window_properties.title = kFlutterWindowTitle;  
52 - window_properties.width = kFlutterWindowWidth;  
53 - window_properties.height = kFlutterWindowHeight;  
54 -  
55 - // Start the engine.  
56 - if (!flutter_controller.CreateWindow(window_properties, assets_path,  
57 - arguments)) {  
58 - return EXIT_FAILURE;  
59 - }  
60 - RegisterPlugins(&flutter_controller);  
61 -  
62 - // Run until the window is closed.  
63 - while (flutter_controller.RunEventLoopWithTimeout(  
64 - std::chrono::milliseconds::max())) {  
65 - }  
66 - return EXIT_SUCCESS;  
67 -}  
1 -#include "window_configuration.h"  
2 -  
3 -const char *kFlutterWindowTitle = "get_state";  
4 -const unsigned int kFlutterWindowWidth = 800;  
5 -const unsigned int kFlutterWindowHeight = 600;  
1 -#ifndef WINDOW_CONFIGURATION_  
2 -#define WINDOW_CONFIGURATION_  
3 -  
4 -// This is a temporary approach to isolate common customizations from main.cpp,  
5 -// where the APIs are still in flux. This should simplify re-creating the  
6 -// runner while preserving local changes.  
7 -//  
8 -// Longer term there should be simpler configuration options for common  
9 -// customizations like this, without requiring native code changes.  
10 -  
11 -extern const char *kFlutterWindowTitle;  
12 -extern const unsigned int kFlutterWindowWidth;  
13 -extern const unsigned int kFlutterWindowHeight;  
14 -  
15 -#endif // WINDOW_CONFIGURATION_  
@@ -7,42 +7,42 @@ packages: @@ -7,42 +7,42 @@ packages:
7 name: async 7 name: async
8 url: "https://pub.dartlang.org" 8 url: "https://pub.dartlang.org"
9 source: hosted 9 source: hosted
10 - version: "2.4.2" 10 + version: "2.5.0-nullsafety"
11 boolean_selector: 11 boolean_selector:
12 dependency: transitive 12 dependency: transitive
13 description: 13 description:
14 name: boolean_selector 14 name: boolean_selector
15 url: "https://pub.dartlang.org" 15 url: "https://pub.dartlang.org"
16 source: hosted 16 source: hosted
17 - version: "2.0.0" 17 + version: "2.1.0-nullsafety"
18 characters: 18 characters:
19 dependency: transitive 19 dependency: transitive
20 description: 20 description:
21 name: characters 21 name: characters
22 url: "https://pub.dartlang.org" 22 url: "https://pub.dartlang.org"
23 source: hosted 23 source: hosted
24 - version: "1.1.0-nullsafety" 24 + version: "1.1.0-nullsafety.2"
25 charcode: 25 charcode:
26 dependency: transitive 26 dependency: transitive
27 description: 27 description:
28 name: charcode 28 name: charcode
29 url: "https://pub.dartlang.org" 29 url: "https://pub.dartlang.org"
30 source: hosted 30 source: hosted
31 - version: "1.1.3" 31 + version: "1.2.0-nullsafety"
32 clock: 32 clock:
33 dependency: transitive 33 dependency: transitive
34 description: 34 description:
35 name: clock 35 name: clock
36 url: "https://pub.dartlang.org" 36 url: "https://pub.dartlang.org"
37 source: hosted 37 source: hosted
38 - version: "1.0.1" 38 + version: "1.1.0-nullsafety"
39 collection: 39 collection:
40 dependency: transitive 40 dependency: transitive
41 description: 41 description:
42 name: collection 42 name: collection
43 url: "https://pub.dartlang.org" 43 url: "https://pub.dartlang.org"
44 source: hosted 44 source: hosted
45 - version: "1.15.0-nullsafety" 45 + version: "1.15.0-nullsafety.2"
46 dio: 46 dio:
47 dependency: "direct main" 47 dependency: "direct main"
48 description: 48 description:
@@ -56,7 +56,7 @@ packages: @@ -56,7 +56,7 @@ packages:
56 name: fake_async 56 name: fake_async
57 url: "https://pub.dartlang.org" 57 url: "https://pub.dartlang.org"
58 source: hosted 58 source: hosted
59 - version: "1.1.0" 59 + version: "1.1.0-nullsafety"
60 flutter: 60 flutter:
61 dependency: "direct main" 61 dependency: "direct main"
62 description: flutter 62 description: flutter
@@ -70,10 +70,10 @@ packages: @@ -70,10 +70,10 @@ packages:
70 get: 70 get:
71 dependency: "direct main" 71 dependency: "direct main"
72 description: 72 description:
73 - name: get  
74 - url: "https://pub.dartlang.org"  
75 - source: hosted  
76 - version: "3.4.3" 73 + path: ".."
  74 + relative: true
  75 + source: path
  76 + version: "3.5.1"
77 http_parser: 77 http_parser:
78 dependency: transitive 78 dependency: transitive
79 description: 79 description:
@@ -87,21 +87,21 @@ packages: @@ -87,21 +87,21 @@ packages:
87 name: matcher 87 name: matcher
88 url: "https://pub.dartlang.org" 88 url: "https://pub.dartlang.org"
89 source: hosted 89 source: hosted
90 - version: "0.12.8" 90 + version: "0.12.10-nullsafety"
91 meta: 91 meta:
92 dependency: transitive 92 dependency: transitive
93 description: 93 description:
94 name: meta 94 name: meta
95 url: "https://pub.dartlang.org" 95 url: "https://pub.dartlang.org"
96 source: hosted 96 source: hosted
97 - version: "1.3.0-nullsafety" 97 + version: "1.3.0-nullsafety.2"
98 path: 98 path:
99 dependency: transitive 99 dependency: transitive
100 description: 100 description:
101 name: path 101 name: path
102 url: "https://pub.dartlang.org" 102 url: "https://pub.dartlang.org"
103 source: hosted 103 source: hosted
104 - version: "1.7.0" 104 + version: "1.8.0-nullsafety"
105 sky_engine: 105 sky_engine:
106 dependency: transitive 106 dependency: transitive
107 description: flutter 107 description: flutter
@@ -113,55 +113,55 @@ packages: @@ -113,55 +113,55 @@ packages:
113 name: source_span 113 name: source_span
114 url: "https://pub.dartlang.org" 114 url: "https://pub.dartlang.org"
115 source: hosted 115 source: hosted
116 - version: "1.7.0" 116 + version: "1.8.0-nullsafety"
117 stack_trace: 117 stack_trace:
118 dependency: transitive 118 dependency: transitive
119 description: 119 description:
120 name: stack_trace 120 name: stack_trace
121 url: "https://pub.dartlang.org" 121 url: "https://pub.dartlang.org"
122 source: hosted 122 source: hosted
123 - version: "1.9.5" 123 + version: "1.10.0-nullsafety"
124 stream_channel: 124 stream_channel:
125 dependency: transitive 125 dependency: transitive
126 description: 126 description:
127 name: stream_channel 127 name: stream_channel
128 url: "https://pub.dartlang.org" 128 url: "https://pub.dartlang.org"
129 source: hosted 129 source: hosted
130 - version: "2.0.0" 130 + version: "2.1.0-nullsafety"
131 string_scanner: 131 string_scanner:
132 dependency: transitive 132 dependency: transitive
133 description: 133 description:
134 name: string_scanner 134 name: string_scanner
135 url: "https://pub.dartlang.org" 135 url: "https://pub.dartlang.org"
136 source: hosted 136 source: hosted
137 - version: "1.0.5" 137 + version: "1.1.0-nullsafety"
138 term_glyph: 138 term_glyph:
139 dependency: transitive 139 dependency: transitive
140 description: 140 description:
141 name: term_glyph 141 name: term_glyph
142 url: "https://pub.dartlang.org" 142 url: "https://pub.dartlang.org"
143 source: hosted 143 source: hosted
144 - version: "1.1.0" 144 + version: "1.2.0-nullsafety"
145 test_api: 145 test_api:
146 dependency: transitive 146 dependency: transitive
147 description: 147 description:
148 name: test_api 148 name: test_api
149 url: "https://pub.dartlang.org" 149 url: "https://pub.dartlang.org"
150 source: hosted 150 source: hosted
151 - version: "0.2.17" 151 + version: "0.2.19-nullsafety"
152 typed_data: 152 typed_data:
153 dependency: transitive 153 dependency: transitive
154 description: 154 description:
155 name: typed_data 155 name: typed_data
156 url: "https://pub.dartlang.org" 156 url: "https://pub.dartlang.org"
157 source: hosted 157 source: hosted
158 - version: "1.3.0-nullsafety" 158 + version: "1.3.0-nullsafety.2"
159 vector_math: 159 vector_math:
160 dependency: transitive 160 dependency: transitive
161 description: 161 description:
162 name: vector_math 162 name: vector_math
163 url: "https://pub.dartlang.org" 163 url: "https://pub.dartlang.org"
164 source: hosted 164 source: hosted
165 - version: "2.1.0-nullsafety" 165 + version: "2.1.0-nullsafety.2"
166 sdks: 166 sdks:
167 - dart: ">=2.9.0-18.0 <2.9.0" 167 + dart: ">=2.10.0-0.0.dev <2.10.0"
1 import 'package:get/src/core/log.dart'; 1 import 'package:get/src/core/log.dart';
2 import 'package:get/src/navigation/root/smart_management.dart'; 2 import 'package:get/src/navigation/root/smart_management.dart';
3 import 'package:get/src/state_manager/rx/rx_interface.dart'; 3 import 'package:get/src/state_manager/rx/rx_interface.dart';
  4 +import 'package:get/src/utils/queue/get_queue.dart';
4 5
5 class GetConfig { 6 class GetConfig {
6 static SmartManagement smartManagement = SmartManagement.full; 7 static SmartManagement smartManagement = SmartManagement.full;
@@ -196,6 +197,14 @@ class GetInstance { @@ -196,6 +197,14 @@ class GetInstance {
196 return true; 197 return true;
197 } 198 }
198 199
  200 + static GetQueue queue = GetQueue();
  201 +
  202 + // Future<bool> delete<S>({String tag, String key, bool force = false}) async {
  203 + // final s = await queue
  204 + // .add<bool>(() async => dele<S>(tag: tag, key: key, force: force));
  205 + // return s;
  206 + // }
  207 +
199 /// Delete class instance on [S] and clean memory 208 /// Delete class instance on [S] and clean memory
200 Future<bool> delete<S>({String tag, String key, bool force = false}) async { 209 Future<bool> delete<S>({String tag, String key, bool force = false}) async {
201 String newKey; 210 String newKey;
@@ -205,36 +214,39 @@ class GetInstance { @@ -205,36 +214,39 @@ class GetInstance {
205 newKey = key; 214 newKey = key;
206 } 215 }
207 216
208 - if (!_singl.containsKey(newKey)) {  
209 - GetConfig.log('Instance $newKey not found', isError: true);  
210 - return false;  
211 - } 217 + return queue.add<bool>(() async {
  218 + if (!_singl.containsKey(newKey)) {
  219 + GetConfig.log('[GETX] Instance $newKey already been removed.',
  220 + isError: true);
  221 + return false;
  222 + }
212 223
213 - FcBuilder builder = _singl[newKey] as FcBuilder;  
214 - if (builder.permanent && !force) {  
215 - GetConfig.log(  
216 - '[GETX] [$newKey] has been marked as permanent, SmartManagement is not authorized to delete it.',  
217 - isError: true);  
218 - return false;  
219 - }  
220 - final i = builder.dependency; 224 + FcBuilder builder = _singl[newKey] as FcBuilder;
  225 + if (builder.permanent && !force) {
  226 + GetConfig.log(
  227 + '[GETX] [$newKey] has been marked as permanent, SmartManagement is not authorized to delete it.',
  228 + isError: true);
  229 + return false;
  230 + }
  231 + final i = builder.dependency;
221 232
222 - if (i is GetxService && !force) {  
223 - return false;  
224 - }  
225 - if (i is DisposableInterface) {  
226 - await i.onClose();  
227 - GetConfig.log('[GETX] onClose of $newKey called');  
228 - } 233 + if (i is GetxService && !force) {
  234 + return false;
  235 + }
  236 + if (i is DisposableInterface) {
  237 + await i.onClose();
  238 + GetConfig.log('[GETX] onClose of $newKey called');
  239 + }
229 240
230 - _singl.removeWhere((oldKey, value) => (oldKey == newKey));  
231 - if (_singl.containsKey(newKey)) {  
232 - GetConfig.log('[GETX] error on remove object $newKey', isError: true);  
233 - } else {  
234 - GetConfig.log('[GETX] $newKey deleted from memory');  
235 - }  
236 - // _routesKey?.remove(key);  
237 - return true; 241 + _singl.removeWhere((oldKey, value) => (oldKey == newKey));
  242 + if (_singl.containsKey(newKey)) {
  243 + GetConfig.log('[GETX] error on remove object $newKey', isError: true);
  244 + } else {
  245 + GetConfig.log('[GETX] $newKey deleted from memory');
  246 + }
  247 + // _routesKey?.remove(key);
  248 + return true;
  249 + });
238 } 250 }
239 251
240 /// check if instance is registered 252 /// check if instance is registered
1 -export 'get_instance.dart';  
2 -export 'extension_instance.dart';  
3 -export '../navigation/routes/bindings_interface.dart';  
@@ -16,6 +16,7 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> { @@ -16,6 +16,7 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> {
16 @required this.isScrollControlled, 16 @required this.isScrollControlled,
17 RouteSettings settings, 17 RouteSettings settings,
18 }) : assert(isScrollControlled != null), 18 }) : assert(isScrollControlled != null),
  19 + name = "BOTTOMSHEET: ${builder.hashCode}",
19 assert(isDismissible != null), 20 assert(isDismissible != null),
20 assert(enableDrag != null), 21 assert(enableDrag != null),
21 super(settings: settings); 22 super(settings: settings);
@@ -30,6 +31,7 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> { @@ -30,6 +31,7 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> {
30 final Color modalBarrierColor; 31 final Color modalBarrierColor;
31 final bool isDismissible; 32 final bool isDismissible;
32 final bool enableDrag; 33 final bool enableDrag;
  34 + final String name;
33 35
34 // remove safearea from top 36 // remove safearea from top
35 final bool removeTop; 37 final bool removeTop;
  1 +import 'package:flutter/widgets.dart';
  2 +
  3 +import '../../../instance_manager.dart';
  4 +import '../../../route_manager.dart';
  5 +
  6 +class GetDialogRoute<T> extends PopupRoute<T> {
  7 + GetDialogRoute({
  8 + @required RoutePageBuilder pageBuilder,
  9 + bool barrierDismissible = true,
  10 + String barrierLabel,
  11 + Color barrierColor = const Color(0x80000000),
  12 + Duration transitionDuration = const Duration(milliseconds: 200),
  13 + RouteTransitionsBuilder transitionBuilder,
  14 + RouteSettings settings,
  15 + }) : assert(barrierDismissible != null),
  16 + widget = pageBuilder,
  17 + name = "DIALOG: ${pageBuilder.hashCode}",
  18 + _barrierDismissible = barrierDismissible,
  19 + _barrierLabel = barrierLabel,
  20 + _barrierColor = barrierColor,
  21 + _transitionDuration = transitionDuration,
  22 + _transitionBuilder = transitionBuilder,
  23 + super(settings: settings);
  24 +
  25 + final RoutePageBuilder widget;
  26 +
  27 + @override
  28 + bool get barrierDismissible => _barrierDismissible;
  29 + final bool _barrierDismissible;
  30 +
  31 + final String name;
  32 +
  33 + @override
  34 + void dispose() {
  35 + if (GetConfig.smartManagement != SmartManagement.onlyBuilder) {
  36 + WidgetsBinding.instance.addPostFrameCallback(
  37 + (_) => GetInstance().removeDependencyByRoute(name));
  38 + }
  39 + super.dispose();
  40 + }
  41 +
  42 + @override
  43 + String get barrierLabel => _barrierLabel;
  44 + final String _barrierLabel;
  45 +
  46 + @override
  47 + Color get barrierColor => _barrierColor;
  48 + final Color _barrierColor;
  49 +
  50 + @override
  51 + Duration get transitionDuration => _transitionDuration;
  52 + final Duration _transitionDuration;
  53 +
  54 + final RouteTransitionsBuilder _transitionBuilder;
  55 +
  56 + @override
  57 + Widget buildPage(BuildContext context, Animation<double> animation,
  58 + Animation<double> secondaryAnimation) {
  59 + return Semantics(
  60 + child: widget(context, animation, secondaryAnimation),
  61 + scopesRoute: true,
  62 + explicitChildNodes: true,
  63 + );
  64 + }
  65 +
  66 + @override
  67 + Widget buildTransitions(BuildContext context, Animation<double> animation,
  68 + Animation<double> secondaryAnimation, Widget child) {
  69 + if (_transitionBuilder == null) {
  70 + return FadeTransition(
  71 + opacity: CurvedAnimation(
  72 + parent: animation,
  73 + curve: Curves.linear,
  74 + ),
  75 + child: child);
  76 + } // Some default transition
  77 + return _transitionBuilder(context, animation, secondaryAnimation, child);
  78 + }
  79 +}
@@ -4,6 +4,7 @@ import 'package:get/src/core/get_interface.dart'; @@ -4,6 +4,7 @@ import 'package:get/src/core/get_interface.dart';
4 import 'package:get/instance_manager.dart'; 4 import 'package:get/instance_manager.dart';
5 import 'package:get/route_manager.dart'; 5 import 'package:get/route_manager.dart';
6 import 'package:get/src/core/log.dart'; 6 import 'package:get/src/core/log.dart';
  7 +import 'dialog/dialog_route.dart';
7 import 'root/parse_route.dart'; 8 import 'root/parse_route.dart';
8 import 'routes/bindings_interface.dart'; 9 import 'routes/bindings_interface.dart';
9 10
@@ -43,18 +44,20 @@ extension GetNavigation on GetInterface { @@ -43,18 +44,20 @@ extension GetNavigation on GetInterface {
43 bool fullscreenDialog = false, 44 bool fullscreenDialog = false,
44 Object arguments, 45 Object arguments,
45 Bindings binding, 46 Bindings binding,
46 - preventDuplicates = true, 47 + bool preventDuplicates = true,
47 bool popGesture, 48 bool popGesture,
48 }) { 49 }) {
49 - if (preventDuplicates && '/${page.runtimeType}' == currentRoute) { 50 + String routename = "/${page.runtimeType.toString()}";
  51 + if (preventDuplicates && routename == currentRoute) {
50 return null; 52 return null;
51 } 53 }
52 return global(id).currentState.push( 54 return global(id).currentState.push(
53 GetPageRoute( 55 GetPageRoute(
54 opaque: opaque ?? true, 56 opaque: opaque ?? true,
55 page: () => page, 57 page: () => page,
  58 + routeName: routename,
56 settings: RouteSettings( 59 settings: RouteSettings(
57 - name: '/${page.runtimeType}', 60 + // name: forceRouteName ? '${a.runtimeType}' : '',
58 arguments: arguments, 61 arguments: arguments,
59 ), 62 ),
60 popGesture: popGesture ?? defaultPopGesture, 63 popGesture: popGesture ?? defaultPopGesture,
@@ -318,15 +321,16 @@ extension GetNavigation on GetInterface { @@ -318,15 +321,16 @@ extension GetNavigation on GetInterface {
318 preventDuplicates = true, 321 preventDuplicates = true,
319 Duration duration, 322 Duration duration,
320 }) { 323 }) {
321 - if (preventDuplicates && '/${page.runtimeType}' == currentRoute) { 324 + String routename = "/${page.runtimeType.toString()}";
  325 + if (preventDuplicates && routename == currentRoute) {
322 return null; 326 return null;
323 } 327 }
324 return global(id).currentState.pushReplacement(GetPageRoute( 328 return global(id).currentState.pushReplacement(GetPageRoute(
325 opaque: opaque ?? true, 329 opaque: opaque ?? true,
326 page: () => page, 330 page: () => page,
327 binding: binding, 331 binding: binding,
328 - settings:  
329 - RouteSettings(name: '/${page.runtimeType}', arguments: arguments), 332 + settings: RouteSettings(arguments: arguments),
  333 + routeName: routename,
330 fullscreenDialog: fullscreenDialog, 334 fullscreenDialog: fullscreenDialog,
331 popGesture: popGesture ?? defaultPopGesture, 335 popGesture: popGesture ?? defaultPopGesture,
332 transition: transition ?? defaultTransition, 336 transition: transition ?? defaultTransition,
@@ -375,15 +379,17 @@ extension GetNavigation on GetInterface { @@ -375,15 +379,17 @@ extension GetNavigation on GetInterface {
375 }) { 379 }) {
376 var route = (Route<dynamic> rota) => false; 380 var route = (Route<dynamic> rota) => false;
377 381
  382 + String routename = "/${page.runtimeType.toString()}";
  383 +
378 return global(id).currentState.pushAndRemoveUntil( 384 return global(id).currentState.pushAndRemoveUntil(
379 GetPageRoute( 385 GetPageRoute(
380 opaque: opaque ?? true, 386 opaque: opaque ?? true,
381 popGesture: popGesture ?? defaultPopGesture, 387 popGesture: popGesture ?? defaultPopGesture,
382 page: () => page, 388 page: () => page,
383 binding: binding, 389 binding: binding,
384 - settings:  
385 - RouteSettings(name: '/${page.runtimeType}', arguments: arguments), 390 + settings: RouteSettings(arguments: arguments),
386 fullscreenDialog: fullscreenDialog, 391 fullscreenDialog: fullscreenDialog,
  392 + routeName: routename,
387 transition: transition ?? defaultTransition, 393 transition: transition ?? defaultTransition,
388 transitionDuration: duration ?? defaultDurationTransition, 394 transitionDuration: duration ?? defaultDurationTransition,
389 ), 395 ),
@@ -392,44 +398,76 @@ extension GetNavigation on GetInterface { @@ -392,44 +398,76 @@ extension GetNavigation on GetInterface {
392 398
393 /// Show a dialog 399 /// Show a dialog
394 Future<T> dialog<T>( 400 Future<T> dialog<T>(
395 - Widget child, { 401 + Widget widget, {
396 bool barrierDismissible = true, 402 bool barrierDismissible = true,
  403 + Color barrierColor,
  404 + bool useSafeArea = true,
397 bool useRootNavigator = true, 405 bool useRootNavigator = true,
398 - // RouteSettings routeSettings 406 + RouteSettings routeSettings,
399 }) { 407 }) {
400 - return showDialog( 408 + assert(widget != null);
  409 + assert(barrierDismissible != null);
  410 + assert(useSafeArea != null);
  411 + assert(useRootNavigator != null);
  412 + assert(debugCheckHasMaterialLocalizations(context));
  413 +
  414 + final ThemeData theme = Theme.of(context, shadowThemeOnly: true);
  415 + return generalDialog(
  416 + pageBuilder: (BuildContext buildContext, Animation<double> animation,
  417 + Animation<double> secondaryAnimation) {
  418 + final Widget pageChild = widget;
  419 + Widget dialog = Builder(builder: (BuildContext context) {
  420 + return theme != null
  421 + ? Theme(data: theme, child: pageChild)
  422 + : pageChild;
  423 + });
  424 + if (useSafeArea) {
  425 + dialog = SafeArea(child: dialog);
  426 + }
  427 + return dialog;
  428 + },
401 barrierDismissible: barrierDismissible, 429 barrierDismissible: barrierDismissible,
402 - useRootNavigator: useRootNavigator,  
403 - routeSettings: RouteSettings(name: 'dialog'),  
404 - context: overlayContext,  
405 - builder: (_) {  
406 - return child; 430 + barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
  431 + barrierColor: barrierColor ?? Colors.black54,
  432 + transitionDuration: const Duration(milliseconds: 150),
  433 + transitionBuilder: (context, animation, secondaryAnimation, child) {
  434 + return FadeTransition(
  435 + opacity: CurvedAnimation(
  436 + parent: animation,
  437 + curve: Curves.easeOut,
  438 + ),
  439 + child: child,
  440 + );
407 }, 441 },
  442 + useRootNavigator: useRootNavigator,
  443 + routeSettings: routeSettings,
408 ); 444 );
409 } 445 }
410 446
411 /// Api from showGeneralDialog with no context 447 /// Api from showGeneralDialog with no context
412 Future<T> generalDialog<T>({ 448 Future<T> generalDialog<T>({
413 @required RoutePageBuilder pageBuilder, 449 @required RoutePageBuilder pageBuilder,
414 - String barrierLabel = "Dismiss",  
415 - bool barrierDismissible = true, 450 + bool barrierDismissible = false,
  451 + String barrierLabel,
416 Color barrierColor = const Color(0x80000000), 452 Color barrierColor = const Color(0x80000000),
417 Duration transitionDuration = const Duration(milliseconds: 200), 453 Duration transitionDuration = const Duration(milliseconds: 200),
418 RouteTransitionsBuilder transitionBuilder, 454 RouteTransitionsBuilder transitionBuilder,
419 bool useRootNavigator = true, 455 bool useRootNavigator = true,
420 RouteSettings routeSettings, 456 RouteSettings routeSettings,
421 }) { 457 }) {
422 - return showGeneralDialog( 458 + assert(pageBuilder != null);
  459 + assert(useRootNavigator != null);
  460 + assert(!barrierDismissible || barrierLabel != null);
  461 + return Navigator.of(overlayContext, rootNavigator: useRootNavigator)
  462 + .push<T>(GetDialogRoute<T>(
423 pageBuilder: pageBuilder, 463 pageBuilder: pageBuilder,
424 barrierDismissible: barrierDismissible, 464 barrierDismissible: barrierDismissible,
425 barrierLabel: barrierLabel, 465 barrierLabel: barrierLabel,
426 barrierColor: barrierColor, 466 barrierColor: barrierColor,
427 transitionDuration: transitionDuration, 467 transitionDuration: transitionDuration,
428 transitionBuilder: transitionBuilder, 468 transitionBuilder: transitionBuilder,
429 - useRootNavigator: useRootNavigator,  
430 - routeSettings: RouteSettings(name: 'dialog'),  
431 - context: overlayContext,  
432 - ); 469 + settings: routeSettings,
  470 + ));
433 } 471 }
434 472
435 Future<T> defaultDialog<T>({ 473 Future<T> defaultDialog<T>({
@@ -561,7 +599,7 @@ extension GetNavigation on GetInterface { @@ -561,7 +599,7 @@ extension GetNavigation on GetInterface {
561 clipBehavior: clipBehavior, 599 clipBehavior: clipBehavior,
562 isDismissible: isDismissible, 600 isDismissible: isDismissible,
563 modalBarrierColor: barrierColor, 601 modalBarrierColor: barrierColor,
564 - settings: RouteSettings(name: "bottomsheet"), 602 + settings: settings,
565 enableDrag: enableDrag, 603 enableDrag: enableDrag,
566 )); 604 ));
567 } 605 }
@@ -279,17 +279,21 @@ extension Trans on String { @@ -279,17 +279,21 @@ extension Trans on String {
279 Get.translations[Get.locale.languageCode].containsKey(this)) { 279 Get.translations[Get.locale.languageCode].containsKey(this)) {
280 return Get.translations[Get.locale.languageCode][this]; 280 return Get.translations[Get.locale.languageCode][this];
281 // If there is no corresponding language or corresponding key, return the key. 281 // If there is no corresponding language or corresponding key, return the key.
282 - } else if (Get.fallbackLocale != null &&  
283 - Get.translations.containsKey(  
284 - "${Get.fallbackLocale.languageCode}_${Get.fallbackLocale.countryCode}") &&  
285 - Get.translations[ 282 + } else if (Get.fallbackLocale != null) {
  283 + if (Get.translations.containsKey(
  284 + "${Get.fallbackLocale.languageCode}_${Get.fallbackLocale.countryCode}") &&
  285 + Get.translations[
  286 + "${Get.fallbackLocale.languageCode}_${Get.fallbackLocale.countryCode}"]
  287 + .containsKey(this)) {
  288 + return Get.translations[
286 "${Get.fallbackLocale.languageCode}_${Get.fallbackLocale.countryCode}"] 289 "${Get.fallbackLocale.languageCode}_${Get.fallbackLocale.countryCode}"]
287 - .containsKey(this)) {  
288 - return Get.translations[  
289 - "${Get.fallbackLocale.languageCode}_${Get.fallbackLocale.countryCode}"]  
290 - [this];  
291 -  
292 - // Checks if there is a callback language in the absence of the specific country, and if it contains that key. 290 + [this];
  291 + }
  292 + if (Get.translations.containsKey(Get.fallbackLocale.languageCode) &&
  293 + Get.translations[Get.fallbackLocale.languageCode].containsKey(this)) {
  294 + return Get.translations[Get.fallbackLocale.languageCode][this];
  295 + }
  296 + return this;
293 } else { 297 } else {
294 return this; 298 return this;
295 } 299 }
1 -export 'routes/custom_transition.dart';  
2 -export 'routes/transitions_type.dart';  
3 -export 'routes/get_route.dart';  
4 -export 'routes/default_route.dart';  
5 -export 'routes/observers/route_observer.dart';  
6 -export 'root/root_widget.dart';  
7 -export 'snackbar/snack_route.dart';  
8 -export 'bottomsheet/bottomsheet.dart';  
9 -export 'snackbar/snack.dart';  
10 -export '../core/get_main.dart';  
11 -export 'routes/default_route.dart';  
12 -export 'root/smart_management.dart';  
13 -export 'extension_navigation.dart';  
@@ -27,6 +27,7 @@ class GetPageRoute<T> extends PageRoute<T> { @@ -27,6 +27,7 @@ class GetPageRoute<T> extends PageRoute<T> {
27 this.barrierColor, 27 this.barrierColor,
28 this.binding, 28 this.binding,
29 this.bindings, 29 this.bindings,
  30 + this.routeName,
30 this.page, 31 this.page,
31 this.barrierLabel, 32 this.barrierLabel,
32 this.maintainState = true, 33 this.maintainState = true,
@@ -42,6 +43,8 @@ class GetPageRoute<T> extends PageRoute<T> { @@ -42,6 +43,8 @@ class GetPageRoute<T> extends PageRoute<T> {
42 43
43 final GetPageBuilder page; 44 final GetPageBuilder page;
44 45
  46 + final String routeName;
  47 +
45 final CustomTransition customTransition; 48 final CustomTransition customTransition;
46 49
47 final Bindings binding; 50 final Bindings binding;
@@ -119,8 +122,9 @@ class GetPageRoute<T> extends PageRoute<T> { @@ -119,8 +122,9 @@ class GetPageRoute<T> extends PageRoute<T> {
119 element.dependencies(); 122 element.dependencies();
120 } 123 }
121 } 124 }
122 - GetConfig.currentRoute = settings.name;  
123 - return page(); 125 + final pageWidget = page();
  126 + GetConfig.currentRoute = settings.name ?? routeName;
  127 + return pageWidget;
124 } 128 }
125 129
126 static bool isPopGestureInProgress(PageRoute<dynamic> route) { 130 static bool isPopGestureInProgress(PageRoute<dynamic> route) {
@@ -389,8 +393,8 @@ class GetPageRoute<T> extends PageRoute<T> { @@ -389,8 +393,8 @@ class GetPageRoute<T> extends PageRoute<T> {
389 @override 393 @override
390 void dispose() { 394 void dispose() {
391 if (GetConfig.smartManagement != SmartManagement.onlyBuilder) { 395 if (GetConfig.smartManagement != SmartManagement.onlyBuilder) {
392 - WidgetsBinding.instance.addPostFrameCallback(  
393 - (_) => GetInstance().removeDependencyByRoute("${settings.name}")); 396 + WidgetsBinding.instance.addPostFrameCallback((_) => GetInstance()
  397 + .removeDependencyByRoute("${settings?.name ?? routeName}"));
394 } 398 }
395 super.dispose(); 399 super.dispose();
396 } 400 }
1 import 'package:flutter/widgets.dart'; 1 import 'package:flutter/widgets.dart';
  2 +import 'package:get/route_manager.dart';
2 import 'package:get/src/instance/get_instance.dart'; 3 import 'package:get/src/instance/get_instance.dart';
  4 +import 'package:get/src/navigation/dialog/dialog_route.dart';
  5 +import 'package:get/src/navigation/routes/default_route.dart';
  6 +import 'package:get/src/navigation/snackbar/snack_route.dart';
3 7
4 class Routing { 8 class Routing {
5 String current; 9 String current;
@@ -25,7 +29,6 @@ class Routing { @@ -25,7 +29,6 @@ class Routing {
25 29
26 void update(void fn(Routing value)) { 30 void update(void fn(Routing value)) {
27 fn(this); 31 fn(this);
28 - GetConfig.currentRoute = this.current;  
29 } 32 }
30 } 33 }
31 34
@@ -46,28 +49,49 @@ class GetObserver extends NavigatorObserver { @@ -46,28 +49,49 @@ class GetObserver extends NavigatorObserver {
46 // String previousArgs; 49 // String previousArgs;
47 String removed; 50 String removed;
48 51
  52 + String name(Route<dynamic> route) {
  53 + if (route?.settings?.name != null) {
  54 + return route?.settings?.name;
  55 + } else if (route is GetPageRoute) {
  56 + return route.routeName;
  57 + } else if (route is GetDialogRoute) {
  58 + return route.name;
  59 + } else if (route is GetModalBottomSheetRoute) {
  60 + return route.name;
  61 + } else {
  62 + return route?.settings?.name;
  63 + }
  64 + }
  65 +
49 @override 66 @override
50 void didPush(Route<dynamic> route, Route<dynamic> previousRoute) { 67 void didPush(Route<dynamic> route, Route<dynamic> previousRoute) {
51 - if ('${route?.settings?.name}' == 'snackbar') {  
52 - GetConfig.log("[GETX] OPEN SNACKBAR ${route?.settings?.name}");  
53 - } else if ('${route?.settings?.name}' == 'bottomsheet') {  
54 - GetConfig.log("[GETX] OPEN BOTTOMSHEET ${route?.settings?.name}");  
55 - } else if ('${route?.settings?.name}' == 'dialog') {  
56 - GetConfig.log("[GETX] OPEN DIALOG ${route?.settings?.name}");  
57 - } else {  
58 - GetConfig.log("[GETX] GOING TO ROUTE ${route?.settings?.name}"); 68 + bool isGetPageRoute = route is GetPageRoute;
  69 + bool isSnackbar = route is SnackRoute;
  70 + bool isDialog = route is GetDialogRoute;
  71 + bool isBottomSheet = route is GetModalBottomSheetRoute;
  72 + String routeName = name(route);
  73 +
  74 + if (isSnackbar) {
  75 + GetConfig.log("[GETX] OPEN SNACKBAR $routeName");
  76 + } else if (isBottomSheet) {
  77 + GetConfig.log("[GETX] OPEN $routeName");
  78 + } else if (isDialog) {
  79 + GetConfig.log("[GETX] OPEN $routeName");
  80 + } else if (isGetPageRoute) {
  81 + GetConfig.log("[GETX] GOING TO ROUTE $routeName");
59 } 82 }
  83 + GetConfig.currentRoute = routeName;
60 84
61 _routeSend.update((value) { 85 _routeSend.update((value) {
62 - if (route is PageRoute) value.current = '${route?.settings?.name}'; 86 + if (route is PageRoute) value.current = routeName;
63 value.args = route?.settings?.arguments; 87 value.args = route?.settings?.arguments;
64 value.route = route; 88 value.route = route;
65 value.isBack = false; 89 value.isBack = false;
66 value.removed = ''; 90 value.removed = '';
67 value.previous = '${previousRoute?.settings?.name}'; 91 value.previous = '${previousRoute?.settings?.name}';
68 - value.isSnackbar = '${route?.settings?.name}' == 'snackbar';  
69 - value.isBottomSheet = '${route?.settings?.name}' == 'bottomsheet';  
70 - value.isDialog = '${route?.settings?.name}' == 'dialog'; 92 + value.isSnackbar = isSnackbar;
  93 + value.isBottomSheet = isBottomSheet;
  94 + value.isDialog = isDialog;
71 }); 95 });
72 if (routing != null) routing(_routeSend); 96 if (routing != null) routing(_routeSend);
73 } 97 }
@@ -76,15 +100,22 @@ class GetObserver extends NavigatorObserver { @@ -76,15 +100,22 @@ class GetObserver extends NavigatorObserver {
76 void didPop(Route route, Route previousRoute) { 100 void didPop(Route route, Route previousRoute) {
77 super.didPop(route, previousRoute); 101 super.didPop(route, previousRoute);
78 102
79 - if ('${route?.settings?.name}' == 'snackbar') {  
80 - GetConfig.log("[GETX] CLOSE SNACKBAR ${route?.settings?.name}");  
81 - } else if ('${route?.settings?.name}' == 'bottomsheet') {  
82 - GetConfig.log("[GETX] CLOSE BOTTOMSHEET ${route?.settings?.name}");  
83 - } else if ('${route?.settings?.name}' == 'dialog') {  
84 - GetConfig.log("[GETX] CLOSE DIALOG ${route?.settings?.name}");  
85 - } else {  
86 - GetConfig.log("[GETX] BACK ROUTE ${route?.settings?.name}"); 103 + bool isGetPageRoute = route is GetPageRoute;
  104 + bool isSnackbar = route is SnackRoute;
  105 + bool isDialog = route is GetDialogRoute;
  106 + bool isBottomSheet = route is GetModalBottomSheetRoute;
  107 + String routeName = name(route);
  108 +
  109 + if (isSnackbar) {
  110 + GetConfig.log("[GETX] CLOSE SNACKBAR $routeName");
  111 + } else if (isBottomSheet) {
  112 + GetConfig.log("[GETX] CLOSE $routeName");
  113 + } else if (isDialog) {
  114 + GetConfig.log("[GETX] CLOSE $routeName");
  115 + } else if (isGetPageRoute) {
  116 + GetConfig.log("[GETX] CLOSE TO ROUTE $routeName");
87 } 117 }
  118 + GetConfig.currentRoute = routeName;
88 119
89 _routeSend.update((value) { 120 _routeSend.update((value) {
90 if (previousRoute is PageRoute) 121 if (previousRoute is PageRoute)
@@ -104,9 +135,12 @@ class GetObserver extends NavigatorObserver { @@ -104,9 +135,12 @@ class GetObserver extends NavigatorObserver {
104 @override 135 @override
105 void didReplace({Route newRoute, Route oldRoute}) { 136 void didReplace({Route newRoute, Route oldRoute}) {
106 super.didReplace(newRoute: newRoute, oldRoute: oldRoute); 137 super.didReplace(newRoute: newRoute, oldRoute: oldRoute);
  138 +
107 GetConfig.log("[GETX] REPLACE ROUTE ${oldRoute?.settings?.name}"); 139 GetConfig.log("[GETX] REPLACE ROUTE ${oldRoute?.settings?.name}");
108 GetConfig.log("[GETX] NEW ROUTE ${newRoute?.settings?.name}"); 140 GetConfig.log("[GETX] NEW ROUTE ${newRoute?.settings?.name}");
109 141
  142 + GetConfig.currentRoute = name(newRoute);
  143 +
110 _routeSend.update((value) { 144 _routeSend.update((value) {
111 if (newRoute is PageRoute) value.current = '${newRoute?.settings?.name}'; 145 if (newRoute is PageRoute) value.current = '${newRoute?.settings?.name}';
112 value.args = newRoute?.settings?.arguments; 146 value.args = newRoute?.settings?.arguments;
  1 +import 'dart:async';
  2 +
1 import 'package:flutter/widgets.dart'; 3 import 'package:flutter/widgets.dart';
2 import 'package:get/src/state_manager/rx/rx_interface.dart'; 4 import 'package:get/src/state_manager/rx/rx_interface.dart';
  5 +
3 import 'rx_impl.dart'; 6 import 'rx_impl.dart';
4 7
5 Widget obx(Widget Function() builder) { 8 Widget obx(Widget Function() builder) {
@@ -24,6 +27,13 @@ class Obxx extends StatelessWidget { @@ -24,6 +27,13 @@ class Obxx extends StatelessWidget {
24 } 27 }
25 } 28 }
26 29
  30 +/// The simplest reactive widget in GetX.
  31 +///
  32 +/// Just pass your Rx variable in the root scope of the callback to have it
  33 +/// automatically registered for changes.
  34 +///
  35 +/// final _name = "GetX".obs;
  36 +/// Obx(() => Text( _name.value )),... ;
27 class Obx extends StatefulWidget { 37 class Obx extends StatefulWidget {
28 final Widget Function() builder; 38 final Widget Function() builder;
29 39
@@ -33,6 +43,7 @@ class Obx extends StatefulWidget { @@ -33,6 +43,7 @@ class Obx extends StatefulWidget {
33 43
34 class _ObxState extends State<Obx> { 44 class _ObxState extends State<Obx> {
35 RxInterface _observer; 45 RxInterface _observer;
  46 + StreamSubscription subs;
36 47
37 _ObxState() { 48 _ObxState() {
38 _observer = Rx(); 49 _observer = Rx();
@@ -40,12 +51,13 @@ class _ObxState extends State<Obx> { @@ -40,12 +51,13 @@ class _ObxState extends State<Obx> {
40 51
41 @override 52 @override
42 void initState() { 53 void initState() {
43 - _observer.subject.stream.listen((data) => setState(() {})); 54 + subs = _observer.subject.stream.listen((data) => setState(() {}));
44 super.initState(); 55 super.initState();
45 } 56 }
46 57
47 @override 58 @override
48 void dispose() { 59 void dispose() {
  60 + subs.cancel();
49 _observer.close(); 61 _observer.close();
50 super.dispose(); 62 super.dispose();
51 } 63 }
@@ -71,3 +83,59 @@ class _ObxState extends State<Obx> { @@ -71,3 +83,59 @@ class _ObxState extends State<Obx> {
71 @override 83 @override
72 Widget build(BuildContext context) => notifyChilds; 84 Widget build(BuildContext context) => notifyChilds;
73 } 85 }
  86 +
  87 +/// Similar to Obx, but manages a local state.
  88 +/// Pass the initial data in constructor.
  89 +/// Useful for simple local states, like toggles, visibility, themes,
  90 +/// button states, etc.
  91 +/// Sample:
  92 +/// ObxValue((data) => Switch(
  93 +/// value: data.value,
  94 +/// onChanged: (flag) => data.value = flag,
  95 +/// ),
  96 +/// false.obs,
  97 +/// ),
  98 +
  99 +// TODO: change T to a proper Rx interfase, that includes the accessor for ::value
  100 +class ObxValue<T extends RxInterface> extends StatefulWidget {
  101 + final Widget Function(T) builder;
  102 + final T data;
  103 +
  104 + const ObxValue(this.builder, this.data, {Key key}) : super(key: key);
  105 +
  106 + _ObxValueState createState() => _ObxValueState();
  107 +}
  108 +
  109 +class _ObxValueState extends State<ObxValue> {
  110 + RxInterface _observer;
  111 + StreamSubscription subs;
  112 +
  113 + _ObxValueState() {
  114 + _observer = Rx();
  115 + }
  116 +
  117 + @override
  118 + void initState() {
  119 + subs = _observer.subject.stream.listen((data) => setState(() {}));
  120 + super.initState();
  121 + }
  122 +
  123 + @override
  124 + void dispose() {
  125 + subs.cancel();
  126 + _observer.close();
  127 + super.dispose();
  128 + }
  129 +
  130 + Widget get notifyChilds {
  131 + final observer = getObs;
  132 + getObs = _observer;
  133 + // observable is implicity taken from the constructor.
  134 + final result = widget.builder(widget.data);
  135 + getObs = observer;
  136 + return result;
  137 + }
  138 +
  139 + @override
  140 + Widget build(BuildContext context) => notifyChilds;
  141 +}
@@ -3,6 +3,9 @@ import 'package:flutter/widgets.dart'; @@ -3,6 +3,9 @@ import 'package:flutter/widgets.dart';
3 import 'package:get/src/instance/get_instance.dart'; 3 import 'package:get/src/instance/get_instance.dart';
4 import 'package:get/src/navigation/root/smart_management.dart'; 4 import 'package:get/src/navigation/root/smart_management.dart';
5 import 'package:get/src/state_manager/rx/rx_interface.dart'; 5 import 'package:get/src/state_manager/rx/rx_interface.dart';
  6 +import 'package:get/state_manager.dart';
  7 +
  8 +import 'simple_builder.dart';
6 9
7 typedef Disposer = void Function(); 10 typedef Disposer = void Function();
8 11
@@ -48,121 +51,6 @@ class GetxController extends DisposableInterface { @@ -48,121 +51,6 @@ class GetxController extends DisposableInterface {
48 void onClose() async {} 51 void onClose() async {}
49 } 52 }
50 53
51 -// class GetBuilder<T extends GetxController> extends StatefulWidget {  
52 -// final Widget Function(T) builder;  
53 -// final bool global;  
54 -// final String id;  
55 -// final String tag;  
56 -// final bool autoRemove;  
57 -// final bool assignId;  
58 -// final void Function(State state) initState, dispose, didChangeDependencies;  
59 -// final void Function(GetBuilder oldWidget, State state) didUpdateWidget;  
60 -// final T init;  
61 -// const GetBuilder({  
62 -// Key key,  
63 -// this.init,  
64 -// this.global = true,  
65 -// @required this.builder,  
66 -// this.autoRemove = true,  
67 -// this.assignId = false,  
68 -// this.initState,  
69 -// this.tag,  
70 -// this.dispose,  
71 -// this.id,  
72 -// this.didChangeDependencies,  
73 -// this.didUpdateWidget,  
74 -// }) : assert(builder != null),  
75 -// super(key: key);  
76 -// @override  
77 -// _GetBuilderState<T> createState() => _GetBuilderState<T>();  
78 -// }  
79 -  
80 -// class _GetBuilderState<T extends GetxController> extends State<GetBuilder<T>> {  
81 -// GetxController controller;  
82 -// bool isCreator = false;  
83 -// @override  
84 -// void initState() {  
85 -// super.initState();  
86 -  
87 -// if (widget.initState != null) widget.initState(this);  
88 -// if (widget.global) {  
89 -// final isPrepared = GetInstance().isPrepared<T>(tag: widget.tag);  
90 -// final isRegistred = GetInstance().isRegistred<T>(tag: widget.tag);  
91 -  
92 -// if (isPrepared) {  
93 -// if (GetConfig.smartManagement != SmartManagement.keepFactory) {  
94 -// isCreator = true;  
95 -// }  
96 -// controller = GetInstance().find<T>(tag: widget.tag);  
97 -// } else if (isRegistred) {  
98 -// controller = GetInstance().find<T>(tag: widget.tag);  
99 -// isCreator = false;  
100 -// } else {  
101 -// controller = widget.init;  
102 -// isCreator = true;  
103 -// GetInstance().put<T>(controller, tag: widget.tag);  
104 -// }  
105 -// } else {  
106 -// controller = widget.init;  
107 -// isCreator = true;  
108 -// controller?.onStart();  
109 -// }  
110 -  
111 -// if (widget.global &&  
112 -// GetConfig.smartManagement == SmartManagement.onlyBuilder) {  
113 -// controller?.onStart();  
114 -// }  
115 -// (widget.id == null)  
116 -// ? controller.addListener(setState)  
117 -// : controller.addListenerId(widget.id, setState);  
118 -// }  
119 -  
120 -// @override  
121 -// void dispose() {  
122 -// super.dispose();  
123 -// if (widget.dispose != null) widget.dispose(this);  
124 -// if (isCreator || widget.assignId) {  
125 -// if (widget.autoRemove && GetInstance().isRegistred<T>(tag: widget.tag)) {  
126 -// (widget.id == null)  
127 -// ? controller.removeListener(setState)  
128 -// : controller.removeListenerId(widget.id);  
129 -// GetInstance().delete<T>(tag: widget.tag);  
130 -// }  
131 -// } else {  
132 -// (widget.id == null)  
133 -// ? controller.removeListener(setState)  
134 -// : controller.removeListenerId(widget.id);  
135 -// }  
136 -// }  
137 -  
138 -// @override  
139 -// void didChangeDependencies() {  
140 -// super.didChangeDependencies();  
141 -// if (widget.didChangeDependencies != null) {  
142 -// widget.didChangeDependencies(this);  
143 -// }  
144 -// }  
145 -  
146 -// @override  
147 -// void didUpdateWidget(GetBuilder oldWidget) {  
148 -// super.didUpdateWidget(oldWidget as GetBuilder<T>);  
149 -// if (widget.didUpdateWidget != null) widget.didUpdateWidget(oldWidget, this);  
150 -// }  
151 -  
152 -// @override  
153 -// Widget build(BuildContext context) {  
154 -// return widget.builder(controller);  
155 -// }  
156 -// }  
157 -  
158 -// class Updater {  
159 -// final StateSetter updater;  
160 -// final String id;  
161 -// const Updater({this.updater, this.id});  
162 -// }  
163 -  
164 -// typedef UpdaterBuilder = Updater Function();  
165 -  
166 class GetBuilder<T extends GetxController> extends StatefulWidget { 54 class GetBuilder<T extends GetxController> extends StatefulWidget {
167 final Widget Function(T) builder; 55 final Widget Function(T) builder;
168 final bool global; 56 final bool global;
@@ -268,73 +156,23 @@ class _GetBuilderState<T extends GetxController> extends State<GetBuilder<T>> { @@ -268,73 +156,23 @@ class _GetBuilderState<T extends GetxController> extends State<GetBuilder<T>> {
268 if (widget.didUpdateWidget != null) widget.didUpdateWidget(oldWidget, this); 156 if (widget.didUpdateWidget != null) widget.didUpdateWidget(oldWidget, this);
269 } 157 }
270 158
271 - Widget get notifyChildren {  
272 - final old = Value._remove;  
273 - Value._remove = disposers;  
274 - final observer = Value._setter;  
275 - Value._setter = setState;  
276 - final result = widget.builder(controller);  
277 - Value._setter = observer;  
278 - Value._remove = old;  
279 - return result;  
280 - }  
281 -  
282 @override 159 @override
283 - Widget build(BuildContext context) => notifyChildren; 160 + Widget build(BuildContext context) => widget.builder(controller);
284 } 161 }
285 162
  163 +/// This is a experimental feature
286 class Value<T> extends GetxController { 164 class Value<T> extends GetxController {
287 Value([this._value]); 165 Value([this._value]);
288 T _value; 166 T _value;
289 167
290 T get value { 168 T get value {
291 - if (_setter != null) {  
292 - if (!_updaters.contains(_setter)) {  
293 - final add = addListener(_setter);  
294 - _remove.add(add);  
295 - }  
296 - } 169 + TaskManager.instance.notify(_updaters);
297 return _value; 170 return _value;
298 } 171 }
299 172
300 - static StateSetter _setter;  
301 -  
302 - static HashSet<Disposer> _remove;  
303 -  
304 set value(T newValue) { 173 set value(T newValue) {
305 if (_value == newValue) return; 174 if (_value == newValue) return;
306 _value = newValue; 175 _value = newValue;
307 update(); 176 update();
308 } 177 }
309 } 178 }
310 -  
311 -class SimpleBuilder extends StatefulWidget {  
312 - final Widget Function(BuildContext) builder;  
313 - const SimpleBuilder({Key key, @required this.builder})  
314 - : assert(builder != null),  
315 - super(key: key);  
316 - @override  
317 - _SimpleBuilderState createState() => _SimpleBuilderState();  
318 -}  
319 -  
320 -class _SimpleBuilderState extends State<SimpleBuilder> {  
321 - final HashSet<Disposer> disposers = HashSet<Disposer>();  
322 -  
323 - @override  
324 - void dispose() {  
325 - super.dispose();  
326 - disposers.forEach((element) => element());  
327 - }  
328 -  
329 - @override  
330 - Widget build(BuildContext context) {  
331 - HashSet<Disposer> old = Value._remove;  
332 - Value._remove = disposers;  
333 - StateSetter observer = Value._setter;  
334 - Value._setter = setState;  
335 - Widget result = widget.builder(context);  
336 - Value._remove = old;  
337 - Value._setter = observer;  
338 - return result;  
339 - }  
340 -}  
  1 +import 'dart:async';
  2 +import 'dart:collection';
  3 +
  4 +import 'package:flutter/widgets.dart';
  5 +
  6 +import 'get_state.dart';
  7 +
  8 +typedef ValueBuilderUpdateCallback<T> = void Function(T snapshot);
  9 +typedef ValueBuilderBuilder<T> = Widget Function(
  10 + T snapshot, ValueBuilderUpdateCallback<T> updater);
  11 +
  12 +/// Manages a local state like ObxValue, but uses a callback instead of a Rx value.
  13 +///
  14 +/// Sample:
  15 +/// ValueBuilder<bool>(
  16 +/// initialValue: false,
  17 +/// builder: (value, update) => Switch(
  18 +/// value: value,
  19 +/// onChanged: (flag) {
  20 +/// update( flag );
  21 +/// },),
  22 +/// onUpdate: (value) => print("Value updated: $value"),
  23 +/// ),
  24 +class ValueBuilder<T> extends StatefulWidget {
  25 + final T initialValue;
  26 + final ValueBuilderBuilder builder;
  27 + final void Function() onDispose;
  28 + final void Function(T) onUpdate;
  29 +
  30 + const ValueBuilder({
  31 + Key key,
  32 + this.initialValue,
  33 + this.onDispose,
  34 + this.onUpdate,
  35 + @required this.builder,
  36 + }) : super(key: key);
  37 +
  38 + @override
  39 + _ValueBuilderState<T> createState() => _ValueBuilderState<T>();
  40 +}
  41 +
  42 +class _ValueBuilderState<T> extends State<ValueBuilder<T>> {
  43 + T value;
  44 +
  45 + @override
  46 + void initState() {
  47 + super.initState();
  48 + value = widget.initialValue;
  49 + }
  50 +
  51 + @override
  52 + Widget build(BuildContext context) => widget.builder(value, updater);
  53 +
  54 + void updater(T newValue) {
  55 + if (widget.onUpdate != null) {
  56 + widget.onUpdate(newValue);
  57 + }
  58 + setState(() {
  59 + value = newValue;
  60 + });
  61 + }
  62 +
  63 + @override
  64 + void dispose() {
  65 + super.dispose();
  66 + widget?.onDispose?.call();
  67 + if (value is ChangeNotifier) {
  68 + (value as ChangeNotifier)?.dispose();
  69 + } else if (value is StreamController) {
  70 + (value as StreamController)?.close();
  71 + }
  72 + value = null;
  73 + }
  74 +}
  75 +
  76 +// It's a experimental feature
  77 +class SimpleBuilder extends StatefulWidget {
  78 + final Widget Function(BuildContext) builder;
  79 + const SimpleBuilder({Key key, @required this.builder})
  80 + : assert(builder != null),
  81 + super(key: key);
  82 + @override
  83 + _SimpleBuilderState createState() => _SimpleBuilderState();
  84 +}
  85 +
  86 +class _SimpleBuilderState extends State<SimpleBuilder> {
  87 + final HashSet<Disposer> disposers = HashSet<Disposer>();
  88 +
  89 + @override
  90 + void dispose() {
  91 + super.dispose();
  92 + disposers.forEach((element) => element());
  93 + }
  94 +
  95 + @override
  96 + Widget build(BuildContext context) {
  97 + return TaskManager.instance
  98 + .exchange(disposers, setState, widget.builder, context);
  99 + }
  100 +}
  101 +
  102 +class TaskManager {
  103 + TaskManager._();
  104 + static TaskManager _instance;
  105 + static TaskManager get instance => _instance ??= TaskManager._();
  106 +
  107 + StateSetter _setter;
  108 + HashSet<Disposer> _remove;
  109 +
  110 + notify(HashSet<StateSetter> _updaters) {
  111 + if (_setter != null) {
  112 + if (!_updaters.contains(_setter)) {
  113 + _updaters.add(_setter);
  114 + _remove.add(() => _updaters.remove(_setter));
  115 + }
  116 + }
  117 + }
  118 +
  119 + Widget exchange(
  120 + HashSet<Disposer> disposers,
  121 + StateSetter setState,
  122 + Widget Function(BuildContext) builder,
  123 + BuildContext context,
  124 + ) {
  125 + _remove = disposers;
  126 + _setter = setState;
  127 + final result = builder(context);
  128 + _remove = null;
  129 + _setter = null;
  130 + return result;
  131 + }
  132 +}
1 -export 'simple/get_state.dart';  
2 -export 'simple/immutable_state.dart';  
3 -export 'simple/get_view.dart';  
4 -export 'simple/mixin_state.dart';  
5 -export 'rx/rx_interface.dart';  
6 -export 'rx/rx_impl.dart';  
7 -export 'rx/rx_event.dart';  
8 -export 'rx/rx_obx.dart';  
9 -export 'rx/rx_getbuilder.dart';  
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 import 'package:flutter/widgets.dart'; 2 import 'package:flutter/widgets.dart';
  3 +import 'package:flutter/foundation.dart';
3 4
4 extension ContextExtensionss on BuildContext { 5 extension ContextExtensionss on BuildContext {
5 /// The same of [MediaQuery.of(context).size] 6 /// The same of [MediaQuery.of(context).size]
@@ -102,4 +103,27 @@ extension ContextExtensionss on BuildContext { @@ -102,4 +103,27 @@ extension ContextExtensionss on BuildContext {
102 103
103 /// True if the current device is Tablet 104 /// True if the current device is Tablet
104 bool get isTablet => isSmallTablet || isLargeTablet; 105 bool get isTablet => isSmallTablet || isLargeTablet;
  106 +
  107 + /// Returns a specific value according to the screen size
  108 + /// if the device width is higher than or equal to 1200 return [desktop] value.
  109 + /// if the device width is higher than or equal to 600 and less than 1200
  110 + /// return [tablet] value.
  111 + /// if the device width is less than 300 return [watch] value.
  112 + /// in other cases return [mobile] value.
  113 + T responsiveValue<T>({
  114 + T mobile,
  115 + T tablet,
  116 + T desktop,
  117 + T watch,
  118 + }) {
  119 + double deviceWidth = mediaQuerySize.shortestSide;
  120 +
  121 + if (kIsWeb) {
  122 + deviceWidth = mediaQuerySize.width;
  123 + }
  124 + if (deviceWidth >= 1200 && desktop != null) return desktop;
  125 + if (deviceWidth >= 600 && tablet != null) return tablet;
  126 + if (deviceWidth < 300 && watch != null) return watch;
  127 + return mobile;
  128 + }
105 } 129 }
  1 +import 'package:flutter/material.dart';
  2 +import 'package:flutter/widgets.dart';
  3 +import 'package:flutter/foundation.dart';
  4 +
  5 +extension ContextExtensionss on BuildContext {
  6 + /// The same of [MediaQuery.of(context).size]
  7 + Size get mediaQuerySize => MediaQuery.of(this).size;
  8 +
  9 + /// The same of [MediaQuery.of(context).size.height]
  10 + /// Note: updates when you rezise your screen (like on a browser or desktop window)
  11 + double get height => mediaQuerySize.height;
  12 +
  13 + /// The same of [MediaQuery.of(context).size.width]
  14 + /// Note: updates when you rezise your screen (like on a browser or desktop window)
  15 + double get width => mediaQuerySize.width;
  16 +
  17 + /// Gives you the power to get a portion of the height.
  18 + /// Useful for responsive applications.
  19 + ///
  20 + /// [dividedBy] is for when you want to have a portion of the value you would get
  21 + /// like for example: if you want a value that represents a third of the screen
  22 + /// you can set it to 3, and you will get a third of the height
  23 + ///
  24 + /// [reducedBy] is a percentage value of how much of the height you want
  25 + /// if you for example want 46% of the height, then you reduce it by 56%.
  26 + double heightTransformer({double dividedBy = 1, double reducedBy = 0.0}) {
  27 + return (mediaQuerySize.height -
  28 + ((mediaQuerySize.height / 100) * reducedBy)) /
  29 + dividedBy;
  30 + }
  31 +
  32 + /// Gives you the power to get a portion of the width.
  33 + /// Useful for responsive applications.
  34 + ///
  35 + /// [dividedBy] is for when you want to have a portion of the value you would get
  36 + /// like for example: if you want a value that represents a third of the screen
  37 + /// you can set it to 3, and you will get a third of the width
  38 + ///
  39 + /// [reducedBy] is a percentage value of how much of the width you want
  40 + /// if you for example want 46% of the width, then you reduce it by 56%.
  41 + double widthTransformer({double dividedBy = 1, double reducedBy = 0.0}) {
  42 + return (mediaQuerySize.width - ((mediaQuerySize.width / 100) * reducedBy)) /
  43 + dividedBy;
  44 + }
  45 +
  46 + /// Divide the height proportionally by the given value
  47 + double ratio({
  48 + double dividedBy = 1,
  49 + double reducedByW = 0.0,
  50 + double reducedByH = 0.0,
  51 + }) {
  52 + return heightTransformer(dividedBy: dividedBy, reducedBy: reducedByH) /
  53 + widthTransformer(dividedBy: dividedBy, reducedBy: reducedByW);
  54 + }
  55 +
  56 + /// similar to [MediaQuery.of(context).padding]
  57 + ThemeData get theme => Theme.of(this);
  58 +
  59 + /// similar to [MediaQuery.of(context).padding]
  60 + TextTheme get textTheme => Theme.of(this).textTheme;
  61 +
  62 + /// similar to [MediaQuery.of(context).padding]
  63 + EdgeInsets get mediaQueryPadding => MediaQuery.of(this).padding;
  64 +
  65 + /// similar to [MediaQuery.of(context).padding]
  66 + MediaQueryData get mediaQuery => MediaQuery.of(this);
  67 +
  68 + /// similar to [MediaQuery.of(context).viewPadding]
  69 + EdgeInsets get mediaQueryViewPadding => MediaQuery.of(this).viewPadding;
  70 +
  71 + /// similar to [MediaQuery.of(context).viewInsets]
  72 + EdgeInsets get mediaQueryViewInsets => MediaQuery.of(this).viewInsets;
  73 +
  74 + /// similar to [MediaQuery.of(context).orientation]
  75 + Orientation get orientation => MediaQuery.of(this).orientation;
  76 +
  77 + /// check if device is on landscape mode
  78 + bool get isLandscape => orientation == Orientation.landscape;
  79 +
  80 + /// check if device is on portrait mode
  81 + bool get isPortrait => orientation == Orientation.portrait;
  82 +
  83 + /// similar to [MediaQuery.of(this).devicePixelRatio]
  84 + double get devicePixelRatio => MediaQuery.of(this).devicePixelRatio;
  85 +
  86 + /// similar to [MediaQuery.of(this).textScaleFactor]
  87 + double get textScaleFactor => MediaQuery.of(this).textScaleFactor;
  88 +
  89 + /// get the shortestSide from screen
  90 + double get mediaQueryShortestSide => mediaQuerySize.shortestSide;
  91 +
  92 + /// True if width be larger than 800
  93 + bool get showNavbar => (width > 800);
  94 +
  95 + /// True if the shortestSide is smaller than 600p
  96 + bool get isPhone => (mediaQueryShortestSide < 600);
  97 +
  98 + /// True if the shortestSide is largest than 600p
  99 + bool get isSmallTablet => (mediaQueryShortestSide >= 600);
  100 +
  101 + /// True if the shortestSide is largest than 720p
  102 + bool get isLargeTablet => (mediaQueryShortestSide >= 720);
  103 +
  104 + /// True if the current device is Tablet
  105 + bool get isTablet => isSmallTablet || isLargeTablet;
  106 +
  107 + /// Returns a specific value according to the screen size
  108 + /// if the device width is higher than or equal to 1200 return [desktop] value.
  109 + /// if the device width is higher than or equal to 600 and less than 1200
  110 + /// return [tablet] value.
  111 + /// if the device width is less than 300 return [watch] value.
  112 + /// in other cases return [mobile] value.
  113 + T responsiveValue<T>({
  114 + T mobile,
  115 + T tablet,
  116 + T desktop,
  117 + T watch,
  118 + }) {
  119 + double deviceWidth = mediaQuerySize.shortestSide;
  120 +
  121 + if (kIsWeb) {
  122 + deviceWidth = mediaQuerySize.width;
  123 + }
  124 + if (deviceWidth >= 1200 && desktop != null) return desktop;
  125 + if (deviceWidth >= 600 && tablet != null) return tablet;
  126 + if (deviceWidth < 300 && watch != null) return watch;
  127 + return mobile;
  128 + }
  129 +}
  1 +import 'dart:math';
  2 +
  3 +extension Precision on double {
  4 + double toPrecision(int fractionDigits) {
  5 + double mod = pow(10, fractionDigits.toDouble());
  6 + return ((this * mod).round().toDouble() / mod);
  7 + }
  8 +}
  1 +import '../regex/get_utils.dart';
  2 +
  3 +extension GetDynamicUtils on dynamic {
  4 + /// It's This is overloading the IDE's options. Only the most useful and popular options will stay here.
  5 +
  6 + bool get isNull => GetUtils.isNull(this);
  7 + bool get isNullOrBlank => GetUtils.isNullOrBlank(this);
  8 +
  9 + // bool get isOneAKind => GetUtils.isOneAKind(this);
  10 + // bool isLengthLowerThan(int maxLength) =>
  11 + // GetUtils.isLengthLowerThan(this, maxLength);
  12 + // bool isLengthGreaterThan(int maxLength) =>
  13 + // GetUtils.isLengthGreaterThan(this, maxLength);
  14 + // bool isLengthGreaterOrEqual(int maxLength) =>
  15 + // GetUtils.isLengthGreaterOrEqual(this, maxLength);
  16 + // bool isLengthLowerOrEqual(int maxLength) =>
  17 + // GetUtils.isLengthLowerOrEqual(this, maxLength);
  18 + // bool isLengthEqualTo(int maxLength) =>
  19 + // GetUtils.isLengthEqualTo(this, maxLength);
  20 + // bool isLengthBetween(int minLength, int maxLength) =>
  21 + // GetUtils.isLengthBetween(this, minLength, maxLength);
  22 +}
  1 +export 'context_extensions.dart';
  2 +export 'double_extensions.dart';
  3 +export 'dynamic_extensions.dart';
  4 +export 'num_extensions.dart';
  5 +export 'string_extensions.dart';
  6 +export 'widget_extensions.dart';
  1 +import '../regex/get_utils.dart';
  2 +
  3 +extension GetNumUtils on num {
  4 + bool isLowerThan(num b) => GetUtils.isLowerThan(this, b);
  5 + bool isGreaterThan(num b) => GetUtils.isGreaterThan(this, b);
  6 + bool isEqual(num b) => GetUtils.isEqual(this, b);
  7 +}
  1 +import '../regex/get_utils.dart';
  2 +
  3 +extension GetStringUtils on String {
  4 + bool get isNum => GetUtils.isNum(this);
  5 + bool get isNumericOnly => GetUtils.isNumericOnly(this);
  6 + bool get isAlphabetOnly => GetUtils.isAlphabetOnly(this);
  7 + bool get isBool => GetUtils.isBool(this);
  8 + bool get isVectorFileName => GetUtils.isVector(this);
  9 + bool get isImageFileName => GetUtils.isImage(this);
  10 + bool get isAudioFileName => GetUtils.isAudio(this);
  11 + bool get isVideoFileName => GetUtils.isVideo(this);
  12 + bool get isTxtFileName => GetUtils.isTxt(this);
  13 + bool get isDocumentFileName => GetUtils.isDocument(this);
  14 + bool get isExcelFileName => GetUtils.isExcel(this);
  15 + bool get isPPTFileName => GetUtils.isPPT(this);
  16 + bool get isAPKFileName => GetUtils.isAPK(this);
  17 + bool get isPDFFileName => GetUtils.isPDF(this);
  18 + bool get isHTMLFileName => GetUtils.isHTML(this);
  19 + bool get isURL => GetUtils.isURL(this);
  20 + bool get isEmail => GetUtils.isEmail(this);
  21 + bool get isPhoneNumber => GetUtils.isPhoneNumber(this);
  22 + bool get isDateTime => GetUtils.isDateTime(this);
  23 + bool get isMD5 => GetUtils.isMD5(this);
  24 + bool get isSHA1 => GetUtils.isSHA1(this);
  25 + bool get isSHA256 => GetUtils.isSHA256(this);
  26 + bool get isISBN => GetUtils.isISBN(this);
  27 + bool get isBinary => GetUtils.isBinary(this);
  28 + bool get isIPv4 => GetUtils.isIPv4(this);
  29 + bool get isIPv6 => GetUtils.isIPv6(this);
  30 + bool get isHexadecimal => GetUtils.isHexadecimal(this);
  31 + bool get isPalindrom => GetUtils.isPalindrom(this);
  32 + bool get isPassport => GetUtils.isPassport(this);
  33 + bool get isCurrency => GetUtils.isCurrency(this);
  34 + bool isCpf(String s) => GetUtils.isCpf(this);
  35 + bool isCnpj(String s) => GetUtils.isCnpj(this);
  36 + bool isCaseInsensitiveContains(String b) =>
  37 + GetUtils.isCaseInsensitiveContains(this, b);
  38 + bool isCaseInsensitiveContainsAny(String b) =>
  39 + GetUtils.isCaseInsensitiveContainsAny(this, b);
  40 + String capitalize(String s, {bool firstOnly = false}) =>
  41 + GetUtils.capitalize(this, firstOnly: firstOnly);
  42 + String capitalizeFirst(String s) => GetUtils.capitalizeFirst(this);
  43 + String removeAllWhitespace(String s) => GetUtils.removeAllWhitespace(this);
  44 + String camelCase(String s) => GetUtils.camelCase(this);
  45 + String numericOnly(String s, {bool firstWordOnly = false}) =>
  46 + GetUtils.numericOnly(this, firstWordOnly: firstWordOnly);
  47 +}
  1 +import 'package:flutter/widgets.dart';
  2 +
  3 +extension WidgetPaddingX on Widget {
  4 + Widget paddingAll(double padding) =>
  5 + Padding(padding: EdgeInsets.all(padding), child: this);
  6 +
  7 + Widget paddingSymmetric({double horizontal = 0.0, double vertical = 0.0}) =>
  8 + Padding(
  9 + padding:
  10 + EdgeInsets.symmetric(horizontal: horizontal, vertical: vertical),
  11 + child: this);
  12 +
  13 + Widget paddingOnly({
  14 + double left = 0.0,
  15 + double top = 0.0,
  16 + double right = 0.0,
  17 + double bottom = 0.0,
  18 + }) =>
  19 + Padding(
  20 + padding: EdgeInsets.only(
  21 + top: top, left: left, right: right, bottom: bottom),
  22 + child: this);
  23 +
  24 + Widget get paddingZero => Padding(padding: EdgeInsets.zero, child: this);
  25 +}
  26 +
  27 +extension WidgetMarginX on Widget {
  28 + Widget marginAll(double margin) =>
  29 + Container(margin: EdgeInsets.all(margin), child: this);
  30 +
  31 + Widget marginSymmetric({double horizontal = 0.0, double vertical = 0.0}) =>
  32 + Container(
  33 + margin:
  34 + EdgeInsets.symmetric(horizontal: horizontal, vertical: vertical),
  35 + child: this);
  36 +
  37 + Widget marginOnly({
  38 + double left = 0.0,
  39 + double top = 0.0,
  40 + double right = 0.0,
  41 + double bottom = 0.0,
  42 + }) =>
  43 + Container(
  44 + margin: EdgeInsets.only(
  45 + top: top, left: left, right: right, bottom: bottom),
  46 + child: this);
  47 +
  48 + Widget get marginZero => Container(margin: EdgeInsets.zero, child: this);
  49 +}
@@ -27,7 +27,7 @@ class GetUtils { @@ -27,7 +27,7 @@ class GetUtils {
27 } 27 }
28 28
29 /// Checks if string consist only numeric. 29 /// Checks if string consist only numeric.
30 - /// Numeric only doesnt accepting "." which double data type have 30 + /// Numeric only doesn't accepting "." which double data type have
31 static bool isNumericOnly(String s) => 31 static bool isNumericOnly(String s) =>
32 RegexValidation.hasMatch(s, regex.numericOnly); 32 RegexValidation.hasMatch(s, regex.numericOnly);
33 33
1 -export 'context_extensions/extensions.dart';  
2 -export 'queue/get_queue.dart';  
3 -export 'platform/platform.dart';  
4 -export 'regex/get_utils.dart';  
5 -export 'regex/get_utils_extensions.dart';  
1 export 'src/state_manager/simple/get_state.dart'; 1 export 'src/state_manager/simple/get_state.dart';
2 export 'src/state_manager/simple/immutable_state.dart'; 2 export 'src/state_manager/simple/immutable_state.dart';
3 export 'src/state_manager/simple/get_view.dart'; 3 export 'src/state_manager/simple/get_view.dart';
  4 +export 'src/state_manager/simple/simple_builder.dart';
4 export 'src/state_manager/simple/mixin_state.dart'; 5 export 'src/state_manager/simple/mixin_state.dart';
5 export 'src/state_manager/rx/rx_interface.dart'; 6 export 'src/state_manager/rx/rx_interface.dart';
6 export 'src/state_manager/rx/rx_impl.dart'; 7 export 'src/state_manager/rx/rx_impl.dart';
1 -export 'src/utils/context_extensions/extensions.dart'; 1 +export 'src/utils/extensions/export.dart';
2 export 'src/utils/queue/get_queue.dart'; 2 export 'src/utils/queue/get_queue.dart';
3 export 'src/utils/platform/platform.dart'; 3 export 'src/utils/platform/platform.dart';
4 export 'src/utils/regex/get_utils.dart'; 4 export 'src/utils/regex/get_utils.dart';
5 -export 'src/utils/regex/get_utils_extensions.dart';  
1 name: get 1 name: get
2 description: Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with GetX. 2 description: Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with GetX.
3 -version: 3.4.6 3 +version: 3.5.1
4 homepage: https://github.com/jonataslaw/get 4 homepage: https://github.com/jonataslaw/get
5 5
6 environment: 6 environment:
7 - sdk: ">=2.6.0 <3.0.0" 7 + sdk: ">=2.8.0 <3.0.0"
8 8
9 dependencies: 9 dependencies:
10 flutter: 10 flutter:
  1 +import 'package:flutter_test/flutter_test.dart';
  2 +
  3 +void main() {
  4 + test('', () {});
  5 +}
  1 +import 'package:flutter_test/flutter_test.dart';
  2 +import 'package:get/utils.dart';
  3 +
  4 +void main() {
  5 + test('Test for toPrecision on Double', () {
  6 + double testVar = 5.4545454;
  7 + expect(testVar.toPrecision(2), equals(5.45));
  8 + });
  9 +}
  1 +import 'package:flutter_test/flutter_test.dart';
  2 +
  3 +void main() {
  4 + test('', () {});
  5 +}
  1 +import 'package:flutter_test/flutter_test.dart';
  2 +import 'package:get/utils.dart';
  3 +
  4 +void main() {
  5 + num x = 5;
  6 + num y = 7;
  7 + test('Test for var.isLowerThan(value)', () {
  8 + expect(x.isLowerThan(y), true);
  9 + expect(y.isLowerThan(x), false);
  10 + });
  11 + test('Test for var.isGreaterThan(value)', () {
  12 + expect(x.isGreaterThan(y), false);
  13 + expect(y.isGreaterThan(x), true);
  14 + });
  15 + test('Test for var.isGreaterThan(value)', () {
  16 + expect(x.isEqual(y), false);
  17 + expect(y.isEqual(x), false);
  18 + expect(x.isEqual(5), true);
  19 + expect(y.isEqual(7), true);
  20 + });
  21 +}
  1 +import 'package:flutter_test/flutter_test.dart';
  2 +import 'package:get/utils.dart';
  3 +
  4 +void main() {
  5 + group('Test group for extension: isNullOrBlank', () {
  6 + String testString;
  7 + test('String extension: isNullOrBlank', () {
  8 + expect(testString.isNullOrBlank, equals(true));
  9 + });
  10 + test('String extension: isNullOrBlank', () {
  11 + testString = 'Not null anymore';
  12 + expect(testString.isNullOrBlank, equals(false));
  13 + });
  14 + test('String extension: isNullOrBlank', () {
  15 + testString = '';
  16 + expect(testString.isNullOrBlank, equals(true));
  17 + });
  18 + });
  19 +}
  1 +import 'package:flutter/widgets.dart';
  2 +import 'package:flutter_test/flutter_test.dart';
  3 +import 'package:get/utils.dart';
  4 +
  5 +void main() {
  6 + group('Group test for PaddingX Extension', () {
  7 + testWidgets('Test of paddingAll', (WidgetTester tester) async {
  8 + Widget containerTest;
  9 +
  10 + expect(find.byType(Padding), findsNothing);
  11 +
  12 + await tester.pumpWidget(containerTest.paddingAll(16));
  13 +
  14 + expect(find.byType(Padding), findsOneWidget);
  15 + });
  16 +
  17 + testWidgets('Test of paddingOnly', (WidgetTester tester) async {
  18 + Widget containerTest;
  19 +
  20 + expect(find.byType(Padding), findsNothing);
  21 +
  22 + await tester.pumpWidget(containerTest.paddingOnly(top: 16));
  23 +
  24 + expect(find.byType(Padding), findsOneWidget);
  25 + });
  26 +
  27 + testWidgets('Test of paddingSymmetric', (WidgetTester tester) async {
  28 + Widget containerTest;
  29 +
  30 + expect(find.byType(Padding), findsNothing);
  31 +
  32 + await tester.pumpWidget(containerTest.paddingSymmetric(vertical: 16));
  33 +
  34 + expect(find.byType(Padding), findsOneWidget);
  35 + });
  36 +
  37 + testWidgets('Test of paddingZero', (WidgetTester tester) async {
  38 + Widget containerTest;
  39 +
  40 + expect(find.byType(Padding), findsNothing);
  41 +
  42 + await tester.pumpWidget(containerTest.paddingZero);
  43 +
  44 + expect(find.byType(Padding), findsOneWidget);
  45 + });
  46 + });
  47 +
  48 + group('Group test for MarginX Extension', () {
  49 + testWidgets('Test of marginAll', (WidgetTester tester) async {
  50 + Widget containerTest;
  51 +
  52 + await tester.pumpWidget(containerTest.marginAll(16));
  53 +
  54 + expect(find.byType(Container), findsOneWidget);
  55 + });
  56 +
  57 + testWidgets('Test of marginOnly', (WidgetTester tester) async {
  58 + Widget containerTest;
  59 +
  60 + await tester.pumpWidget(containerTest.marginOnly(top: 16));
  61 +
  62 + expect(find.byType(Container), findsOneWidget);
  63 + });
  64 +
  65 + testWidgets('Test of marginSymmetric', (WidgetTester tester) async {
  66 + Widget containerTest;
  67 +
  68 + await tester.pumpWidget(containerTest.marginSymmetric(vertical: 16));
  69 +
  70 + expect(find.byType(Container), findsOneWidget);
  71 + });
  72 +
  73 + testWidgets('Test of marginZero', (WidgetTester tester) async {
  74 + Widget containerTest;
  75 +
  76 + await tester.pumpWidget(containerTest.marginZero);
  77 +
  78 + expect(find.byType(Container), findsOneWidget);
  79 + });
  80 + });
  81 +}