Committed by
GitHub
Merge pull request #1 from jonataslaw/master
update
Showing
58 changed files
with
1263 additions
and
1101 deletions
Too many changes to show.
To preserve performance only 58 of 58+ files are displayed.
.DS_Store
0 → 100644
No preview for this file type
@@ -23,7 +23,7 @@ jobs: | @@ -23,7 +23,7 @@ jobs: | ||
23 | # https://github.com/marketplace/actions/flutter-action | 23 | # https://github.com/marketplace/actions/flutter-action |
24 | - uses: subosito/flutter-action@v1 | 24 | - uses: subosito/flutter-action@v1 |
25 | with: | 25 | with: |
26 | - flutter-version: "1.22.3" | 26 | + flutter-version: "2.0.2" |
27 | channel: "stable" | 27 | channel: "stable" |
28 | - run: flutter pub get | 28 | - run: flutter pub get |
29 | #- run: flutter analyze | 29 | #- run: flutter analyze |
.metadata
0 → 100644
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: 60bd88df915880d23877bfc1602e8ddcf4c4dd2a | ||
8 | + channel: stable | ||
9 | + | ||
10 | +project_type: app |
1 | +## [4.1.2] | ||
2 | +- Fix warning ˜can add data to a closed stream˜ when GetBuilder and Obx are nested | ||
3 | +- Fix get_connect decoder can not be null (@Goddchen) | ||
4 | +- Migrate example code (@3lB4rt0) | ||
5 | +- Fix initial value of nullables (@RafaRuiz) | ||
6 | +- Improve error message to navigation (@maxzod) | ||
7 | +- Fix typo on docs (@Rahulshahare) | ||
8 | +- Fixed darktheme being changed only through Get.changeTheme and not through the DarkTheme theme property in MaterialApp (@GoldenSoju) | ||
9 | +- Fix controller is removed when navigate to same page (@eduardoflorence) | ||
10 | +- Fix missing reload() and reloadAll() to Get extensions (@lkloon123) | ||
11 | + | ||
12 | + | ||
13 | +## [4.1.1] | ||
14 | +- Remove mandatory initialValue to nullables types | ||
15 | + | ||
16 | +## [4.1.0] | ||
17 | +- Added Rxn to non nullables reactives types | ||
18 | + | ||
19 | +## [4.0.3] | ||
20 | +- Added new linter rules to improve score | ||
21 | + | ||
22 | +## [4.0.2] | ||
23 | +- Removed "!" of if else conditions until the null-safety of the dart is consistent for using it. | ||
24 | + | ||
25 | +## [4.0.1] | ||
26 | +- Fix changelog | ||
27 | + | ||
28 | +## [4.0.0] | ||
29 | +- Added append function to StateMixin. Now is possible track loading, success and error handle of your application with ONE LINE OF CODE. Ex: append(()=> api.getUser); | ||
30 | +- Migrate to null-safety | ||
31 | +- Added ScrollMixin to controllers | ||
32 | +- Added loadingMore status to RxStatus | ||
33 | +- Fix content-type qual null (@katekko) | ||
34 | +- Made GetInstance non nullable (@eduardoflorence) | ||
35 | +- Fix multi-parameters url (@iMrLopez) | ||
36 | +- Fix Expected value of SkDeletable error (@obadajasm) | ||
37 | +- Added triggers, an Rx method that triggers events, even if they are the same as the previous event (@RafaRuiz) | ||
38 | +- Improve docs: (@CNAD666), (@dhhAndroid), (@Jackylee1992), | ||
39 | + | ||
40 | +Switching to null-safety: | ||
41 | +You can continue using GetX as normal, with as little breaking changes as possible. | ||
42 | +It is still possible to declare the var.obs variable, and this remains the preferred way, forcing null-safety and giving you all the security that sound null-safety delivers to your app. However, if you need to use null, we also provide a solution for you. | ||
43 | +Declare the variables with `?` Ex: `final Rx<int?> count = 0.obs`. | ||
44 | +You can also use custom Rxn types with null-safety: | ||
45 | +`RxInt` == not nullable | ||
46 | +`RxnInt` == nullable. | ||
47 | + | ||
1 | ## [3.25.6] | 48 | ## [3.25.6] |
2 | - Added documentation in French (@kamazoun) | 49 | - Added documentation in French (@kamazoun) |
3 | - Fix logs messages (@damphat) | 50 | - Fix logs messages (@damphat) |
@@ -119,7 +119,7 @@ void main() => runApp(GetMaterialApp(home: Home())); | @@ -119,7 +119,7 @@ void main() => runApp(GetMaterialApp(home: Home())); | ||
119 | ``` | 119 | ``` |
120 | 120 | ||
121 | - Note: this does not modify the MaterialApp of the Flutter, GetMaterialApp is not a modified MaterialApp, it is just a pre-configured Widget, which has the default MaterialApp as a child. You can configure this manually, but it is definitely not necessary. GetMaterialApp will create routes, inject them, inject translations, inject everything you need for route navigation. If you use Get only for state management or dependency management, it is not necessary to use GetMaterialApp. GetMaterialApp is necessary for routes, snackbars, internationalization, bottomSheets, dialogs, and high-level apis related to routes and absence of context. | 121 | - Note: this does not modify the MaterialApp of the Flutter, GetMaterialApp is not a modified MaterialApp, it is just a pre-configured Widget, which has the default MaterialApp as a child. You can configure this manually, but it is definitely not necessary. GetMaterialApp will create routes, inject them, inject translations, inject everything you need for route navigation. If you use Get only for state management or dependency management, it is not necessary to use GetMaterialApp. GetMaterialApp is necessary for routes, snackbars, internationalization, bottomSheets, dialogs, and high-level apis related to routes and absence of context. |
122 | -- Note²: This step in only necessary if you gonna use route management (`Get.to()`, `Get.back()` and so on). If you not gonna use it then it is not necessary to do step 1 | 122 | +- Note²: This step is only necessary if you gonna use route management (`Get.to()`, `Get.back()` and so on). If you not gonna use it then it is not necessary to do step 1 |
123 | 123 | ||
124 | - Step 2: | 124 | - Step 2: |
125 | Create your business logic class and place all variables, methods and controllers inside it. | 125 | Create your business logic class and place all variables, methods and controllers inside it. |
@@ -214,7 +214,7 @@ Obx(() => Text("${controller.name}")); | @@ -214,7 +214,7 @@ Obx(() => Text("${controller.name}")); | ||
214 | 214 | ||
215 | ### 关于状态管理的更多细节 | 215 | ### 关于状态管理的更多细节 |
216 | 216 | ||
217 | -**关于状态管理更深入的解释请查看[这里](./documentation/zh_CN/state_management.md)。在那里你将看到更多的例子,以及简单的阶段管理器和响应式状态管理器之间的区别**。 | 217 | +**关于状态管理更深入的解释请查看[这里](./documentation/zh_CN/state_management.md)。在那里你将看到更多的例子,以及简单的状态管理器和响应式状态管理器之间的区别**。 |
218 | 218 | ||
219 | 你会对GetX的能力有一个很好的了解。 | 219 | 你会对GetX的能力有一个很好的了解。 |
220 | 220 |
@@ -20,6 +20,8 @@ linter: | @@ -20,6 +20,8 @@ linter: | ||
20 | # INCLUDE_FIX (copy of effective dart 1.2.0) | 20 | # INCLUDE_FIX (copy of effective dart 1.2.0) |
21 | # STYLE | 21 | # STYLE |
22 | camel_case_types: true | 22 | camel_case_types: true |
23 | + close_sinks: true | ||
24 | + unnecessary_statements: true | ||
23 | camel_case_extensions: true | 25 | camel_case_extensions: true |
24 | library_names: true | 26 | library_names: true |
25 | file_names: true | 27 | file_names: true |
@@ -246,6 +246,28 @@ print(Get.parameters['user']); | @@ -246,6 +246,28 @@ print(Get.parameters['user']); | ||
246 | // out: 34954 | 246 | // out: 34954 |
247 | ``` | 247 | ``` |
248 | 248 | ||
249 | +or send multiple parameters like this | ||
250 | + | ||
251 | +```dart | ||
252 | +Get.toNamed("/profile/34954?flag=true&country=italy"); | ||
253 | +``` | ||
254 | +or | ||
255 | +```dart | ||
256 | +var parameters = <String, String>{"flag": "true","country": "italy",}; | ||
257 | +Get.toNamed("/profile/34954", parameters: parameters); | ||
258 | +``` | ||
259 | + | ||
260 | +On second screen take the data by parameters as usually | ||
261 | + | ||
262 | +```dart | ||
263 | +print(Get.parameters['user']); | ||
264 | +print(Get.parameters['flag']); | ||
265 | +print(Get.parameters['country']); | ||
266 | +// out: 34954 true italy | ||
267 | +``` | ||
268 | + | ||
269 | + | ||
270 | + | ||
249 | And now, all you need to do is use Get.toNamed() to navigate your named routes, without any context (you can call your routes directly from your BLoC or Controller class), and when your app is compiled to the web, your routes will appear in the url <3 | 271 | And now, all you need to do is use Get.toNamed() to navigate your named routes, without any context (you can call your routes directly from your BLoC or Controller class), and when your app is compiled to the web, your routes will appear in the url <3 |
250 | 272 | ||
251 | ### Middleware | 273 | ### Middleware |
@@ -242,7 +242,21 @@ Y en la segunda pantalla tome los datos por parámetro | @@ -242,7 +242,21 @@ Y en la segunda pantalla tome los datos por parámetro | ||
242 | 242 | ||
243 | ```dart | 243 | ```dart |
244 | print(Get.parameters['user']); | 244 | print(Get.parameters['user']); |
245 | -// out: 34954 | 245 | +// salida: 34954 |
246 | +``` | ||
247 | + | ||
248 | +o envie multiples parametros de la siguiente manera | ||
249 | + | ||
250 | +```dart | ||
251 | +Get.toNamed("/profile/34954?flag=true"); | ||
252 | +``` | ||
253 | + | ||
254 | +En la segunda pantalla tome los parametros como lo haria normalmente | ||
255 | + | ||
256 | +```dart | ||
257 | +print(Get.parameters['user']); | ||
258 | +print(Get.parameters['flag']); | ||
259 | +// salida: 34954 true | ||
246 | ``` | 260 | ``` |
247 | 261 | ||
248 | Y ahora, todo lo que necesita hacer es usar Get.toNamed() para navegar por sus rutas nombradas, sin ningún contexto (puede llamar a sus rutas directamente desde su clase BLoC o Controller), y cuando su aplicación se compila para web, sus rutas aparecerán en la url del navegador <3 | 262 | Y ahora, todo lo que necesita hacer es usar Get.toNamed() para navegar por sus rutas nombradas, sin ningún contexto (puede llamar a sus rutas directamente desde su clase BLoC o Controller), y cuando su aplicación se compila para web, sus rutas aparecerán en la url del navegador <3 |
@@ -247,6 +247,20 @@ print(Get.parameters['user']); | @@ -247,6 +247,20 @@ print(Get.parameters['user']); | ||
247 | // donne: 34954 | 247 | // donne: 34954 |
248 | ``` | 248 | ``` |
249 | 249 | ||
250 | +ou envoyer plusieurs paramètres comme celui-ci | ||
251 | + | ||
252 | +```dart | ||
253 | +Get.toNamed("/profile/34954?flag=true"); | ||
254 | +``` | ||
255 | + | ||
256 | +Sur le deuxième écran, prenez les données par paramètres comme d'habitude | ||
257 | + | ||
258 | +```dart | ||
259 | +print(Get.parameters['user']); | ||
260 | +print(Get.parameters['flag']); | ||
261 | +// donne: 34954 true | ||
262 | +``` | ||
263 | + | ||
250 | Et maintenant, tout ce que vous avez à faire est d'utiliser Get.toNamed() pour parcourir vos routes nommées, sans aucun contexte (vous pouvez appeler vos routes directement à partir de votre classe BLoC ou Controller), et lorsque votre application est compilée sur le Web, vos routes apparaîtront dans l'url <3 | 264 | Et maintenant, tout ce que vous avez à faire est d'utiliser Get.toNamed() pour parcourir vos routes nommées, sans aucun contexte (vous pouvez appeler vos routes directement à partir de votre classe BLoC ou Controller), et lorsque votre application est compilée sur le Web, vos routes apparaîtront dans l'url <3 |
251 | 265 | ||
252 | ### Middleware | 266 | ### Middleware |
@@ -248,6 +248,21 @@ print(Get.parameters['user']); | @@ -248,6 +248,21 @@ print(Get.parameters['user']); | ||
248 | // keluaran: 34954 | 248 | // keluaran: 34954 |
249 | ``` | 249 | ``` |
250 | 250 | ||
251 | +atau kirim beberapa parameter seperti ini | ||
252 | + | ||
253 | +```dart | ||
254 | +Get.toNamed("/profile/34954?flag=true"); | ||
255 | +``` | ||
256 | + | ||
257 | +Pada layar kedua, ambil data berdasarkan parameter seperti biasanya | ||
258 | + | ||
259 | +```dart | ||
260 | +print(Get.parameters['user']); | ||
261 | +print(Get.parameters['flag']); | ||
262 | +// keluaran: 34954 true | ||
263 | +``` | ||
264 | + | ||
265 | + | ||
251 | Dan sekarang, yang anda perlu lakukan adalah menggunakan Get.toNamed() untuk bernavigasi ke named route anda, tanpa konteks (anda bisa memanggil route secara langsung dari kelas BLoC atau Controller), dan ketika aplikasi anda di-compile di web, route anda akan muncul di url <3 | 266 | Dan sekarang, yang anda perlu lakukan adalah menggunakan Get.toNamed() untuk bernavigasi ke named route anda, tanpa konteks (anda bisa memanggil route secara langsung dari kelas BLoC atau Controller), dan ketika aplikasi anda di-compile di web, route anda akan muncul di url <3 |
252 | 267 | ||
253 | ### Middleware | 268 | ### Middleware |
@@ -246,6 +246,23 @@ print(Get.parameters['user']); | @@ -246,6 +246,23 @@ print(Get.parameters['user']); | ||
246 | // 출력: 34954 | 246 | // 출력: 34954 |
247 | ``` | 247 | ``` |
248 | 248 | ||
249 | + | ||
250 | +또는 이와 같은 여러 매개 변수를 보냅니다. | ||
251 | + | ||
252 | +```dart | ||
253 | +Get.toNamed("/profile/34954?flag=true"); | ||
254 | +``` | ||
255 | + | ||
256 | +두 번째 화면에서 일반적으로 매개 변수별로 데이터를 가져옵니다. | ||
257 | + | ||
258 | +```dart | ||
259 | +print(Get.parameters['user']); | ||
260 | +print(Get.parameters['flag']); | ||
261 | +// 출력: 34954 true | ||
262 | +``` | ||
263 | + | ||
264 | + | ||
265 | + | ||
249 | 이제 Get.toNamed()를 사용하여 어떤 context도 없이 명명된 라우트를 탐색하고 (BLoC 또는 Controller 클래스로 부터 직접 라우트를 호출할 수 있음) 앱이 웹으로 컴파일되면 경로는 url에 표시됩니다. <3 | 266 | 이제 Get.toNamed()를 사용하여 어떤 context도 없이 명명된 라우트를 탐색하고 (BLoC 또는 Controller 클래스로 부터 직접 라우트를 호출할 수 있음) 앱이 웹으로 컴파일되면 경로는 url에 표시됩니다. <3 |
250 | 267 | ||
251 | ### 미들웨어 | 268 | ### 미들웨어 |
@@ -322,9 +322,26 @@ Get.toNamed("/segunda/34954"); | @@ -322,9 +322,26 @@ Get.toNamed("/segunda/34954"); | ||
322 | Na segunda tela receba os dados usando `Get.parameters[]` | 322 | Na segunda tela receba os dados usando `Get.parameters[]` |
323 | 323 | ||
324 | ```dart | 324 | ```dart |
325 | -print(Get.parameters['user']); // valor: 34954 | 325 | +print(Get.parameters['user']); |
326 | +// valor: 34954 | ||
326 | ``` | 327 | ``` |
327 | 328 | ||
329 | + | ||
330 | +ou envie vários parâmetros como este | ||
331 | + | ||
332 | +```dart | ||
333 | +Get.toNamed("/profile/34954?flag=true"); | ||
334 | +``` | ||
335 | + | ||
336 | +Na segunda tela, pegue os dados por parâmetros normalmente | ||
337 | +```dart | ||
338 | +print(Get.parameters['user']); | ||
339 | +print(Get.parameters['flag']); | ||
340 | +// valor: 34954 true | ||
341 | +``` | ||
342 | + | ||
343 | + | ||
344 | + | ||
328 | E agora, tudo que você precisa fazer é usar `Get.toNamed)` para navegar por suas rotas nomeadas, sem nenhum `context` (você pode chamar suas rotas diretamente do seu BLoc ou do Controller), e quando seu aplicativo é compilado para a web, suas rotas vão aparecer na url ❤ | 345 | E agora, tudo que você precisa fazer é usar `Get.toNamed)` para navegar por suas rotas nomeadas, sem nenhum `context` (você pode chamar suas rotas diretamente do seu BLoc ou do Controller), e quando seu aplicativo é compilado para a web, suas rotas vão aparecer na url ❤ |
329 | 346 | ||
330 | #### Middleware | 347 | #### Middleware |
@@ -246,6 +246,22 @@ print(Get.parameters['user']); | @@ -246,6 +246,22 @@ print(Get.parameters['user']); | ||
246 | // out: 34954 | 246 | // out: 34954 |
247 | ``` | 247 | ``` |
248 | 248 | ||
249 | +или отправьте несколько таких параметров | ||
250 | + | ||
251 | +```dart | ||
252 | +Get.toNamed("/profile/34954?flag=true"); | ||
253 | +``` | ||
254 | + | ||
255 | +На втором экране взять данные по параметрам как обычно. | ||
256 | + | ||
257 | +```dart | ||
258 | +print(Get.parameters['user']); | ||
259 | +print(Get.parameters['flag']); | ||
260 | +// out: 34954 true | ||
261 | +``` | ||
262 | + | ||
263 | + | ||
264 | + | ||
249 | И теперь все, что вам нужно сделать, это использовать Get.toNamed() для навигации по именованным маршрутам без какого-либо контекста (вы можете вызывать свои маршруты непосредственно из класса BLoC или контроллера), а когда ваше приложение будет скомпилировано в Интернете, ваше маршруты появятся в url <3 | 265 | И теперь все, что вам нужно сделать, это использовать Get.toNamed() для навигации по именованным маршрутам без какого-либо контекста (вы можете вызывать свои маршруты непосредственно из класса BLoC или контроллера), а когда ваше приложение будет скомпилировано в Интернете, ваше маршруты появятся в url <3 |
250 | 266 | ||
251 | ### Middleware | 267 | ### Middleware |
@@ -243,6 +243,21 @@ print(Get.parameters['user']); | @@ -243,6 +243,21 @@ print(Get.parameters['user']); | ||
243 | // out: 34954 | 243 | // out: 34954 |
244 | ``` | 244 | ``` |
245 | 245 | ||
246 | +或像这样发送多个参数 | ||
247 | + | ||
248 | +```dart | ||
249 | +Get.toNamed("/profile/34954?flag=true"); | ||
250 | +``` | ||
251 | + | ||
252 | +在第二个屏幕上,通常按参数获取数据 | ||
253 | + | ||
254 | +```dart | ||
255 | +print(Get.parameters['user']); | ||
256 | +print(Get.parameters['flag']); | ||
257 | +// out: 34954 true | ||
258 | +``` | ||
259 | + | ||
260 | + | ||
246 | 现在,你需要做的就是使用Get.toNamed()来导航你的别名路由,不需要任何context(你可以直接从你的BLoC或Controller类中调用你的路由),当你的应用程序被编译到web时,你的路由将出现在URL中。 | 261 | 现在,你需要做的就是使用Get.toNamed()来导航你的别名路由,不需要任何context(你可以直接从你的BLoC或Controller类中调用你的路由),当你的应用程序被编译到web时,你的路由将出现在URL中。 |
247 | 262 | ||
248 | ### 中间件 | 263 | ### 中间件 |
@@ -343,25 +343,24 @@ ListView.builder ( | @@ -343,25 +343,24 @@ ListView.builder ( | ||
343 | ```dart | 343 | ```dart |
344 | // model | 344 | // model |
345 | // 我们将使整个类成为可观察的,而不是每个属性。 | 345 | // 我们将使整个类成为可观察的,而不是每个属性。 |
346 | -class User() { | ||
347 | - User({this.name = '', this.age = 0}); | ||
348 | - String name; | ||
349 | - int age; | 346 | +class User{ |
347 | + User({this.name = '', this.age = 0}); | ||
348 | + String name; | ||
349 | + int age; | ||
350 | } | 350 | } |
351 | 351 | ||
352 | - | ||
353 | // controller | 352 | // controller |
354 | final user = User().obs; | 353 | final user = User().obs; |
355 | //当你需要更新user变量时。 | 354 | //当你需要更新user变量时。 |
356 | user.update( (user) { // 这个参数是你要更新的类本身。 | 355 | user.update( (user) { // 这个参数是你要更新的类本身。 |
357 | -user.name = 'Jonny'; | ||
358 | -user.age = 18; | 356 | + user.name = 'Jonny'; |
357 | + user.age = 18; | ||
359 | }); | 358 | }); |
360 | // 更新user变量的另一种方式。 | 359 | // 更新user变量的另一种方式。 |
361 | user(User(name: 'João', age: 35)); | 360 | user(User(name: 'João', age: 35)); |
362 | 361 | ||
363 | // view | 362 | // view |
364 | -Obx(()=> Text("Name ${user.value.name}: Age: ${user.value.age}")) | 363 | +Obx(()=> Text("Name ${user.value.name}: Age: ${user.value.age}")); |
365 | // 你也可以不使用.value来访问模型值。 | 364 | // 你也可以不使用.value来访问模型值。 |
366 | user().name; // 注意是user变量,而不是类变量(首字母是小写的)。 | 365 | user().name; // 注意是user变量,而不是类变量(首字母是小写的)。 |
367 | ``` | 366 | ``` |
@@ -410,7 +409,7 @@ interval(count1, (_) => print("interval $_"), time: Duration(seconds: 1)); | @@ -410,7 +409,7 @@ interval(count1, (_) => print("interval $_"), time: Duration(seconds: 1)); | ||
410 | 这个`condition`定义了`callback`函数何时执行。 | 409 | 这个`condition`定义了`callback`函数何时执行。 |
411 | 410 | ||
412 | 所有worker都会返回一个`Worker`实例,你可以用它来取消(通过`dispose()`)worker。 | 411 | 所有worker都会返回一个`Worker`实例,你可以用它来取消(通过`dispose()`)worker。 |
413 | - | 412 | + |
414 | - **`ever`** | 413 | - **`ever`** |
415 | 每当_Rx_变量发出一个新的值时,就会被调用。 | 414 | 每当_Rx_变量发出一个新的值时,就会被调用。 |
416 | 415 | ||
@@ -666,7 +665,7 @@ GetBuilder<Controller>( | @@ -666,7 +665,7 @@ GetBuilder<Controller>( | ||
666 | 665 | ||
667 | ```dart | 666 | ```dart |
668 | GetBuilder<Controller>( | 667 | GetBuilder<Controller>( |
669 | - id: 'text' 、、这里 | 668 | + id: 'text', //这里 |
670 | init: Controller(), // 每个控制器只用一次 | 669 | init: Controller(), // 每个控制器只用一次 |
671 | builder: (_) => Text( | 670 | builder: (_) => Text( |
672 | '${Get.find<Controller>().counter}', //here | 671 | '${Get.find<Controller>().counter}', //here |
@@ -282,6 +282,7 @@ As the view has only widgets, you can use a view for android, and another for iO | @@ -282,6 +282,7 @@ As the view has only widgets, you can use a view for android, and another for iO | ||
282 | However, some examples like internationalization, Snackbars without context, validators, responsiveness and other Getx resources, were not explored (and it would not even be possible to explore all resources in such a simple example), so below is an example not very complete, but trying demonstrate how to use internationalization, reactive custom classes, reactive lists, snackbars contextless, workers etc. | 282 | However, some examples like internationalization, Snackbars without context, validators, responsiveness and other Getx resources, were not explored (and it would not even be possible to explore all resources in such a simple example), so below is an example not very complete, but trying demonstrate how to use internationalization, reactive custom classes, reactive lists, snackbars contextless, workers etc. |
283 | 283 | ||
284 | ```dart | 284 | ```dart |
285 | +import 'dart:ui'; | ||
285 | import 'package:flutter/material.dart'; | 286 | import 'package:flutter/material.dart'; |
286 | import 'package:get/get.dart'; | 287 | import 'package:get/get.dart'; |
287 | 288 | ||
@@ -397,29 +398,27 @@ class Second extends GetView<ControllerX> { | @@ -397,29 +398,27 @@ class Second extends GetView<ControllerX> { | ||
397 | child: Column( | 398 | child: Column( |
398 | mainAxisAlignment: MainAxisAlignment.center, | 399 | mainAxisAlignment: MainAxisAlignment.center, |
399 | children: [ | 400 | children: [ |
400 | - GetX<ControllerX>( | ||
401 | - // Using bindings you don't need of init: method | ||
402 | - // Using Getx you can take controller instance of "builder: (_)" | ||
403 | - builder: (_) { | 401 | + Obx( |
402 | + () { | ||
404 | print("count1 rebuild"); | 403 | print("count1 rebuild"); |
405 | - return Text('${_.count1}'); | 404 | + return Text('${controller.count1}'); |
406 | }, | 405 | }, |
407 | ), | 406 | ), |
408 | - GetX<ControllerX>( | ||
409 | - builder: (_) { | 407 | + Obx( |
408 | + () { | ||
410 | print("count2 rebuild"); | 409 | print("count2 rebuild"); |
411 | return Text('${controller.count2}'); | 410 | return Text('${controller.count2}'); |
412 | }, | 411 | }, |
413 | ), | 412 | ), |
414 | - GetX<ControllerX>(builder: (_) { | 413 | + Obx(() { |
415 | print("sum rebuild"); | 414 | print("sum rebuild"); |
416 | - return Text('${_.sum}'); | 415 | + return Text('${controller.sum}'); |
417 | }), | 416 | }), |
418 | - GetX<ControllerX>( | ||
419 | - builder: (_) => Text('Name: ${controller.user.value.name}'), | 417 | + Obx( |
418 | + () => Text('Name: ${controller.user.value?.name}'), | ||
420 | ), | 419 | ), |
421 | - GetX<ControllerX>( | ||
422 | - builder: (_) => Text('Age: ${_.user.value.age}'), | 420 | + Obx( |
421 | + () => Text('Age: ${controller.user.value?.age}'), | ||
423 | ), | 422 | ), |
424 | ElevatedButton( | 423 | ElevatedButton( |
425 | child: Text("Go to last page"), | 424 | child: Text("Go to last page"), |
@@ -440,25 +439,25 @@ class Second extends GetView<ControllerX> { | @@ -440,25 +439,25 @@ class Second extends GetView<ControllerX> { | ||
440 | ElevatedButton( | 439 | ElevatedButton( |
441 | child: Text("Increment"), | 440 | child: Text("Increment"), |
442 | onPressed: () { | 441 | onPressed: () { |
443 | - Get.find<ControllerX>().increment(); | 442 | + controller.increment(); |
444 | }, | 443 | }, |
445 | ), | 444 | ), |
446 | ElevatedButton( | 445 | ElevatedButton( |
447 | child: Text("Increment"), | 446 | child: Text("Increment"), |
448 | onPressed: () { | 447 | onPressed: () { |
449 | - Get.find<ControllerX>().increment2(); | 448 | + controller.increment2(); |
450 | }, | 449 | }, |
451 | ), | 450 | ), |
452 | ElevatedButton( | 451 | ElevatedButton( |
453 | child: Text("Update name"), | 452 | child: Text("Update name"), |
454 | onPressed: () { | 453 | onPressed: () { |
455 | - Get.find<ControllerX>().updateUser(); | 454 | + controller.updateUser(); |
456 | }, | 455 | }, |
457 | ), | 456 | ), |
458 | ElevatedButton( | 457 | ElevatedButton( |
459 | child: Text("Dispose worker"), | 458 | child: Text("Dispose worker"), |
460 | onPressed: () { | 459 | onPressed: () { |
461 | - Get.find<ControllerX>().disposeWorker(); | 460 | + controller.disposeWorker(); |
462 | }, | 461 | }, |
463 | ), | 462 | ), |
464 | ], | 463 | ], |
@@ -509,7 +508,7 @@ class ControllerX extends GetxController { | @@ -509,7 +508,7 @@ class ControllerX extends GetxController { | ||
509 | 508 | ||
510 | updateUser() { | 509 | updateUser() { |
511 | user.update((value) { | 510 | user.update((value) { |
512 | - value.name = 'Jose'; | 511 | + value!.name = 'Jose'; |
513 | value.age = 30; | 512 | value.age = 30; |
514 | }); | 513 | }); |
515 | } | 514 | } |
@@ -523,7 +522,7 @@ class ControllerX extends GetxController { | @@ -523,7 +522,7 @@ class ControllerX extends GetxController { | ||
523 | /// Here is an outline of how you can use them: | 522 | /// Here is an outline of how you can use them: |
524 | 523 | ||
525 | /// made this if you need cancel you worker | 524 | /// made this if you need cancel you worker |
526 | - Worker _ever; | 525 | + late Worker _ever; |
527 | 526 | ||
528 | @override | 527 | @override |
529 | onInit() { | 528 | onInit() { |
@@ -562,8 +561,8 @@ class SizeTransitions extends CustomTransition { | @@ -562,8 +561,8 @@ class SizeTransitions extends CustomTransition { | ||
562 | @override | 561 | @override |
563 | Widget buildTransition( | 562 | Widget buildTransition( |
564 | BuildContext context, | 563 | BuildContext context, |
565 | - Curve curve, | ||
566 | - Alignment alignment, | 564 | + Curve? curve, |
565 | + Alignment? alignment, | ||
567 | Animation<double> animation, | 566 | Animation<double> animation, |
568 | Animation<double> secondaryAnimation, | 567 | Animation<double> secondaryAnimation, |
569 | Widget child) { | 568 | Widget child) { |
@@ -572,7 +571,7 @@ class SizeTransitions extends CustomTransition { | @@ -572,7 +571,7 @@ class SizeTransitions extends CustomTransition { | ||
572 | child: SizeTransition( | 571 | child: SizeTransition( |
573 | sizeFactor: CurvedAnimation( | 572 | sizeFactor: CurvedAnimation( |
574 | parent: animation, | 573 | parent: animation, |
575 | - curve: curve, | 574 | + curve: curve!, |
576 | ), | 575 | ), |
577 | child: child, | 576 | child: child, |
578 | ), | 577 | ), |
1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
2 | import 'package:get/get.dart'; | 2 | import 'package:get/get.dart'; |
3 | 3 | ||
4 | -import 'en_US.dart'; | ||
5 | -import 'pt_BR.dart'; | 4 | +import 'en_us.dart'; |
5 | +import 'pt_br.dart'; | ||
6 | 6 | ||
7 | class TranslationService extends Translations { | 7 | class TranslationService extends Translations { |
8 | - static final locale = Get.deviceLocale; | 8 | + static Locale get locale => Get.deviceLocale; |
9 | static final fallbackLocale = Locale('en', 'US'); | 9 | static final fallbackLocale = Locale('en', 'US'); |
10 | - @override | 10 | + @override |
11 | Map<String, Map<String, String>> get keys => { | 11 | Map<String, Map<String, String>> get keys => { |
12 | - 'en_US': en_US, | ||
13 | - 'pt_BR': pt_BR, | ||
14 | - }; | ||
15 | -} | ||
12 | + 'en_US': en_US, | ||
13 | + 'pt_BR': pt_BR, | ||
14 | + }; | ||
15 | +} |
@@ -9,7 +9,7 @@ void main() { | @@ -9,7 +9,7 @@ void main() { | ||
9 | } | 9 | } |
10 | 10 | ||
11 | class MyApp extends StatelessWidget { | 11 | class MyApp extends StatelessWidget { |
12 | - const MyApp({Key key}) : super(key: key); | 12 | + const MyApp({Key? key}) : super(key: key); |
13 | 13 | ||
14 | @override | 14 | @override |
15 | Widget build(BuildContext context) { | 15 | Widget build(BuildContext context) { |
@@ -9,7 +9,8 @@ abstract class IHomeProvider { | @@ -9,7 +9,8 @@ abstract class IHomeProvider { | ||
9 | class HomeProvider extends GetConnect implements IHomeProvider { | 9 | class HomeProvider extends GetConnect implements IHomeProvider { |
10 | @override | 10 | @override |
11 | void onInit() { | 11 | void onInit() { |
12 | - httpClient.defaultDecoder = CasesModel.fromJson; | 12 | + httpClient.defaultDecoder = |
13 | + (val) => CasesModel.fromJson(val as Map<String, dynamic>); | ||
13 | httpClient.baseUrl = 'https://api.covid19api.com'; | 14 | httpClient.baseUrl = 'https://api.covid19api.com'; |
14 | } | 15 | } |
15 | 16 |
@@ -3,16 +3,16 @@ import '../domain/entity/cases_model.dart'; | @@ -3,16 +3,16 @@ import '../domain/entity/cases_model.dart'; | ||
3 | import 'home_api_provider.dart'; | 3 | import 'home_api_provider.dart'; |
4 | 4 | ||
5 | class HomeRepository implements IHomeRepository { | 5 | class HomeRepository implements IHomeRepository { |
6 | - HomeRepository({this.provider}); | 6 | + HomeRepository({required this.provider}); |
7 | final IHomeProvider provider; | 7 | final IHomeProvider provider; |
8 | 8 | ||
9 | @override | 9 | @override |
10 | Future<CasesModel> getCases() async { | 10 | Future<CasesModel> getCases() async { |
11 | final cases = await provider.getCases("/summary"); | 11 | final cases = await provider.getCases("/summary"); |
12 | if (cases.status.hasError) { | 12 | if (cases.status.hasError) { |
13 | - return Future.error(cases.statusText); | 13 | + return Future.error(cases.statusText!); |
14 | } else { | 14 | } else { |
15 | - return cases.body; | 15 | + return cases.body!; |
16 | } | 16 | } |
17 | } | 17 | } |
18 | } | 18 | } |
1 | // To parse this JSON data, do | 1 | // To parse this JSON data, do |
2 | // | 2 | // |
3 | -// final CasesModel = CasesModelFromJson(jsonString); | 3 | +// final welcome = welcomeFromJson(jsonString); |
4 | 4 | ||
5 | import 'dart:convert'; | 5 | import 'dart:convert'; |
6 | 6 | ||
7 | class CasesModel { | 7 | class CasesModel { |
8 | - final Global global; | ||
9 | - final List<Country> countries; | ||
10 | - final String date; | ||
11 | - | ||
12 | CasesModel({ | 8 | CasesModel({ |
13 | - this.global, | ||
14 | - this.countries, | ||
15 | - this.date, | 9 | + required this.id, |
10 | + required this.message, | ||
11 | + required this.global, | ||
12 | + required this.countries, | ||
13 | + required this.date, | ||
16 | }); | 14 | }); |
17 | 15 | ||
18 | - static CasesModel fromRawJson(String str) => | 16 | + final String id; |
17 | + final String message; | ||
18 | + final Global global; | ||
19 | + final List<Country> countries; | ||
20 | + final DateTime date; | ||
21 | + | ||
22 | + factory CasesModel.fromRawJson(String str) => | ||
19 | CasesModel.fromJson(json.decode(str) as Map<String, dynamic>); | 23 | CasesModel.fromJson(json.decode(str) as Map<String, dynamic>); |
20 | 24 | ||
21 | String toRawJson() => json.encode(toJson()); | 25 | String toRawJson() => json.encode(toJson()); |
22 | 26 | ||
23 | - static CasesModel fromJson(dynamic json) => CasesModel( | ||
24 | - global: json["Global"] == null | ||
25 | - ? null | ||
26 | - : Global.fromJson(json["Global"] as Map<String, dynamic>), | ||
27 | - countries: json["Countries"] == null | ||
28 | - ? null | ||
29 | - : List<Country>.from( | ||
30 | - (json["Countries"] as List<dynamic>) | ||
31 | - .map((x) => Country.fromJson(x as Map<String, dynamic>)), | ||
32 | - ), | ||
33 | - date: json["Date"] == null ? null : json["Date"] as String, | 27 | + factory CasesModel.fromJson(Map<String, dynamic> json) => CasesModel( |
28 | + id: json["ID"] as String, | ||
29 | + message: json["Message"] as String, | ||
30 | + global: Global.fromJson(json["Global"] as Map<String, dynamic>), | ||
31 | + countries: List<Country>.from((json["Countries"] as Iterable).map( | ||
32 | + (x) => Country.fromJson(x as Map<String, dynamic>), | ||
33 | + )), | ||
34 | + date: DateTime.parse(json["Date"] as String), | ||
34 | ); | 35 | ); |
35 | 36 | ||
36 | Map<String, dynamic> toJson() => { | 37 | Map<String, dynamic> toJson() => { |
37 | - "Global": global == null ? null : global.toJson(), | ||
38 | - "Countries": countries == null | ||
39 | - ? null | ||
40 | - : List<dynamic>.from(countries.map((x) => x.toJson())), | ||
41 | - "Date": date == null ? null : date, | 38 | + "ID": id, |
39 | + "Message": message, | ||
40 | + "Global": global.toJson(), | ||
41 | + "Countries": List<dynamic>.from(countries.map((x) => x.toJson())), | ||
42 | + "Date": date.toIso8601String(), | ||
42 | }; | 43 | }; |
43 | } | 44 | } |
44 | 45 | ||
45 | class Country { | 46 | class Country { |
47 | + Country({ | ||
48 | + required this.id, | ||
49 | + required this.country, | ||
50 | + required this.countryCode, | ||
51 | + required this.slug, | ||
52 | + required this.newConfirmed, | ||
53 | + required this.totalConfirmed, | ||
54 | + required this.newDeaths, | ||
55 | + required this.totalDeaths, | ||
56 | + required this.newRecovered, | ||
57 | + required this.totalRecovered, | ||
58 | + required this.date, | ||
59 | + required this.premium, | ||
60 | + }); | ||
61 | + | ||
62 | + final String id; | ||
46 | final String country; | 63 | final String country; |
47 | final String countryCode; | 64 | final String countryCode; |
48 | final String slug; | 65 | final String slug; |
@@ -52,20 +69,8 @@ class Country { | @@ -52,20 +69,8 @@ class Country { | ||
52 | final int totalDeaths; | 69 | final int totalDeaths; |
53 | final int newRecovered; | 70 | final int newRecovered; |
54 | final int totalRecovered; | 71 | final int totalRecovered; |
55 | - final String date; | ||
56 | - | ||
57 | - Country({ | ||
58 | - this.country, | ||
59 | - this.countryCode, | ||
60 | - this.slug, | ||
61 | - this.newConfirmed, | ||
62 | - this.totalConfirmed, | ||
63 | - this.newDeaths, | ||
64 | - this.totalDeaths, | ||
65 | - this.newRecovered, | ||
66 | - this.totalRecovered, | ||
67 | - this.date, | ||
68 | - }); | 72 | + final DateTime date; |
73 | + final Premium premium; | ||
69 | 74 | ||
70 | factory Country.fromRawJson(String str) => | 75 | factory Country.fromRawJson(String str) => |
71 | Country.fromJson(json.decode(str) as Map<String, dynamic>); | 76 | Country.fromJson(json.decode(str) as Map<String, dynamic>); |
@@ -73,56 +78,67 @@ class Country { | @@ -73,56 +78,67 @@ class Country { | ||
73 | String toRawJson() => json.encode(toJson()); | 78 | String toRawJson() => json.encode(toJson()); |
74 | 79 | ||
75 | factory Country.fromJson(Map<String, dynamic> json) => Country( | 80 | factory Country.fromJson(Map<String, dynamic> json) => Country( |
76 | - country: json["Country"] == null ? null : json["Country"] as String, | ||
77 | - countryCode: | ||
78 | - json["CountryCode"] == null ? null : json["CountryCode"] as String, | ||
79 | - slug: json["Slug"] == null ? null : json["Slug"] as String, | ||
80 | - newConfirmed: | ||
81 | - json["NewConfirmed"] == null ? null : json["NewConfirmed"] as int, | ||
82 | - totalConfirmed: json["TotalConfirmed"] == null | ||
83 | - ? null | ||
84 | - : json["TotalConfirmed"] as int, | ||
85 | - newDeaths: json["NewDeaths"] == null ? null : json["NewDeaths"] as int, | ||
86 | - totalDeaths: | ||
87 | - json["TotalDeaths"] == null ? null : json["TotalDeaths"] as int, | ||
88 | - newRecovered: | ||
89 | - json["NewRecovered"] == null ? null : json["NewRecovered"] as int, | ||
90 | - totalRecovered: json["TotalRecovered"] == null | ||
91 | - ? null | ||
92 | - : json["TotalRecovered"] as int, | ||
93 | - date: json["Date"] == null ? null : json["Date"] as String, | 81 | + id: json["ID"] as String, |
82 | + country: json["Country"] as String, | ||
83 | + countryCode: json["CountryCode"] as String, | ||
84 | + slug: json["Slug"] as String, | ||
85 | + newConfirmed: json["NewConfirmed"] as int, | ||
86 | + totalConfirmed: json["TotalConfirmed"] as int, | ||
87 | + newDeaths: json["NewDeaths"] as int, | ||
88 | + totalDeaths: json["TotalDeaths"] as int, | ||
89 | + newRecovered: json["NewRecovered"] as int, | ||
90 | + totalRecovered: json["TotalRecovered"] as int, | ||
91 | + date: DateTime.parse(json["Date"] as String), | ||
92 | + premium: Premium.fromJson(json["Premium"] as Map<String, dynamic>), | ||
94 | ); | 93 | ); |
95 | 94 | ||
96 | Map<String, dynamic> toJson() => { | 95 | Map<String, dynamic> toJson() => { |
97 | - "Country": country == null ? null : country, | ||
98 | - "CountryCode": countryCode == null ? null : countryCode, | ||
99 | - "Slug": slug == null ? null : slug, | ||
100 | - "NewConfirmed": newConfirmed == null ? null : newConfirmed, | ||
101 | - "TotalConfirmed": totalConfirmed == null ? null : totalConfirmed, | ||
102 | - "NewDeaths": newDeaths == null ? null : newDeaths, | ||
103 | - "TotalDeaths": totalDeaths == null ? null : totalDeaths, | ||
104 | - "NewRecovered": newRecovered == null ? null : newRecovered, | ||
105 | - "TotalRecovered": totalRecovered == null ? null : totalRecovered, | ||
106 | - "Date": date == null ? null : date, | 96 | + "ID": id, |
97 | + "Country": country, | ||
98 | + "CountryCode": countryCode, | ||
99 | + "Slug": slug, | ||
100 | + "NewConfirmed": newConfirmed, | ||
101 | + "TotalConfirmed": totalConfirmed, | ||
102 | + "NewDeaths": newDeaths, | ||
103 | + "TotalDeaths": totalDeaths, | ||
104 | + "NewRecovered": newRecovered, | ||
105 | + "TotalRecovered": totalRecovered, | ||
106 | + "Date": date.toIso8601String(), | ||
107 | + "Premium": premium.toJson(), | ||
107 | }; | 108 | }; |
108 | } | 109 | } |
109 | 110 | ||
111 | +class Premium { | ||
112 | + Premium(); | ||
113 | + | ||
114 | + factory Premium.fromRawJson(String str) => | ||
115 | + Premium.fromJson(json.decode(str) as Map<String, dynamic>); | ||
116 | + | ||
117 | + String toRawJson() => json.encode(toJson()); | ||
118 | + | ||
119 | + factory Premium.fromJson(Map<String, dynamic> json) => Premium(); | ||
120 | + | ||
121 | + Map<String, dynamic> toJson() => {}; | ||
122 | +} | ||
123 | + | ||
110 | class Global { | 124 | class Global { |
125 | + Global({ | ||
126 | + required this.newConfirmed, | ||
127 | + required this.totalConfirmed, | ||
128 | + required this.newDeaths, | ||
129 | + required this.totalDeaths, | ||
130 | + required this.newRecovered, | ||
131 | + required this.totalRecovered, | ||
132 | + required this.date, | ||
133 | + }); | ||
134 | + | ||
111 | final int newConfirmed; | 135 | final int newConfirmed; |
112 | final int totalConfirmed; | 136 | final int totalConfirmed; |
113 | final int newDeaths; | 137 | final int newDeaths; |
114 | final int totalDeaths; | 138 | final int totalDeaths; |
115 | final int newRecovered; | 139 | final int newRecovered; |
116 | final int totalRecovered; | 140 | final int totalRecovered; |
117 | - | ||
118 | - Global({ | ||
119 | - this.newConfirmed, | ||
120 | - this.totalConfirmed, | ||
121 | - this.newDeaths, | ||
122 | - this.totalDeaths, | ||
123 | - this.newRecovered, | ||
124 | - this.totalRecovered, | ||
125 | - }); | 141 | + final DateTime date; |
126 | 142 | ||
127 | factory Global.fromRawJson(String str) => | 143 | factory Global.fromRawJson(String str) => |
128 | Global.fromJson(json.decode(str) as Map<String, dynamic>); | 144 | Global.fromJson(json.decode(str) as Map<String, dynamic>); |
@@ -130,27 +146,22 @@ class Global { | @@ -130,27 +146,22 @@ class Global { | ||
130 | String toRawJson() => json.encode(toJson()); | 146 | String toRawJson() => json.encode(toJson()); |
131 | 147 | ||
132 | factory Global.fromJson(Map<String, dynamic> json) => Global( | 148 | factory Global.fromJson(Map<String, dynamic> json) => Global( |
133 | - newConfirmed: | ||
134 | - json["NewConfirmed"] == null ? null : json["NewConfirmed"] as int, | ||
135 | - totalConfirmed: json["TotalConfirmed"] == null | ||
136 | - ? null | ||
137 | - : json["TotalConfirmed"] as int, | ||
138 | - newDeaths: json["NewDeaths"] == null ? null : json["NewDeaths"] as int, | ||
139 | - totalDeaths: | ||
140 | - json["TotalDeaths"] == null ? null : json["TotalDeaths"] as int, | ||
141 | - newRecovered: | ||
142 | - json["NewRecovered"] == null ? null : json["NewRecovered"] as int, | ||
143 | - totalRecovered: json["TotalRecovered"] == null | ||
144 | - ? null | ||
145 | - : json["TotalRecovered"] as int, | 149 | + newConfirmed: json["NewConfirmed"] as int, |
150 | + totalConfirmed: json["TotalConfirmed"] as int, | ||
151 | + newDeaths: json["NewDeaths"] as int, | ||
152 | + totalDeaths: json["TotalDeaths"] as int, | ||
153 | + newRecovered: json["NewRecovered"] as int, | ||
154 | + totalRecovered: json["TotalRecovered"] as int, | ||
155 | + date: DateTime.parse(json["Date"] as String), | ||
146 | ); | 156 | ); |
147 | 157 | ||
148 | Map<String, dynamic> toJson() => { | 158 | Map<String, dynamic> toJson() => { |
149 | - "NewConfirmed": newConfirmed == null ? null : newConfirmed, | ||
150 | - "TotalConfirmed": totalConfirmed == null ? null : totalConfirmed, | ||
151 | - "NewDeaths": newDeaths == null ? null : newDeaths, | ||
152 | - "TotalDeaths": totalDeaths == null ? null : totalDeaths, | ||
153 | - "NewRecovered": newRecovered == null ? null : newRecovered, | ||
154 | - "TotalRecovered": totalRecovered == null ? null : totalRecovered, | 159 | + "NewConfirmed": newConfirmed, |
160 | + "TotalConfirmed": totalConfirmed, | ||
161 | + "NewDeaths": newDeaths, | ||
162 | + "TotalDeaths": totalDeaths, | ||
163 | + "NewRecovered": newRecovered, | ||
164 | + "TotalRecovered": totalRecovered, | ||
165 | + "Date": date.toIso8601String(), | ||
155 | }; | 166 | }; |
156 | } | 167 | } |
@@ -4,22 +4,16 @@ import '../../domain/adapters/repository_adapter.dart'; | @@ -4,22 +4,16 @@ import '../../domain/adapters/repository_adapter.dart'; | ||
4 | import '../../domain/entity/cases_model.dart'; | 4 | import '../../domain/entity/cases_model.dart'; |
5 | 5 | ||
6 | class HomeController extends SuperController<CasesModel> { | 6 | class HomeController extends SuperController<CasesModel> { |
7 | - HomeController({this.homeRepository}); | 7 | + HomeController({required this.homeRepository}); |
8 | 8 | ||
9 | - /// inject repo abstraction dependency | ||
10 | final IHomeRepository homeRepository; | 9 | final IHomeRepository homeRepository; |
11 | 10 | ||
12 | - /// When the controller is initialized, make the http request | ||
13 | @override | 11 | @override |
14 | void onInit() { | 12 | void onInit() { |
15 | super.onInit(); | 13 | super.onInit(); |
16 | - // show loading on start, data on success | ||
17 | - // and error message on error with 0 boilerplate | ||
18 | - homeRepository.getCases().then((data) { | ||
19 | - change(data, status: RxStatus.success()); | ||
20 | - }, onError: (err) { | ||
21 | - change(null, status: RxStatus.error(err.toString())); | ||
22 | - }); | 14 | + |
15 | + //Loading, Success, Error handle with 1 line of code | ||
16 | + append(() => homeRepository.getCases); | ||
23 | } | 17 | } |
24 | 18 | ||
25 | @override | 19 | @override |
@@ -18,7 +18,6 @@ class CountryView extends GetView<HomeController> { | @@ -18,7 +18,6 @@ class CountryView extends GetView<HomeController> { | ||
18 | child: BackdropFilter( | 18 | child: BackdropFilter( |
19 | filter: ImageFilter.blur(sigmaX: 15.0, sigmaY: 15.0), | 19 | filter: ImageFilter.blur(sigmaX: 15.0, sigmaY: 15.0), |
20 | child: Container( | 20 | child: Container( |
21 | - decoration: BoxDecoration(color: Colors.white.withOpacity(0.0)), | ||
22 | child: Scaffold( | 21 | child: Scaffold( |
23 | backgroundColor: Colors.transparent, | 22 | backgroundColor: Colors.transparent, |
24 | appBar: AppBar( | 23 | appBar: AppBar( |
@@ -29,9 +28,9 @@ class CountryView extends GetView<HomeController> { | @@ -29,9 +28,9 @@ class CountryView extends GetView<HomeController> { | ||
29 | ), | 28 | ), |
30 | body: Center( | 29 | body: Center( |
31 | child: ListView.builder( | 30 | child: ListView.builder( |
32 | - itemCount: controller.state.countries.length, | 31 | + itemCount: controller.state!.countries.length, |
33 | itemBuilder: (context, index) { | 32 | itemBuilder: (context, index) { |
34 | - final country = controller.state.countries[index]; | 33 | + final country = controller.state!.countries[index]; |
35 | return ListTile( | 34 | return ListTile( |
36 | onTap: () { | 35 | onTap: () { |
37 | Get.toNamed('/home/country/details', | 36 | Get.toNamed('/home/country/details', |
@@ -21,7 +21,6 @@ class DetailsView extends StatelessWidget { | @@ -21,7 +21,6 @@ class DetailsView extends StatelessWidget { | ||
21 | child: BackdropFilter( | 21 | child: BackdropFilter( |
22 | filter: ImageFilter.blur(sigmaX: 15.0, sigmaY: 15.0), | 22 | filter: ImageFilter.blur(sigmaX: 15.0, sigmaY: 15.0), |
23 | child: Container( | 23 | child: Container( |
24 | - decoration: BoxDecoration(color: Colors.white.withOpacity(0.0)), | ||
25 | child: Scaffold( | 24 | child: Scaffold( |
26 | backgroundColor: Colors.transparent, | 25 | backgroundColor: Colors.transparent, |
27 | appBar: AppBar( | 26 | appBar: AppBar( |
@@ -42,7 +42,7 @@ class HomeView extends GetView<HomeController> { | @@ -42,7 +42,7 @@ class HomeView extends GetView<HomeController> { | ||
42 | ), | 42 | ), |
43 | ), | 43 | ), |
44 | Text( | 44 | Text( |
45 | - '${state.global.totalConfirmed}', | 45 | + '${state!.global.totalConfirmed}', |
46 | style: TextStyle(fontSize: 45, fontWeight: FontWeight.bold), | 46 | style: TextStyle(fontSize: 45, fontWeight: FontWeight.bold), |
47 | ), | 47 | ), |
48 | SizedBox( | 48 | SizedBox( |
@@ -18,7 +18,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev | @@ -18,7 +18,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev | ||
18 | version: 1.0.0+1 | 18 | version: 1.0.0+1 |
19 | 19 | ||
20 | environment: | 20 | environment: |
21 | - sdk: ">=2.7.0 <3.0.0" | 21 | + sdk: ">=2.12.0 <3.0.0" |
22 | 22 | ||
23 | dependencies: | 23 | dependencies: |
24 | flutter: | 24 | flutter: |
@@ -28,7 +28,7 @@ dependencies: | @@ -28,7 +28,7 @@ dependencies: | ||
28 | # Use with the CupertinoIcons class for iOS style icons. | 28 | # Use with the CupertinoIcons class for iOS style icons. |
29 | get: | 29 | get: |
30 | path: ../ | 30 | path: ../ |
31 | - get_test: ^3.13.3 | 31 | + #get_test: ^3.13.3 |
32 | 32 | ||
33 | dependency_overrides: | 33 | dependency_overrides: |
34 | get: | 34 | get: |
@@ -6,8 +6,8 @@ import 'package:get/get.dart'; | @@ -6,8 +6,8 @@ import 'package:get/get.dart'; | ||
6 | import 'package:get_demo/pages/home/domain/adapters/repository_adapter.dart'; | 6 | import 'package:get_demo/pages/home/domain/adapters/repository_adapter.dart'; |
7 | import 'package:get_demo/pages/home/domain/entity/cases_model.dart'; | 7 | import 'package:get_demo/pages/home/domain/entity/cases_model.dart'; |
8 | import 'package:get_demo/pages/home/presentation/controllers/home_controller.dart'; | 8 | import 'package:get_demo/pages/home/presentation/controllers/home_controller.dart'; |
9 | -import 'package:get_demo/routes/app_pages.dart'; | ||
10 | -import 'package:get_test/get_test.dart'; | 9 | +// import 'package:get_demo/routes/app_pages.dart'; |
10 | +// import 'package:get_test/get_test.dart'; | ||
11 | import 'package:matcher/matcher.dart' as m; | 11 | import 'package:matcher/matcher.dart' as m; |
12 | 12 | ||
13 | class MockRepository implements IHomeRepository { | 13 | class MockRepository implements IHomeRepository { |
@@ -17,7 +17,18 @@ class MockRepository implements IHomeRepository { | @@ -17,7 +17,18 @@ class MockRepository implements IHomeRepository { | ||
17 | 17 | ||
18 | if (Random().nextBool()) { | 18 | if (Random().nextBool()) { |
19 | return CasesModel( | 19 | return CasesModel( |
20 | - global: Global(totalDeaths: 100, totalConfirmed: 200), | 20 | + global: Global( |
21 | + totalDeaths: 100, | ||
22 | + totalConfirmed: 200, | ||
23 | + date: DateTime.now(), | ||
24 | + newConfirmed: 0, | ||
25 | + newDeaths: 0, | ||
26 | + newRecovered: 0, | ||
27 | + totalRecovered: 0), | ||
28 | + countries: [], | ||
29 | + date: DateTime.now(), | ||
30 | + id: '', | ||
31 | + message: '', | ||
21 | ); | 32 | ); |
22 | } | 33 | } |
23 | 34 | ||
@@ -26,6 +37,7 @@ class MockRepository implements IHomeRepository { | @@ -26,6 +37,7 @@ class MockRepository implements IHomeRepository { | ||
26 | } | 37 | } |
27 | 38 | ||
28 | void main() { | 39 | void main() { |
40 | + WidgetsFlutterBinding.ensureInitialized(); | ||
29 | setUpAll(() => HttpOverrides.global = null); | 41 | setUpAll(() => HttpOverrides.global = null); |
30 | final binding = BindingsBuilder(() { | 42 | final binding = BindingsBuilder(() { |
31 | Get.lazyPut<IHomeRepository>(() => MockRepository()); | 43 | Get.lazyPut<IHomeRepository>(() => MockRepository()); |
@@ -69,13 +81,25 @@ void main() { | @@ -69,13 +81,25 @@ void main() { | ||
69 | } | 81 | } |
70 | 82 | ||
71 | if (controller.status.isSuccess) { | 83 | if (controller.status.isSuccess) { |
72 | - expect(controller.state.global.totalDeaths, 100); | ||
73 | - expect(controller.state.global.totalConfirmed, 200); | 84 | + expect(controller.state!.global.totalDeaths, 100); |
85 | + expect(controller.state!.global.totalConfirmed, 200); | ||
74 | } | 86 | } |
75 | }); | 87 | }); |
76 | 88 | ||
89 | + test('ever', () async { | ||
90 | + final count = ''.obs; | ||
91 | + var result = ''; | ||
92 | + ever<String>(count, (value) { | ||
93 | + result = value; | ||
94 | + }); | ||
95 | + count.value = '1'; | ||
96 | + expect('1', result); | ||
97 | + }); | ||
98 | + | ||
77 | /// Tests with GetTests | 99 | /// Tests with GetTests |
78 | - getTest( | 100 | + /// TEMPORARILY REMOVED from the null-safetym branch as |
101 | + /// get_test is not yet null safety. | ||
102 | + /* getTest( | ||
79 | "test description", | 103 | "test description", |
80 | getPages: AppPages.routes, | 104 | getPages: AppPages.routes, |
81 | initialRoute: AppPages.INITIAL, | 105 | initialRoute: AppPages.INITIAL, |
@@ -104,33 +128,6 @@ void main() { | @@ -104,33 +128,6 @@ void main() { | ||
104 | ), | 128 | ), |
105 | test: (e) { | 129 | test: (e) { |
106 | expect(find.text("ban:0"), findsOneWidget); | 130 | expect(find.text("ban:0"), findsOneWidget); |
107 | - expect(e.count.value, 0); | ||
108 | - }, | ||
109 | - ); | ||
110 | - | ||
111 | - testGetBuilder( | ||
112 | - 'GetBuilder test', | ||
113 | - widget: GetBuilder<Controller>( | ||
114 | - init: Controller(), | ||
115 | - builder: (controller) { | ||
116 | - return Text("ban:${controller.count}"); | ||
117 | - }, | ||
118 | - ), | ||
119 | - test: (e) { | ||
120 | - expect(find.text("ban:0"), findsOneWidget); | ||
121 | - expect(e.count.value, 0); | ||
122 | - }, | ||
123 | - ); | ||
124 | - | ||
125 | - testObx( | ||
126 | - 'Obx test', | ||
127 | - widget: (controller) => Obx( | ||
128 | - () => Text("ban:${controller.count}"), | ||
129 | - ), | ||
130 | - controller: Controller(), | ||
131 | - test: (e) { | ||
132 | - expect(find.text("ban:0"), findsOneWidget); | ||
133 | - expect(e.count.value, 0); | ||
134 | }, | 131 | }, |
135 | ); | 132 | ); |
136 | 133 | ||
@@ -151,7 +148,7 @@ void main() { | @@ -151,7 +148,7 @@ void main() { | ||
151 | onClose: (c) { | 148 | onClose: (c) { |
152 | print('onClose'); | 149 | print('onClose'); |
153 | }, | 150 | }, |
154 | - ); | 151 | + );*/ |
155 | } | 152 | } |
156 | 153 | ||
157 | class Controller extends GetxController { | 154 | class Controller extends GetxController { |
@@ -13,74 +13,74 @@ export 'http/src/response/response.dart'; | @@ -13,74 +13,74 @@ export 'http/src/response/response.dart'; | ||
13 | export 'sockets/sockets.dart'; | 13 | export 'sockets/sockets.dart'; |
14 | 14 | ||
15 | abstract class GetConnectInterface with GetLifeCycleBase { | 15 | abstract class GetConnectInterface with GetLifeCycleBase { |
16 | - List<GetSocket> sockets; | 16 | + List<GetSocket>? sockets; |
17 | GetHttpClient get httpClient; | 17 | GetHttpClient get httpClient; |
18 | 18 | ||
19 | Future<Response<T>> get<T>( | 19 | Future<Response<T>> get<T>( |
20 | String url, { | 20 | String url, { |
21 | - Map<String, String> headers, | ||
22 | - String contentType, | ||
23 | - Map<String, dynamic> query, | ||
24 | - Decoder<T> decoder, | 21 | + Map<String, String>? headers, |
22 | + String? contentType, | ||
23 | + Map<String, dynamic>? query, | ||
24 | + Decoder<T>? decoder, | ||
25 | }); | 25 | }); |
26 | 26 | ||
27 | Future<Response<T>> request<T>( | 27 | Future<Response<T>> request<T>( |
28 | String url, | 28 | String url, |
29 | String method, { | 29 | String method, { |
30 | dynamic body, | 30 | dynamic body, |
31 | - String contentType, | ||
32 | - Map<String, String> headers, | ||
33 | - Map<String, dynamic> query, | ||
34 | - Decoder<T> decoder, | 31 | + String? contentType, |
32 | + Map<String, String>? headers, | ||
33 | + Map<String, dynamic>? query, | ||
34 | + Decoder<T>? decoder, | ||
35 | }); | 35 | }); |
36 | Future<Response<T>> post<T>( | 36 | Future<Response<T>> post<T>( |
37 | String url, | 37 | String url, |
38 | dynamic body, { | 38 | dynamic body, { |
39 | - String contentType, | ||
40 | - Map<String, String> headers, | ||
41 | - Map<String, dynamic> query, | ||
42 | - Decoder<T> decoder, | 39 | + String? contentType, |
40 | + Map<String, String>? headers, | ||
41 | + Map<String, dynamic>? query, | ||
42 | + Decoder<T>? decoder, | ||
43 | }); | 43 | }); |
44 | 44 | ||
45 | Future<Response<T>> put<T>( | 45 | Future<Response<T>> put<T>( |
46 | String url, | 46 | String url, |
47 | dynamic body, { | 47 | dynamic body, { |
48 | - String contentType, | ||
49 | - Map<String, String> headers, | ||
50 | - Map<String, dynamic> query, | ||
51 | - Decoder<T> decoder, | 48 | + String? contentType, |
49 | + Map<String, String>? headers, | ||
50 | + Map<String, dynamic>? query, | ||
51 | + Decoder<T>? decoder, | ||
52 | }); | 52 | }); |
53 | 53 | ||
54 | Future<Response<T>> delete<T>( | 54 | Future<Response<T>> delete<T>( |
55 | String url, { | 55 | String url, { |
56 | - Map<String, String> headers, | ||
57 | - String contentType, | ||
58 | - Map<String, dynamic> query, | ||
59 | - Decoder<T> decoder, | 56 | + Map<String, String>? headers, |
57 | + String? contentType, | ||
58 | + Map<String, dynamic>? query, | ||
59 | + Decoder<T>? decoder, | ||
60 | }); | 60 | }); |
61 | 61 | ||
62 | Future<Response<T>> patch<T>( | 62 | Future<Response<T>> patch<T>( |
63 | String url, | 63 | String url, |
64 | dynamic body, { | 64 | dynamic body, { |
65 | - String contentType, | ||
66 | - Map<String, String> headers, | ||
67 | - Map<String, dynamic> query, | ||
68 | - Decoder<T> decoder, | ||
69 | - Progress uploadProgress, | 65 | + String? contentType, |
66 | + Map<String, String>? headers, | ||
67 | + Map<String, dynamic>? query, | ||
68 | + Decoder<T>? decoder, | ||
69 | + Progress? uploadProgress, | ||
70 | }); | 70 | }); |
71 | 71 | ||
72 | Future<GraphQLResponse<T>> query<T>( | 72 | Future<GraphQLResponse<T>> query<T>( |
73 | String query, { | 73 | String query, { |
74 | - String url, | ||
75 | - Map<String, dynamic> variables, | ||
76 | - Map<String, String> headers, | 74 | + String? url, |
75 | + Map<String, dynamic>? variables, | ||
76 | + Map<String, String>? headers, | ||
77 | }); | 77 | }); |
78 | 78 | ||
79 | Future<GraphQLResponse<T>> mutation<T>( | 79 | Future<GraphQLResponse<T>> mutation<T>( |
80 | String mutation, { | 80 | String mutation, { |
81 | - String url, | ||
82 | - Map<String, dynamic> variables, | ||
83 | - Map<String, String> headers, | 81 | + String? url, |
82 | + Map<String, dynamic>? variables, | ||
83 | + Map<String, String>? headers, | ||
84 | }); | 84 | }); |
85 | 85 | ||
86 | GetSocket socket( | 86 | GetSocket socket( |
@@ -103,16 +103,16 @@ class GetConnect extends GetConnectInterface { | @@ -103,16 +103,16 @@ class GetConnect extends GetConnectInterface { | ||
103 | 103 | ||
104 | bool allowAutoSignedCert; | 104 | bool allowAutoSignedCert; |
105 | String userAgent; | 105 | String userAgent; |
106 | - String baseUrl; | 106 | + String? baseUrl; |
107 | String defaultContentType = 'application/json; charset=utf-8'; | 107 | String defaultContentType = 'application/json; charset=utf-8'; |
108 | bool followRedirects; | 108 | bool followRedirects; |
109 | int maxRedirects; | 109 | int maxRedirects; |
110 | int maxAuthRetries; | 110 | int maxAuthRetries; |
111 | - Decoder defaultDecoder; | 111 | + Decoder? defaultDecoder; |
112 | Duration timeout; | 112 | Duration timeout; |
113 | - List<TrustedCertificate> trustedCertificates; | ||
114 | - GetHttpClient _httpClient; | ||
115 | - List<GetSocket> _sockets; | 113 | + List<TrustedCertificate>? trustedCertificates; |
114 | + GetHttpClient? _httpClient; | ||
115 | + List<GetSocket>? _sockets; | ||
116 | 116 | ||
117 | @override | 117 | @override |
118 | List<GetSocket> get sockets => _sockets ??= <GetSocket>[]; | 118 | List<GetSocket> get sockets => _sockets ??= <GetSocket>[]; |
@@ -132,10 +132,10 @@ class GetConnect extends GetConnectInterface { | @@ -132,10 +132,10 @@ class GetConnect extends GetConnectInterface { | ||
132 | @override | 132 | @override |
133 | Future<Response<T>> get<T>( | 133 | Future<Response<T>> get<T>( |
134 | String url, { | 134 | String url, { |
135 | - Map<String, String> headers, | ||
136 | - String contentType, | ||
137 | - Map<String, dynamic> query, | ||
138 | - Decoder<T> decoder, | 135 | + Map<String, String>? headers, |
136 | + String? contentType, | ||
137 | + Map<String, dynamic>? query, | ||
138 | + Decoder<T>? decoder, | ||
139 | }) { | 139 | }) { |
140 | _checkIfDisposed(); | 140 | _checkIfDisposed(); |
141 | return httpClient.get<T>( | 141 | return httpClient.get<T>( |
@@ -149,13 +149,13 @@ class GetConnect extends GetConnectInterface { | @@ -149,13 +149,13 @@ class GetConnect extends GetConnectInterface { | ||
149 | 149 | ||
150 | @override | 150 | @override |
151 | Future<Response<T>> post<T>( | 151 | Future<Response<T>> post<T>( |
152 | - String url, | 152 | + String? url, |
153 | dynamic body, { | 153 | dynamic body, { |
154 | - String contentType, | ||
155 | - Map<String, String> headers, | ||
156 | - Map<String, dynamic> query, | ||
157 | - Decoder<T> decoder, | ||
158 | - Progress uploadProgress, | 154 | + String? contentType, |
155 | + Map<String, String>? headers, | ||
156 | + Map<String, dynamic>? query, | ||
157 | + Decoder<T>? decoder, | ||
158 | + Progress? uploadProgress, | ||
159 | }) { | 159 | }) { |
160 | _checkIfDisposed(); | 160 | _checkIfDisposed(); |
161 | return httpClient.post<T>( | 161 | return httpClient.post<T>( |
@@ -173,11 +173,11 @@ class GetConnect extends GetConnectInterface { | @@ -173,11 +173,11 @@ class GetConnect extends GetConnectInterface { | ||
173 | Future<Response<T>> put<T>( | 173 | Future<Response<T>> put<T>( |
174 | String url, | 174 | String url, |
175 | dynamic body, { | 175 | dynamic body, { |
176 | - String contentType, | ||
177 | - Map<String, String> headers, | ||
178 | - Map<String, dynamic> query, | ||
179 | - Decoder<T> decoder, | ||
180 | - Progress uploadProgress, | 176 | + String? contentType, |
177 | + Map<String, String>? headers, | ||
178 | + Map<String, dynamic>? query, | ||
179 | + Decoder<T>? decoder, | ||
180 | + Progress? uploadProgress, | ||
181 | }) { | 181 | }) { |
182 | _checkIfDisposed(); | 182 | _checkIfDisposed(); |
183 | return httpClient.put<T>( | 183 | return httpClient.put<T>( |
@@ -195,11 +195,11 @@ class GetConnect extends GetConnectInterface { | @@ -195,11 +195,11 @@ class GetConnect extends GetConnectInterface { | ||
195 | Future<Response<T>> patch<T>( | 195 | Future<Response<T>> patch<T>( |
196 | String url, | 196 | String url, |
197 | dynamic body, { | 197 | dynamic body, { |
198 | - String contentType, | ||
199 | - Map<String, String> headers, | ||
200 | - Map<String, dynamic> query, | ||
201 | - Decoder<T> decoder, | ||
202 | - Progress uploadProgress, | 198 | + String? contentType, |
199 | + Map<String, String>? headers, | ||
200 | + Map<String, dynamic>? query, | ||
201 | + Decoder<T>? decoder, | ||
202 | + Progress? uploadProgress, | ||
203 | }) { | 203 | }) { |
204 | _checkIfDisposed(); | 204 | _checkIfDisposed(); |
205 | return httpClient.patch<T>( | 205 | return httpClient.patch<T>( |
@@ -218,11 +218,11 @@ class GetConnect extends GetConnectInterface { | @@ -218,11 +218,11 @@ class GetConnect extends GetConnectInterface { | ||
218 | String url, | 218 | String url, |
219 | String method, { | 219 | String method, { |
220 | dynamic body, | 220 | dynamic body, |
221 | - String contentType, | ||
222 | - Map<String, String> headers, | ||
223 | - Map<String, dynamic> query, | ||
224 | - Decoder<T> decoder, | ||
225 | - Progress uploadProgress, | 221 | + String? contentType, |
222 | + Map<String, String>? headers, | ||
223 | + Map<String, dynamic>? query, | ||
224 | + Decoder<T>? decoder, | ||
225 | + Progress? uploadProgress, | ||
226 | }) { | 226 | }) { |
227 | _checkIfDisposed(); | 227 | _checkIfDisposed(); |
228 | return httpClient.request<T>( | 228 | return httpClient.request<T>( |
@@ -240,10 +240,10 @@ class GetConnect extends GetConnectInterface { | @@ -240,10 +240,10 @@ class GetConnect extends GetConnectInterface { | ||
240 | @override | 240 | @override |
241 | Future<Response<T>> delete<T>( | 241 | Future<Response<T>> delete<T>( |
242 | String url, { | 242 | String url, { |
243 | - Map<String, String> headers, | ||
244 | - String contentType, | ||
245 | - Map<String, dynamic> query, | ||
246 | - Decoder<T> decoder, | 243 | + Map<String, String>? headers, |
244 | + String? contentType, | ||
245 | + Map<String, dynamic>? query, | ||
246 | + Decoder<T>? decoder, | ||
247 | }) { | 247 | }) { |
248 | _checkIfDisposed(); | 248 | _checkIfDisposed(); |
249 | return httpClient.delete( | 249 | return httpClient.delete( |
@@ -262,14 +262,14 @@ class GetConnect extends GetConnectInterface { | @@ -262,14 +262,14 @@ class GetConnect extends GetConnectInterface { | ||
262 | }) { | 262 | }) { |
263 | _checkIfDisposed(isHttp: false); | 263 | _checkIfDisposed(isHttp: false); |
264 | 264 | ||
265 | - final _socket = GetSocket(_concatUrl(url), ping: ping); | 265 | + final _socket = GetSocket(_concatUrl(url)!, ping: ping); |
266 | sockets.add(_socket); | 266 | sockets.add(_socket); |
267 | return _socket; | 267 | return _socket; |
268 | } | 268 | } |
269 | 269 | ||
270 | - String _concatUrl(String url) { | 270 | + String? _concatUrl(String? url) { |
271 | if (url == null) return baseUrl; | 271 | if (url == null) return baseUrl; |
272 | - return baseUrl == null ? url : baseUrl + url; | 272 | + return baseUrl == null ? url : baseUrl! + url; |
273 | } | 273 | } |
274 | 274 | ||
275 | /// query allow made GraphQL raw querys | 275 | /// query allow made GraphQL raw querys |
@@ -294,9 +294,9 @@ class GetConnect extends GetConnectInterface { | @@ -294,9 +294,9 @@ class GetConnect extends GetConnectInterface { | ||
294 | @override | 294 | @override |
295 | Future<GraphQLResponse<T>> query<T>( | 295 | Future<GraphQLResponse<T>> query<T>( |
296 | String query, { | 296 | String query, { |
297 | - String url, | ||
298 | - Map<String, dynamic> variables, | ||
299 | - Map<String, String> headers, | 297 | + String? url, |
298 | + Map<String, dynamic>? variables, | ||
299 | + Map<String, String>? headers, | ||
300 | }) async { | 300 | }) async { |
301 | try { | 301 | try { |
302 | final res = await post( | 302 | final res = await post( |
@@ -316,7 +316,7 @@ class GetConnect extends GetConnectInterface { | @@ -316,7 +316,7 @@ class GetConnect extends GetConnectInterface { | ||
316 | )) | 316 | )) |
317 | .toList()); | 317 | .toList()); |
318 | } | 318 | } |
319 | - return GraphQLResponse<T>(body: res.body['data'] as T); | 319 | + return GraphQLResponse<T>(body: res.body['data'] as T?); |
320 | } on Exception catch (_) { | 320 | } on Exception catch (_) { |
321 | return GraphQLResponse<T>(graphQLErrors: [ | 321 | return GraphQLResponse<T>(graphQLErrors: [ |
322 | GraphQLError( | 322 | GraphQLError( |
@@ -330,9 +330,9 @@ class GetConnect extends GetConnectInterface { | @@ -330,9 +330,9 @@ class GetConnect extends GetConnectInterface { | ||
330 | @override | 330 | @override |
331 | Future<GraphQLResponse<T>> mutation<T>( | 331 | Future<GraphQLResponse<T>> mutation<T>( |
332 | String mutation, { | 332 | String mutation, { |
333 | - String url, | ||
334 | - Map<String, dynamic> variables, | ||
335 | - Map<String, String> headers, | 333 | + String? url, |
334 | + Map<String, dynamic>? variables, | ||
335 | + Map<String, String>? headers, | ||
336 | }) async { | 336 | }) async { |
337 | try { | 337 | try { |
338 | final res = await post( | 338 | final res = await post( |
@@ -352,7 +352,7 @@ class GetConnect extends GetConnectInterface { | @@ -352,7 +352,7 @@ class GetConnect extends GetConnectInterface { | ||
352 | )) | 352 | )) |
353 | .toList()); | 353 | .toList()); |
354 | } | 354 | } |
355 | - return GraphQLResponse<T>(body: res.body['data'] as T); | 355 | + return GraphQLResponse<T>(body: res.body['data'] as T?); |
356 | } on Exception catch (_) { | 356 | } on Exception catch (_) { |
357 | return GraphQLResponse<T>(graphQLErrors: [ | 357 | return GraphQLResponse<T>(graphQLErrors: [ |
358 | GraphQLError( | 358 | GraphQLError( |
1 | class GetHttpException implements Exception { | 1 | class GetHttpException implements Exception { |
2 | final String message; | 2 | final String message; |
3 | 3 | ||
4 | - final Uri uri; | 4 | + final Uri? uri; |
5 | 5 | ||
6 | GetHttpException(this.message, [this.uri]); | 6 | GetHttpException(this.message, [this.uri]); |
7 | 7 | ||
@@ -11,8 +11,8 @@ class GetHttpException implements Exception { | @@ -11,8 +11,8 @@ class GetHttpException implements Exception { | ||
11 | 11 | ||
12 | class GraphQLError { | 12 | class GraphQLError { |
13 | GraphQLError({this.code, this.message}); | 13 | GraphQLError({this.code, this.message}); |
14 | - final String message; | ||
15 | - final String code; | 14 | + final String? message; |
15 | + final String? code; | ||
16 | 16 | ||
17 | @override | 17 | @override |
18 | String toString() => 'GETCONNECT ERROR:\n\tcode:$code\n\tmessage:$message'; | 18 | String toString() => 'GETCONNECT ERROR:\n\tcode:$code\n\tmessage:$message'; |
1 | import 'dart:async'; | 1 | import 'dart:async'; |
2 | import 'dart:convert'; | 2 | import 'dart:convert'; |
3 | -import 'package:flutter/foundation.dart'; | ||
4 | 3 | ||
5 | import '../src/certificates/certificates.dart'; | 4 | import '../src/certificates/certificates.dart'; |
6 | import '../src/exceptions/exceptions.dart'; | 5 | import '../src/exceptions/exceptions.dart'; |
@@ -20,7 +19,7 @@ typedef Progress = Function(double percent); | @@ -20,7 +19,7 @@ typedef Progress = Function(double percent); | ||
20 | 19 | ||
21 | class GetHttpClient { | 20 | class GetHttpClient { |
22 | String userAgent; | 21 | String userAgent; |
23 | - String baseUrl; | 22 | + String? baseUrl; |
24 | 23 | ||
25 | String defaultContentType = 'application/json; charset=utf-8'; | 24 | String defaultContentType = 'application/json; charset=utf-8'; |
26 | 25 | ||
@@ -28,7 +27,7 @@ class GetHttpClient { | @@ -28,7 +27,7 @@ class GetHttpClient { | ||
28 | int maxRedirects; | 27 | int maxRedirects; |
29 | int maxAuthRetries; | 28 | int maxAuthRetries; |
30 | 29 | ||
31 | - Decoder defaultDecoder; | 30 | + Decoder? defaultDecoder; |
32 | 31 | ||
33 | Duration timeout; | 32 | Duration timeout; |
34 | 33 | ||
@@ -46,7 +45,7 @@ class GetHttpClient { | @@ -46,7 +45,7 @@ class GetHttpClient { | ||
46 | this.maxAuthRetries = 1, | 45 | this.maxAuthRetries = 1, |
47 | bool allowAutoSignedCert = false, | 46 | bool allowAutoSignedCert = false, |
48 | this.baseUrl, | 47 | this.baseUrl, |
49 | - List<TrustedCertificate> trustedCertificates, | 48 | + List<TrustedCertificate>? trustedCertificates, |
50 | }) : _httpClient = HttpRequestImpl( | 49 | }) : _httpClient = HttpRequestImpl( |
51 | allowAutoSignedCert: allowAutoSignedCert, | 50 | allowAutoSignedCert: allowAutoSignedCert, |
52 | trustedCertificates: trustedCertificates, | 51 | trustedCertificates: trustedCertificates, |
@@ -73,11 +72,11 @@ class GetHttpClient { | @@ -73,11 +72,11 @@ class GetHttpClient { | ||
73 | _modifier.removeResponseModifier<T>(interceptor); | 72 | _modifier.removeResponseModifier<T>(interceptor); |
74 | } | 73 | } |
75 | 74 | ||
76 | - Uri _createUri(String url, Map<String, dynamic> query) { | 75 | + Uri _createUri(String? url, Map<String, dynamic>? query) { |
77 | if (baseUrl != null) { | 76 | if (baseUrl != null) { |
78 | - url = baseUrl + url; | 77 | + url = baseUrl! + url!; |
79 | } | 78 | } |
80 | - final uri = Uri.parse(url); | 79 | + final uri = Uri.parse(url!); |
81 | if (query != null) { | 80 | if (query != null) { |
82 | return uri.replace(queryParameters: query); | 81 | return uri.replace(queryParameters: query); |
83 | } | 82 | } |
@@ -85,16 +84,16 @@ class GetHttpClient { | @@ -85,16 +84,16 @@ class GetHttpClient { | ||
85 | } | 84 | } |
86 | 85 | ||
87 | Future<Request<T>> _requestWithBody<T>( | 86 | Future<Request<T>> _requestWithBody<T>( |
88 | - String url, | ||
89 | - String contentType, | 87 | + String? url, |
88 | + String? contentType, | ||
90 | dynamic body, | 89 | dynamic body, |
91 | String method, | 90 | String method, |
92 | - Map<String, dynamic> query, | ||
93 | - Decoder<T> decoder, | ||
94 | - Progress uploadProgress, | 91 | + Map<String, dynamic>? query, |
92 | + Decoder<T>? decoder, | ||
93 | + Progress? uploadProgress, | ||
95 | ) async { | 94 | ) async { |
96 | - List<int> bodyBytes; | ||
97 | - BodyBytesStream bodyStream; | 95 | + List<int>? bodyBytes; |
96 | + Stream<List<int>>? bodyStream; | ||
98 | final headers = <String, String>{}; | 97 | final headers = <String, String>{}; |
99 | 98 | ||
100 | headers['user-agent'] = userAgent; | 99 | headers['user-agent'] = userAgent; |
@@ -146,9 +145,9 @@ class GetHttpClient { | @@ -146,9 +145,9 @@ class GetHttpClient { | ||
146 | ); | 145 | ); |
147 | } | 146 | } |
148 | 147 | ||
149 | - BodyBytesStream _trackProgress( | 148 | + Stream<List<int>> _trackProgress( |
150 | List<int> bodyBytes, | 149 | List<int> bodyBytes, |
151 | - Progress uploadProgress, | 150 | + Progress? uploadProgress, |
152 | ) { | 151 | ) { |
153 | var total = 0; | 152 | var total = 0; |
154 | var length = bodyBytes.length; | 153 | var length = bodyBytes.length; |
@@ -164,12 +163,12 @@ class GetHttpClient { | @@ -164,12 +163,12 @@ class GetHttpClient { | ||
164 | sink.add(data); | 163 | sink.add(data); |
165 | }), | 164 | }), |
166 | ); | 165 | ); |
167 | - return BodyBytesStream(byteStream); | 166 | + return byteStream; |
168 | } | 167 | } |
169 | 168 | ||
170 | void _setSimpleHeaders( | 169 | void _setSimpleHeaders( |
171 | Map<String, String> headers, | 170 | Map<String, String> headers, |
172 | - String contentType, | 171 | + String? contentType, |
173 | ) { | 172 | ) { |
174 | headers['content-type'] = contentType ?? defaultContentType; | 173 | headers['content-type'] = contentType ?? defaultContentType; |
175 | headers['user-agent'] = userAgent; | 174 | headers['user-agent'] = userAgent; |
@@ -179,7 +178,7 @@ class GetHttpClient { | @@ -179,7 +178,7 @@ class GetHttpClient { | ||
179 | HandlerExecute<T> handler, { | 178 | HandlerExecute<T> handler, { |
180 | bool authenticate = false, | 179 | bool authenticate = false, |
181 | int requestNumber = 1, | 180 | int requestNumber = 1, |
182 | - Map<String, String> headers, | 181 | + Map<String, String>? headers, |
183 | }) async { | 182 | }) async { |
184 | try { | 183 | try { |
185 | var request = await handler(); | 184 | var request = await handler(); |
@@ -188,7 +187,7 @@ class GetHttpClient { | @@ -188,7 +187,7 @@ class GetHttpClient { | ||
188 | request.headers[key] = value; | 187 | request.headers[key] = value; |
189 | }); | 188 | }); |
190 | 189 | ||
191 | - if (authenticate) await _modifier.authenticator(request); | 190 | + if (authenticate) await _modifier.authenticator!(request); |
192 | await _modifier.modifyRequest(request); | 191 | await _modifier.modifyRequest(request); |
193 | 192 | ||
194 | var response = await _httpClient.send<T>(request); | 193 | var response = await _httpClient.send<T>(request); |
@@ -238,9 +237,9 @@ class GetHttpClient { | @@ -238,9 +237,9 @@ class GetHttpClient { | ||
238 | 237 | ||
239 | Future<Request<T>> _get<T>( | 238 | Future<Request<T>> _get<T>( |
240 | String url, | 239 | String url, |
241 | - String contentType, | ||
242 | - Map<String, dynamic> query, | ||
243 | - Decoder<T> decoder, | 240 | + String? contentType, |
241 | + Map<String, dynamic>? query, | ||
242 | + Decoder<T>? decoder, | ||
244 | ) { | 243 | ) { |
245 | final headers = <String, String>{}; | 244 | final headers = <String, String>{}; |
246 | _setSimpleHeaders(headers, contentType); | 245 | _setSimpleHeaders(headers, contentType); |
@@ -250,19 +249,19 @@ class GetHttpClient { | @@ -250,19 +249,19 @@ class GetHttpClient { | ||
250 | method: 'get', | 249 | method: 'get', |
251 | url: uri, | 250 | url: uri, |
252 | headers: headers, | 251 | headers: headers, |
253 | - decoder: decoder ?? (defaultDecoder as Decoder<T>), | 252 | + decoder: decoder ?? (defaultDecoder as Decoder<T>?), |
254 | contentLength: 0, | 253 | contentLength: 0, |
255 | )); | 254 | )); |
256 | } | 255 | } |
257 | 256 | ||
258 | Future<Request<T>> _request<T>( | 257 | Future<Request<T>> _request<T>( |
259 | - String url, | 258 | + String? url, |
260 | String method, { | 259 | String method, { |
261 | - String contentType, | ||
262 | - @required dynamic body, | ||
263 | - @required Map<String, dynamic> query, | ||
264 | - Decoder<T> decoder, | ||
265 | - @required Progress uploadProgress, | 260 | + String? contentType, |
261 | + required dynamic body, | ||
262 | + required Map<String, dynamic>? query, | ||
263 | + Decoder<T>? decoder, | ||
264 | + required Progress? uploadProgress, | ||
266 | }) { | 265 | }) { |
267 | return _requestWithBody<T>( | 266 | return _requestWithBody<T>( |
268 | url, | 267 | url, |
@@ -270,16 +269,16 @@ class GetHttpClient { | @@ -270,16 +269,16 @@ class GetHttpClient { | ||
270 | body, | 269 | body, |
271 | method, | 270 | method, |
272 | query, | 271 | query, |
273 | - decoder ?? (defaultDecoder as Decoder<T>), | 272 | + decoder ?? (defaultDecoder as Decoder<T>?), |
274 | uploadProgress, | 273 | uploadProgress, |
275 | ); | 274 | ); |
276 | } | 275 | } |
277 | 276 | ||
278 | Request<T> _delete<T>( | 277 | Request<T> _delete<T>( |
279 | String url, | 278 | String url, |
280 | - String contentType, | ||
281 | - Map<String, dynamic> query, | ||
282 | - Decoder<T> decoder, | 279 | + String? contentType, |
280 | + Map<String, dynamic>? query, | ||
281 | + Decoder<T>? decoder, | ||
283 | ) { | 282 | ) { |
284 | final headers = <String, String>{}; | 283 | final headers = <String, String>{}; |
285 | _setSimpleHeaders(headers, contentType); | 284 | _setSimpleHeaders(headers, contentType); |
@@ -289,18 +288,18 @@ class GetHttpClient { | @@ -289,18 +288,18 @@ class GetHttpClient { | ||
289 | method: 'delete', | 288 | method: 'delete', |
290 | url: uri, | 289 | url: uri, |
291 | headers: headers, | 290 | headers: headers, |
292 | - decoder: decoder ?? (defaultDecoder as Decoder<T>), | 291 | + decoder: decoder ?? (defaultDecoder as Decoder<T>?), |
293 | ); | 292 | ); |
294 | } | 293 | } |
295 | 294 | ||
296 | Future<Response<T>> patch<T>( | 295 | Future<Response<T>> patch<T>( |
297 | String url, { | 296 | String url, { |
298 | dynamic body, | 297 | dynamic body, |
299 | - String contentType, | ||
300 | - Map<String, String> headers, | ||
301 | - Map<String, dynamic> query, | ||
302 | - Decoder<T> decoder, | ||
303 | - Progress uploadProgress, | 298 | + String? contentType, |
299 | + Map<String, String>? headers, | ||
300 | + Map<String, dynamic>? query, | ||
301 | + Decoder<T>? decoder, | ||
302 | + Progress? uploadProgress, | ||
304 | // List<MultipartFile> files, | 303 | // List<MultipartFile> files, |
305 | }) async { | 304 | }) async { |
306 | try { | 305 | try { |
@@ -328,13 +327,13 @@ class GetHttpClient { | @@ -328,13 +327,13 @@ class GetHttpClient { | ||
328 | } | 327 | } |
329 | 328 | ||
330 | Future<Response<T>> post<T>( | 329 | Future<Response<T>> post<T>( |
331 | - String url, { | 330 | + String? url, { |
332 | dynamic body, | 331 | dynamic body, |
333 | - String contentType, | ||
334 | - Map<String, String> headers, | ||
335 | - Map<String, dynamic> query, | ||
336 | - Decoder<T> decoder, | ||
337 | - Progress uploadProgress, | 332 | + String? contentType, |
333 | + Map<String, String>? headers, | ||
334 | + Map<String, dynamic>? query, | ||
335 | + Decoder<T>? decoder, | ||
336 | + Progress? uploadProgress, | ||
338 | // List<MultipartFile> files, | 337 | // List<MultipartFile> files, |
339 | }) async { | 338 | }) async { |
340 | try { | 339 | try { |
@@ -365,11 +364,11 @@ class GetHttpClient { | @@ -365,11 +364,11 @@ class GetHttpClient { | ||
365 | String url, | 364 | String url, |
366 | String method, { | 365 | String method, { |
367 | dynamic body, | 366 | dynamic body, |
368 | - String contentType, | ||
369 | - Map<String, String> headers, | ||
370 | - Map<String, dynamic> query, | ||
371 | - Decoder<T> decoder, | ||
372 | - Progress uploadProgress, | 367 | + String? contentType, |
368 | + Map<String, String>? headers, | ||
369 | + Map<String, dynamic>? query, | ||
370 | + Decoder<T>? decoder, | ||
371 | + Progress? uploadProgress, | ||
373 | }) async { | 372 | }) async { |
374 | try { | 373 | try { |
375 | var response = await _performRequest<T>( | 374 | var response = await _performRequest<T>( |
@@ -398,11 +397,11 @@ class GetHttpClient { | @@ -398,11 +397,11 @@ class GetHttpClient { | ||
398 | Future<Response<T>> put<T>( | 397 | Future<Response<T>> put<T>( |
399 | String url, { | 398 | String url, { |
400 | dynamic body, | 399 | dynamic body, |
401 | - String contentType, | ||
402 | - Map<String, String> headers, | ||
403 | - Map<String, dynamic> query, | ||
404 | - Decoder<T> decoder, | ||
405 | - Progress uploadProgress, | 400 | + String? contentType, |
401 | + Map<String, String>? headers, | ||
402 | + Map<String, dynamic>? query, | ||
403 | + Decoder<T>? decoder, | ||
404 | + Progress? uploadProgress, | ||
406 | }) async { | 405 | }) async { |
407 | try { | 406 | try { |
408 | var response = await _performRequest<T>( | 407 | var response = await _performRequest<T>( |
@@ -430,10 +429,10 @@ class GetHttpClient { | @@ -430,10 +429,10 @@ class GetHttpClient { | ||
430 | 429 | ||
431 | Future<Response<T>> get<T>( | 430 | Future<Response<T>> get<T>( |
432 | String url, { | 431 | String url, { |
433 | - Map<String, String> headers, | ||
434 | - String contentType, | ||
435 | - Map<String, dynamic> query, | ||
436 | - Decoder<T> decoder, | 432 | + Map<String, String>? headers, |
433 | + String? contentType, | ||
434 | + Map<String, dynamic>? query, | ||
435 | + Decoder<T>? decoder, | ||
437 | }) async { | 436 | }) async { |
438 | try { | 437 | try { |
439 | var response = await _performRequest<T>( | 438 | var response = await _performRequest<T>( |
@@ -514,10 +513,10 @@ class GetHttpClient { | @@ -514,10 +513,10 @@ class GetHttpClient { | ||
514 | 513 | ||
515 | Future<Response<T>> delete<T>( | 514 | Future<Response<T>> delete<T>( |
516 | String url, { | 515 | String url, { |
517 | - Map<String, String> headers, | ||
518 | - String contentType, | ||
519 | - Map<String, dynamic> query, | ||
520 | - Decoder<T> decoder, | 516 | + Map<String, String>? headers, |
517 | + String? contentType, | ||
518 | + Map<String, dynamic>? query, | ||
519 | + Decoder<T>? decoder, | ||
521 | }) async { | 520 | }) async { |
522 | try { | 521 | try { |
523 | var response = await _performRequest<T>( | 522 | var response = await _performRequest<T>( |
1 | import 'dart:async'; | 1 | import 'dart:async'; |
2 | import 'dart:html' as html; | 2 | import 'dart:html' as html; |
3 | -import 'dart:typed_data'; | ||
4 | 3 | ||
5 | import '../../certificates/certificates.dart'; | 4 | import '../../certificates/certificates.dart'; |
6 | import '../../exceptions/exceptions.dart'; | 5 | import '../../exceptions/exceptions.dart'; |
@@ -13,7 +12,7 @@ import '../utils/body_decoder.dart'; | @@ -13,7 +12,7 @@ import '../utils/body_decoder.dart'; | ||
13 | class HttpRequestImpl implements HttpRequestBase { | 12 | class HttpRequestImpl implements HttpRequestBase { |
14 | HttpRequestImpl({ | 13 | HttpRequestImpl({ |
15 | bool allowAutoSignedCert = true, | 14 | bool allowAutoSignedCert = true, |
16 | - List<TrustedCertificate> trustedCertificates, | 15 | + List<TrustedCertificate>? trustedCertificates, |
17 | }); | 16 | }); |
18 | 17 | ||
19 | /// The currently active XHRs. | 18 | /// The currently active XHRs. |
@@ -41,16 +40,16 @@ class HttpRequestImpl implements HttpRequestBase { | @@ -41,16 +40,16 @@ class HttpRequestImpl implements HttpRequestBase { | ||
41 | 40 | ||
42 | var completer = Completer<Response<T>>(); | 41 | var completer = Completer<Response<T>>(); |
43 | xhr.onLoad.first.then((_) { | 42 | xhr.onLoad.first.then((_) { |
44 | - var blob = xhr.response as html.Blob ?? html.Blob([]); | 43 | + var blob = xhr.response as html.Blob? ?? html.Blob([]); |
45 | var reader = html.FileReader(); | 44 | var reader = html.FileReader(); |
46 | 45 | ||
47 | reader.onLoad.first.then((_) async { | 46 | reader.onLoad.first.then((_) async { |
48 | - var bodyBytes = BodyBytesStream.fromBytes(reader.result as Uint8List); | 47 | + var bodyBytes = BodyBytesStream.fromBytes(reader.result as List<int>); |
49 | 48 | ||
50 | final stringBody = | 49 | final stringBody = |
51 | await bodyBytesToString(bodyBytes, xhr.responseHeaders); | 50 | await bodyBytesToString(bodyBytes, xhr.responseHeaders); |
52 | 51 | ||
53 | - String contentType; | 52 | + String? contentType; |
54 | 53 | ||
55 | if (xhr.responseHeaders.containsKey('content-type')) { | 54 | if (xhr.responseHeaders.containsKey('content-type')) { |
56 | contentType = xhr.responseHeaders['content-type']; | 55 | contentType = xhr.responseHeaders['content-type']; |
@@ -10,24 +10,24 @@ import '../utils/body_decoder.dart'; | @@ -10,24 +10,24 @@ import '../utils/body_decoder.dart'; | ||
10 | 10 | ||
11 | /// A `dart:io` implementation of `HttpRequestBase`. | 11 | /// A `dart:io` implementation of `HttpRequestBase`. |
12 | class HttpRequestImpl extends HttpRequestBase { | 12 | class HttpRequestImpl extends HttpRequestBase { |
13 | - io.HttpClient _httpClient; | ||
14 | - io.SecurityContext _securityContext; | 13 | + io.HttpClient? _httpClient; |
14 | + io.SecurityContext? _securityContext; | ||
15 | 15 | ||
16 | HttpRequestImpl({ | 16 | HttpRequestImpl({ |
17 | bool allowAutoSignedCert = true, | 17 | bool allowAutoSignedCert = true, |
18 | - List<TrustedCertificate> trustedCertificates, | 18 | + List<TrustedCertificate>? trustedCertificates, |
19 | }) { | 19 | }) { |
20 | _httpClient = io.HttpClient(); | 20 | _httpClient = io.HttpClient(); |
21 | if (trustedCertificates != null) { | 21 | if (trustedCertificates != null) { |
22 | _securityContext = io.SecurityContext(); | 22 | _securityContext = io.SecurityContext(); |
23 | for (final trustedCertificate in trustedCertificates) { | 23 | for (final trustedCertificate in trustedCertificates) { |
24 | - _securityContext | 24 | + _securityContext! |
25 | .setTrustedCertificatesBytes(List.from(trustedCertificate.bytes)); | 25 | .setTrustedCertificatesBytes(List.from(trustedCertificate.bytes)); |
26 | } | 26 | } |
27 | } | 27 | } |
28 | 28 | ||
29 | _httpClient = io.HttpClient(context: _securityContext); | 29 | _httpClient = io.HttpClient(context: _securityContext); |
30 | - _httpClient.badCertificateCallback = (_, __, ___) => allowAutoSignedCert; | 30 | + _httpClient!.badCertificateCallback = (_, __, ___) => allowAutoSignedCert; |
31 | } | 31 | } |
32 | 32 | ||
33 | @override | 33 | @override |
@@ -36,7 +36,7 @@ class HttpRequestImpl extends HttpRequestBase { | @@ -36,7 +36,7 @@ class HttpRequestImpl extends HttpRequestBase { | ||
36 | //var stream = BodyBytesStream.fromBytes(requestBody ?? const []); | 36 | //var stream = BodyBytesStream.fromBytes(requestBody ?? const []); |
37 | 37 | ||
38 | try { | 38 | try { |
39 | - var ioRequest = (await _httpClient.openUrl(request.method, request.url)) | 39 | + var ioRequest = (await _httpClient!.openUrl(request.method, request.url)) |
40 | ..followRedirects = request.followRedirects | 40 | ..followRedirects = request.followRedirects |
41 | ..persistentConnection = request.persistentConnection | 41 | ..persistentConnection = request.persistentConnection |
42 | ..maxRedirects = request.maxRedirects | 42 | ..maxRedirects = request.maxRedirects |
@@ -50,7 +50,7 @@ class HttpRequestImpl extends HttpRequestBase { | @@ -50,7 +50,7 @@ class HttpRequestImpl extends HttpRequestBase { | ||
50 | headers[key] = values.join(','); | 50 | headers[key] = values.join(','); |
51 | }); | 51 | }); |
52 | 52 | ||
53 | - final bodyBytes = BodyBytesStream(response); | 53 | + final bodyBytes = (response); |
54 | final stringBody = await bodyBytesToString(bodyBytes, headers); | 54 | final stringBody = await bodyBytesToString(bodyBytes, headers); |
55 | 55 | ||
56 | final body = bodyDecoded<T>( | 56 | final body = bodyDecoded<T>( |
@@ -77,7 +77,7 @@ class HttpRequestImpl extends HttpRequestBase { | @@ -77,7 +77,7 @@ class HttpRequestImpl extends HttpRequestBase { | ||
77 | @override | 77 | @override |
78 | void close() { | 78 | void close() { |
79 | if (_httpClient != null) { | 79 | if (_httpClient != null) { |
80 | - _httpClient.close(force: true); | 80 | + _httpClient!.close(force: true); |
81 | _httpClient = null; | 81 | _httpClient = null; |
82 | } | 82 | } |
83 | } | 83 | } |
@@ -16,14 +16,14 @@ class MockClient extends HttpRequestBase { | @@ -16,14 +16,14 @@ class MockClient extends HttpRequestBase { | ||
16 | @override | 16 | @override |
17 | Future<Response<T>> send<T>(Request<T> request) async { | 17 | Future<Response<T>> send<T>(Request<T> request) async { |
18 | var requestBody = await request.bodyBytes.toBytes(); | 18 | var requestBody = await request.bodyBytes.toBytes(); |
19 | - var bodyBytes = BodyBytesStream.fromBytes(requestBody ?? const []); | 19 | + var bodyBytes = BodyBytesStream.fromBytes(requestBody); |
20 | 20 | ||
21 | var response = await _handler(request); | 21 | var response = await _handler(request); |
22 | 22 | ||
23 | - final stringBody = await bodyBytesToString(bodyBytes, response.headers); | 23 | + final stringBody = await bodyBytesToString(bodyBytes, response.headers!); |
24 | 24 | ||
25 | - var mimeType = response.headers.containsKey('content-type') | ||
26 | - ? response.headers['content-type'] | 25 | + var mimeType = response.headers!.containsKey('content-type') |
26 | + ? response.headers!['content-type'] | ||
27 | : ''; | 27 | : ''; |
28 | 28 | ||
29 | final body = bodyDecoded<T>( | 29 | final body = bodyDecoded<T>( |
@@ -6,7 +6,7 @@ import '../interface/request_base.dart'; | @@ -6,7 +6,7 @@ import '../interface/request_base.dart'; | ||
6 | class HttpRequestImpl extends HttpRequestBase { | 6 | class HttpRequestImpl extends HttpRequestBase { |
7 | HttpRequestImpl({ | 7 | HttpRequestImpl({ |
8 | bool allowAutoSignedCert = true, | 8 | bool allowAutoSignedCert = true, |
9 | - List<TrustedCertificate> trustedCertificates, | 9 | + List<TrustedCertificate>? trustedCertificates, |
10 | }); | 10 | }); |
11 | @override | 11 | @override |
12 | void close() {} | 12 | void close() {} |
@@ -4,8 +4,8 @@ import '../../../../../get_core/get_core.dart'; | @@ -4,8 +4,8 @@ import '../../../../../get_core/get_core.dart'; | ||
4 | 4 | ||
5 | import '../../request/request.dart'; | 5 | import '../../request/request.dart'; |
6 | 6 | ||
7 | -T bodyDecoded<T>(Request<T> request, String stringBody, String mimeType) { | ||
8 | - T body; | 7 | +T? bodyDecoded<T>(Request<T> request, String stringBody, String? mimeType) { |
8 | + T? body; | ||
9 | var bodyToDecode; | 9 | var bodyToDecode; |
10 | 10 | ||
11 | if (mimeType != null && mimeType.contains('application/json')) { | 11 | if (mimeType != null && mimeType.contains('application/json')) { |
@@ -23,9 +23,9 @@ T bodyDecoded<T>(Request<T> request, String stringBody, String mimeType) { | @@ -23,9 +23,9 @@ T bodyDecoded<T>(Request<T> request, String stringBody, String mimeType) { | ||
23 | if (stringBody == '') { | 23 | if (stringBody == '') { |
24 | body = null; | 24 | body = null; |
25 | } else if (request.decoder == null) { | 25 | } else if (request.decoder == null) { |
26 | - body = bodyToDecode as T; | 26 | + body = bodyToDecode as T?; |
27 | } else { | 27 | } else { |
28 | - body = request.decoder(bodyToDecode); | 28 | + body = request.decoder!(bodyToDecode); |
29 | } | 29 | } |
30 | } on Exception catch (_) { | 30 | } on Exception catch (_) { |
31 | body = stringBody as T; | 31 | body = stringBody as T; |
@@ -3,17 +3,17 @@ import 'dart:async'; | @@ -3,17 +3,17 @@ import 'dart:async'; | ||
3 | import '../request/request.dart'; | 3 | import '../request/request.dart'; |
4 | import '../response/response.dart'; | 4 | import '../response/response.dart'; |
5 | 5 | ||
6 | -typedef RequestModifier<T> = FutureOr<Request<T>> Function(Request<T> request); | 6 | +typedef RequestModifier<T> = FutureOr<Request<T>> Function(Request<T?> request); |
7 | 7 | ||
8 | typedef ResponseModifier<T> = FutureOr Function( | 8 | typedef ResponseModifier<T> = FutureOr Function( |
9 | - Request<T> request, Response<T> response); | 9 | + Request<T?> request, Response<T?> response); |
10 | 10 | ||
11 | typedef HandlerExecute<T> = Future<Request<T>> Function(); | 11 | typedef HandlerExecute<T> = Future<Request<T>> Function(); |
12 | 12 | ||
13 | class GetModifier<T> { | 13 | class GetModifier<T> { |
14 | final _requestModifiers = <RequestModifier>[]; | 14 | final _requestModifiers = <RequestModifier>[]; |
15 | final _responseModifiers = <ResponseModifier>[]; | 15 | final _responseModifiers = <ResponseModifier>[]; |
16 | - RequestModifier authenticator; | 16 | + RequestModifier? authenticator; |
17 | 17 | ||
18 | void addRequestModifier<T>(RequestModifier<T> interceptor) { | 18 | void addRequestModifier<T>(RequestModifier<T> interceptor) { |
19 | _requestModifiers.add(interceptor as RequestModifier); | 19 | _requestModifiers.add(interceptor as RequestModifier); |
@@ -57,9 +57,7 @@ class FormData { | @@ -57,9 +57,7 @@ class FormData { | ||
57 | String _fileHeader(MapEntry<String, MultipartFile> file) { | 57 | String _fileHeader(MapEntry<String, MultipartFile> file) { |
58 | var header = | 58 | var header = |
59 | 'content-disposition: form-data; name="${browserEncode(file.key)}"'; | 59 | 'content-disposition: form-data; name="${browserEncode(file.key)}"'; |
60 | - if (file.value.filename != null) { | ||
61 | - header = '$header; filename="${browserEncode(file.value.filename)}"'; | ||
62 | - } | 60 | + header = '$header; filename="${browserEncode(file.value.filename)}"'; |
63 | header = '$header\r\n' | 61 | header = '$header\r\n' |
64 | 'content-type: ${file.value.contentType}'; | 62 | 'content-type: ${file.value.contentType}'; |
65 | return '$header\r\n\r\n'; | 63 | return '$header\r\n\r\n'; |
@@ -83,7 +81,7 @@ class FormData { | @@ -83,7 +81,7 @@ class FormData { | ||
83 | _maxBoundaryLength + | 81 | _maxBoundaryLength + |
84 | '\r\n'.length + | 82 | '\r\n'.length + |
85 | utf8.encode(_fileHeader(file)).length + | 83 | utf8.encode(_fileHeader(file)).length + |
86 | - file.value.length + | 84 | + file.value.length! + |
87 | '\r\n'.length; | 85 | '\r\n'.length; |
88 | } | 86 | } |
89 | 87 | ||
@@ -109,7 +107,7 @@ class FormData { | @@ -109,7 +107,7 @@ class FormData { | ||
109 | for (final file in files) { | 107 | for (final file in files) { |
110 | yield separator; | 108 | yield separator; |
111 | yield utf8.encode(_fileHeader(file)); | 109 | yield utf8.encode(_fileHeader(file)); |
112 | - yield* file.value.stream; | 110 | + yield* file.value.stream!; |
113 | yield line; | 111 | yield line; |
114 | } | 112 | } |
115 | yield close; | 113 | yield close; |
1 | -import 'package:flutter/foundation.dart'; | ||
2 | - | ||
3 | import '../http/stub/file_decoder_stub.dart' | 1 | import '../http/stub/file_decoder_stub.dart' |
4 | if (dart.library.html) '../http/html/file_decoder_html.dart' | 2 | if (dart.library.html) '../http/html/file_decoder_html.dart' |
5 | if (dart.library.io) '../http/io/file_decoder_io.dart'; | 3 | if (dart.library.io) '../http/io/file_decoder_io.dart'; |
@@ -9,7 +7,7 @@ import '../request/request.dart'; | @@ -9,7 +7,7 @@ import '../request/request.dart'; | ||
9 | class MultipartFile { | 7 | class MultipartFile { |
10 | MultipartFile( | 8 | MultipartFile( |
11 | dynamic data, { | 9 | dynamic data, { |
12 | - @required this.filename, | 10 | + required this.filename, |
13 | this.contentType = 'application/octet-stream', | 11 | this.contentType = 'application/octet-stream', |
14 | }) : _bytes = fileToBytes(data) { | 12 | }) : _bytes = fileToBytes(data) { |
15 | _length = _bytes.length; | 13 | _length = _bytes.length; |
@@ -21,13 +19,13 @@ class MultipartFile { | @@ -21,13 +19,13 @@ class MultipartFile { | ||
21 | final String contentType; | 19 | final String contentType; |
22 | 20 | ||
23 | /// This stream will emit the file content of File. | 21 | /// This stream will emit the file content of File. |
24 | - BodyBytesStream _stream; | 22 | + Stream<List<int>>? _stream; |
25 | 23 | ||
26 | - int _length; | 24 | + int? _length; |
27 | 25 | ||
28 | - BodyBytesStream get stream => _stream; | 26 | + Stream<List<int>>? get stream => _stream; |
29 | 27 | ||
30 | - int get length => _length; | 28 | + int? get length => _length; |
31 | 29 | ||
32 | final String filename; | 30 | final String filename; |
33 | } | 31 | } |
@@ -2,8 +2,6 @@ import 'dart:async'; | @@ -2,8 +2,6 @@ import 'dart:async'; | ||
2 | import 'dart:convert'; | 2 | import 'dart:convert'; |
3 | import 'dart:typed_data'; | 3 | import 'dart:typed_data'; |
4 | 4 | ||
5 | -import 'package:flutter/foundation.dart'; | ||
6 | - | ||
7 | import '../http.dart'; | 5 | import '../http.dart'; |
8 | import '../multipart/form_data.dart'; | 6 | import '../multipart/form_data.dart'; |
9 | 7 | ||
@@ -14,16 +12,16 @@ class Request<T> { | @@ -14,16 +12,16 @@ class Request<T> { | ||
14 | /// The [Uri] from request | 12 | /// The [Uri] from request |
15 | final Uri url; | 13 | final Uri url; |
16 | 14 | ||
17 | - final Decoder<T> decoder; | 15 | + final Decoder<T>? decoder; |
18 | 16 | ||
19 | /// The Http Method from this [Request] | 17 | /// The Http Method from this [Request] |
20 | /// ex: `GET`,`POST`,`PUT`,`DELETE` | 18 | /// ex: `GET`,`POST`,`PUT`,`DELETE` |
21 | final String method; | 19 | final String method; |
22 | 20 | ||
23 | - final int contentLength; | 21 | + final int? contentLength; |
24 | 22 | ||
25 | /// The BodyBytesStream of body from this [Request] | 23 | /// The BodyBytesStream of body from this [Request] |
26 | - final BodyBytesStream bodyBytes; | 24 | + final Stream<List<int>> bodyBytes; |
27 | 25 | ||
28 | /// When true, the client will follow redirects to resolves this [Request] | 26 | /// When true, the client will follow redirects to resolves this [Request] |
29 | final bool followRedirects; | 27 | final bool followRedirects; |
@@ -33,45 +31,41 @@ class Request<T> { | @@ -33,45 +31,41 @@ class Request<T> { | ||
33 | 31 | ||
34 | final bool persistentConnection; | 32 | final bool persistentConnection; |
35 | 33 | ||
36 | - final FormData files; | 34 | + final FormData? files; |
37 | 35 | ||
38 | const Request._({ | 36 | const Request._({ |
39 | - @required this.method, | ||
40 | - @required this.bodyBytes, | ||
41 | - @required this.url, | ||
42 | - @required this.headers, | ||
43 | - @required this.contentLength, | ||
44 | - @required this.followRedirects, | ||
45 | - @required this.maxRedirects, | ||
46 | - @required this.files, | ||
47 | - @required this.persistentConnection, | ||
48 | - @required this.decoder, | 37 | + required this.method, |
38 | + required this.bodyBytes, | ||
39 | + required this.url, | ||
40 | + required this.headers, | ||
41 | + required this.contentLength, | ||
42 | + required this.followRedirects, | ||
43 | + required this.maxRedirects, | ||
44 | + required this.files, | ||
45 | + required this.persistentConnection, | ||
46 | + required this.decoder, | ||
49 | }); | 47 | }); |
50 | 48 | ||
51 | factory Request({ | 49 | factory Request({ |
52 | - @required Uri url, | ||
53 | - @required String method, | ||
54 | - @required Map<String, String> headers, | ||
55 | - BodyBytesStream bodyBytes, | 50 | + required Uri url, |
51 | + required String method, | ||
52 | + required Map<String, String> headers, | ||
53 | + Stream<List<int>>? bodyBytes, | ||
56 | bool followRedirects = true, | 54 | bool followRedirects = true, |
57 | int maxRedirects = 4, | 55 | int maxRedirects = 4, |
58 | - int contentLength, | ||
59 | - FormData files, | 56 | + int? contentLength, |
57 | + FormData? files, | ||
60 | bool persistentConnection = true, | 58 | bool persistentConnection = true, |
61 | - Decoder<T> decoder, | 59 | + Decoder<T>? decoder, |
62 | }) { | 60 | }) { |
63 | - assert(url != null); | ||
64 | - assert(method != null); | ||
65 | - assert(followRedirects != null); | ||
66 | if (followRedirects) { | 61 | if (followRedirects) { |
67 | - assert(maxRedirects != null); | ||
68 | assert(maxRedirects > 0); | 62 | assert(maxRedirects > 0); |
69 | } | 63 | } |
70 | return Request._( | 64 | return Request._( |
71 | url: url, | 65 | url: url, |
72 | method: method, | 66 | method: method, |
73 | bodyBytes: bodyBytes ??= BodyBytesStream.fromBytes(const []), | 67 | bodyBytes: bodyBytes ??= BodyBytesStream.fromBytes(const []), |
74 | - headers: Map.from(headers ??= <String, String>{}), | 68 | + headers: Map.from(headers), |
75 | followRedirects: followRedirects, | 69 | followRedirects: followRedirects, |
76 | maxRedirects: maxRedirects, | 70 | maxRedirects: maxRedirects, |
77 | contentLength: contentLength, | 71 | contentLength: contentLength, |
@@ -82,11 +76,9 @@ class Request<T> { | @@ -82,11 +76,9 @@ class Request<T> { | ||
82 | } | 76 | } |
83 | } | 77 | } |
84 | 78 | ||
85 | -class BodyBytesStream extends StreamView<List<int>> { | ||
86 | - BodyBytesStream(Stream<List<int>> stream) : super(stream); | ||
87 | - | ||
88 | - factory BodyBytesStream.fromBytes(List<int> bytes) => | ||
89 | - BodyBytesStream(Stream.fromIterable([bytes])); | 79 | +extension BodyBytesStream on Stream<List<int>> { |
80 | + static Stream<List<int>> fromBytes(List<int> bytes) => | ||
81 | + Stream.fromIterable([bytes]); | ||
90 | 82 | ||
91 | Future<Uint8List> toBytes() { | 83 | Future<Uint8List> toBytes() { |
92 | var completer = Completer<Uint8List>(); | 84 | var completer = Completer<Uint8List>(); |
@@ -95,7 +87,7 @@ class BodyBytesStream extends StreamView<List<int>> { | @@ -95,7 +87,7 @@ class BodyBytesStream extends StreamView<List<int>> { | ||
95 | Uint8List.fromList(bytes), | 87 | Uint8List.fromList(bytes), |
96 | ), | 88 | ), |
97 | ); | 89 | ); |
98 | - listen(sink.add, | 90 | + listen((val) => sink.add(val), |
99 | onError: completer.completeError, | 91 | onError: completer.completeError, |
100 | onDone: sink.close, | 92 | onDone: sink.close, |
101 | cancelOnError: true); | 93 | cancelOnError: true); |
@@ -5,8 +5,8 @@ import '../request/request.dart'; | @@ -5,8 +5,8 @@ import '../request/request.dart'; | ||
5 | import '../status/http_status.dart'; | 5 | import '../status/http_status.dart'; |
6 | 6 | ||
7 | class GraphQLResponse<T> extends Response<T> { | 7 | class GraphQLResponse<T> extends Response<T> { |
8 | - final List<GraphQLError> graphQLErrors; | ||
9 | - GraphQLResponse({T body, this.graphQLErrors}) : super(body: body); | 8 | + final List<GraphQLError>? graphQLErrors; |
9 | + GraphQLResponse({T? body, this.graphQLErrors}) : super(body: body); | ||
10 | } | 10 | } |
11 | 11 | ||
12 | class Response<T> { | 12 | class Response<T> { |
@@ -21,16 +21,16 @@ class Response<T> { | @@ -21,16 +21,16 @@ class Response<T> { | ||
21 | }); | 21 | }); |
22 | 22 | ||
23 | /// The Http [Request] linked with this [Response]. | 23 | /// The Http [Request] linked with this [Response]. |
24 | - final Request request; | 24 | + final Request? request; |
25 | 25 | ||
26 | /// The response headers. | 26 | /// The response headers. |
27 | - final Map<String, String> headers; | 27 | + final Map<String, String>? headers; |
28 | 28 | ||
29 | /// The status code returned by the server. | 29 | /// The status code returned by the server. |
30 | - final int statusCode; | 30 | + final int? statusCode; |
31 | 31 | ||
32 | /// Human-readable context for [statusCode]. | 32 | /// Human-readable context for [statusCode]. |
33 | - final String statusText; | 33 | + final String? statusText; |
34 | 34 | ||
35 | /// [HttpStatus] from [Response]. `status.connectionError` is true | 35 | /// [HttpStatus] from [Response]. `status.connectionError` is true |
36 | /// when statusCode is null. `status.isUnauthorized` is true when | 36 | /// when statusCode is null. `status.isUnauthorized` is true when |
@@ -49,19 +49,19 @@ class Response<T> { | @@ -49,19 +49,19 @@ class Response<T> { | ||
49 | bool get unauthorized => status.isUnauthorized; | 49 | bool get unauthorized => status.isUnauthorized; |
50 | 50 | ||
51 | /// The response body as a Stream of Bytes. | 51 | /// The response body as a Stream of Bytes. |
52 | - final BodyBytesStream bodyBytes; | 52 | + final Stream<List<int>>? bodyBytes; |
53 | 53 | ||
54 | /// The response body as a Stream of Bytes. | 54 | /// The response body as a Stream of Bytes. |
55 | - final String bodyString; | 55 | + final String? bodyString; |
56 | 56 | ||
57 | /// The decoded body of this [Response]. You can access the | 57 | /// The decoded body of this [Response]. You can access the |
58 | /// body parameters as Map | 58 | /// body parameters as Map |
59 | /// Ex: body['title']; | 59 | /// Ex: body['title']; |
60 | - final T body; | 60 | + final T? body; |
61 | } | 61 | } |
62 | 62 | ||
63 | Future<String> bodyBytesToString( | 63 | Future<String> bodyBytesToString( |
64 | - BodyBytesStream bodyBytes, Map<String, String> headers) { | 64 | + Stream<List<int>> bodyBytes, Map<String, String> headers) { |
65 | return bodyBytes.bytesToString(_encodingForHeaders(headers)); | 65 | return bodyBytes.bytesToString(_encodingForHeaders(headers)); |
66 | } | 66 | } |
67 | 67 | ||
@@ -70,13 +70,13 @@ Future<String> bodyBytesToString( | @@ -70,13 +70,13 @@ Future<String> bodyBytesToString( | ||
70 | /// Defaults to [latin1] if the headers don't specify a charset or if that | 70 | /// Defaults to [latin1] if the headers don't specify a charset or if that |
71 | /// charset is unknown. | 71 | /// charset is unknown. |
72 | Encoding _encodingForHeaders(Map<String, String> headers) => | 72 | Encoding _encodingForHeaders(Map<String, String> headers) => |
73 | - _encodingForCharset(_contentTypeForHeaders(headers).parameters['charset']); | 73 | + _encodingForCharset(_contentTypeForHeaders(headers).parameters!['charset']); |
74 | 74 | ||
75 | /// Returns the [Encoding] that corresponds to [charset]. | 75 | /// Returns the [Encoding] that corresponds to [charset]. |
76 | /// | 76 | /// |
77 | /// Returns [fallback] if [charset] is null or if no [Encoding] was found that | 77 | /// Returns [fallback] if [charset] is null or if no [Encoding] was found that |
78 | /// corresponds to [charset]. | 78 | /// corresponds to [charset]. |
79 | -Encoding _encodingForCharset(String charset, [Encoding fallback = latin1]) { | 79 | +Encoding _encodingForCharset(String? charset, [Encoding fallback = latin1]) { |
80 | if (charset == null) return fallback; | 80 | if (charset == null) return fallback; |
81 | return Encoding.getByName(charset) ?? fallback; | 81 | return Encoding.getByName(charset) ?? fallback; |
82 | } | 82 | } |
@@ -92,10 +92,10 @@ HeaderValue _contentTypeForHeaders(Map<String, String> headers) { | @@ -92,10 +92,10 @@ HeaderValue _contentTypeForHeaders(Map<String, String> headers) { | ||
92 | 92 | ||
93 | class HeaderValue { | 93 | class HeaderValue { |
94 | String _value; | 94 | String _value; |
95 | - Map<String, String> _parameters; | ||
96 | - Map<String, String> _unmodifiableParameters; | 95 | + Map<String, String?>? _parameters; |
96 | + Map<String, String?>? _unmodifiableParameters; | ||
97 | 97 | ||
98 | - HeaderValue([this._value = '', Map<String, String> parameters]) { | 98 | + HeaderValue([this._value = '', Map<String, String>? parameters]) { |
99 | if (parameters != null) { | 99 | if (parameters != null) { |
100 | _parameters = HashMap<String, String>.from(parameters); | 100 | _parameters = HashMap<String, String>.from(parameters); |
101 | } | 101 | } |
@@ -103,7 +103,7 @@ class HeaderValue { | @@ -103,7 +103,7 @@ class HeaderValue { | ||
103 | 103 | ||
104 | static HeaderValue parse(String value, | 104 | static HeaderValue parse(String value, |
105 | {String parameterSeparator = ';', | 105 | {String parameterSeparator = ';', |
106 | - String valueSeparator, | 106 | + String? valueSeparator, |
107 | bool preserveBackslash = false}) { | 107 | bool preserveBackslash = false}) { |
108 | var result = HeaderValue(); | 108 | var result = HeaderValue(); |
109 | result._parse(value, parameterSeparator, valueSeparator, preserveBackslash); | 109 | result._parse(value, parameterSeparator, valueSeparator, preserveBackslash); |
@@ -116,9 +116,9 @@ class HeaderValue { | @@ -116,9 +116,9 @@ class HeaderValue { | ||
116 | _parameters ??= HashMap<String, String>(); | 116 | _parameters ??= HashMap<String, String>(); |
117 | } | 117 | } |
118 | 118 | ||
119 | - Map<String, String> get parameters { | 119 | + Map<String, String?>? get parameters { |
120 | _ensureParameters(); | 120 | _ensureParameters(); |
121 | - _unmodifiableParameters ??= UnmodifiableMapView(_parameters); | 121 | + _unmodifiableParameters ??= UnmodifiableMapView(_parameters!); |
122 | return _unmodifiableParameters; | 122 | return _unmodifiableParameters; |
123 | } | 123 | } |
124 | 124 | ||
@@ -126,15 +126,15 @@ class HeaderValue { | @@ -126,15 +126,15 @@ class HeaderValue { | ||
126 | String toString() { | 126 | String toString() { |
127 | var stringBuffer = StringBuffer(); | 127 | var stringBuffer = StringBuffer(); |
128 | stringBuffer.write(_value); | 128 | stringBuffer.write(_value); |
129 | - if (parameters != null && parameters.isNotEmpty) { | ||
130 | - _parameters.forEach((name, value) { | 129 | + if (parameters != null && parameters!.isNotEmpty) { |
130 | + _parameters!.forEach((name, value) { | ||
131 | stringBuffer..write('; ')..write(name)..write('=')..write(value); | 131 | stringBuffer..write('; ')..write(name)..write('=')..write(value); |
132 | }); | 132 | }); |
133 | } | 133 | } |
134 | return stringBuffer.toString(); | 134 | return stringBuffer.toString(); |
135 | } | 135 | } |
136 | 136 | ||
137 | - void _parse(String value, String parameterSeparator, String valueSeparator, | 137 | + void _parse(String value, String parameterSeparator, String? valueSeparator, |
138 | bool preserveBackslash) { | 138 | bool preserveBackslash) { |
139 | var index = 0; | 139 | var index = 0; |
140 | 140 | ||
@@ -173,7 +173,7 @@ class HeaderValue { | @@ -173,7 +173,7 @@ class HeaderValue { | ||
173 | } | 173 | } |
174 | 174 | ||
175 | void parseParameters() { | 175 | void parseParameters() { |
176 | - var parameters = HashMap<String, String>(); | 176 | + var parameters = HashMap<String, String?>(); |
177 | _parameters = UnmodifiableMapView(parameters); | 177 | _parameters = UnmodifiableMapView(parameters); |
178 | 178 | ||
179 | String parseParameterName() { | 179 | String parseParameterName() { |
@@ -191,7 +191,7 @@ class HeaderValue { | @@ -191,7 +191,7 @@ class HeaderValue { | ||
191 | return value.substring(start, index).toLowerCase(); | 191 | return value.substring(start, index).toLowerCase(); |
192 | } | 192 | } |
193 | 193 | ||
194 | - String parseParameterValue() { | 194 | + String? parseParameterValue() { |
195 | if (!done() && value[index] == '\"') { | 195 | if (!done() && value[index] == '\"') { |
196 | var stringBuffer = StringBuffer(); | 196 | var stringBuffer = StringBuffer(); |
197 | index++; | 197 | index++; |
1 | class HttpStatus { | 1 | class HttpStatus { |
2 | HttpStatus(this.code); | 2 | HttpStatus(this.code); |
3 | 3 | ||
4 | - final int code; | 4 | + final int? code; |
5 | 5 | ||
6 | static const int continue_ = 100; | 6 | static const int continue_ = 100; |
7 | static const int switchingProtocols = 101; | 7 | static const int switchingProtocols = 101; |
@@ -83,7 +83,7 @@ class HttpStatus { | @@ -83,7 +83,7 @@ class HttpStatus { | ||
83 | between(internalServerError, networkConnectTimeoutError); | 83 | between(internalServerError, networkConnectTimeoutError); |
84 | 84 | ||
85 | bool between(int begin, int end) { | 85 | bool between(int begin, int end) { |
86 | - return !connectionError && code >= begin && code <= end; | 86 | + return !connectionError && code! >= begin && code! <= end; |
87 | } | 87 | } |
88 | 88 | ||
89 | bool get isOk => between(200, 299); | 89 | bool get isOk => between(200, 299); |
1 | -import 'dart:async'; | ||
2 | import 'dart:convert'; | 1 | import 'dart:convert'; |
3 | -import '../request/request.dart'; | ||
4 | 2 | ||
5 | bool isTokenChar(int byte) { | 3 | bool isTokenChar(int byte) { |
6 | return byte > 31 && byte < 128 && !SEPARATOR_MAP[byte]; | 4 | return byte > 31 && byte < 128 && !SEPARATOR_MAP[byte]; |
@@ -52,10 +50,9 @@ String validateField(String field) { | @@ -52,10 +50,9 @@ String validateField(String field) { | ||
52 | return field.toLowerCase(); | 50 | return field.toLowerCase(); |
53 | } | 51 | } |
54 | 52 | ||
55 | -BodyBytesStream toBodyBytesStream(Stream<List<int>> stream) { | ||
56 | - if (stream is BodyBytesStream) return stream; | ||
57 | - return BodyBytesStream(stream); | ||
58 | -} | 53 | +// Stream<List<int>> toBodyBytesStream(Stream<List<int>> stream) { |
54 | +// return (stream); | ||
55 | +// } | ||
59 | 56 | ||
60 | final _asciiOnly = RegExp(r'^[\x00-\x7F]+$'); | 57 | final _asciiOnly = RegExp(r'^[\x00-\x7F]+$'); |
61 | 58 |
1 | import 'dart:convert'; | 1 | import 'dart:convert'; |
2 | 2 | ||
3 | class Close { | 3 | class Close { |
4 | - final String message; | ||
5 | - final int reason; | 4 | + final String? message; |
5 | + final int? reason; | ||
6 | 6 | ||
7 | Close(this.message, this.reason); | 7 | Close(this.message, this.reason); |
8 | 8 | ||
@@ -19,31 +19,31 @@ typedef CloseSocket = void Function(Close); | @@ -19,31 +19,31 @@ typedef CloseSocket = void Function(Close); | ||
19 | typedef MessageSocket = void Function(dynamic val); | 19 | typedef MessageSocket = void Function(dynamic val); |
20 | 20 | ||
21 | class SocketNotifier { | 21 | class SocketNotifier { |
22 | - var _onMessages = <MessageSocket>[]; | ||
23 | - var _onEvents = <String, MessageSocket>{}; | ||
24 | - var _onCloses = <CloseSocket>[]; | ||
25 | - var _onErrors = <CloseSocket>[]; | 22 | + List<void Function(dynamic)>? _onMessages = <MessageSocket>[]; |
23 | + Map<String, void Function(dynamic)>? _onEvents = <String, MessageSocket>{}; | ||
24 | + List<void Function(Close)>? _onCloses = <CloseSocket>[]; | ||
25 | + List<void Function(Close)>? _onErrors = <CloseSocket>[]; | ||
26 | 26 | ||
27 | - OpenSocket open; | 27 | + late OpenSocket open; |
28 | 28 | ||
29 | void addMessages(MessageSocket socket) { | 29 | void addMessages(MessageSocket socket) { |
30 | - _onMessages.add((socket)); | 30 | + _onMessages!.add((socket)); |
31 | } | 31 | } |
32 | 32 | ||
33 | void addEvents(String event, MessageSocket socket) { | 33 | void addEvents(String event, MessageSocket socket) { |
34 | - _onEvents[event] = socket; | 34 | + _onEvents![event] = socket; |
35 | } | 35 | } |
36 | 36 | ||
37 | void addCloses(CloseSocket socket) { | 37 | void addCloses(CloseSocket socket) { |
38 | - _onCloses.add(socket); | 38 | + _onCloses!.add(socket); |
39 | } | 39 | } |
40 | 40 | ||
41 | void addErrors(CloseSocket socket) { | 41 | void addErrors(CloseSocket socket) { |
42 | - _onErrors.add((socket)); | 42 | + _onErrors!.add((socket)); |
43 | } | 43 | } |
44 | 44 | ||
45 | void notifyData(dynamic data) { | 45 | void notifyData(dynamic data) { |
46 | - for (var item in _onMessages) { | 46 | + for (var item in _onMessages!) { |
47 | item(data); | 47 | item(data); |
48 | } | 48 | } |
49 | if (data is String) { | 49 | if (data is String) { |
@@ -52,14 +52,14 @@ class SocketNotifier { | @@ -52,14 +52,14 @@ class SocketNotifier { | ||
52 | } | 52 | } |
53 | 53 | ||
54 | void notifyClose(Close err) { | 54 | void notifyClose(Close err) { |
55 | - for (var item in _onCloses) { | 55 | + for (var item in _onCloses!) { |
56 | item(err); | 56 | item(err); |
57 | } | 57 | } |
58 | } | 58 | } |
59 | 59 | ||
60 | void notifyError(Close err) { | 60 | void notifyError(Close err) { |
61 | // rooms.removeWhere((key, value) => value.contains(_ws)); | 61 | // rooms.removeWhere((key, value) => value.contains(_ws)); |
62 | - for (var item in _onErrors) { | 62 | + for (var item in _onErrors!) { |
63 | item(err); | 63 | item(err); |
64 | } | 64 | } |
65 | } | 65 | } |
@@ -69,8 +69,8 @@ class SocketNotifier { | @@ -69,8 +69,8 @@ class SocketNotifier { | ||
69 | var msg = jsonDecode(message); | 69 | var msg = jsonDecode(message); |
70 | final event = msg['type']; | 70 | final event = msg['type']; |
71 | final data = msg['data']; | 71 | final data = msg['data']; |
72 | - if (_onEvents.containsKey(event)) { | ||
73 | - _onEvents[event](data); | 72 | + if (_onEvents!.containsKey(event)) { |
73 | + _onEvents![event]!(data); | ||
74 | } | 74 | } |
75 | } on Exception catch (_) { | 75 | } on Exception catch (_) { |
76 | return; | 76 | return; |
@@ -15,8 +15,8 @@ enum ConnectionStatus { | @@ -15,8 +15,8 @@ enum ConnectionStatus { | ||
15 | 15 | ||
16 | class BaseWebSocket { | 16 | class BaseWebSocket { |
17 | String url; | 17 | String url; |
18 | - WebSocket socket; | ||
19 | - SocketNotifier socketNotifier = SocketNotifier(); | 18 | + WebSocket? socket; |
19 | + SocketNotifier? socketNotifier = SocketNotifier(); | ||
20 | Duration ping; | 20 | Duration ping; |
21 | bool isDisposed = false; | 21 | bool isDisposed = false; |
22 | bool allowSelfSigned; | 22 | bool allowSelfSigned; |
@@ -30,39 +30,39 @@ class BaseWebSocket { | @@ -30,39 +30,39 @@ class BaseWebSocket { | ||
30 | ? url.replaceAll('https:', 'wss:') | 30 | ? url.replaceAll('https:', 'wss:') |
31 | : url.replaceAll('http:', 'ws:'); | 31 | : url.replaceAll('http:', 'ws:'); |
32 | } | 32 | } |
33 | - ConnectionStatus connectionStatus; | ||
34 | - Timer _t; | 33 | + ConnectionStatus? connectionStatus; |
34 | + Timer? _t; | ||
35 | 35 | ||
36 | void connect() { | 36 | void connect() { |
37 | try { | 37 | try { |
38 | connectionStatus = ConnectionStatus.connecting; | 38 | connectionStatus = ConnectionStatus.connecting; |
39 | socket = WebSocket(url); | 39 | socket = WebSocket(url); |
40 | - socket.onOpen.listen((e) { | 40 | + socket!.onOpen.listen((e) { |
41 | socketNotifier?.open(); | 41 | socketNotifier?.open(); |
42 | _t = Timer?.periodic(ping, (t) { | 42 | _t = Timer?.periodic(ping, (t) { |
43 | - socket.send(''); | 43 | + socket!.send(''); |
44 | }); | 44 | }); |
45 | connectionStatus = ConnectionStatus.connected; | 45 | connectionStatus = ConnectionStatus.connected; |
46 | }); | 46 | }); |
47 | 47 | ||
48 | - socket.onMessage.listen((event) { | ||
49 | - socketNotifier.notifyData(event.data); | 48 | + socket!.onMessage.listen((event) { |
49 | + socketNotifier!.notifyData(event.data); | ||
50 | }); | 50 | }); |
51 | 51 | ||
52 | - socket.onClose.listen((e) { | 52 | + socket!.onClose.listen((e) { |
53 | _t?.cancel(); | 53 | _t?.cancel(); |
54 | 54 | ||
55 | connectionStatus = ConnectionStatus.closed; | 55 | connectionStatus = ConnectionStatus.closed; |
56 | - socketNotifier.notifyClose(Close(e.reason, e.code)); | 56 | + socketNotifier!.notifyClose(Close(e.reason, e.code)); |
57 | }); | 57 | }); |
58 | - socket.onError.listen((event) { | 58 | + socket!.onError.listen((event) { |
59 | _t?.cancel(); | 59 | _t?.cancel(); |
60 | - socketNotifier.notifyError(Close(event.toString(), 0)); | 60 | + socketNotifier!.notifyError(Close(event.toString(), 0)); |
61 | connectionStatus = ConnectionStatus.closed; | 61 | connectionStatus = ConnectionStatus.closed; |
62 | }); | 62 | }); |
63 | } on Exception catch (e) { | 63 | } on Exception catch (e) { |
64 | _t?.cancel(); | 64 | _t?.cancel(); |
65 | - socketNotifier.notifyError(Close(e.toString(), 500)); | 65 | + socketNotifier!.notifyError(Close(e.toString(), 500)); |
66 | connectionStatus = ConnectionStatus.closed; | 66 | connectionStatus = ConnectionStatus.closed; |
67 | // close(500, e.toString()); | 67 | // close(500, e.toString()); |
68 | } | 68 | } |
@@ -70,35 +70,35 @@ class BaseWebSocket { | @@ -70,35 +70,35 @@ class BaseWebSocket { | ||
70 | 70 | ||
71 | // ignore: use_setters_to_change_properties | 71 | // ignore: use_setters_to_change_properties |
72 | void onOpen(OpenSocket fn) { | 72 | void onOpen(OpenSocket fn) { |
73 | - socketNotifier.open = fn; | 73 | + socketNotifier!.open = fn; |
74 | } | 74 | } |
75 | 75 | ||
76 | void onClose(CloseSocket fn) { | 76 | void onClose(CloseSocket fn) { |
77 | - socketNotifier.addCloses(fn); | 77 | + socketNotifier!.addCloses(fn); |
78 | } | 78 | } |
79 | 79 | ||
80 | void onError(CloseSocket fn) { | 80 | void onError(CloseSocket fn) { |
81 | - socketNotifier.addErrors(fn); | 81 | + socketNotifier!.addErrors(fn); |
82 | } | 82 | } |
83 | 83 | ||
84 | void onMessage(MessageSocket fn) { | 84 | void onMessage(MessageSocket fn) { |
85 | - socketNotifier.addMessages(fn); | 85 | + socketNotifier!.addMessages(fn); |
86 | } | 86 | } |
87 | 87 | ||
88 | void on(String event, MessageSocket message) { | 88 | void on(String event, MessageSocket message) { |
89 | - socketNotifier.addEvents(event, message); | 89 | + socketNotifier!.addEvents(event, message); |
90 | } | 90 | } |
91 | 91 | ||
92 | - void close([int status, String reason]) { | ||
93 | - if (socket != null) socket.close(status, reason); | 92 | + void close([int? status, String? reason]) { |
93 | + socket?.close(status, reason); | ||
94 | } | 94 | } |
95 | 95 | ||
96 | void send(dynamic data) { | 96 | void send(dynamic data) { |
97 | if (connectionStatus == ConnectionStatus.closed) { | 97 | if (connectionStatus == ConnectionStatus.closed) { |
98 | connect(); | 98 | connect(); |
99 | } | 99 | } |
100 | - if (socket != null && socket.readyState == WebSocket.OPEN) { | ||
101 | - socket.send(data); | 100 | + if (socket != null && socket!.readyState == WebSocket.OPEN) { |
101 | + socket!.send(data); | ||
102 | } else { | 102 | } else { |
103 | Get.log('WebSocket not connected, message $data not sent'); | 103 | Get.log('WebSocket not connected, message $data not sent'); |
104 | } | 104 | } |
@@ -109,7 +109,7 @@ class BaseWebSocket { | @@ -109,7 +109,7 @@ class BaseWebSocket { | ||
109 | } | 109 | } |
110 | 110 | ||
111 | void dispose() { | 111 | void dispose() { |
112 | - socketNotifier.dispose(); | 112 | + socketNotifier!.dispose(); |
113 | socketNotifier = null; | 113 | socketNotifier = null; |
114 | isDisposed = true; | 114 | isDisposed = true; |
115 | } | 115 | } |
@@ -15,8 +15,8 @@ enum ConnectionStatus { | @@ -15,8 +15,8 @@ enum ConnectionStatus { | ||
15 | 15 | ||
16 | class BaseWebSocket { | 16 | class BaseWebSocket { |
17 | String url; | 17 | String url; |
18 | - WebSocket socket; | ||
19 | - SocketNotifier socketNotifier = SocketNotifier(); | 18 | + WebSocket? socket; |
19 | + SocketNotifier? socketNotifier = SocketNotifier(); | ||
20 | bool isDisposed = false; | 20 | bool isDisposed = false; |
21 | BaseWebSocket( | 21 | BaseWebSocket( |
22 | this.url, { | 22 | this.url, { |
@@ -26,7 +26,7 @@ class BaseWebSocket { | @@ -26,7 +26,7 @@ class BaseWebSocket { | ||
26 | Duration ping; | 26 | Duration ping; |
27 | bool allowSelfSigned; | 27 | bool allowSelfSigned; |
28 | 28 | ||
29 | - ConnectionStatus connectionStatus; | 29 | + ConnectionStatus? connectionStatus; |
30 | 30 | ||
31 | Future connect() async { | 31 | Future connect() async { |
32 | if (isDisposed) { | 32 | if (isDisposed) { |
@@ -38,52 +38,51 @@ class BaseWebSocket { | @@ -38,52 +38,51 @@ class BaseWebSocket { | ||
38 | ? await _connectForSelfSignedCert(url) | 38 | ? await _connectForSelfSignedCert(url) |
39 | : await WebSocket.connect(url); | 39 | : await WebSocket.connect(url); |
40 | 40 | ||
41 | - socket.pingInterval = ping; | 41 | + socket!.pingInterval = ping; |
42 | socketNotifier?.open(); | 42 | socketNotifier?.open(); |
43 | connectionStatus = ConnectionStatus.connected; | 43 | connectionStatus = ConnectionStatus.connected; |
44 | 44 | ||
45 | - socket.listen((data) { | ||
46 | - socketNotifier.notifyData(data); | 45 | + socket!.listen((data) { |
46 | + socketNotifier!.notifyData(data); | ||
47 | }, onError: (err) { | 47 | }, onError: (err) { |
48 | - socketNotifier.notifyError(Close(err.toString(), 1005)); | 48 | + socketNotifier!.notifyError(Close(err.toString(), 1005)); |
49 | }, onDone: () { | 49 | }, onDone: () { |
50 | connectionStatus = ConnectionStatus.closed; | 50 | connectionStatus = ConnectionStatus.closed; |
51 | - socketNotifier | ||
52 | - .notifyClose(Close('Connection Closed', socket.closeCode)); | 51 | + socketNotifier! |
52 | + .notifyClose(Close('Connection Closed', socket!.closeCode)); | ||
53 | }, cancelOnError: true); | 53 | }, cancelOnError: true); |
54 | return; | 54 | return; |
55 | } on SocketException catch (e) { | 55 | } on SocketException catch (e) { |
56 | connectionStatus = ConnectionStatus.closed; | 56 | connectionStatus = ConnectionStatus.closed; |
57 | - socketNotifier.notifyError(Close(e.osError.message, e.osError.errorCode)); | 57 | + socketNotifier! |
58 | + .notifyError(Close(e.osError!.message, e.osError!.errorCode)); | ||
58 | return; | 59 | return; |
59 | } | 60 | } |
60 | } | 61 | } |
61 | 62 | ||
62 | // ignore: use_setters_to_change_properties | 63 | // ignore: use_setters_to_change_properties |
63 | void onOpen(OpenSocket fn) { | 64 | void onOpen(OpenSocket fn) { |
64 | - socketNotifier.open = fn; | 65 | + socketNotifier!.open = fn; |
65 | } | 66 | } |
66 | 67 | ||
67 | void onClose(CloseSocket fn) { | 68 | void onClose(CloseSocket fn) { |
68 | - socketNotifier.addCloses(fn); | 69 | + socketNotifier!.addCloses(fn); |
69 | } | 70 | } |
70 | 71 | ||
71 | void onError(CloseSocket fn) { | 72 | void onError(CloseSocket fn) { |
72 | - socketNotifier.addErrors(fn); | 73 | + socketNotifier!.addErrors(fn); |
73 | } | 74 | } |
74 | 75 | ||
75 | void onMessage(MessageSocket fn) { | 76 | void onMessage(MessageSocket fn) { |
76 | - socketNotifier.addMessages(fn); | 77 | + socketNotifier!.addMessages(fn); |
77 | } | 78 | } |
78 | 79 | ||
79 | void on(String event, MessageSocket message) { | 80 | void on(String event, MessageSocket message) { |
80 | - socketNotifier.addEvents(event, message); | 81 | + socketNotifier!.addEvents(event, message); |
81 | } | 82 | } |
82 | 83 | ||
83 | - void close([int status, String reason]) { | ||
84 | - if (socket != null) { | ||
85 | - socket.close(status, reason); | ||
86 | - } | 84 | + void close([int? status, String? reason]) { |
85 | + socket?.close(status, reason); | ||
87 | } | 86 | } |
88 | 87 | ||
89 | void send(dynamic data) async { | 88 | void send(dynamic data) async { |
@@ -92,12 +91,12 @@ class BaseWebSocket { | @@ -92,12 +91,12 @@ class BaseWebSocket { | ||
92 | } | 91 | } |
93 | 92 | ||
94 | if (socket != null) { | 93 | if (socket != null) { |
95 | - socket.add(data); | 94 | + socket!.add(data); |
96 | } | 95 | } |
97 | } | 96 | } |
98 | 97 | ||
99 | void dispose() { | 98 | void dispose() { |
100 | - socketNotifier.dispose(); | 99 | + socketNotifier!.dispose(); |
101 | socketNotifier = null; | 100 | socketNotifier = null; |
102 | isDisposed = true; | 101 | isDisposed = true; |
103 | } | 102 | } |
@@ -36,7 +36,7 @@ class BaseWebSocket { | @@ -36,7 +36,7 @@ class BaseWebSocket { | ||
36 | throw 'To use sockets you need dart:io or dart:html'; | 36 | throw 'To use sockets you need dart:io or dart:html'; |
37 | } | 37 | } |
38 | 38 | ||
39 | - void close([int status, String reason]) { | 39 | + void close([int? status, String? reason]) { |
40 | throw 'To use sockets you need dart:io or dart:html'; | 40 | throw 'To use sockets you need dart:io or dart:html'; |
41 | } | 41 | } |
42 | 42 |
@@ -5,7 +5,7 @@ import 'smart_management.dart'; | @@ -5,7 +5,7 @@ import 'smart_management.dart'; | ||
5 | /// class through extensions | 5 | /// class through extensions |
6 | abstract class GetInterface { | 6 | abstract class GetInterface { |
7 | SmartManagement smartManagement = SmartManagement.full; | 7 | SmartManagement smartManagement = SmartManagement.full; |
8 | - String reference; | 8 | + String? reference; |
9 | bool isLogEnable = true; | 9 | bool isLogEnable = true; |
10 | LogWriterCallback log = defaultLogWriterCallback; | 10 | LogWriterCallback log = defaultLogWriterCallback; |
11 | } | 11 | } |
@@ -42,7 +42,7 @@ class BindingsBuilder<T> extends Bindings { | @@ -42,7 +42,7 @@ class BindingsBuilder<T> extends Bindings { | ||
42 | /// ), | 42 | /// ), |
43 | /// ``` | 43 | /// ``` |
44 | factory BindingsBuilder.put(InstanceBuilderCallback<T> builder, | 44 | factory BindingsBuilder.put(InstanceBuilderCallback<T> builder, |
45 | - {String tag, bool permanent = false}) { | 45 | + {String? tag, bool permanent = false}) { |
46 | return BindingsBuilder( | 46 | return BindingsBuilder( |
47 | () => GetInstance().put<T>(builder(), tag: tag, permanent: permanent)); | 47 | () => GetInstance().put<T>(builder(), tag: tag, permanent: permanent)); |
48 | } | 48 | } |
@@ -28,7 +28,7 @@ extension Inst on GetInterface { | @@ -28,7 +28,7 @@ extension Inst on GetInterface { | ||
28 | /// Subsequent calls to [Get.lazyPut()] with the same parameters | 28 | /// Subsequent calls to [Get.lazyPut()] with the same parameters |
29 | /// (<[S]> and optionally [tag] will **not** override the original). | 29 | /// (<[S]> and optionally [tag] will **not** override the original). |
30 | void lazyPut<S>(InstanceBuilderCallback<S> builder, | 30 | void lazyPut<S>(InstanceBuilderCallback<S> builder, |
31 | - {String tag, bool fenix = false}) { | 31 | + {String? tag, bool fenix = false}) { |
32 | GetInstance().lazyPut<S>(builder, tag: tag, fenix: fenix); | 32 | GetInstance().lazyPut<S>(builder, tag: tag, fenix: fenix); |
33 | } | 33 | } |
34 | 34 | ||
@@ -40,7 +40,7 @@ extension Inst on GetInterface { | @@ -40,7 +40,7 @@ extension Inst on GetInterface { | ||
40 | /// Awaits for the resolution of the Future from [builder()] parameter and | 40 | /// Awaits for the resolution of the Future from [builder()] parameter and |
41 | /// stores the Instance returned. | 41 | /// stores the Instance returned. |
42 | Future<S> putAsync<S>(AsyncInstanceBuilderCallback<S> builder, | 42 | Future<S> putAsync<S>(AsyncInstanceBuilderCallback<S> builder, |
43 | - {String tag, bool permanent = false}) async => | 43 | + {String? tag, bool permanent = false}) async => |
44 | GetInstance().putAsync<S>(builder, tag: tag, permanent: permanent); | 44 | GetInstance().putAsync<S>(builder, tag: tag, permanent: permanent); |
45 | 45 | ||
46 | /// Creates a new Class Instance [S] from the builder callback[S]. | 46 | /// Creates a new Class Instance [S] from the builder callback[S]. |
@@ -61,13 +61,13 @@ extension Inst on GetInterface { | @@ -61,13 +61,13 @@ extension Inst on GetInterface { | ||
61 | /// Repl b = find(); | 61 | /// Repl b = find(); |
62 | /// print(a==b); (false)``` | 62 | /// print(a==b); (false)``` |
63 | void create<S>(InstanceBuilderCallback<S> builder, | 63 | void create<S>(InstanceBuilderCallback<S> builder, |
64 | - {String tag, bool permanent = true}) => | 64 | + {String? tag, bool permanent = true}) => |
65 | GetInstance().create<S>(builder, tag: tag, permanent: permanent); | 65 | GetInstance().create<S>(builder, tag: tag, permanent: permanent); |
66 | 66 | ||
67 | /// Finds a Instance of the required Class <[S]>(or [tag]) | 67 | /// Finds a Instance of the required Class <[S]>(or [tag]) |
68 | /// In the case of using [Get.create()], it will generate an Instance | 68 | /// In the case of using [Get.create()], it will generate an Instance |
69 | /// each time you call [Get.find()]. | 69 | /// each time you call [Get.find()]. |
70 | - S find<S>({String tag}) => GetInstance().find<S>(tag: tag); | 70 | + S find<S>({String? tag}) => GetInstance().find<S>(tag: tag); |
71 | 71 | ||
72 | /// Injects an [Instance<S>] in memory. | 72 | /// Injects an [Instance<S>] in memory. |
73 | /// | 73 | /// |
@@ -84,9 +84,9 @@ extension Inst on GetInterface { | @@ -84,9 +84,9 @@ extension Inst on GetInterface { | ||
84 | /// and [Get.delete()] | 84 | /// and [Get.delete()] |
85 | /// - [builder] If defined, the [dependency] must be returned from here | 85 | /// - [builder] If defined, the [dependency] must be returned from here |
86 | S put<S>(S dependency, | 86 | S put<S>(S dependency, |
87 | - {String tag, | 87 | + {String? tag, |
88 | bool permanent = false, | 88 | bool permanent = false, |
89 | - InstanceBuilderCallback<S> builder}) => | 89 | + InstanceBuilderCallback<S>? builder}) => |
90 | GetInstance().put<S>(dependency, tag: tag, permanent: permanent); | 90 | GetInstance().put<S>(dependency, tag: tag, permanent: permanent); |
91 | 91 | ||
92 | /// Clears all registered instances (and/or tags). | 92 | /// Clears all registered instances (and/or tags). |
@@ -104,15 +104,21 @@ extension Inst on GetInterface { | @@ -104,15 +104,21 @@ extension Inst on GetInterface { | ||
104 | /// | 104 | /// |
105 | /// - [tag] Optional "tag" used to register the Instance | 105 | /// - [tag] Optional "tag" used to register the Instance |
106 | /// - [force] Will delete an Instance even if marked as [permanent]. | 106 | /// - [force] Will delete an Instance even if marked as [permanent]. |
107 | - Future<bool> delete<S>({String tag, bool force = false}) async => | 107 | + Future<bool> delete<S>({String? tag, bool force = false}) async => |
108 | GetInstance().delete<S>(tag: tag, force: force); | 108 | GetInstance().delete<S>(tag: tag, force: force); |
109 | 109 | ||
110 | + void reloadAll({bool force = false}) => GetInstance().reloadAll(force: force); | ||
111 | + | ||
112 | + void reload<S>({String? tag, String? key, bool force = false}) => | ||
113 | + GetInstance().reload<S>(tag: tag, key: key, force: force); | ||
114 | + | ||
110 | /// Checks if a Class Instance<[S]> (or [tag]) is registered in memory. | 115 | /// Checks if a Class Instance<[S]> (or [tag]) is registered in memory. |
111 | /// - [tag] optional, if you use a [tag] to register the Instance. | 116 | /// - [tag] optional, if you use a [tag] to register the Instance. |
112 | - bool isRegistered<S>({String tag}) => GetInstance().isRegistered<S>(tag: tag); | 117 | + bool isRegistered<S>({String? tag}) => |
118 | + GetInstance().isRegistered<S>(tag: tag); | ||
113 | 119 | ||
114 | /// Checks if an Instance<[S]> (or [tag]) returned from a factory builder | 120 | /// Checks if an Instance<[S]> (or [tag]) returned from a factory builder |
115 | /// [Get.lazyPut()], is registered in memory. | 121 | /// [Get.lazyPut()], is registered in memory. |
116 | /// - [tag] optional, if you use a [tag] to register the Instance. | 122 | /// - [tag] optional, if you use a [tag] to register the Instance. |
117 | - bool isPrepared<S>({String tag}) => GetInstance().isPrepared<S>(tag: tag); | 123 | + bool isPrepared<S>({String? tag}) => GetInstance().isPrepared<S>(tag: tag); |
118 | } | 124 | } |
1 | import 'dart:async'; | 1 | import 'dart:async'; |
2 | import 'dart:collection'; | 2 | import 'dart:collection'; |
3 | 3 | ||
4 | -import 'package:flutter/foundation.dart'; | ||
5 | - | ||
6 | import '../../get_core/get_core.dart'; | 4 | import '../../get_core/get_core.dart'; |
7 | 5 | ||
8 | import 'lifecycle.dart'; | 6 | import 'lifecycle.dart'; |
9 | 7 | ||
10 | class InstanceInfo { | 8 | class InstanceInfo { |
11 | - final bool isPermanent; | ||
12 | - final bool isSingleton; | ||
13 | - bool get isCreate => !isSingleton; | 9 | + final bool? isPermanent; |
10 | + final bool? isSingleton; | ||
11 | + bool get isCreate => !isSingleton!; | ||
14 | final bool isRegistered; | 12 | final bool isRegistered; |
15 | final bool isPrepared; | 13 | final bool isPrepared; |
16 | - final bool isInit; | 14 | + final bool? isInit; |
17 | const InstanceInfo({ | 15 | const InstanceInfo({ |
18 | - @required this.isPermanent, | ||
19 | - @required this.isSingleton, | ||
20 | - @required this.isRegistered, | ||
21 | - @required this.isPrepared, | ||
22 | - @required this.isInit, | 16 | + required this.isPermanent, |
17 | + required this.isSingleton, | ||
18 | + required this.isRegistered, | ||
19 | + required this.isPrepared, | ||
20 | + required this.isInit, | ||
23 | }); | 21 | }); |
24 | } | 22 | } |
25 | 23 | ||
@@ -28,7 +26,7 @@ class GetInstance { | @@ -28,7 +26,7 @@ class GetInstance { | ||
28 | 26 | ||
29 | const GetInstance._(); | 27 | const GetInstance._(); |
30 | 28 | ||
31 | - static GetInstance _getInstance; | 29 | + static GetInstance? _getInstance; |
32 | 30 | ||
33 | T call<T>() => find<T>(); | 31 | T call<T>() => find<T>(); |
34 | 32 | ||
@@ -42,13 +40,13 @@ class GetInstance { | @@ -42,13 +40,13 @@ class GetInstance { | ||
42 | 40 | ||
43 | /// Holds a reference to [Get.reference] when the Instance was | 41 | /// Holds a reference to [Get.reference] when the Instance was |
44 | /// created to manage the memory. | 42 | /// created to manage the memory. |
45 | - static final Map<String, String> _routesKey = {}; | 43 | + static final Map<String, String?> _routesKey = {}; |
46 | 44 | ||
47 | /// Stores the onClose() references of instances created with [Get.create()] | 45 | /// Stores the onClose() references of instances created with [Get.create()] |
48 | /// using the [Get.reference]. | 46 | /// using the [Get.reference]. |
49 | /// Experimental feature to keep the lifecycle and memory management with | 47 | /// Experimental feature to keep the lifecycle and memory management with |
50 | /// non-singleton instances. | 48 | /// non-singleton instances. |
51 | - static final Map<String, HashSet<Function>> _routesByCreate = {}; | 49 | + static final Map<String?, HashSet<Function>> _routesByCreate = {}; |
52 | 50 | ||
53 | void printInstanceStack() { | 51 | void printInstanceStack() { |
54 | Get.log(_routesKey.toString()); | 52 | Get.log(_routesKey.toString()); |
@@ -56,7 +54,7 @@ class GetInstance { | @@ -56,7 +54,7 @@ class GetInstance { | ||
56 | 54 | ||
57 | void injector<S>( | 55 | void injector<S>( |
58 | InjectorBuilderCallback<S> fn, { | 56 | InjectorBuilderCallback<S> fn, { |
59 | - String tag, | 57 | + String? tag, |
60 | bool fenix = false, | 58 | bool fenix = false, |
61 | // bool permanent = false, | 59 | // bool permanent = false, |
62 | }) { | 60 | }) { |
@@ -73,7 +71,7 @@ class GetInstance { | @@ -73,7 +71,7 @@ class GetInstance { | ||
73 | /// stores the Instance returned. | 71 | /// stores the Instance returned. |
74 | Future<S> putAsync<S>( | 72 | Future<S> putAsync<S>( |
75 | AsyncInstanceBuilderCallback<S> builder, { | 73 | AsyncInstanceBuilderCallback<S> builder, { |
76 | - String tag, | 74 | + String? tag, |
77 | bool permanent = false, | 75 | bool permanent = false, |
78 | }) async { | 76 | }) async { |
79 | return put<S>(await builder(), tag: tag, permanent: permanent); | 77 | return put<S>(await builder(), tag: tag, permanent: permanent); |
@@ -91,9 +89,9 @@ class GetInstance { | @@ -91,9 +89,9 @@ class GetInstance { | ||
91 | /// [Get.smartManagement] rules. | 89 | /// [Get.smartManagement] rules. |
92 | S put<S>( | 90 | S put<S>( |
93 | S dependency, { | 91 | S dependency, { |
94 | - String tag, | 92 | + String? tag, |
95 | bool permanent = false, | 93 | bool permanent = false, |
96 | - @deprecated InstanceBuilderCallback<S> builder, | 94 | + @deprecated InstanceBuilderCallback<S>? builder, |
97 | }) { | 95 | }) { |
98 | _insert( | 96 | _insert( |
99 | isSingleton: true, | 97 | isSingleton: true, |
@@ -127,8 +125,8 @@ class GetInstance { | @@ -127,8 +125,8 @@ class GetInstance { | ||
127 | /// (<[S]> and optionally [tag] will **not** override the original). | 125 | /// (<[S]> and optionally [tag] will **not** override the original). |
128 | void lazyPut<S>( | 126 | void lazyPut<S>( |
129 | InstanceBuilderCallback<S> builder, { | 127 | InstanceBuilderCallback<S> builder, { |
130 | - String tag, | ||
131 | - bool fenix, | 128 | + String? tag, |
129 | + bool? fenix, | ||
132 | bool permanent = false, | 130 | bool permanent = false, |
133 | }) { | 131 | }) { |
134 | _insert( | 132 | _insert( |
@@ -158,7 +156,7 @@ class GetInstance { | @@ -158,7 +156,7 @@ class GetInstance { | ||
158 | /// print(a==b); (false)``` | 156 | /// print(a==b); (false)``` |
159 | void create<S>( | 157 | void create<S>( |
160 | InstanceBuilderCallback<S> builder, { | 158 | InstanceBuilderCallback<S> builder, { |
161 | - String tag, | 159 | + String? tag, |
162 | bool permanent = true, | 160 | bool permanent = true, |
163 | }) { | 161 | }) { |
164 | _insert( | 162 | _insert( |
@@ -171,13 +169,12 @@ class GetInstance { | @@ -171,13 +169,12 @@ class GetInstance { | ||
171 | 169 | ||
172 | /// Injects the Instance [S] builder into the [_singleton] HashMap. | 170 | /// Injects the Instance [S] builder into the [_singleton] HashMap. |
173 | void _insert<S>({ | 171 | void _insert<S>({ |
174 | - bool isSingleton, | ||
175 | - String name, | 172 | + bool? isSingleton, |
173 | + String? name, | ||
176 | bool permanent = false, | 174 | bool permanent = false, |
177 | - InstanceBuilderCallback<S> builder, | 175 | + required InstanceBuilderCallback<S> builder, |
178 | bool fenix = false, | 176 | bool fenix = false, |
179 | }) { | 177 | }) { |
180 | - assert(builder != null); | ||
181 | final key = _getKey(S, name); | 178 | final key = _getKey(S, name); |
182 | _singl.putIfAbsent( | 179 | _singl.putIfAbsent( |
183 | key, | 180 | key, |
@@ -206,14 +203,12 @@ class GetInstance { | @@ -206,14 +203,12 @@ class GetInstance { | ||
206 | 203 | ||
207 | /// Removes [Get.create()] instances registered in [routeName]. | 204 | /// Removes [Get.create()] instances registered in [routeName]. |
208 | if (_routesByCreate.containsKey(routeName)) { | 205 | if (_routesByCreate.containsKey(routeName)) { |
209 | - for (final onClose in _routesByCreate[routeName]) { | 206 | + for (final onClose in _routesByCreate[routeName]!) { |
210 | // assure the [DisposableInterface] instance holding a reference | 207 | // assure the [DisposableInterface] instance holding a reference |
211 | // to [onClose()] wasn't disposed. | 208 | // to [onClose()] wasn't disposed. |
212 | - if (onClose != null) { | ||
213 | - onClose(); | ||
214 | - } | 209 | + onClose(); |
215 | } | 210 | } |
216 | - _routesByCreate[routeName].clear(); | 211 | + _routesByCreate[routeName]!.clear(); |
217 | _routesByCreate.remove(routeName); | 212 | _routesByCreate.remove(routeName); |
218 | } | 213 | } |
219 | 214 | ||
@@ -222,7 +217,7 @@ class GetInstance { | @@ -222,7 +217,7 @@ class GetInstance { | ||
222 | } | 217 | } |
223 | 218 | ||
224 | for (final element in keysToRemove) { | 219 | for (final element in keysToRemove) { |
225 | - _routesKey?.remove(element); | 220 | + _routesKey.remove(element); |
226 | } | 221 | } |
227 | keysToRemove.clear(); | 222 | keysToRemove.clear(); |
228 | } | 223 | } |
@@ -236,14 +231,14 @@ class GetInstance { | @@ -236,14 +231,14 @@ class GetInstance { | ||
236 | /// (not for Singletons access). | 231 | /// (not for Singletons access). |
237 | /// Returns the instance if not initialized, required for Get.create() to | 232 | /// Returns the instance if not initialized, required for Get.create() to |
238 | /// work properly. | 233 | /// work properly. |
239 | - S _initDependencies<S>({String name}) { | 234 | + S? _initDependencies<S>({String? name}) { |
240 | final key = _getKey(S, name); | 235 | final key = _getKey(S, name); |
241 | - final isInit = _singl[key].isInit; | ||
242 | - S i; | 236 | + final isInit = _singl[key]!.isInit; |
237 | + S? i; | ||
243 | if (!isInit) { | 238 | if (!isInit) { |
244 | i = _startController<S>(tag: name); | 239 | i = _startController<S>(tag: name); |
245 | - if (_singl[key].isSingleton) { | ||
246 | - _singl[key].isInit = true; | 240 | + if (_singl[key]!.isSingleton!) { |
241 | + _singl[key]!.isInit = true; | ||
247 | if (Get.smartManagement != SmartManagement.onlyBuilder) { | 242 | if (Get.smartManagement != SmartManagement.onlyBuilder) { |
248 | _registerRouteInstance<S>(tag: name); | 243 | _registerRouteInstance<S>(tag: name); |
249 | } | 244 | } |
@@ -254,11 +249,11 @@ class GetInstance { | @@ -254,11 +249,11 @@ class GetInstance { | ||
254 | 249 | ||
255 | /// Links a Class instance [S] (or [tag]) to the current route. | 250 | /// Links a Class instance [S] (or [tag]) to the current route. |
256 | /// Requires usage of [GetMaterialApp]. | 251 | /// Requires usage of [GetMaterialApp]. |
257 | - void _registerRouteInstance<S>({String tag}) { | 252 | + void _registerRouteInstance<S>({String? tag}) { |
258 | _routesKey.putIfAbsent(_getKey(S, tag), () => Get.reference); | 253 | _routesKey.putIfAbsent(_getKey(S, tag), () => Get.reference); |
259 | } | 254 | } |
260 | 255 | ||
261 | - InstanceInfo getInstanceInfo<S>({String tag}) { | 256 | + InstanceInfo getInstanceInfo<S>({String? tag}) { |
262 | final build = _getDependency<S>(tag: tag); | 257 | final build = _getDependency<S>(tag: tag); |
263 | 258 | ||
264 | return InstanceInfo( | 259 | return InstanceInfo( |
@@ -270,7 +265,7 @@ class GetInstance { | @@ -270,7 +265,7 @@ class GetInstance { | ||
270 | ); | 265 | ); |
271 | } | 266 | } |
272 | 267 | ||
273 | - _InstanceBuilderFactory _getDependency<S>({String tag, String key}) { | 268 | + _InstanceBuilderFactory? _getDependency<S>({String? tag, String? key}) { |
274 | final newKey = key ?? _getKey(S, tag); | 269 | final newKey = key ?? _getKey(S, tag); |
275 | 270 | ||
276 | if (!_singl.containsKey(newKey)) { | 271 | if (!_singl.containsKey(newKey)) { |
@@ -282,31 +277,30 @@ class GetInstance { | @@ -282,31 +277,30 @@ class GetInstance { | ||
282 | } | 277 | } |
283 | 278 | ||
284 | /// Initializes the controller | 279 | /// Initializes the controller |
285 | - S _startController<S>({String tag}) { | 280 | + S _startController<S>({String? tag}) { |
286 | final key = _getKey(S, tag); | 281 | final key = _getKey(S, tag); |
287 | - final i = _singl[key].getDependency() as S; | 282 | + final i = _singl[key]!.getDependency() as S; |
288 | if (i is GetLifeCycleBase) { | 283 | if (i is GetLifeCycleBase) { |
289 | - if (i.onStart != null) { | ||
290 | - i.onStart(); | ||
291 | - if (tag == null) { | ||
292 | - Get.log('Instance "$S" has been initialized'); | ||
293 | - } else { | ||
294 | - Get.log('Instance "$S" with tag "$tag" has been initialized'); | ||
295 | - } | 284 | + i.onStart(); |
285 | + if (tag == null) { | ||
286 | + Get.log('Instance "$S" has been initialized'); | ||
287 | + } else { | ||
288 | + Get.log('Instance "$S" with tag "$tag" has been initialized'); | ||
296 | } | 289 | } |
297 | - if (!_singl[key].isSingleton && i.onDelete != null) { | 290 | + if (!_singl[key]!.isSingleton!) { |
298 | _routesByCreate[Get.reference] ??= HashSet<Function>(); | 291 | _routesByCreate[Get.reference] ??= HashSet<Function>(); |
299 | - _routesByCreate[Get.reference].add(i.onDelete); | 292 | + // _routesByCreate[Get.reference]!.add(i.onDelete as Function); |
293 | + _routesByCreate[Get.reference]!.add(i.onDelete); | ||
300 | } | 294 | } |
301 | } | 295 | } |
302 | return i; | 296 | return i; |
303 | } | 297 | } |
304 | 298 | ||
305 | - S putOrFind<S>(InstanceBuilderCallback<S> dep, {String tag}) { | 299 | + S putOrFind<S>(InstanceBuilderCallback<S> dep, {String? tag}) { |
306 | final key = _getKey(S, tag); | 300 | final key = _getKey(S, tag); |
307 | 301 | ||
308 | if (_singl.containsKey(key)) { | 302 | if (_singl.containsKey(key)) { |
309 | - return _singl[key].getDependency() as S; | 303 | + return _singl[key]!.getDependency() as S; |
310 | } else { | 304 | } else { |
311 | return GetInstance().put(dep(), tag: tag); | 305 | return GetInstance().put(dep(), tag: tag); |
312 | } | 306 | } |
@@ -317,7 +311,7 @@ class GetInstance { | @@ -317,7 +311,7 @@ class GetInstance { | ||
317 | /// it will create an instance each time you call [find]. | 311 | /// it will create an instance each time you call [find]. |
318 | /// If the registered type <[S]> (or [tag]) is a Controller, | 312 | /// If the registered type <[S]> (or [tag]) is a Controller, |
319 | /// it will initialize it's lifecycle. | 313 | /// it will initialize it's lifecycle. |
320 | - S find<S>({String tag}) { | 314 | + S find<S>({String? tag}) { |
321 | final key = _getKey(S, tag); | 315 | final key = _getKey(S, tag); |
322 | if (isRegistered<S>(tag: tag)) { | 316 | if (isRegistered<S>(tag: tag)) { |
323 | if (_singl[key] == null) { | 317 | if (_singl[key] == null) { |
@@ -332,7 +326,7 @@ class GetInstance { | @@ -332,7 +326,7 @@ class GetInstance { | ||
332 | /// `initDependencies`, so we have to return the instance from there | 326 | /// `initDependencies`, so we have to return the instance from there |
333 | /// to make it compatible with `Get.create()`. | 327 | /// to make it compatible with `Get.create()`. |
334 | final i = _initDependencies<S>(name: tag); | 328 | final i = _initDependencies<S>(name: tag); |
335 | - return i ?? _singl[key].getDependency() as S; | 329 | + return i ?? _singl[key]!.getDependency() as S; |
336 | } else { | 330 | } else { |
337 | // ignore: lines_longer_than_80_chars | 331 | // ignore: lines_longer_than_80_chars |
338 | throw '"$S" not found. You need to call "Get.put($S())" or "Get.lazyPut(()=>$S())"'; | 332 | throw '"$S" not found. You need to call "Get.put($S())" or "Get.lazyPut(()=>$S())"'; |
@@ -341,7 +335,7 @@ class GetInstance { | @@ -341,7 +335,7 @@ class GetInstance { | ||
341 | 335 | ||
342 | /// Generates the key based on [type] (and optionally a [name]) | 336 | /// Generates the key based on [type] (and optionally a [name]) |
343 | /// to register an Instance Builder in the hashmap. | 337 | /// to register an Instance Builder in the hashmap. |
344 | - String _getKey(Type type, String name) { | 338 | + String _getKey(Type type, String? name) { |
345 | return name == null ? type.toString() : type.toString() + name; | 339 | return name == null ? type.toString() : type.toString() + name; |
346 | } | 340 | } |
347 | 341 | ||
@@ -374,7 +368,7 @@ class GetInstance { | @@ -374,7 +368,7 @@ class GetInstance { | ||
374 | /// - [key] For internal usage, is the processed key used to register | 368 | /// - [key] For internal usage, is the processed key used to register |
375 | /// the Instance. **don't use** it unless you know what you are doing. | 369 | /// the Instance. **don't use** it unless you know what you are doing. |
376 | /// - [force] Will delete an Instance even if marked as [permanent]. | 370 | /// - [force] Will delete an Instance even if marked as [permanent]. |
377 | - bool delete<S>({String tag, String key, bool force = false}) { | 371 | + bool delete<S>({String? tag, String? key, bool force = false}) { |
378 | final newKey = key ?? _getKey(S, tag); | 372 | final newKey = key ?? _getKey(S, tag); |
379 | 373 | ||
380 | if (!_singl.containsKey(newKey)) { | 374 | if (!_singl.containsKey(newKey)) { |
@@ -382,7 +376,7 @@ class GetInstance { | @@ -382,7 +376,7 @@ class GetInstance { | ||
382 | return false; | 376 | return false; |
383 | } | 377 | } |
384 | 378 | ||
385 | - final builder = _singl[newKey]; | 379 | + final builder = _singl[newKey]!; |
386 | 380 | ||
387 | if (builder.permanent && !force) { | 381 | if (builder.permanent && !force) { |
388 | Get.log( | 382 | Get.log( |
@@ -398,7 +392,7 @@ class GetInstance { | @@ -398,7 +392,7 @@ class GetInstance { | ||
398 | return false; | 392 | return false; |
399 | } | 393 | } |
400 | 394 | ||
401 | - if (i is GetLifeCycleBase && i.onDelete != null) { | 395 | + if (i is GetLifeCycleBase) { |
402 | i.onDelete(); | 396 | i.onDelete(); |
403 | Get.log('"$newKey" onDelete() called'); | 397 | Get.log('"$newKey" onDelete() called'); |
404 | } | 398 | } |
@@ -430,7 +424,7 @@ class GetInstance { | @@ -430,7 +424,7 @@ class GetInstance { | ||
430 | }); | 424 | }); |
431 | } | 425 | } |
432 | 426 | ||
433 | - void reload<S>({String tag, String key, bool force = false}) { | 427 | + void reload<S>({String? tag, String? key, bool force = false}) { |
434 | final newKey = key ?? _getKey(S, tag); | 428 | final newKey = key ?? _getKey(S, tag); |
435 | 429 | ||
436 | final builder = _getDependency<S>(tag: tag, key: newKey); | 430 | final builder = _getDependency<S>(tag: tag, key: newKey); |
@@ -451,12 +445,12 @@ class GetInstance { | @@ -451,12 +445,12 @@ class GetInstance { | ||
451 | 445 | ||
452 | /// Check if a Class Instance<[S]> (or [tag]) is registered in memory. | 446 | /// Check if a Class Instance<[S]> (or [tag]) is registered in memory. |
453 | /// - [tag] is optional, if you used a [tag] to register the Instance. | 447 | /// - [tag] is optional, if you used a [tag] to register the Instance. |
454 | - bool isRegistered<S>({String tag}) => _singl.containsKey(_getKey(S, tag)); | 448 | + bool isRegistered<S>({String? tag}) => _singl.containsKey(_getKey(S, tag)); |
455 | 449 | ||
456 | /// Checks if a lazy factory callback ([Get.lazyPut()] that returns an | 450 | /// Checks if a lazy factory callback ([Get.lazyPut()] that returns an |
457 | /// Instance<[S]> is registered in memory. | 451 | /// Instance<[S]> is registered in memory. |
458 | /// - [tag] is optional, if you used a [tag] to register the lazy Instance. | 452 | /// - [tag] is optional, if you used a [tag] to register the lazy Instance. |
459 | - bool isPrepared<S>({String tag}) { | 453 | + bool isPrepared<S>({String? tag}) { |
460 | final newKey = _getKey(S, tag); | 454 | final newKey = _getKey(S, tag); |
461 | 455 | ||
462 | final builder = _getDependency<S>(tag: tag, key: newKey); | 456 | final builder = _getDependency<S>(tag: tag, key: newKey); |
@@ -481,14 +475,14 @@ typedef AsyncInstanceBuilderCallback<S> = Future<S> Function(); | @@ -481,14 +475,14 @@ typedef AsyncInstanceBuilderCallback<S> = Future<S> Function(); | ||
481 | class _InstanceBuilderFactory<S> { | 475 | class _InstanceBuilderFactory<S> { |
482 | /// Marks the Builder as a single instance. | 476 | /// Marks the Builder as a single instance. |
483 | /// For reusing [dependency] instead of [builderFunc] | 477 | /// For reusing [dependency] instead of [builderFunc] |
484 | - bool isSingleton; | 478 | + bool? isSingleton; |
485 | 479 | ||
486 | /// When fenix mode is avaliable, when a new instance is need | 480 | /// When fenix mode is avaliable, when a new instance is need |
487 | /// Instance manager will recreate a new instance of S | 481 | /// Instance manager will recreate a new instance of S |
488 | bool fenix; | 482 | bool fenix; |
489 | 483 | ||
490 | /// Stores the actual object instance when [isSingleton]=true. | 484 | /// Stores the actual object instance when [isSingleton]=true. |
491 | - S dependency; | 485 | + S? dependency; |
492 | 486 | ||
493 | /// Generates (and regenerates) the instance when [isSingleton]=false. | 487 | /// Generates (and regenerates) the instance when [isSingleton]=false. |
494 | /// Usually used by factory methods | 488 | /// Usually used by factory methods |
@@ -500,7 +494,7 @@ class _InstanceBuilderFactory<S> { | @@ -500,7 +494,7 @@ class _InstanceBuilderFactory<S> { | ||
500 | 494 | ||
501 | bool isInit = false; | 495 | bool isInit = false; |
502 | 496 | ||
503 | - String tag; | 497 | + String? tag; |
504 | 498 | ||
505 | _InstanceBuilderFactory( | 499 | _InstanceBuilderFactory( |
506 | this.isSingleton, | 500 | this.isSingleton, |
@@ -521,12 +515,12 @@ class _InstanceBuilderFactory<S> { | @@ -521,12 +515,12 @@ class _InstanceBuilderFactory<S> { | ||
521 | 515 | ||
522 | /// Gets the actual instance by it's [builderFunc] or the persisted instance. | 516 | /// Gets the actual instance by it's [builderFunc] or the persisted instance. |
523 | S getDependency() { | 517 | S getDependency() { |
524 | - if (isSingleton) { | 518 | + if (isSingleton!) { |
525 | if (dependency == null) { | 519 | if (dependency == null) { |
526 | _showInitLog(); | 520 | _showInitLog(); |
527 | dependency = builderFunc(); | 521 | dependency = builderFunc(); |
528 | } | 522 | } |
529 | - return dependency; | 523 | + return dependency!; |
530 | } else { | 524 | } else { |
531 | return builderFunc(); | 525 | return builderFunc(); |
532 | } | 526 | } |
@@ -5,11 +5,11 @@ import '../../get_core/get_core.dart'; | @@ -5,11 +5,11 @@ import '../../get_core/get_core.dart'; | ||
5 | /// methods. | 5 | /// methods. |
6 | /// Used in [DisposableInterface] to avoid the danger of overriding onStart. | 6 | /// Used in [DisposableInterface] to avoid the danger of overriding onStart. |
7 | class _InternalFinalCallback<T> { | 7 | class _InternalFinalCallback<T> { |
8 | - ValueUpdater<T> _callback; | 8 | + ValueUpdater<T>? _callback; |
9 | 9 | ||
10 | - _InternalFinalCallback({ValueUpdater<T> callback}) : _callback = callback; | 10 | + _InternalFinalCallback({ValueUpdater<T>? callback}) : _callback = callback; |
11 | 11 | ||
12 | - T call() => _callback.call(); | 12 | + T call() => _callback!.call(); |
13 | } | 13 | } |
14 | 14 | ||
15 | /// The [GetLifeCycle] | 15 | /// The [GetLifeCycle] |
@@ -14,24 +14,21 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> { | @@ -14,24 +14,21 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> { | ||
14 | this.modalBarrierColor, | 14 | this.modalBarrierColor, |
15 | this.isDismissible = true, | 15 | this.isDismissible = true, |
16 | this.enableDrag = true, | 16 | this.enableDrag = true, |
17 | - @required this.isScrollControlled, | ||
18 | - RouteSettings settings, | 17 | + required this.isScrollControlled, |
18 | + RouteSettings? settings, | ||
19 | this.enterBottomSheetDuration = const Duration(milliseconds: 250), | 19 | this.enterBottomSheetDuration = const Duration(milliseconds: 250), |
20 | this.exitBottomSheetDuration = const Duration(milliseconds: 200), | 20 | this.exitBottomSheetDuration = const Duration(milliseconds: 200), |
21 | - }) : assert(isScrollControlled != null), | ||
22 | - name = "BOTTOMSHEET: ${builder.hashCode}", | ||
23 | - assert(isDismissible != null), | ||
24 | - assert(enableDrag != null), | 21 | + }) : name = "BOTTOMSHEET: ${builder.hashCode}", |
25 | super(settings: settings); | 22 | super(settings: settings); |
26 | - final bool isPersistent; | ||
27 | - final WidgetBuilder builder; | ||
28 | - final ThemeData theme; | 23 | + final bool? isPersistent; |
24 | + final WidgetBuilder? builder; | ||
25 | + final ThemeData? theme; | ||
29 | final bool isScrollControlled; | 26 | final bool isScrollControlled; |
30 | - final Color backgroundColor; | ||
31 | - final double elevation; | ||
32 | - final ShapeBorder shape; | ||
33 | - final Clip clipBehavior; | ||
34 | - final Color modalBarrierColor; | 27 | + final Color? backgroundColor; |
28 | + final double? elevation; | ||
29 | + final ShapeBorder? shape; | ||
30 | + final Clip? clipBehavior; | ||
31 | + final Color? modalBarrierColor; | ||
35 | final bool isDismissible; | 32 | final bool isDismissible; |
36 | final bool enableDrag; | 33 | final bool enableDrag; |
37 | final String name; | 34 | final String name; |
@@ -47,21 +44,21 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> { | @@ -47,21 +44,21 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> { | ||
47 | bool get barrierDismissible => isDismissible; | 44 | bool get barrierDismissible => isDismissible; |
48 | 45 | ||
49 | @override | 46 | @override |
50 | - final String barrierLabel; | 47 | + final String? barrierLabel; |
51 | 48 | ||
52 | @override | 49 | @override |
53 | Color get barrierColor => modalBarrierColor ?? Colors.black54; | 50 | Color get barrierColor => modalBarrierColor ?? Colors.black54; |
54 | 51 | ||
55 | - AnimationController _animationController; | 52 | + AnimationController? _animationController; |
56 | 53 | ||
57 | @override | 54 | @override |
58 | AnimationController createAnimationController() { | 55 | AnimationController createAnimationController() { |
59 | assert(_animationController == null); | 56 | assert(_animationController == null); |
60 | _animationController = | 57 | _animationController = |
61 | - BottomSheet.createAnimationController(navigator.overlay); | ||
62 | - _animationController.duration = enterBottomSheetDuration; | ||
63 | - _animationController.reverseDuration = exitBottomSheetDuration; | ||
64 | - return _animationController; | 58 | + BottomSheet.createAnimationController(navigator!.overlay!); |
59 | + _animationController!.duration = enterBottomSheetDuration; | ||
60 | + _animationController!.reverseDuration = exitBottomSheetDuration; | ||
61 | + return _animationController!; | ||
65 | } | 62 | } |
66 | 63 | ||
67 | @override | 64 | @override |
@@ -80,10 +77,10 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> { | @@ -80,10 +77,10 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> { | ||
80 | child: _GetModalBottomSheet<T>( | 77 | child: _GetModalBottomSheet<T>( |
81 | route: this, | 78 | route: this, |
82 | backgroundColor: backgroundColor ?? | 79 | backgroundColor: backgroundColor ?? |
83 | - sheetTheme?.modalBackgroundColor ?? | ||
84 | - sheetTheme?.backgroundColor, | 80 | + sheetTheme.modalBackgroundColor ?? |
81 | + sheetTheme.backgroundColor, | ||
85 | elevation: | 82 | elevation: |
86 | - elevation ?? sheetTheme?.modalElevation ?? sheetTheme?.elevation, | 83 | + elevation ?? sheetTheme.modalElevation ?? sheetTheme.elevation, |
87 | shape: shape, | 84 | shape: shape, |
88 | clipBehavior: clipBehavior, | 85 | clipBehavior: clipBehavior, |
89 | isScrollControlled: isScrollControlled, | 86 | isScrollControlled: isScrollControlled, |
@@ -91,14 +88,14 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> { | @@ -91,14 +88,14 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> { | ||
91 | ), | 88 | ), |
92 | ), | 89 | ), |
93 | ); | 90 | ); |
94 | - if (theme != null) bottomSheet = Theme(data: theme, child: bottomSheet); | 91 | + if (theme != null) bottomSheet = Theme(data: theme!, child: bottomSheet); |
95 | return bottomSheet; | 92 | return bottomSheet; |
96 | } | 93 | } |
97 | } | 94 | } |
98 | 95 | ||
99 | class _GetModalBottomSheet<T> extends StatefulWidget { | 96 | class _GetModalBottomSheet<T> extends StatefulWidget { |
100 | const _GetModalBottomSheet({ | 97 | const _GetModalBottomSheet({ |
101 | - Key key, | 98 | + Key? key, |
102 | this.route, | 99 | this.route, |
103 | this.backgroundColor, | 100 | this.backgroundColor, |
104 | this.elevation, | 101 | this.elevation, |
@@ -107,16 +104,14 @@ class _GetModalBottomSheet<T> extends StatefulWidget { | @@ -107,16 +104,14 @@ class _GetModalBottomSheet<T> extends StatefulWidget { | ||
107 | this.isScrollControlled = false, | 104 | this.isScrollControlled = false, |
108 | this.enableDrag = true, | 105 | this.enableDrag = true, |
109 | this.isPersistent = false, | 106 | this.isPersistent = false, |
110 | - }) : assert(isScrollControlled != null), | ||
111 | - assert(enableDrag != null), | ||
112 | - super(key: key); | 107 | + }) : super(key: key); |
113 | final bool isPersistent; | 108 | final bool isPersistent; |
114 | - final GetModalBottomSheetRoute<T> route; | 109 | + final GetModalBottomSheetRoute<T>? route; |
115 | final bool isScrollControlled; | 110 | final bool isScrollControlled; |
116 | - final Color backgroundColor; | ||
117 | - final double elevation; | ||
118 | - final ShapeBorder shape; | ||
119 | - final Clip clipBehavior; | 111 | + final Color? backgroundColor; |
112 | + final double? elevation; | ||
113 | + final ShapeBorder? shape; | ||
114 | + final Clip? clipBehavior; | ||
120 | final bool enableDrag; | 115 | final bool enableDrag; |
121 | 116 | ||
122 | @override | 117 | @override |
@@ -142,13 +137,13 @@ class _GetModalBottomSheetState<T> extends State<_GetModalBottomSheet<T>> { | @@ -142,13 +137,13 @@ class _GetModalBottomSheetState<T> extends State<_GetModalBottomSheet<T>> { | ||
142 | final routeLabel = _getRouteLabel(localizations); | 137 | final routeLabel = _getRouteLabel(localizations); |
143 | 138 | ||
144 | return AnimatedBuilder( | 139 | return AnimatedBuilder( |
145 | - animation: widget.route.animation, | 140 | + animation: widget.route!.animation!, |
146 | builder: (context, child) { | 141 | builder: (context, child) { |
147 | // Disable the initial animation when accessible navigation is on so | 142 | // Disable the initial animation when accessible navigation is on so |
148 | // that the semantics are added to the tree at the correct time. | 143 | // that the semantics are added to the tree at the correct time. |
149 | final animationValue = mediaQuery.accessibleNavigation | 144 | final animationValue = mediaQuery.accessibleNavigation |
150 | ? 1.0 | 145 | ? 1.0 |
151 | - : widget.route.animation.value; | 146 | + : widget.route!.animation!.value; |
152 | return Semantics( | 147 | return Semantics( |
153 | scopesRoute: true, | 148 | scopesRoute: true, |
154 | namesRoute: true, | 149 | namesRoute: true, |
@@ -160,13 +155,13 @@ class _GetModalBottomSheetState<T> extends State<_GetModalBottomSheet<T>> { | @@ -160,13 +155,13 @@ class _GetModalBottomSheetState<T> extends State<_GetModalBottomSheet<T>> { | ||
160 | animationValue, widget.isScrollControlled), | 155 | animationValue, widget.isScrollControlled), |
161 | child: widget.isPersistent == false | 156 | child: widget.isPersistent == false |
162 | ? BottomSheet( | 157 | ? BottomSheet( |
163 | - animationController: widget.route._animationController, | 158 | + animationController: widget.route!._animationController, |
164 | onClosing: () { | 159 | onClosing: () { |
165 | - if (widget.route.isCurrent) { | 160 | + if (widget.route!.isCurrent) { |
166 | Navigator.pop(context); | 161 | Navigator.pop(context); |
167 | } | 162 | } |
168 | }, | 163 | }, |
169 | - builder: widget.route.builder, | 164 | + builder: widget.route!.builder!, |
170 | backgroundColor: widget.backgroundColor, | 165 | backgroundColor: widget.backgroundColor, |
171 | elevation: widget.elevation, | 166 | elevation: widget.elevation, |
172 | shape: widget.shape, | 167 | shape: widget.shape, |
@@ -176,13 +171,13 @@ class _GetModalBottomSheetState<T> extends State<_GetModalBottomSheet<T>> { | @@ -176,13 +171,13 @@ class _GetModalBottomSheetState<T> extends State<_GetModalBottomSheet<T>> { | ||
176 | : Scaffold( | 171 | : Scaffold( |
177 | bottomSheet: BottomSheet( | 172 | bottomSheet: BottomSheet( |
178 | animationController: | 173 | animationController: |
179 | - widget.route._animationController, | 174 | + widget.route!._animationController, |
180 | onClosing: () { | 175 | onClosing: () { |
181 | // if (widget.route.isCurrent) { | 176 | // if (widget.route.isCurrent) { |
182 | // Navigator.pop(context); | 177 | // Navigator.pop(context); |
183 | // } | 178 | // } |
184 | }, | 179 | }, |
185 | - builder: widget.route.builder, | 180 | + builder: widget.route!.builder!, |
186 | backgroundColor: widget.backgroundColor, | 181 | backgroundColor: widget.backgroundColor, |
187 | elevation: widget.elevation, | 182 | elevation: widget.elevation, |
188 | shape: widget.shape, | 183 | shape: widget.shape, |
@@ -199,7 +194,7 @@ class _GetModalBottomSheetState<T> extends State<_GetModalBottomSheet<T>> { | @@ -199,7 +194,7 @@ class _GetModalBottomSheetState<T> extends State<_GetModalBottomSheet<T>> { | ||
199 | 194 | ||
200 | class _GetPerModalBottomSheet<T> extends StatefulWidget { | 195 | class _GetPerModalBottomSheet<T> extends StatefulWidget { |
201 | const _GetPerModalBottomSheet({ | 196 | const _GetPerModalBottomSheet({ |
202 | - Key key, | 197 | + Key? key, |
203 | this.route, | 198 | this.route, |
204 | this.isPersistent, | 199 | this.isPersistent, |
205 | this.backgroundColor, | 200 | this.backgroundColor, |
@@ -208,16 +203,14 @@ class _GetPerModalBottomSheet<T> extends StatefulWidget { | @@ -208,16 +203,14 @@ class _GetPerModalBottomSheet<T> extends StatefulWidget { | ||
208 | this.clipBehavior, | 203 | this.clipBehavior, |
209 | this.isScrollControlled = false, | 204 | this.isScrollControlled = false, |
210 | this.enableDrag = true, | 205 | this.enableDrag = true, |
211 | - }) : assert(isScrollControlled != null), | ||
212 | - assert(enableDrag != null), | ||
213 | - super(key: key); | ||
214 | - final bool isPersistent; | ||
215 | - final GetModalBottomSheetRoute<T> route; | 206 | + }) : super(key: key); |
207 | + final bool? isPersistent; | ||
208 | + final GetModalBottomSheetRoute<T>? route; | ||
216 | final bool isScrollControlled; | 209 | final bool isScrollControlled; |
217 | - final Color backgroundColor; | ||
218 | - final double elevation; | ||
219 | - final ShapeBorder shape; | ||
220 | - final Clip clipBehavior; | 210 | + final Color? backgroundColor; |
211 | + final double? elevation; | ||
212 | + final ShapeBorder? shape; | ||
213 | + final Clip? clipBehavior; | ||
221 | final bool enableDrag; | 214 | final bool enableDrag; |
222 | 215 | ||
223 | @override | 216 | @override |
@@ -247,13 +240,13 @@ class _GetPerModalBottomSheetState<T> | @@ -247,13 +240,13 @@ class _GetPerModalBottomSheetState<T> | ||
247 | final routeLabel = _getRouteLabel(localizations); | 240 | final routeLabel = _getRouteLabel(localizations); |
248 | 241 | ||
249 | return AnimatedBuilder( | 242 | return AnimatedBuilder( |
250 | - animation: widget.route.animation, | 243 | + animation: widget.route!.animation!, |
251 | builder: (context, child) { | 244 | builder: (context, child) { |
252 | // Disable the initial animation when accessible navigation is on so | 245 | // Disable the initial animation when accessible navigation is on so |
253 | // that the semantics are added to the tree at the correct time. | 246 | // that the semantics are added to the tree at the correct time. |
254 | final animationValue = mediaQuery.accessibleNavigation | 247 | final animationValue = mediaQuery.accessibleNavigation |
255 | ? 1.0 | 248 | ? 1.0 |
256 | - : widget.route.animation.value; | 249 | + : widget.route!.animation!.value; |
257 | return Semantics( | 250 | return Semantics( |
258 | scopesRoute: true, | 251 | scopesRoute: true, |
259 | namesRoute: true, | 252 | namesRoute: true, |
@@ -265,13 +258,13 @@ class _GetPerModalBottomSheetState<T> | @@ -265,13 +258,13 @@ class _GetPerModalBottomSheetState<T> | ||
265 | animationValue, widget.isScrollControlled), | 258 | animationValue, widget.isScrollControlled), |
266 | child: widget.isPersistent == false | 259 | child: widget.isPersistent == false |
267 | ? BottomSheet( | 260 | ? BottomSheet( |
268 | - animationController: widget.route._animationController, | 261 | + animationController: widget.route!._animationController, |
269 | onClosing: () { | 262 | onClosing: () { |
270 | - if (widget.route.isCurrent) { | 263 | + if (widget.route!.isCurrent) { |
271 | Navigator.pop(context); | 264 | Navigator.pop(context); |
272 | } | 265 | } |
273 | }, | 266 | }, |
274 | - builder: widget.route.builder, | 267 | + builder: widget.route!.builder!, |
275 | backgroundColor: widget.backgroundColor, | 268 | backgroundColor: widget.backgroundColor, |
276 | elevation: widget.elevation, | 269 | elevation: widget.elevation, |
277 | shape: widget.shape, | 270 | shape: widget.shape, |
@@ -281,13 +274,13 @@ class _GetPerModalBottomSheetState<T> | @@ -281,13 +274,13 @@ class _GetPerModalBottomSheetState<T> | ||
281 | : Scaffold( | 274 | : Scaffold( |
282 | bottomSheet: BottomSheet( | 275 | bottomSheet: BottomSheet( |
283 | animationController: | 276 | animationController: |
284 | - widget.route._animationController, | 277 | + widget.route!._animationController, |
285 | onClosing: () { | 278 | onClosing: () { |
286 | // if (widget.route.isCurrent) { | 279 | // if (widget.route.isCurrent) { |
287 | // Navigator.pop(context); | 280 | // Navigator.pop(context); |
288 | // } | 281 | // } |
289 | }, | 282 | }, |
290 | - builder: widget.route.builder, | 283 | + builder: widget.route!.builder!, |
291 | backgroundColor: widget.backgroundColor, | 284 | backgroundColor: widget.backgroundColor, |
292 | elevation: widget.elevation, | 285 | elevation: widget.elevation, |
293 | shape: widget.shape, | 286 | shape: widget.shape, |
@@ -4,15 +4,14 @@ import '../../../get_instance/src/get_instance.dart'; | @@ -4,15 +4,14 @@ import '../../../get_instance/src/get_instance.dart'; | ||
4 | 4 | ||
5 | class GetDialogRoute<T> extends PopupRoute<T> { | 5 | class GetDialogRoute<T> extends PopupRoute<T> { |
6 | GetDialogRoute({ | 6 | GetDialogRoute({ |
7 | - @required RoutePageBuilder pageBuilder, | 7 | + required RoutePageBuilder pageBuilder, |
8 | bool barrierDismissible = true, | 8 | bool barrierDismissible = true, |
9 | - String barrierLabel, | 9 | + String? barrierLabel, |
10 | Color barrierColor = const Color(0x80000000), | 10 | Color barrierColor = const Color(0x80000000), |
11 | Duration transitionDuration = const Duration(milliseconds: 200), | 11 | Duration transitionDuration = const Duration(milliseconds: 200), |
12 | - RouteTransitionsBuilder transitionBuilder, | ||
13 | - RouteSettings settings, | ||
14 | - }) : assert(barrierDismissible != null), | ||
15 | - widget = pageBuilder, | 12 | + RouteTransitionsBuilder? transitionBuilder, |
13 | + RouteSettings? settings, | ||
14 | + }) : widget = pageBuilder, | ||
16 | name = "DIALOG: ${pageBuilder.hashCode}", | 15 | name = "DIALOG: ${pageBuilder.hashCode}", |
17 | _barrierDismissible = barrierDismissible, | 16 | _barrierDismissible = barrierDismissible, |
18 | _barrierLabel = barrierLabel, | 17 | _barrierLabel = barrierLabel, |
@@ -32,15 +31,15 @@ class GetDialogRoute<T> extends PopupRoute<T> { | @@ -32,15 +31,15 @@ class GetDialogRoute<T> extends PopupRoute<T> { | ||
32 | @override | 31 | @override |
33 | void dispose() { | 32 | void dispose() { |
34 | if (Get.smartManagement != SmartManagement.onlyBuilder) { | 33 | if (Get.smartManagement != SmartManagement.onlyBuilder) { |
35 | - WidgetsBinding.instance.addPostFrameCallback( | 34 | + WidgetsBinding.instance!.addPostFrameCallback( |
36 | (_) => GetInstance().removeDependencyByRoute(name)); | 35 | (_) => GetInstance().removeDependencyByRoute(name)); |
37 | } | 36 | } |
38 | super.dispose(); | 37 | super.dispose(); |
39 | } | 38 | } |
40 | 39 | ||
41 | @override | 40 | @override |
42 | - String get barrierLabel => _barrierLabel; | ||
43 | - final String _barrierLabel; | 41 | + String? get barrierLabel => _barrierLabel; |
42 | + final String? _barrierLabel; | ||
44 | 43 | ||
45 | @override | 44 | @override |
46 | Color get barrierColor => _barrierColor; | 45 | Color get barrierColor => _barrierColor; |
@@ -50,7 +49,7 @@ class GetDialogRoute<T> extends PopupRoute<T> { | @@ -50,7 +49,7 @@ class GetDialogRoute<T> extends PopupRoute<T> { | ||
50 | Duration get transitionDuration => _transitionDuration; | 49 | Duration get transitionDuration => _transitionDuration; |
51 | final Duration _transitionDuration; | 50 | final Duration _transitionDuration; |
52 | 51 | ||
53 | - final RouteTransitionsBuilder _transitionBuilder; | 52 | + final RouteTransitionsBuilder? _transitionBuilder; |
54 | 53 | ||
55 | @override | 54 | @override |
56 | Widget buildPage(BuildContext context, Animation<double> animation, | 55 | Widget buildPage(BuildContext context, Animation<double> animation, |
@@ -73,6 +72,6 @@ class GetDialogRoute<T> extends PopupRoute<T> { | @@ -73,6 +72,6 @@ class GetDialogRoute<T> extends PopupRoute<T> { | ||
73 | ), | 72 | ), |
74 | child: child); | 73 | child: child); |
75 | } // Some default transition | 74 | } // Some default transition |
76 | - return _transitionBuilder(context, animation, secondaryAnimation, child); | 75 | + return _transitionBuilder!(context, animation, secondaryAnimation, child); |
77 | } | 76 | } |
78 | } | 77 | } |
@@ -14,42 +14,42 @@ import 'routes/transitions_type.dart'; | @@ -14,42 +14,42 @@ import 'routes/transitions_type.dart'; | ||
14 | 14 | ||
15 | extension ExtensionSnackbar on GetInterface { | 15 | extension ExtensionSnackbar on GetInterface { |
16 | void rawSnackbar({ | 16 | void rawSnackbar({ |
17 | - String title, | ||
18 | - String message, | ||
19 | - Widget titleText, | ||
20 | - Widget messageText, | ||
21 | - Widget icon, | 17 | + String? title, |
18 | + String? message, | ||
19 | + Widget? titleText, | ||
20 | + Widget? messageText, | ||
21 | + Widget? icon, | ||
22 | bool instantInit = true, | 22 | bool instantInit = true, |
23 | bool shouldIconPulse = true, | 23 | bool shouldIconPulse = true, |
24 | - double maxWidth, | 24 | + double? maxWidth, |
25 | EdgeInsets margin = const EdgeInsets.all(0.0), | 25 | EdgeInsets margin = const EdgeInsets.all(0.0), |
26 | EdgeInsets padding = const EdgeInsets.all(16), | 26 | EdgeInsets padding = const EdgeInsets.all(16), |
27 | double borderRadius = 0.0, | 27 | double borderRadius = 0.0, |
28 | - Color borderColor, | 28 | + Color? borderColor, |
29 | double borderWidth = 1.0, | 29 | double borderWidth = 1.0, |
30 | Color backgroundColor = const Color(0xFF303030), | 30 | Color backgroundColor = const Color(0xFF303030), |
31 | - Color leftBarIndicatorColor, | ||
32 | - List<BoxShadow> boxShadows, | ||
33 | - Gradient backgroundGradient, | ||
34 | - Widget mainButton, | ||
35 | - OnTap onTap, | 31 | + Color? leftBarIndicatorColor, |
32 | + List<BoxShadow>? boxShadows, | ||
33 | + Gradient? backgroundGradient, | ||
34 | + Widget? mainButton, | ||
35 | + OnTap? onTap, | ||
36 | Duration duration = const Duration(seconds: 3), | 36 | Duration duration = const Duration(seconds: 3), |
37 | bool isDismissible = true, | 37 | bool isDismissible = true, |
38 | SnackDismissDirection dismissDirection = SnackDismissDirection.VERTICAL, | 38 | SnackDismissDirection dismissDirection = SnackDismissDirection.VERTICAL, |
39 | bool showProgressIndicator = false, | 39 | bool showProgressIndicator = false, |
40 | - AnimationController progressIndicatorController, | ||
41 | - Color progressIndicatorBackgroundColor, | ||
42 | - Animation<Color> progressIndicatorValueColor, | 40 | + AnimationController? progressIndicatorController, |
41 | + Color? progressIndicatorBackgroundColor, | ||
42 | + Animation<Color>? progressIndicatorValueColor, | ||
43 | SnackPosition snackPosition = SnackPosition.BOTTOM, | 43 | SnackPosition snackPosition = SnackPosition.BOTTOM, |
44 | SnackStyle snackStyle = SnackStyle.FLOATING, | 44 | SnackStyle snackStyle = SnackStyle.FLOATING, |
45 | Curve forwardAnimationCurve = Curves.easeOutCirc, | 45 | Curve forwardAnimationCurve = Curves.easeOutCirc, |
46 | Curve reverseAnimationCurve = Curves.easeOutCirc, | 46 | Curve reverseAnimationCurve = Curves.easeOutCirc, |
47 | Duration animationDuration = const Duration(seconds: 1), | 47 | Duration animationDuration = const Duration(seconds: 1), |
48 | - SnackbarStatusCallback snackbarStatus, | ||
49 | - double barBlur = 0.0, | 48 | + SnackbarStatusCallback? snackbarStatus, |
49 | + double? barBlur = 0.0, | ||
50 | double overlayBlur = 0.0, | 50 | double overlayBlur = 0.0, |
51 | - Color overlayColor, | ||
52 | - Form userInputForm, | 51 | + Color? overlayColor, |
52 | + Form? userInputForm, | ||
53 | }) async { | 53 | }) async { |
54 | final getBar = GetBar( | 54 | final getBar = GetBar( |
55 | snackbarStatus: snackbarStatus, | 55 | snackbarStatus: snackbarStatus, |
@@ -76,7 +76,7 @@ extension ExtensionSnackbar on GetInterface { | @@ -76,7 +76,7 @@ extension ExtensionSnackbar on GetInterface { | ||
76 | onTap: onTap, | 76 | onTap: onTap, |
77 | isDismissible: isDismissible, | 77 | isDismissible: isDismissible, |
78 | dismissDirection: dismissDirection, | 78 | dismissDirection: dismissDirection, |
79 | - showProgressIndicator: showProgressIndicator ?? false, | 79 | + showProgressIndicator: showProgressIndicator, |
80 | progressIndicatorController: progressIndicatorController, | 80 | progressIndicatorController: progressIndicatorController, |
81 | progressIndicatorBackgroundColor: progressIndicatorBackgroundColor, | 81 | progressIndicatorBackgroundColor: progressIndicatorBackgroundColor, |
82 | progressIndicatorValueColor: progressIndicatorValueColor, | 82 | progressIndicatorValueColor: progressIndicatorValueColor, |
@@ -92,70 +92,68 @@ extension ExtensionSnackbar on GetInterface { | @@ -92,70 +92,68 @@ extension ExtensionSnackbar on GetInterface { | ||
92 | if (instantInit) { | 92 | if (instantInit) { |
93 | getBar.show(); | 93 | getBar.show(); |
94 | } else { | 94 | } else { |
95 | - SchedulerBinding.instance.addPostFrameCallback((_) { | 95 | + SchedulerBinding.instance!.addPostFrameCallback((_) { |
96 | getBar.show(); | 96 | getBar.show(); |
97 | }); | 97 | }); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | - Future<T> showSnackbar<T>(GetBar snackbar) { | ||
102 | - return key?.currentState?.push(SnackRoute<T>(snack: snackbar)); | 101 | + Future<T?>? showSnackbar<T>(GetBar snackbar) { |
102 | + return key.currentState?.push(SnackRoute<T>(snack: snackbar)); | ||
103 | } | 103 | } |
104 | 104 | ||
105 | void snackbar<T>( | 105 | void snackbar<T>( |
106 | String title, | 106 | String title, |
107 | String message, { | 107 | String message, { |
108 | - Color colorText, | ||
109 | - Duration duration, | 108 | + Color? colorText, |
109 | + Duration? duration, | ||
110 | 110 | ||
111 | /// with instantInit = false you can put snackbar on initState | 111 | /// with instantInit = false you can put snackbar on initState |
112 | bool instantInit = true, | 112 | bool instantInit = true, |
113 | - SnackPosition snackPosition, | ||
114 | - Widget titleText, | ||
115 | - Widget messageText, | ||
116 | - Widget icon, | ||
117 | - bool shouldIconPulse, | ||
118 | - double maxWidth, | ||
119 | - EdgeInsets margin, | ||
120 | - EdgeInsets padding, | ||
121 | - double borderRadius, | ||
122 | - Color borderColor, | ||
123 | - double borderWidth, | ||
124 | - Color backgroundColor, | ||
125 | - Color leftBarIndicatorColor, | ||
126 | - List<BoxShadow> boxShadows, | ||
127 | - Gradient backgroundGradient, | ||
128 | - TextButton mainButton, | ||
129 | - OnTap onTap, | ||
130 | - bool isDismissible, | ||
131 | - bool showProgressIndicator, | ||
132 | - SnackDismissDirection dismissDirection, | ||
133 | - AnimationController progressIndicatorController, | ||
134 | - Color progressIndicatorBackgroundColor, | ||
135 | - Animation<Color> progressIndicatorValueColor, | ||
136 | - SnackStyle snackStyle, | ||
137 | - Curve forwardAnimationCurve, | ||
138 | - Curve reverseAnimationCurve, | ||
139 | - Duration animationDuration, | ||
140 | - double barBlur, | ||
141 | - double overlayBlur, | ||
142 | - SnackbarStatusCallback snackbarStatus, | ||
143 | - Color overlayColor, | ||
144 | - Form userInputForm, | 113 | + SnackPosition? snackPosition, |
114 | + Widget? titleText, | ||
115 | + Widget? messageText, | ||
116 | + Widget? icon, | ||
117 | + bool? shouldIconPulse, | ||
118 | + double? maxWidth, | ||
119 | + EdgeInsets? margin, | ||
120 | + EdgeInsets? padding, | ||
121 | + double? borderRadius, | ||
122 | + Color? borderColor, | ||
123 | + double? borderWidth, | ||
124 | + Color? backgroundColor, | ||
125 | + Color? leftBarIndicatorColor, | ||
126 | + List<BoxShadow>? boxShadows, | ||
127 | + Gradient? backgroundGradient, | ||
128 | + TextButton? mainButton, | ||
129 | + OnTap? onTap, | ||
130 | + bool? isDismissible, | ||
131 | + bool? showProgressIndicator, | ||
132 | + SnackDismissDirection? dismissDirection, | ||
133 | + AnimationController? progressIndicatorController, | ||
134 | + Color? progressIndicatorBackgroundColor, | ||
135 | + Animation<Color>? progressIndicatorValueColor, | ||
136 | + SnackStyle? snackStyle, | ||
137 | + Curve? forwardAnimationCurve, | ||
138 | + Curve? reverseAnimationCurve, | ||
139 | + Duration? animationDuration, | ||
140 | + double? barBlur, | ||
141 | + double? overlayBlur, | ||
142 | + SnackbarStatusCallback? snackbarStatus, | ||
143 | + Color? overlayColor, | ||
144 | + Form? userInputForm, | ||
145 | }) async { | 145 | }) async { |
146 | final getBar = GetBar( | 146 | final getBar = GetBar( |
147 | snackbarStatus: snackbarStatus, | 147 | snackbarStatus: snackbarStatus, |
148 | - titleText: (title == null) | ||
149 | - ? null | ||
150 | - : titleText ?? | ||
151 | - Text( | ||
152 | - title, | ||
153 | - style: TextStyle( | ||
154 | - color: colorText ?? iconColor ?? Colors.black, | ||
155 | - fontWeight: FontWeight.w800, | ||
156 | - fontSize: 16, | ||
157 | - ), | ||
158 | - ), | 148 | + titleText: titleText ?? |
149 | + Text( | ||
150 | + title, | ||
151 | + style: TextStyle( | ||
152 | + color: colorText ?? iconColor ?? Colors.black, | ||
153 | + fontWeight: FontWeight.w800, | ||
154 | + fontSize: 16, | ||
155 | + ), | ||
156 | + ), | ||
159 | messageText: messageText ?? | 157 | messageText: messageText ?? |
160 | Text( | 158 | Text( |
161 | message, | 159 | message, |
@@ -200,7 +198,7 @@ extension ExtensionSnackbar on GetInterface { | @@ -200,7 +198,7 @@ extension ExtensionSnackbar on GetInterface { | ||
200 | showSnackbar<T>(getBar); | 198 | showSnackbar<T>(getBar); |
201 | } else { | 199 | } else { |
202 | routing.isSnackbar = true; | 200 | routing.isSnackbar = true; |
203 | - SchedulerBinding.instance.addPostFrameCallback((_) { | 201 | + SchedulerBinding.instance!.addPostFrameCallback((_) { |
204 | showSnackbar<T>(getBar); | 202 | showSnackbar<T>(getBar); |
205 | }); | 203 | }); |
206 | } | 204 | } |
@@ -212,33 +210,27 @@ extension ExtensionDialog on GetInterface { | @@ -212,33 +210,27 @@ extension ExtensionDialog on GetInterface { | ||
212 | /// You can pass a [transitionDuration] and/or [transitionCurve], | 210 | /// You can pass a [transitionDuration] and/or [transitionCurve], |
213 | /// overriding the defaults when the dialog shows up and closes. | 211 | /// overriding the defaults when the dialog shows up and closes. |
214 | /// When the dialog closes, uses those animations in reverse. | 212 | /// When the dialog closes, uses those animations in reverse. |
215 | - Future<T> dialog<T>( | 213 | + Future<T?> dialog<T>( |
216 | Widget widget, { | 214 | Widget widget, { |
217 | bool barrierDismissible = true, | 215 | bool barrierDismissible = true, |
218 | - Color barrierColor, | 216 | + Color? barrierColor, |
219 | bool useSafeArea = true, | 217 | bool useSafeArea = true, |
220 | bool useRootNavigator = true, | 218 | bool useRootNavigator = true, |
221 | - Object arguments, | ||
222 | - Duration transitionDuration, | ||
223 | - Curve transitionCurve, | ||
224 | - String name, | ||
225 | - RouteSettings routeSettings, | 219 | + Object? arguments, |
220 | + Duration? transitionDuration, | ||
221 | + Curve? transitionCurve, | ||
222 | + String? name, | ||
223 | + RouteSettings? routeSettings, | ||
226 | }) { | 224 | }) { |
227 | - assert(widget != null); | ||
228 | - assert(barrierDismissible != null); | ||
229 | - assert(useSafeArea != null); | ||
230 | - assert(useRootNavigator != null); | ||
231 | - assert(debugCheckHasMaterialLocalizations(context)); | 225 | + assert(debugCheckHasMaterialLocalizations(context!)); |
232 | 226 | ||
233 | // final theme = Theme.of(context, shadowThemeOnly: true); | 227 | // final theme = Theme.of(context, shadowThemeOnly: true); |
234 | - final theme = Theme.of(context); | 228 | + final theme = Theme.of(context!); |
235 | return generalDialog<T>( | 229 | return generalDialog<T>( |
236 | pageBuilder: (buildContext, animation, secondaryAnimation) { | 230 | pageBuilder: (buildContext, animation, secondaryAnimation) { |
237 | final pageChild = widget; | 231 | final pageChild = widget; |
238 | Widget dialog = Builder(builder: (context) { | 232 | Widget dialog = Builder(builder: (context) { |
239 | - return theme != null | ||
240 | - ? Theme(data: theme, child: pageChild) | ||
241 | - : pageChild; | 233 | + return Theme(data: theme, child: pageChild); |
242 | }); | 234 | }); |
243 | if (useSafeArea) { | 235 | if (useSafeArea) { |
244 | dialog = SafeArea(child: dialog); | 236 | dialog = SafeArea(child: dialog); |
@@ -246,7 +238,7 @@ extension ExtensionDialog on GetInterface { | @@ -246,7 +238,7 @@ extension ExtensionDialog on GetInterface { | ||
246 | return dialog; | 238 | return dialog; |
247 | }, | 239 | }, |
248 | barrierDismissible: barrierDismissible, | 240 | barrierDismissible: barrierDismissible, |
249 | - barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel, | 241 | + barrierLabel: MaterialLocalizations.of(context!).modalBarrierDismissLabel, |
250 | barrierColor: barrierColor ?? Colors.black54, | 242 | barrierColor: barrierColor ?? Colors.black54, |
251 | transitionDuration: transitionDuration ?? defaultDialogTransitionDuration, | 243 | transitionDuration: transitionDuration ?? defaultDialogTransitionDuration, |
252 | transitionBuilder: (context, animation, secondaryAnimation, child) { | 244 | transitionBuilder: (context, animation, secondaryAnimation, child) { |
@@ -265,20 +257,18 @@ extension ExtensionDialog on GetInterface { | @@ -265,20 +257,18 @@ extension ExtensionDialog on GetInterface { | ||
265 | } | 257 | } |
266 | 258 | ||
267 | /// Api from showGeneralDialog with no context | 259 | /// Api from showGeneralDialog with no context |
268 | - Future<T> generalDialog<T>({ | ||
269 | - @required RoutePageBuilder pageBuilder, | 260 | + Future<T?> generalDialog<T>({ |
261 | + required RoutePageBuilder pageBuilder, | ||
270 | bool barrierDismissible = false, | 262 | bool barrierDismissible = false, |
271 | - String barrierLabel, | 263 | + String? barrierLabel, |
272 | Color barrierColor = const Color(0x80000000), | 264 | Color barrierColor = const Color(0x80000000), |
273 | Duration transitionDuration = const Duration(milliseconds: 200), | 265 | Duration transitionDuration = const Duration(milliseconds: 200), |
274 | - RouteTransitionsBuilder transitionBuilder, | 266 | + RouteTransitionsBuilder? transitionBuilder, |
275 | bool useRootNavigator = true, | 267 | bool useRootNavigator = true, |
276 | - RouteSettings routeSettings, | 268 | + RouteSettings? routeSettings, |
277 | }) { | 269 | }) { |
278 | - assert(pageBuilder != null); | ||
279 | - assert(useRootNavigator != null); | ||
280 | assert(!barrierDismissible || barrierLabel != null); | 270 | assert(!barrierDismissible || barrierLabel != null); |
281 | - return Navigator.of(overlayContext, rootNavigator: useRootNavigator) | 271 | + return Navigator.of(overlayContext!, rootNavigator: useRootNavigator) |
282 | .push<T>(GetDialogRoute<T>( | 272 | .push<T>(GetDialogRoute<T>( |
283 | pageBuilder: pageBuilder, | 273 | pageBuilder: pageBuilder, |
284 | barrierDismissible: barrierDismissible, | 274 | barrierDismissible: barrierDismissible, |
@@ -291,32 +281,32 @@ extension ExtensionDialog on GetInterface { | @@ -291,32 +281,32 @@ extension ExtensionDialog on GetInterface { | ||
291 | } | 281 | } |
292 | 282 | ||
293 | /// Custom UI Dialog. | 283 | /// Custom UI Dialog. |
294 | - Future<T> defaultDialog<T>({ | 284 | + Future<T?> defaultDialog<T>({ |
295 | String title = "Alert", | 285 | String title = "Alert", |
296 | - TextStyle titleStyle, | ||
297 | - Widget content, | ||
298 | - VoidCallback onConfirm, | ||
299 | - VoidCallback onCancel, | ||
300 | - VoidCallback onCustom, | ||
301 | - Color cancelTextColor, | ||
302 | - Color confirmTextColor, | ||
303 | - String textConfirm, | ||
304 | - String textCancel, | ||
305 | - String textCustom, | ||
306 | - Widget confirm, | ||
307 | - Widget cancel, | ||
308 | - Widget custom, | ||
309 | - Color backgroundColor, | 286 | + TextStyle? titleStyle, |
287 | + Widget? content, | ||
288 | + VoidCallback? onConfirm, | ||
289 | + VoidCallback? onCancel, | ||
290 | + VoidCallback? onCustom, | ||
291 | + Color? cancelTextColor, | ||
292 | + Color? confirmTextColor, | ||
293 | + String? textConfirm, | ||
294 | + String? textCancel, | ||
295 | + String? textCustom, | ||
296 | + Widget? confirm, | ||
297 | + Widget? cancel, | ||
298 | + Widget? custom, | ||
299 | + Color? backgroundColor, | ||
310 | bool barrierDismissible = true, | 300 | bool barrierDismissible = true, |
311 | - Color buttonColor, | 301 | + Color? buttonColor, |
312 | String middleText = "Dialog made in 3 lines of code", | 302 | String middleText = "Dialog made in 3 lines of code", |
313 | - TextStyle middleTextStyle, | 303 | + TextStyle? middleTextStyle, |
314 | double radius = 20.0, | 304 | double radius = 20.0, |
315 | // ThemeData themeData, | 305 | // ThemeData themeData, |
316 | - List<Widget> actions, | 306 | + List<Widget>? actions, |
317 | 307 | ||
318 | // onWillPop Scope | 308 | // onWillPop Scope |
319 | - WillPopCallback onWillPop, | 309 | + WillPopCallback? onWillPop, |
320 | }) { | 310 | }) { |
321 | var leanCancel = onCancel != null || textCancel != null; | 311 | var leanCancel = onCancel != null || textCancel != null; |
322 | var leanConfirm = onConfirm != null || textConfirm != null; | 312 | var leanConfirm = onConfirm != null || textConfirm != null; |
@@ -355,7 +345,6 @@ extension ExtensionDialog on GetInterface { | @@ -355,7 +345,6 @@ extension ExtensionDialog on GetInterface { | ||
355 | actions.add(TextButton( | 345 | actions.add(TextButton( |
356 | style: TextButton.styleFrom( | 346 | style: TextButton.styleFrom( |
357 | tapTargetSize: MaterialTapTargetSize.shrinkWrap, | 347 | tapTargetSize: MaterialTapTargetSize.shrinkWrap, |
358 | - //color: buttonColor ?? theme.accentColor, | ||
359 | backgroundColor: buttonColor ?? theme.accentColor, | 348 | backgroundColor: buttonColor ?? theme.accentColor, |
360 | shape: RoundedRectangleBorder( | 349 | shape: RoundedRectangleBorder( |
361 | borderRadius: BorderRadius.circular(100)), | 350 | borderRadius: BorderRadius.circular(100)), |
@@ -374,6 +363,7 @@ extension ExtensionDialog on GetInterface { | @@ -374,6 +363,7 @@ extension ExtensionDialog on GetInterface { | ||
374 | Widget baseAlertDialog = AlertDialog( | 363 | Widget baseAlertDialog = AlertDialog( |
375 | titlePadding: EdgeInsets.all(8), | 364 | titlePadding: EdgeInsets.all(8), |
376 | contentPadding: EdgeInsets.all(8), | 365 | contentPadding: EdgeInsets.all(8), |
366 | + | ||
377 | backgroundColor: backgroundColor ?? theme.dialogBackgroundColor, | 367 | backgroundColor: backgroundColor ?? theme.dialogBackgroundColor, |
378 | shape: RoundedRectangleBorder( | 368 | shape: RoundedRectangleBorder( |
379 | borderRadius: BorderRadius.all(Radius.circular(radius))), | 369 | borderRadius: BorderRadius.all(Radius.circular(radius))), |
@@ -383,7 +373,7 @@ extension ExtensionDialog on GetInterface { | @@ -383,7 +373,7 @@ extension ExtensionDialog on GetInterface { | ||
383 | mainAxisSize: MainAxisSize.min, | 373 | mainAxisSize: MainAxisSize.min, |
384 | children: [ | 374 | children: [ |
385 | content ?? | 375 | content ?? |
386 | - Text(middleText ?? "", | 376 | + Text(middleText, |
387 | textAlign: TextAlign.center, style: middleTextStyle), | 377 | textAlign: TextAlign.center, style: middleTextStyle), |
388 | SizedBox(height: 16), | 378 | SizedBox(height: 16), |
389 | ButtonTheme( | 379 | ButtonTheme( |
@@ -420,39 +410,34 @@ extension ExtensionDialog on GetInterface { | @@ -420,39 +410,34 @@ extension ExtensionDialog on GetInterface { | ||
420 | } | 410 | } |
421 | 411 | ||
422 | extension ExtensionBottomSheet on GetInterface { | 412 | extension ExtensionBottomSheet on GetInterface { |
423 | - Future<T> bottomSheet<T>( | 413 | + Future<T?> bottomSheet<T>( |
424 | Widget bottomsheet, { | 414 | Widget bottomsheet, { |
425 | - Color backgroundColor, | ||
426 | - double elevation, | 415 | + Color? backgroundColor, |
416 | + double? elevation, | ||
427 | bool persistent = true, | 417 | bool persistent = true, |
428 | - ShapeBorder shape, | ||
429 | - Clip clipBehavior, | ||
430 | - Color barrierColor, | ||
431 | - bool ignoreSafeArea, | 418 | + ShapeBorder? shape, |
419 | + Clip? clipBehavior, | ||
420 | + Color? barrierColor, | ||
421 | + bool? ignoreSafeArea, | ||
432 | bool isScrollControlled = false, | 422 | bool isScrollControlled = false, |
433 | bool useRootNavigator = false, | 423 | bool useRootNavigator = false, |
434 | bool isDismissible = true, | 424 | bool isDismissible = true, |
435 | bool enableDrag = true, | 425 | bool enableDrag = true, |
436 | - RouteSettings settings, | ||
437 | - Duration enterBottomSheetDuration, | ||
438 | - Duration exitBottomSheetDuration, | 426 | + RouteSettings? settings, |
427 | + Duration? enterBottomSheetDuration, | ||
428 | + Duration? exitBottomSheetDuration, | ||
439 | }) { | 429 | }) { |
440 | - assert(bottomsheet != null); | ||
441 | - assert(persistent != null); | ||
442 | - assert(isScrollControlled != null); | ||
443 | - assert(useRootNavigator != null); | ||
444 | - assert(isDismissible != null); | ||
445 | - assert(enableDrag != null); | ||
446 | - | ||
447 | - return Navigator.of(overlayContext, rootNavigator: useRootNavigator) | 430 | + return Navigator.of(overlayContext!, rootNavigator: useRootNavigator) |
448 | .push(GetModalBottomSheetRoute<T>( | 431 | .push(GetModalBottomSheetRoute<T>( |
449 | builder: (_) => bottomsheet, | 432 | builder: (_) => bottomsheet, |
450 | isPersistent: persistent, | 433 | isPersistent: persistent, |
451 | // theme: Theme.of(key.currentContext, shadowThemeOnly: true), | 434 | // theme: Theme.of(key.currentContext, shadowThemeOnly: true), |
452 | - theme: Theme.of(key.currentContext), | 435 | + theme: Theme.of(key.currentContext!), |
453 | isScrollControlled: isScrollControlled, | 436 | isScrollControlled: isScrollControlled, |
454 | - barrierLabel: | ||
455 | - MaterialLocalizations.of(key.currentContext).modalBarrierDismissLabel, | 437 | + |
438 | + barrierLabel: MaterialLocalizations.of(key.currentContext!) | ||
439 | + .modalBarrierDismissLabel, | ||
440 | + | ||
456 | backgroundColor: backgroundColor ?? Colors.transparent, | 441 | backgroundColor: backgroundColor ?? Colors.transparent, |
457 | elevation: elevation, | 442 | elevation: elevation, |
458 | shape: shape, | 443 | shape: shape, |
@@ -491,24 +476,24 @@ extension GetNavigation on GetInterface { | @@ -491,24 +476,24 @@ extension GetNavigation on GetInterface { | ||
491 | /// | 476 | /// |
492 | /// By default, GetX will prevent you from push a route that you already in, | 477 | /// By default, GetX will prevent you from push a route that you already in, |
493 | /// if you want to push anyway, set [preventDuplicates] to false | 478 | /// if you want to push anyway, set [preventDuplicates] to false |
494 | - Future<T> to<T>( | 479 | + Future<T?>? to<T>( |
495 | dynamic page, { | 480 | dynamic page, { |
496 | - bool opaque, | ||
497 | - Transition transition, | ||
498 | - Curve curve, | ||
499 | - Duration duration, | ||
500 | - int id, | 481 | + bool? opaque, |
482 | + Transition? transition, | ||
483 | + Curve? curve, | ||
484 | + Duration? duration, | ||
485 | + int? id, | ||
501 | bool fullscreenDialog = false, | 486 | bool fullscreenDialog = false, |
502 | dynamic arguments, | 487 | dynamic arguments, |
503 | - Bindings binding, | 488 | + Bindings? binding, |
504 | bool preventDuplicates = true, | 489 | bool preventDuplicates = true, |
505 | - bool popGesture, | 490 | + bool? popGesture, |
506 | }) { | 491 | }) { |
507 | var routeName = "/${page.runtimeType.toString()}"; | 492 | var routeName = "/${page.runtimeType.toString()}"; |
508 | if (preventDuplicates && routeName == currentRoute) { | 493 | if (preventDuplicates && routeName == currentRoute) { |
509 | return null; | 494 | return null; |
510 | } | 495 | } |
511 | - return global(id)?.currentState?.push<T>( | 496 | + return global(id).currentState?.push<T>( |
512 | GetPageRoute<T>( | 497 | GetPageRoute<T>( |
513 | opaque: opaque ?? true, | 498 | opaque: opaque ?? true, |
514 | page: _resolve(page, 'to'), | 499 | page: _resolve(page, 'to'), |
@@ -536,6 +521,9 @@ extension GetNavigation on GetInterface { | @@ -536,6 +521,9 @@ extension GetNavigation on GetInterface { | ||
536 | Using a widget function instead of a widget fully guarantees that the widget and its controllers will be removed from memory when they are no longer used. | 521 | Using a widget function instead of a widget fully guarantees that the widget and its controllers will be removed from memory when they are no longer used. |
537 | '''); | 522 | '''); |
538 | return () => page; | 523 | return () => page; |
524 | + } else if (page is String) { | ||
525 | + throw '''Unexpected String, | ||
526 | +use toNamed() instead'''; | ||
539 | } else { | 527 | } else { |
540 | throw '''Unexpected format, | 528 | throw '''Unexpected format, |
541 | you can only use widgets and widget functions here'''; | 529 | you can only use widgets and widget functions here'''; |
@@ -558,12 +546,12 @@ you can only use widgets and widget functions here'''; | @@ -558,12 +546,12 @@ you can only use widgets and widget functions here'''; | ||
558 | /// if you want to push anyway, set [preventDuplicates] to false | 546 | /// if you want to push anyway, set [preventDuplicates] to false |
559 | /// | 547 | /// |
560 | /// Note: Always put a slash on the route ('/page1'), to avoid unnexpected errors | 548 | /// Note: Always put a slash on the route ('/page1'), to avoid unnexpected errors |
561 | - Future<T> toNamed<T>( | 549 | + Future<T?>? toNamed<T>( |
562 | String page, { | 550 | String page, { |
563 | dynamic arguments, | 551 | dynamic arguments, |
564 | - int id, | 552 | + int? id, |
565 | bool preventDuplicates = true, | 553 | bool preventDuplicates = true, |
566 | - Map<String, String> parameters, | 554 | + Map<String, String>? parameters, |
567 | }) { | 555 | }) { |
568 | if (preventDuplicates && page == currentRoute) { | 556 | if (preventDuplicates && page == currentRoute) { |
569 | return null; | 557 | return null; |
@@ -574,7 +562,7 @@ you can only use widgets and widget functions here'''; | @@ -574,7 +562,7 @@ you can only use widgets and widget functions here'''; | ||
574 | page = uri.toString(); | 562 | page = uri.toString(); |
575 | } | 563 | } |
576 | 564 | ||
577 | - return global(id)?.currentState?.pushNamed<T>( | 565 | + return global(id).currentState?.pushNamed<T>( |
578 | page, | 566 | page, |
579 | arguments: arguments, | 567 | arguments: arguments, |
580 | ); | 568 | ); |
@@ -596,12 +584,12 @@ you can only use widgets and widget functions here'''; | @@ -596,12 +584,12 @@ you can only use widgets and widget functions here'''; | ||
596 | /// if you want to push anyway, set [preventDuplicates] to false | 584 | /// if you want to push anyway, set [preventDuplicates] to false |
597 | /// | 585 | /// |
598 | /// Note: Always put a slash on the route ('/page1'), to avoid unnexpected errors | 586 | /// Note: Always put a slash on the route ('/page1'), to avoid unnexpected errors |
599 | - Future<T> offNamed<T>( | 587 | + Future<T?>? offNamed<T>( |
600 | String page, { | 588 | String page, { |
601 | dynamic arguments, | 589 | dynamic arguments, |
602 | - int id, | 590 | + int? id, |
603 | bool preventDuplicates = true, | 591 | bool preventDuplicates = true, |
604 | - Map<String, String> parameters, | 592 | + Map<String, String>? parameters, |
605 | }) { | 593 | }) { |
606 | if (preventDuplicates && page == currentRoute) { | 594 | if (preventDuplicates && page == currentRoute) { |
607 | return null; | 595 | return null; |
@@ -611,7 +599,7 @@ you can only use widgets and widget functions here'''; | @@ -611,7 +599,7 @@ you can only use widgets and widget functions here'''; | ||
611 | final uri = Uri(path: page, queryParameters: parameters); | 599 | final uri = Uri(path: page, queryParameters: parameters); |
612 | page = uri.toString(); | 600 | page = uri.toString(); |
613 | } | 601 | } |
614 | - return global(id)?.currentState?.pushReplacementNamed( | 602 | + return global(id).currentState?.pushReplacementNamed( |
615 | page, | 603 | page, |
616 | arguments: arguments, | 604 | arguments: arguments, |
617 | ); | 605 | ); |
@@ -630,10 +618,10 @@ you can only use widgets and widget functions here'''; | @@ -630,10 +618,10 @@ you can only use widgets and widget functions here'''; | ||
630 | /// or also like this: | 618 | /// or also like this: |
631 | /// `Get.until((route) => !Get.isDialogOpen())`, to make sure the | 619 | /// `Get.until((route) => !Get.isDialogOpen())`, to make sure the |
632 | /// dialog is closed | 620 | /// dialog is closed |
633 | - void until(RoutePredicate predicate, {int id}) { | 621 | + void until(RoutePredicate predicate, {int? id}) { |
634 | // if (key.currentState.mounted) // add this if appear problems on future with route navigate | 622 | // if (key.currentState.mounted) // add this if appear problems on future with route navigate |
635 | // when widget don't mounted | 623 | // when widget don't mounted |
636 | - return global(id)?.currentState?.popUntil(predicate); | 624 | + return global(id).currentState?.popUntil(predicate); |
637 | } | 625 | } |
638 | 626 | ||
639 | /// **Navigation.pushAndRemoveUntil()** shortcut.<br><br> | 627 | /// **Navigation.pushAndRemoveUntil()** shortcut.<br><br> |
@@ -654,10 +642,10 @@ you can only use widgets and widget functions here'''; | @@ -654,10 +642,10 @@ you can only use widgets and widget functions here'''; | ||
654 | /// or also like this: | 642 | /// or also like this: |
655 | /// `Get.until((route) => !Get.isDialogOpen())`, to make sure the dialog | 643 | /// `Get.until((route) => !Get.isDialogOpen())`, to make sure the dialog |
656 | /// is closed | 644 | /// is closed |
657 | - Future<T> offUntil<T>(Route<T> page, RoutePredicate predicate, {int id}) { | 645 | + Future<T?>? offUntil<T>(Route<T> page, RoutePredicate predicate, {int? id}) { |
658 | // if (key.currentState.mounted) // add this if appear problems on future with route navigate | 646 | // if (key.currentState.mounted) // add this if appear problems on future with route navigate |
659 | // when widget don't mounted | 647 | // when widget don't mounted |
660 | - return global(id)?.currentState?.pushAndRemoveUntil<T>(page, predicate); | 648 | + return global(id).currentState?.pushAndRemoveUntil<T>(page, predicate); |
661 | } | 649 | } |
662 | 650 | ||
663 | /// **Navigation.pushNamedAndRemoveUntil()** shortcut.<br><br> | 651 | /// **Navigation.pushNamedAndRemoveUntil()** shortcut.<br><br> |
@@ -678,19 +666,19 @@ you can only use widgets and widget functions here'''; | @@ -678,19 +666,19 @@ you can only use widgets and widget functions here'''; | ||
678 | /// to make sure the dialog is closed | 666 | /// to make sure the dialog is closed |
679 | /// | 667 | /// |
680 | /// Note: Always put a slash on the route name ('/page1'), to avoid unexpected errors | 668 | /// Note: Always put a slash on the route name ('/page1'), to avoid unexpected errors |
681 | - Future<T> offNamedUntil<T>( | 669 | + Future<T?>? offNamedUntil<T>( |
682 | String page, | 670 | String page, |
683 | RoutePredicate predicate, { | 671 | RoutePredicate predicate, { |
684 | - int id, | 672 | + int? id, |
685 | dynamic arguments, | 673 | dynamic arguments, |
686 | - Map<String, String> parameters, | 674 | + Map<String, String>? parameters, |
687 | }) { | 675 | }) { |
688 | if (parameters != null) { | 676 | if (parameters != null) { |
689 | final uri = Uri(path: page, queryParameters: parameters); | 677 | final uri = Uri(path: page, queryParameters: parameters); |
690 | page = uri.toString(); | 678 | page = uri.toString(); |
691 | } | 679 | } |
692 | 680 | ||
693 | - return global(id)?.currentState?.pushNamedAndRemoveUntil<T>( | 681 | + return global(id).currentState?.pushNamedAndRemoveUntil<T>( |
694 | page, | 682 | page, |
695 | predicate, | 683 | predicate, |
696 | arguments: arguments, | 684 | arguments: arguments, |
@@ -708,18 +696,18 @@ you can only use widgets and widget functions here'''; | @@ -708,18 +696,18 @@ you can only use widgets and widget functions here'''; | ||
708 | /// The `offNamed()` pop a page, and goes to the next. The | 696 | /// The `offNamed()` pop a page, and goes to the next. The |
709 | /// `offAndToNamed()` goes to the next page, and removes the previous one. | 697 | /// `offAndToNamed()` goes to the next page, and removes the previous one. |
710 | /// The route transition animation is different. | 698 | /// The route transition animation is different. |
711 | - Future<T> offAndToNamed<T>( | 699 | + Future<T?>? offAndToNamed<T>( |
712 | String page, { | 700 | String page, { |
713 | dynamic arguments, | 701 | dynamic arguments, |
714 | - int id, | 702 | + int? id, |
715 | dynamic result, | 703 | dynamic result, |
716 | - Map<String, String> parameters, | 704 | + Map<String, String>? parameters, |
717 | }) { | 705 | }) { |
718 | if (parameters != null) { | 706 | if (parameters != null) { |
719 | final uri = Uri(path: page, queryParameters: parameters); | 707 | final uri = Uri(path: page, queryParameters: parameters); |
720 | page = uri.toString(); | 708 | page = uri.toString(); |
721 | } | 709 | } |
722 | - return global(id)?.currentState?.popAndPushNamed( | 710 | + return global(id).currentState?.popAndPushNamed( |
723 | page, | 711 | page, |
724 | arguments: arguments, | 712 | arguments: arguments, |
725 | result: result, | 713 | result: result, |
@@ -732,8 +720,8 @@ you can only use widgets and widget functions here'''; | @@ -732,8 +720,8 @@ you can only use widgets and widget functions here'''; | ||
732 | /// | 720 | /// |
733 | /// [id] is for when you are using nested navigation, | 721 | /// [id] is for when you are using nested navigation, |
734 | /// as explained in documentation | 722 | /// as explained in documentation |
735 | - void removeRoute(Route<dynamic> route, {int id}) { | ||
736 | - return global(id)?.currentState?.removeRoute(route); | 723 | + void removeRoute(Route<dynamic> route, {int? id}) { |
724 | + return global(id).currentState?.removeRoute(route); | ||
737 | } | 725 | } |
738 | 726 | ||
739 | /// **Navigation.pushNamedAndRemoveUntil()** shortcut.<br><br> | 727 | /// **Navigation.pushNamedAndRemoveUntil()** shortcut.<br><br> |
@@ -756,19 +744,19 @@ you can only use widgets and widget functions here'''; | @@ -756,19 +744,19 @@ you can only use widgets and widget functions here'''; | ||
756 | /// as explained in documentation | 744 | /// as explained in documentation |
757 | /// | 745 | /// |
758 | /// Note: Always put a slash on the route ('/page1'), to avoid unexpected errors | 746 | /// Note: Always put a slash on the route ('/page1'), to avoid unexpected errors |
759 | - Future<T> offAllNamed<T>( | 747 | + Future<T?>? offAllNamed<T>( |
760 | String newRouteName, { | 748 | String newRouteName, { |
761 | - RoutePredicate predicate, | 749 | + RoutePredicate? predicate, |
762 | dynamic arguments, | 750 | dynamic arguments, |
763 | - int id, | ||
764 | - Map<String, String> parameters, | 751 | + int? id, |
752 | + Map<String, String>? parameters, | ||
765 | }) { | 753 | }) { |
766 | if (parameters != null) { | 754 | if (parameters != null) { |
767 | final uri = Uri(path: newRouteName, queryParameters: parameters); | 755 | final uri = Uri(path: newRouteName, queryParameters: parameters); |
768 | newRouteName = uri.toString(); | 756 | newRouteName = uri.toString(); |
769 | } | 757 | } |
770 | 758 | ||
771 | - return global(id)?.currentState?.pushNamedAndRemoveUntil<T>( | 759 | + return global(id).currentState?.pushNamedAndRemoveUntil<T>( |
772 | newRouteName, | 760 | newRouteName, |
773 | predicate ?? (_) => false, | 761 | predicate ?? (_) => false, |
774 | arguments: arguments, | 762 | arguments: arguments, |
@@ -777,11 +765,11 @@ you can only use widgets and widget functions here'''; | @@ -777,11 +765,11 @@ you can only use widgets and widget functions here'''; | ||
777 | 765 | ||
778 | /// Returns true if a Snackbar, Dialog or BottomSheet is currently OPEN | 766 | /// Returns true if a Snackbar, Dialog or BottomSheet is currently OPEN |
779 | bool get isOverlaysOpen => | 767 | bool get isOverlaysOpen => |
780 | - (isSnackbarOpen || isDialogOpen || isBottomSheetOpen); | 768 | + (isSnackbarOpen! || isDialogOpen! || isBottomSheetOpen!); |
781 | 769 | ||
782 | /// Returns true if there is no Snackbar, Dialog or BottomSheet open | 770 | /// Returns true if there is no Snackbar, Dialog or BottomSheet open |
783 | bool get isOverlaysClosed => | 771 | bool get isOverlaysClosed => |
784 | - (!isSnackbarOpen && !isDialogOpen && !isBottomSheetOpen); | 772 | + (!isSnackbarOpen! && !isDialogOpen! && !isBottomSheetOpen!); |
785 | 773 | ||
786 | /// **Navigation.popUntil()** shortcut.<br><br> | 774 | /// **Navigation.popUntil()** shortcut.<br><br> |
787 | /// | 775 | /// |
@@ -796,10 +784,10 @@ you can only use widgets and widget functions here'''; | @@ -796,10 +784,10 @@ you can only use widgets and widget functions here'''; | ||
796 | /// It has the advantage of not needing context, so you can call | 784 | /// It has the advantage of not needing context, so you can call |
797 | /// from your business logic. | 785 | /// from your business logic. |
798 | void back<T>({ | 786 | void back<T>({ |
799 | - T result, | 787 | + T? result, |
800 | bool closeOverlays = false, | 788 | bool closeOverlays = false, |
801 | bool canPop = true, | 789 | bool canPop = true, |
802 | - int id, | 790 | + int? id, |
803 | }) { | 791 | }) { |
804 | if (closeOverlays && isOverlaysOpen) { | 792 | if (closeOverlays && isOverlaysOpen) { |
805 | navigator?.popUntil((route) { | 793 | navigator?.popUntil((route) { |
@@ -807,11 +795,11 @@ you can only use widgets and widget functions here'''; | @@ -807,11 +795,11 @@ you can only use widgets and widget functions here'''; | ||
807 | }); | 795 | }); |
808 | } | 796 | } |
809 | if (canPop) { | 797 | if (canPop) { |
810 | - if (global(id)?.currentState?.canPop() == true) { | ||
811 | - global(id)?.currentState?.pop<T>(result); | 798 | + if (global(id).currentState?.canPop() == true) { |
799 | + global(id).currentState?.pop<T>(result); | ||
812 | } | 800 | } |
813 | } else { | 801 | } else { |
814 | - global(id)?.currentState?.pop<T>(result); | 802 | + global(id).currentState?.pop<T>(result); |
815 | } | 803 | } |
816 | } | 804 | } |
817 | 805 | ||
@@ -821,12 +809,12 @@ you can only use widgets and widget functions here'''; | @@ -821,12 +809,12 @@ you can only use widgets and widget functions here'''; | ||
821 | /// | 809 | /// |
822 | /// [id] is for when you are using nested navigation, | 810 | /// [id] is for when you are using nested navigation, |
823 | /// as explained in documentation | 811 | /// as explained in documentation |
824 | - void close(int times, [int id]) { | ||
825 | - if ((times == null) || (times < 1)) { | 812 | + void close(int times, [int? id]) { |
813 | + if (times < 1) { | ||
826 | times = 1; | 814 | times = 1; |
827 | } | 815 | } |
828 | var count = 0; | 816 | var count = 0; |
829 | - var back = global(id)?.currentState?.popUntil((route) => count++ == times); | 817 | + var back = global(id).currentState?.popUntil((route) => count++ == times); |
830 | 818 | ||
831 | return back; | 819 | return back; |
832 | } | 820 | } |
@@ -856,25 +844,25 @@ you can only use widgets and widget functions here'''; | @@ -856,25 +844,25 @@ you can only use widgets and widget functions here'''; | ||
856 | /// | 844 | /// |
857 | /// By default, GetX will prevent you from push a route that you already in, | 845 | /// By default, GetX will prevent you from push a route that you already in, |
858 | /// if you want to push anyway, set [preventDuplicates] to false | 846 | /// if you want to push anyway, set [preventDuplicates] to false |
859 | - Future<T> off<T>( | 847 | + Future<T?>? off<T>( |
860 | dynamic page, { | 848 | dynamic page, { |
861 | bool opaque = false, | 849 | bool opaque = false, |
862 | - Transition transition, | ||
863 | - Curve curve, | ||
864 | - bool popGesture, | ||
865 | - int id, | 850 | + Transition? transition, |
851 | + Curve? curve, | ||
852 | + bool? popGesture, | ||
853 | + int? id, | ||
866 | dynamic arguments, | 854 | dynamic arguments, |
867 | - Bindings binding, | 855 | + Bindings? binding, |
868 | bool fullscreenDialog = false, | 856 | bool fullscreenDialog = false, |
869 | bool preventDuplicates = true, | 857 | bool preventDuplicates = true, |
870 | - Duration duration, | 858 | + Duration? duration, |
871 | }) { | 859 | }) { |
872 | var routeName = "/${page.runtimeType.toString()}"; | 860 | var routeName = "/${page.runtimeType.toString()}"; |
873 | if (preventDuplicates && routeName == currentRoute) { | 861 | if (preventDuplicates && routeName == currentRoute) { |
874 | return null; | 862 | return null; |
875 | } | 863 | } |
876 | - return global(id)?.currentState?.pushReplacement(GetPageRoute( | ||
877 | - opaque: opaque ?? true, | 864 | + return global(id).currentState?.pushReplacement(GetPageRoute( |
865 | + opaque: opaque, | ||
878 | page: _resolve(page, 'off'), | 866 | page: _resolve(page, 'off'), |
879 | binding: binding, | 867 | binding: binding, |
880 | settings: RouteSettings(arguments: arguments), | 868 | settings: RouteSettings(arguments: arguments), |
@@ -917,24 +905,24 @@ you can only use widgets and widget functions here'''; | @@ -917,24 +905,24 @@ you can only use widgets and widget functions here'''; | ||
917 | /// | 905 | /// |
918 | /// By default, GetX will prevent you from push a route that you already in, | 906 | /// By default, GetX will prevent you from push a route that you already in, |
919 | /// if you want to push anyway, set [preventDuplicates] to false | 907 | /// if you want to push anyway, set [preventDuplicates] to false |
920 | - Future<T> offAll<T>( | 908 | + Future<T?>? offAll<T>( |
921 | dynamic page, { | 909 | dynamic page, { |
922 | - RoutePredicate predicate, | 910 | + RoutePredicate? predicate, |
923 | bool opaque = false, | 911 | bool opaque = false, |
924 | - bool popGesture, | ||
925 | - int id, | 912 | + bool? popGesture, |
913 | + int? id, | ||
926 | dynamic arguments, | 914 | dynamic arguments, |
927 | - Bindings binding, | 915 | + Bindings? binding, |
928 | bool fullscreenDialog = false, | 916 | bool fullscreenDialog = false, |
929 | - Transition transition, | ||
930 | - Curve curve, | ||
931 | - Duration duration, | 917 | + Transition? transition, |
918 | + Curve? curve, | ||
919 | + Duration? duration, | ||
932 | }) { | 920 | }) { |
933 | var routeName = "/${page.runtimeType.toString()}"; | 921 | var routeName = "/${page.runtimeType.toString()}"; |
934 | 922 | ||
935 | - return global(id)?.currentState?.pushAndRemoveUntil<T>( | 923 | + return global(id).currentState?.pushAndRemoveUntil<T>( |
936 | GetPageRoute<T>( | 924 | GetPageRoute<T>( |
937 | - opaque: opaque ?? true, | 925 | + opaque: opaque, |
938 | popGesture: popGesture ?? defaultPopGesture, | 926 | popGesture: popGesture ?? defaultPopGesture, |
939 | page: _resolve(page, 'offAll'), | 927 | page: _resolve(page, 'offAll'), |
940 | binding: binding, | 928 | binding: binding, |
@@ -948,32 +936,28 @@ you can only use widgets and widget functions here'''; | @@ -948,32 +936,28 @@ you can only use widgets and widget functions here'''; | ||
948 | predicate ?? (route) => false); | 936 | predicate ?? (route) => false); |
949 | } | 937 | } |
950 | 938 | ||
951 | - void addPages(List<GetPage> getPages) { | 939 | + void addPages(List<GetPage>? getPages) { |
952 | if (getPages != null) { | 940 | if (getPages != null) { |
953 | - if (routeTree == null) { | ||
954 | - routeTree = ParseRouteTree(); | ||
955 | - } | 941 | + routeTree = ParseRouteTree(); |
956 | 942 | ||
957 | routeTree.addRoutes(getPages); | 943 | routeTree.addRoutes(getPages); |
958 | } | 944 | } |
959 | } | 945 | } |
960 | 946 | ||
961 | void addPage(GetPage getPage) { | 947 | void addPage(GetPage getPage) { |
962 | - if (getPage != null) { | ||
963 | - if (routeTree == null) routeTree = ParseRouteTree(); | ||
964 | - routeTree.addRoute(getPage); | ||
965 | - } | 948 | + routeTree = ParseRouteTree(); |
949 | + routeTree.addRoute(getPage); | ||
966 | } | 950 | } |
967 | 951 | ||
968 | /// change default config of Get | 952 | /// change default config of Get |
969 | void config( | 953 | void config( |
970 | - {bool enableLog, | ||
971 | - LogWriterCallback logWriterCallback, | ||
972 | - bool defaultPopGesture, | ||
973 | - bool defaultOpaqueRoute, | ||
974 | - Duration defaultDurationTransition, | ||
975 | - bool defaultGlobalState, | ||
976 | - Transition defaultTransition}) { | 954 | + {bool? enableLog, |
955 | + LogWriterCallback? logWriterCallback, | ||
956 | + bool? defaultPopGesture, | ||
957 | + bool? defaultOpaqueRoute, | ||
958 | + Duration? defaultDurationTransition, | ||
959 | + bool? defaultGlobalState, | ||
960 | + Transition? defaultTransition}) { | ||
977 | if (enableLog != null) { | 961 | if (enableLog != null) { |
978 | Get.isLogEnable = enableLog; | 962 | Get.isLogEnable = enableLog; |
979 | } | 963 | } |
@@ -1014,7 +998,7 @@ you can only use widgets and widget functions here'''; | @@ -1014,7 +998,7 @@ you can only use widgets and widget functions here'''; | ||
1014 | /// Your entire application will be rebuilt, and touch events will not | 998 | /// Your entire application will be rebuilt, and touch events will not |
1015 | /// work until the end of rendering. | 999 | /// work until the end of rendering. |
1016 | void forceAppUpdate() { | 1000 | void forceAppUpdate() { |
1017 | - engine.performReassemble(); | 1001 | + engine!.performReassemble(); |
1018 | } | 1002 | } |
1019 | 1003 | ||
1020 | void appUpdate() => getxController.update(); | 1004 | void appUpdate() => getxController.update(); |
@@ -1027,17 +1011,17 @@ you can only use widgets and widget functions here'''; | @@ -1027,17 +1011,17 @@ you can only use widgets and widget functions here'''; | ||
1027 | getxController.setThemeMode(themeMode); | 1011 | getxController.setThemeMode(themeMode); |
1028 | } | 1012 | } |
1029 | 1013 | ||
1030 | - GlobalKey<NavigatorState> addKey(GlobalKey<NavigatorState> newKey) { | 1014 | + GlobalKey<NavigatorState>? addKey(GlobalKey<NavigatorState> newKey) { |
1031 | getxController.key = newKey; | 1015 | getxController.key = newKey; |
1032 | return key; | 1016 | return key; |
1033 | } | 1017 | } |
1034 | 1018 | ||
1035 | - GlobalKey<NavigatorState> nestedKey(int key) { | 1019 | + GlobalKey<NavigatorState>? nestedKey(dynamic key) { |
1036 | keys.putIfAbsent(key, () => GlobalKey<NavigatorState>()); | 1020 | keys.putIfAbsent(key, () => GlobalKey<NavigatorState>()); |
1037 | return keys[key]; | 1021 | return keys[key]; |
1038 | } | 1022 | } |
1039 | 1023 | ||
1040 | - GlobalKey<NavigatorState> global(int k) { | 1024 | + GlobalKey<NavigatorState> global(int? k) { |
1041 | GlobalKey<NavigatorState> _key; | 1025 | GlobalKey<NavigatorState> _key; |
1042 | if (k == null) { | 1026 | if (k == null) { |
1043 | _key = key; | 1027 | _key = key; |
@@ -1045,7 +1029,7 @@ you can only use widgets and widget functions here'''; | @@ -1045,7 +1029,7 @@ you can only use widgets and widget functions here'''; | ||
1045 | if (!keys.containsKey(k)) { | 1029 | if (!keys.containsKey(k)) { |
1046 | throw 'Route id ($k) not found'; | 1030 | throw 'Route id ($k) not found'; |
1047 | } | 1031 | } |
1048 | - _key = keys[k]; | 1032 | + _key = keys[k]!; |
1049 | } | 1033 | } |
1050 | 1034 | ||
1051 | if (_key.currentContext == null && !testMode) { | 1035 | if (_key.currentContext == null && !testMode) { |
@@ -1061,12 +1045,6 @@ you can only use widgets and widget functions here'''; | @@ -1061,12 +1045,6 @@ you can only use widgets and widget functions here'''; | ||
1061 | return _key; | 1045 | return _key; |
1062 | } | 1046 | } |
1063 | 1047 | ||
1064 | - @Deprecated(''' | ||
1065 | -Since version 2.8 it is possible to access the properties | ||
1066 | -[Get.arguments] and [Get.currentRoute] directly. | ||
1067 | -[routeSettings] is useless and should not be used.''') | ||
1068 | - RouteSettings get routeSettings => null; | ||
1069 | - | ||
1070 | /// give current arguments | 1048 | /// give current arguments |
1071 | dynamic get arguments => routing.args; | 1049 | dynamic get arguments => routing.args; |
1072 | 1050 | ||
@@ -1077,16 +1055,16 @@ Since version 2.8 it is possible to access the properties | @@ -1077,16 +1055,16 @@ Since version 2.8 it is possible to access the properties | ||
1077 | String get previousRoute => routing.previous; | 1055 | String get previousRoute => routing.previous; |
1078 | 1056 | ||
1079 | /// check if snackbar is open | 1057 | /// check if snackbar is open |
1080 | - bool get isSnackbarOpen => routing.isSnackbar; | 1058 | + bool? get isSnackbarOpen => routing.isSnackbar; |
1081 | 1059 | ||
1082 | /// check if dialog is open | 1060 | /// check if dialog is open |
1083 | - bool get isDialogOpen => routing.isDialog; | 1061 | + bool? get isDialogOpen => routing.isDialog; |
1084 | 1062 | ||
1085 | /// check if bottomsheet is open | 1063 | /// check if bottomsheet is open |
1086 | - bool get isBottomSheetOpen => routing.isBottomSheet; | 1064 | + bool? get isBottomSheetOpen => routing.isBottomSheet; |
1087 | 1065 | ||
1088 | /// check a raw current route | 1066 | /// check a raw current route |
1089 | - Route<dynamic> get rawRoute => routing.route; | 1067 | + Route<dynamic>? get rawRoute => routing.route; |
1090 | 1068 | ||
1091 | /// check if popGesture is enable | 1069 | /// check if popGesture is enable |
1092 | bool get isPopGestureEnable => defaultPopGesture; | 1070 | bool get isPopGestureEnable => defaultPopGesture; |
@@ -1095,12 +1073,12 @@ Since version 2.8 it is possible to access the properties | @@ -1095,12 +1073,12 @@ Since version 2.8 it is possible to access the properties | ||
1095 | bool get isOpaqueRouteDefault => defaultOpaqueRoute; | 1073 | bool get isOpaqueRouteDefault => defaultOpaqueRoute; |
1096 | 1074 | ||
1097 | /// give access to currentContext | 1075 | /// give access to currentContext |
1098 | - BuildContext get context => key?.currentContext; | 1076 | + BuildContext? get context => key.currentContext; |
1099 | 1077 | ||
1100 | /// give access to current Overlay Context | 1078 | /// give access to current Overlay Context |
1101 | - BuildContext get overlayContext { | ||
1102 | - BuildContext overlay; | ||
1103 | - key?.currentState?.overlay?.context?.visitChildElements((element) { | 1079 | + BuildContext? get overlayContext { |
1080 | + BuildContext? overlay; | ||
1081 | + key.currentState?.overlay?.context.visitChildElements((element) { | ||
1104 | overlay = element; | 1082 | overlay = element; |
1105 | }); | 1083 | }); |
1106 | return overlay; | 1084 | return overlay; |
@@ -1108,25 +1086,23 @@ Since version 2.8 it is possible to access the properties | @@ -1108,25 +1086,23 @@ Since version 2.8 it is possible to access the properties | ||
1108 | 1086 | ||
1109 | /// give access to Theme.of(context) | 1087 | /// give access to Theme.of(context) |
1110 | ThemeData get theme { | 1088 | ThemeData get theme { |
1111 | - ThemeData _theme; | 1089 | + var _theme = ThemeData.fallback(); |
1112 | if (context != null) { | 1090 | if (context != null) { |
1113 | - _theme = Theme.of(context); | 1091 | + _theme = Theme.of(context!); |
1114 | } | 1092 | } |
1115 | return _theme; | 1093 | return _theme; |
1116 | } | 1094 | } |
1117 | 1095 | ||
1118 | ///The current [WidgetsBinding] | 1096 | ///The current [WidgetsBinding] |
1119 | - WidgetsBinding get engine { | 1097 | + WidgetsBinding? get engine { |
1120 | if (WidgetsBinding.instance == null) { | 1098 | if (WidgetsBinding.instance == null) { |
1121 | WidgetsFlutterBinding(); | 1099 | WidgetsFlutterBinding(); |
1122 | } | 1100 | } |
1123 | return WidgetsBinding.instance; | 1101 | return WidgetsBinding.instance; |
1124 | } | 1102 | } |
1125 | 1103 | ||
1126 | - //TODO: Change to ui.SingletonFlutterWindow rather dynamic | ||
1127 | - //when Flutter update stable. dynamic is used to avoid Breaking Changes | ||
1128 | /// The window to which this binding is bound. | 1104 | /// The window to which this binding is bound. |
1129 | - dynamic get window => ui.window; | 1105 | + ui.SingletonFlutterWindow get window => ui.window; |
1130 | 1106 | ||
1131 | Locale get deviceLocale => ui.window.locale; | 1107 | Locale get deviceLocale => ui.window.locale; |
1132 | 1108 | ||
@@ -1153,10 +1129,10 @@ Since version 2.8 it is possible to access the properties | @@ -1153,10 +1129,10 @@ Since version 2.8 it is possible to access the properties | ||
1153 | double get textScaleFactor => ui.window.textScaleFactor; | 1129 | double get textScaleFactor => ui.window.textScaleFactor; |
1154 | 1130 | ||
1155 | /// give access to TextTheme.of(context) | 1131 | /// give access to TextTheme.of(context) |
1156 | - TextTheme get textTheme => theme?.textTheme; | 1132 | + TextTheme get textTheme => theme.textTheme; |
1157 | 1133 | ||
1158 | /// give access to Mediaquery.of(context) | 1134 | /// give access to Mediaquery.of(context) |
1159 | - MediaQueryData get mediaQuery => MediaQuery.of(context); | 1135 | + MediaQueryData get mediaQuery => MediaQuery.of(context!); |
1160 | 1136 | ||
1161 | /// Check if dark mode theme is enable | 1137 | /// Check if dark mode theme is enable |
1162 | bool get isDarkMode => (theme.brightness == Brightness.dark); | 1138 | bool get isDarkMode => (theme.brightness == Brightness.dark); |
@@ -1166,10 +1142,10 @@ Since version 2.8 it is possible to access the properties | @@ -1166,10 +1142,10 @@ Since version 2.8 it is possible to access the properties | ||
1166 | (ui.window.platformBrightness == Brightness.dark); | 1142 | (ui.window.platformBrightness == Brightness.dark); |
1167 | 1143 | ||
1168 | /// give access to Theme.of(context).iconTheme.color | 1144 | /// give access to Theme.of(context).iconTheme.color |
1169 | - Color get iconColor => theme?.iconTheme?.color; | 1145 | + Color? get iconColor => theme.iconTheme.color; |
1170 | 1146 | ||
1171 | /// give access to FocusScope.of(context) | 1147 | /// give access to FocusScope.of(context) |
1172 | - FocusNode get focusScope => FocusManager.instance.primaryFocus; | 1148 | + FocusNode? get focusScope => FocusManager.instance.primaryFocus; |
1173 | 1149 | ||
1174 | // /// give access to Immutable MediaQuery.of(context).size.height | 1150 | // /// give access to Immutable MediaQuery.of(context).size.height |
1175 | // double get height => MediaQuery.of(context).size.height; | 1151 | // double get height => MediaQuery.of(context).size.height; |
@@ -1177,16 +1153,16 @@ Since version 2.8 it is possible to access the properties | @@ -1177,16 +1153,16 @@ Since version 2.8 it is possible to access the properties | ||
1177 | // /// give access to Immutable MediaQuery.of(context).size.width | 1153 | // /// give access to Immutable MediaQuery.of(context).size.width |
1178 | // double get width => MediaQuery.of(context).size.width; | 1154 | // double get width => MediaQuery.of(context).size.width; |
1179 | 1155 | ||
1180 | - GlobalKey<NavigatorState> get key => getxController?.key; | 1156 | + GlobalKey<NavigatorState> get key => getxController.key; |
1181 | 1157 | ||
1182 | - Map<int, GlobalKey<NavigatorState>> get keys => getxController?.keys; | 1158 | + Map<dynamic, GlobalKey<NavigatorState>> get keys => getxController.keys; |
1183 | 1159 | ||
1184 | GetMaterialController get rootController => getxController; | 1160 | GetMaterialController get rootController => getxController; |
1185 | 1161 | ||
1186 | bool get defaultPopGesture => getxController.defaultPopGesture; | 1162 | bool get defaultPopGesture => getxController.defaultPopGesture; |
1187 | bool get defaultOpaqueRoute => getxController.defaultOpaqueRoute; | 1163 | bool get defaultOpaqueRoute => getxController.defaultOpaqueRoute; |
1188 | 1164 | ||
1189 | - Transition get defaultTransition => getxController.defaultTransition; | 1165 | + Transition? get defaultTransition => getxController.defaultTransition; |
1190 | 1166 | ||
1191 | Duration get defaultTransitionDuration { | 1167 | Duration get defaultTransitionDuration { |
1192 | return getxController.defaultTransitionDuration; | 1168 | return getxController.defaultTransitionDuration; |
@@ -1204,15 +1180,15 @@ Since version 2.8 it is possible to access the properties | @@ -1204,15 +1180,15 @@ Since version 2.8 it is possible to access the properties | ||
1204 | 1180 | ||
1205 | Routing get routing => getxController.routing; | 1181 | Routing get routing => getxController.routing; |
1206 | 1182 | ||
1207 | - Map<String, String> get parameters => getxController.parameters; | ||
1208 | - set parameters(Map<String, String> newParameters) => | 1183 | + Map<String, String?> get parameters => getxController.parameters; |
1184 | + set parameters(Map<String, String?> newParameters) => | ||
1209 | getxController.parameters = newParameters; | 1185 | getxController.parameters = newParameters; |
1210 | 1186 | ||
1211 | ParseRouteTree get routeTree => getxController.routeTree; | 1187 | ParseRouteTree get routeTree => getxController.routeTree; |
1212 | set routeTree(ParseRouteTree tree) => getxController.routeTree = tree; | 1188 | set routeTree(ParseRouteTree tree) => getxController.routeTree = tree; |
1213 | 1189 | ||
1214 | - CustomTransition get customTransition => getxController.customTransition; | ||
1215 | - set customTransition(CustomTransition newTransition) => | 1190 | + CustomTransition? get customTransition => getxController.customTransition; |
1191 | + set customTransition(CustomTransition? newTransition) => | ||
1216 | getxController.customTransition = newTransition; | 1192 | getxController.customTransition = newTransition; |
1217 | 1193 | ||
1218 | bool get testMode => getxController.testMode; | 1194 | bool get testMode => getxController.testMode; |
@@ -1224,4 +1200,4 @@ Since version 2.8 it is possible to access the properties | @@ -1224,4 +1200,4 @@ Since version 2.8 it is possible to access the properties | ||
1224 | /// It replaces the Flutter Navigator, but needs no context. | 1200 | /// It replaces the Flutter Navigator, but needs no context. |
1225 | /// You can to use navigator.push(YourRoute()) rather | 1201 | /// You can to use navigator.push(YourRoute()) rather |
1226 | /// Navigator.push(context, YourRoute()); | 1202 | /// Navigator.push(context, YourRoute()); |
1227 | -NavigatorState get navigator => GetNavigation(Get).key.currentState; | 1203 | +NavigatorState? get navigator => GetNavigation(Get).key.currentState; |
@@ -10,16 +10,18 @@ import 'root_controller.dart'; | @@ -10,16 +10,18 @@ import 'root_controller.dart'; | ||
10 | 10 | ||
11 | class GetCupertinoApp extends StatelessWidget { | 11 | class GetCupertinoApp extends StatelessWidget { |
12 | const GetCupertinoApp({ | 12 | const GetCupertinoApp({ |
13 | - Key key, | 13 | + Key? key, |
14 | this.theme, | 14 | this.theme, |
15 | this.navigatorKey, | 15 | this.navigatorKey, |
16 | this.home, | 16 | this.home, |
17 | - this.routes = const <String, WidgetBuilder>{}, | 17 | + Map<String, Widget Function(BuildContext)> this.routes = |
18 | + const <String, WidgetBuilder>{}, | ||
18 | this.initialRoute, | 19 | this.initialRoute, |
19 | this.onGenerateRoute, | 20 | this.onGenerateRoute, |
20 | this.onGenerateInitialRoutes, | 21 | this.onGenerateInitialRoutes, |
21 | this.onUnknownRoute, | 22 | this.onUnknownRoute, |
22 | - this.navigatorObservers = const <NavigatorObserver>[], | 23 | + List<NavigatorObserver> this.navigatorObservers = |
24 | + const <NavigatorObserver>[], | ||
23 | this.builder, | 25 | this.builder, |
24 | this.translationsKeys, | 26 | this.translationsKeys, |
25 | this.translations, | 27 | this.translations, |
@@ -58,78 +60,70 @@ class GetCupertinoApp extends StatelessWidget { | @@ -58,78 +60,70 @@ class GetCupertinoApp extends StatelessWidget { | ||
58 | this.highContrastTheme, | 60 | this.highContrastTheme, |
59 | this.highContrastDarkTheme, | 61 | this.highContrastDarkTheme, |
60 | this.actions, | 62 | this.actions, |
61 | - }) : assert(routes != null), | ||
62 | - assert(navigatorObservers != null), | ||
63 | - assert(title != null), | ||
64 | - assert(showPerformanceOverlay != null), | ||
65 | - assert(checkerboardRasterCacheImages != null), | ||
66 | - assert(checkerboardOffscreenLayers != null), | ||
67 | - assert(showSemanticsDebugger != null), | ||
68 | - assert(debugShowCheckedModeBanner != null), | ||
69 | - routeInformationProvider = null, | 63 | + }) : routeInformationProvider = null, |
70 | routeInformationParser = null, | 64 | routeInformationParser = null, |
71 | routerDelegate = null, | 65 | routerDelegate = null, |
72 | backButtonDispatcher = null, | 66 | backButtonDispatcher = null, |
73 | super(key: key); | 67 | super(key: key); |
74 | 68 | ||
75 | - final GlobalKey<NavigatorState> navigatorKey; | ||
76 | - final Widget home; | ||
77 | - final Map<String, WidgetBuilder> routes; | ||
78 | - final String initialRoute; | ||
79 | - final RouteFactory onGenerateRoute; | ||
80 | - final InitialRouteListFactory onGenerateInitialRoutes; | ||
81 | - final RouteFactory onUnknownRoute; | ||
82 | - final List<NavigatorObserver> navigatorObservers; | ||
83 | - final TransitionBuilder builder; | 69 | + final GlobalKey<NavigatorState>? navigatorKey; |
70 | + final Widget? home; | ||
71 | + final Map<String, WidgetBuilder>? routes; | ||
72 | + final String? initialRoute; | ||
73 | + final RouteFactory? onGenerateRoute; | ||
74 | + final InitialRouteListFactory? onGenerateInitialRoutes; | ||
75 | + final RouteFactory? onUnknownRoute; | ||
76 | + final List<NavigatorObserver>? navigatorObservers; | ||
77 | + final TransitionBuilder? builder; | ||
84 | final String title; | 78 | final String title; |
85 | - final GenerateAppTitle onGenerateTitle; | ||
86 | - final CustomTransition customTransition; | ||
87 | - final Color color; | ||
88 | - final Map<String, Map<String, String>> translationsKeys; | ||
89 | - final Translations translations; | ||
90 | - final TextDirection textDirection; | ||
91 | - final Locale locale; | ||
92 | - final Locale fallbackLocale; | ||
93 | - final Iterable<LocalizationsDelegate<dynamic>> localizationsDelegates; | ||
94 | - final LocaleListResolutionCallback localeListResolutionCallback; | ||
95 | - final LocaleResolutionCallback localeResolutionCallback; | 79 | + final GenerateAppTitle? onGenerateTitle; |
80 | + final CustomTransition? customTransition; | ||
81 | + final Color? color; | ||
82 | + final Map<String, Map<String, String>>? translationsKeys; | ||
83 | + final Translations? translations; | ||
84 | + final TextDirection? textDirection; | ||
85 | + final Locale? locale; | ||
86 | + final Locale? fallbackLocale; | ||
87 | + final Iterable<LocalizationsDelegate<dynamic>>? localizationsDelegates; | ||
88 | + final LocaleListResolutionCallback? localeListResolutionCallback; | ||
89 | + final LocaleResolutionCallback? localeResolutionCallback; | ||
96 | final Iterable<Locale> supportedLocales; | 90 | final Iterable<Locale> supportedLocales; |
97 | final bool showPerformanceOverlay; | 91 | final bool showPerformanceOverlay; |
98 | final bool checkerboardRasterCacheImages; | 92 | final bool checkerboardRasterCacheImages; |
99 | final bool checkerboardOffscreenLayers; | 93 | final bool checkerboardOffscreenLayers; |
100 | final bool showSemanticsDebugger; | 94 | final bool showSemanticsDebugger; |
101 | final bool debugShowCheckedModeBanner; | 95 | final bool debugShowCheckedModeBanner; |
102 | - final Map<LogicalKeySet, Intent> shortcuts; | ||
103 | - final ThemeData highContrastTheme; | ||
104 | - final ThemeData highContrastDarkTheme; | ||
105 | - final Map<Type, Action<Intent>> actions; | ||
106 | - final Function(Routing) routingCallback; | ||
107 | - final Transition defaultTransition; | ||
108 | - final bool opaqueRoute; | ||
109 | - final VoidCallback onInit; | ||
110 | - final VoidCallback onReady; | ||
111 | - final VoidCallback onDispose; | ||
112 | - final bool enableLog; | ||
113 | - final LogWriterCallback logWriterCallback; | ||
114 | - final bool popGesture; | 96 | + final Map<LogicalKeySet, Intent>? shortcuts; |
97 | + final ThemeData? highContrastTheme; | ||
98 | + final ThemeData? highContrastDarkTheme; | ||
99 | + final Map<Type, Action<Intent>>? actions; | ||
100 | + final Function(Routing?)? routingCallback; | ||
101 | + final Transition? defaultTransition; | ||
102 | + final bool? opaqueRoute; | ||
103 | + final VoidCallback? onInit; | ||
104 | + final VoidCallback? onReady; | ||
105 | + final VoidCallback? onDispose; | ||
106 | + final bool? enableLog; | ||
107 | + final LogWriterCallback? logWriterCallback; | ||
108 | + final bool? popGesture; | ||
115 | final SmartManagement smartManagement; | 109 | final SmartManagement smartManagement; |
116 | - final Bindings initialBinding; | ||
117 | - final Duration transitionDuration; | ||
118 | - final bool defaultGlobalState; | ||
119 | - final List<GetPage> getPages; | ||
120 | - final GetPage unknownRoute; | ||
121 | - final RouteInformationProvider routeInformationProvider; | ||
122 | - final RouteInformationParser<Object> routeInformationParser; | ||
123 | - final RouterDelegate<Object> routerDelegate; | ||
124 | - final BackButtonDispatcher backButtonDispatcher; | ||
125 | - final CupertinoThemeData theme; | 110 | + final Bindings? initialBinding; |
111 | + final Duration? transitionDuration; | ||
112 | + final bool? defaultGlobalState; | ||
113 | + final List<GetPage>? getPages; | ||
114 | + final GetPage? unknownRoute; | ||
115 | + final RouteInformationProvider? routeInformationProvider; | ||
116 | + final RouteInformationParser<Object>? routeInformationParser; | ||
117 | + final RouterDelegate<Object>? routerDelegate; | ||
118 | + final BackButtonDispatcher? backButtonDispatcher; | ||
119 | + final CupertinoThemeData? theme; | ||
126 | 120 | ||
127 | const GetCupertinoApp.router({ | 121 | const GetCupertinoApp.router({ |
128 | - Key key, | 122 | + Key? key, |
129 | this.theme, | 123 | this.theme, |
130 | this.routeInformationProvider, | 124 | this.routeInformationProvider, |
131 | - @required this.routeInformationParser, | ||
132 | - @required this.routerDelegate, | 125 | + required RouteInformationParser<Object> this.routeInformationParser, |
126 | + required RouterDelegate<Object> this.routerDelegate, | ||
133 | this.backButtonDispatcher, | 127 | this.backButtonDispatcher, |
134 | this.builder, | 128 | this.builder, |
135 | this.title = '', | 129 | this.title = '', |
@@ -169,15 +163,7 @@ class GetCupertinoApp extends StatelessWidget { | @@ -169,15 +163,7 @@ class GetCupertinoApp extends StatelessWidget { | ||
169 | this.defaultGlobalState, | 163 | this.defaultGlobalState, |
170 | this.getPages, | 164 | this.getPages, |
171 | this.unknownRoute, | 165 | this.unknownRoute, |
172 | - }) : assert(routeInformationParser != null), | ||
173 | - assert(routerDelegate != null), | ||
174 | - assert(title != null), | ||
175 | - assert(showPerformanceOverlay != null), | ||
176 | - assert(checkerboardRasterCacheImages != null), | ||
177 | - assert(checkerboardOffscreenLayers != null), | ||
178 | - assert(showSemanticsDebugger != null), | ||
179 | - assert(debugShowCheckedModeBanner != null), | ||
180 | - navigatorObservers = null, | 166 | + }) : navigatorObservers = null, |
181 | navigatorKey = null, | 167 | navigatorKey = null, |
182 | onGenerateRoute = null, | 168 | onGenerateRoute = null, |
183 | home = null, | 169 | home = null, |
@@ -201,7 +187,7 @@ class GetCupertinoApp extends StatelessWidget { | @@ -201,7 +187,7 @@ class GetCupertinoApp extends StatelessWidget { | ||
201 | onDispose?.call(); | 187 | onDispose?.call(); |
202 | }, | 188 | }, |
203 | initState: (i) { | 189 | initState: (i) { |
204 | - Get.engine.addPostFrameCallback((timeStamp) { | 190 | + Get.engine!.addPostFrameCallback((timeStamp) { |
205 | onReady?.call(); | 191 | onReady?.call(); |
206 | }); | 192 | }); |
207 | if (locale != null) Get.locale = locale; | 193 | if (locale != null) Get.locale = locale; |
@@ -209,9 +195,9 @@ class GetCupertinoApp extends StatelessWidget { | @@ -209,9 +195,9 @@ class GetCupertinoApp extends StatelessWidget { | ||
209 | if (fallbackLocale != null) Get.fallbackLocale = fallbackLocale; | 195 | if (fallbackLocale != null) Get.fallbackLocale = fallbackLocale; |
210 | 196 | ||
211 | if (translations != null) { | 197 | if (translations != null) { |
212 | - Get.addTranslations(translations.keys); | 198 | + Get.addTranslations(translations!.keys); |
213 | } else if (translationsKeys != null) { | 199 | } else if (translationsKeys != null) { |
214 | - Get.addTranslations(translationsKeys); | 200 | + Get.addTranslations(translationsKeys!); |
215 | } | 201 | } |
216 | 202 | ||
217 | Get.customTransition = customTransition; | 203 | Get.customTransition = customTransition; |
@@ -233,8 +219,8 @@ class GetCupertinoApp extends StatelessWidget { | @@ -233,8 +219,8 @@ class GetCupertinoApp extends StatelessWidget { | ||
233 | }, | 219 | }, |
234 | builder: (_) => routerDelegate != null | 220 | builder: (_) => routerDelegate != null |
235 | ? CupertinoApp.router( | 221 | ? CupertinoApp.router( |
236 | - routerDelegate: routerDelegate, | ||
237 | - routeInformationParser: routeInformationParser, | 222 | + routerDelegate: routerDelegate!, |
223 | + routeInformationParser: routeInformationParser!, | ||
238 | backButtonDispatcher: backButtonDispatcher, | 224 | backButtonDispatcher: backButtonDispatcher, |
239 | routeInformationProvider: routeInformationProvider, | 225 | routeInformationProvider: routeInformationProvider, |
240 | key: _.unikey, | 226 | key: _.unikey, |
@@ -245,31 +231,29 @@ class GetCupertinoApp extends StatelessWidget { | @@ -245,31 +231,29 @@ class GetCupertinoApp extends StatelessWidget { | ||
245 | (rtlLanguages.contains(Get.locale?.languageCode) | 231 | (rtlLanguages.contains(Get.locale?.languageCode) |
246 | ? TextDirection.rtl | 232 | ? TextDirection.rtl |
247 | : TextDirection.ltr), | 233 | : TextDirection.ltr), |
248 | - child: builder == null ? child : builder(context, child), | 234 | + child: builder == null ? child! : builder!(context, child), |
249 | ); | 235 | ); |
250 | }, | 236 | }, |
251 | - title: title ?? '', | 237 | + title: title, |
252 | onGenerateTitle: onGenerateTitle, | 238 | onGenerateTitle: onGenerateTitle, |
253 | color: color, | 239 | color: color, |
254 | locale: Get.locale ?? locale, | 240 | locale: Get.locale ?? locale, |
255 | localizationsDelegates: localizationsDelegates, | 241 | localizationsDelegates: localizationsDelegates, |
256 | localeListResolutionCallback: localeListResolutionCallback, | 242 | localeListResolutionCallback: localeListResolutionCallback, |
257 | localeResolutionCallback: localeResolutionCallback, | 243 | localeResolutionCallback: localeResolutionCallback, |
258 | - supportedLocales: | ||
259 | - supportedLocales ?? const <Locale>[Locale('en', 'US')], | ||
260 | - showPerformanceOverlay: showPerformanceOverlay ?? false, | ||
261 | - checkerboardRasterCacheImages: | ||
262 | - checkerboardRasterCacheImages ?? false, | ||
263 | - checkerboardOffscreenLayers: checkerboardOffscreenLayers ?? false, | ||
264 | - showSemanticsDebugger: showSemanticsDebugger ?? false, | ||
265 | - debugShowCheckedModeBanner: debugShowCheckedModeBanner ?? true, | 244 | + supportedLocales: supportedLocales, |
245 | + showPerformanceOverlay: showPerformanceOverlay, | ||
246 | + checkerboardRasterCacheImages: checkerboardRasterCacheImages, | ||
247 | + checkerboardOffscreenLayers: checkerboardOffscreenLayers, | ||
248 | + showSemanticsDebugger: showSemanticsDebugger, | ||
249 | + debugShowCheckedModeBanner: debugShowCheckedModeBanner, | ||
266 | shortcuts: shortcuts, | 250 | shortcuts: shortcuts, |
267 | ) | 251 | ) |
268 | : CupertinoApp( | 252 | : CupertinoApp( |
269 | key: _.unikey, | 253 | key: _.unikey, |
270 | theme: theme, | 254 | theme: theme, |
271 | navigatorKey: | 255 | navigatorKey: |
272 | - (navigatorKey == null ? Get.key : Get.addKey(navigatorKey)), | 256 | + (navigatorKey == null ? Get.key : Get.addKey(navigatorKey!)), |
273 | home: home, | 257 | home: home, |
274 | routes: routes ?? const <String, WidgetBuilder>{}, | 258 | routes: routes ?? const <String, WidgetBuilder>{}, |
275 | initialRoute: initialRoute, | 259 | initialRoute: initialRoute, |
@@ -285,31 +269,29 @@ class GetCupertinoApp extends StatelessWidget { | @@ -285,31 +269,29 @@ class GetCupertinoApp extends StatelessWidget { | ||
285 | : <NavigatorObserver>[ | 269 | : <NavigatorObserver>[ |
286 | GetObserver(routingCallback, Get.routing) | 270 | GetObserver(routingCallback, Get.routing) |
287 | ] | 271 | ] |
288 | - ..addAll(navigatorObservers)), | 272 | + ..addAll(navigatorObservers!)), |
289 | builder: (context, child) { | 273 | builder: (context, child) { |
290 | return Directionality( | 274 | return Directionality( |
291 | textDirection: textDirection ?? | 275 | textDirection: textDirection ?? |
292 | (rtlLanguages.contains(Get.locale?.languageCode) | 276 | (rtlLanguages.contains(Get.locale?.languageCode) |
293 | ? TextDirection.rtl | 277 | ? TextDirection.rtl |
294 | : TextDirection.ltr), | 278 | : TextDirection.ltr), |
295 | - child: builder == null ? child : builder(context, child), | 279 | + child: builder == null ? child! : builder!(context, child), |
296 | ); | 280 | ); |
297 | }, | 281 | }, |
298 | - title: title ?? '', | 282 | + title: title, |
299 | onGenerateTitle: onGenerateTitle, | 283 | onGenerateTitle: onGenerateTitle, |
300 | color: color, | 284 | color: color, |
301 | locale: Get.locale ?? locale, | 285 | locale: Get.locale ?? locale, |
302 | localizationsDelegates: localizationsDelegates, | 286 | localizationsDelegates: localizationsDelegates, |
303 | localeListResolutionCallback: localeListResolutionCallback, | 287 | localeListResolutionCallback: localeListResolutionCallback, |
304 | localeResolutionCallback: localeResolutionCallback, | 288 | localeResolutionCallback: localeResolutionCallback, |
305 | - supportedLocales: | ||
306 | - supportedLocales ?? const <Locale>[Locale('en', 'US')], | ||
307 | - showPerformanceOverlay: showPerformanceOverlay ?? false, | ||
308 | - checkerboardRasterCacheImages: | ||
309 | - checkerboardRasterCacheImages ?? false, | ||
310 | - checkerboardOffscreenLayers: checkerboardOffscreenLayers ?? false, | ||
311 | - showSemanticsDebugger: showSemanticsDebugger ?? false, | ||
312 | - debugShowCheckedModeBanner: debugShowCheckedModeBanner ?? true, | 289 | + supportedLocales: supportedLocales, |
290 | + showPerformanceOverlay: showPerformanceOverlay, | ||
291 | + checkerboardRasterCacheImages: checkerboardRasterCacheImages, | ||
292 | + checkerboardOffscreenLayers: checkerboardOffscreenLayers, | ||
293 | + showSemanticsDebugger: showSemanticsDebugger, | ||
294 | + debugShowCheckedModeBanner: debugShowCheckedModeBanner, | ||
313 | shortcuts: shortcuts, | 295 | shortcuts: shortcuts, |
314 | // actions: actions, | 296 | // actions: actions, |
315 | )); | 297 | )); |
@@ -10,15 +10,17 @@ import 'root_controller.dart'; | @@ -10,15 +10,17 @@ import 'root_controller.dart'; | ||
10 | 10 | ||
11 | class GetMaterialApp extends StatelessWidget { | 11 | class GetMaterialApp extends StatelessWidget { |
12 | const GetMaterialApp({ | 12 | const GetMaterialApp({ |
13 | - Key key, | 13 | + Key? key, |
14 | this.navigatorKey, | 14 | this.navigatorKey, |
15 | this.home, | 15 | this.home, |
16 | - this.routes = const <String, WidgetBuilder>{}, | 16 | + Map<String, Widget Function(BuildContext)> this.routes = |
17 | + const <String, WidgetBuilder>{}, | ||
17 | this.initialRoute, | 18 | this.initialRoute, |
18 | this.onGenerateRoute, | 19 | this.onGenerateRoute, |
19 | this.onGenerateInitialRoutes, | 20 | this.onGenerateInitialRoutes, |
20 | this.onUnknownRoute, | 21 | this.onUnknownRoute, |
21 | - this.navigatorObservers = const <NavigatorObserver>[], | 22 | + List<NavigatorObserver> this.navigatorObservers = |
23 | + const <NavigatorObserver>[], | ||
22 | this.builder, | 24 | this.builder, |
23 | this.textDirection, | 25 | this.textDirection, |
24 | this.title = '', | 26 | this.title = '', |
@@ -61,81 +63,72 @@ class GetMaterialApp extends StatelessWidget { | @@ -61,81 +63,72 @@ class GetMaterialApp extends StatelessWidget { | ||
61 | this.highContrastTheme, | 63 | this.highContrastTheme, |
62 | this.highContrastDarkTheme, | 64 | this.highContrastDarkTheme, |
63 | this.actions, | 65 | this.actions, |
64 | - }) : assert(routes != null), | ||
65 | - assert(navigatorObservers != null), | ||
66 | - assert(title != null), | ||
67 | - assert(debugShowMaterialGrid != null), | ||
68 | - assert(showPerformanceOverlay != null), | ||
69 | - assert(checkerboardRasterCacheImages != null), | ||
70 | - assert(checkerboardOffscreenLayers != null), | ||
71 | - assert(showSemanticsDebugger != null), | ||
72 | - assert(debugShowCheckedModeBanner != null), | ||
73 | - routeInformationProvider = null, | 66 | + }) : routeInformationProvider = null, |
74 | routeInformationParser = null, | 67 | routeInformationParser = null, |
75 | routerDelegate = null, | 68 | routerDelegate = null, |
76 | backButtonDispatcher = null, | 69 | backButtonDispatcher = null, |
77 | super(key: key); | 70 | super(key: key); |
78 | 71 | ||
79 | - final GlobalKey<NavigatorState> navigatorKey; | ||
80 | - final Widget home; | ||
81 | - final Map<String, WidgetBuilder> routes; | ||
82 | - final String initialRoute; | ||
83 | - final RouteFactory onGenerateRoute; | ||
84 | - final InitialRouteListFactory onGenerateInitialRoutes; | ||
85 | - final RouteFactory onUnknownRoute; | ||
86 | - final List<NavigatorObserver> navigatorObservers; | ||
87 | - final TransitionBuilder builder; | 72 | + final GlobalKey<NavigatorState>? navigatorKey; |
73 | + final Widget? home; | ||
74 | + final Map<String, WidgetBuilder>? routes; | ||
75 | + final String? initialRoute; | ||
76 | + final RouteFactory? onGenerateRoute; | ||
77 | + final InitialRouteListFactory? onGenerateInitialRoutes; | ||
78 | + final RouteFactory? onUnknownRoute; | ||
79 | + final List<NavigatorObserver>? navigatorObservers; | ||
80 | + final TransitionBuilder? builder; | ||
88 | final String title; | 81 | final String title; |
89 | - final GenerateAppTitle onGenerateTitle; | ||
90 | - final ThemeData theme; | ||
91 | - final ThemeData darkTheme; | 82 | + final GenerateAppTitle? onGenerateTitle; |
83 | + final ThemeData? theme; | ||
84 | + final ThemeData? darkTheme; | ||
92 | final ThemeMode themeMode; | 85 | final ThemeMode themeMode; |
93 | - final CustomTransition customTransition; | ||
94 | - final Color color; | ||
95 | - final Map<String, Map<String, String>> translationsKeys; | ||
96 | - final Translations translations; | ||
97 | - final TextDirection textDirection; | ||
98 | - final Locale locale; | ||
99 | - final Locale fallbackLocale; | ||
100 | - final Iterable<LocalizationsDelegate<dynamic>> localizationsDelegates; | ||
101 | - final LocaleListResolutionCallback localeListResolutionCallback; | ||
102 | - final LocaleResolutionCallback localeResolutionCallback; | 86 | + final CustomTransition? customTransition; |
87 | + final Color? color; | ||
88 | + final Map<String, Map<String, String>>? translationsKeys; | ||
89 | + final Translations? translations; | ||
90 | + final TextDirection? textDirection; | ||
91 | + final Locale? locale; | ||
92 | + final Locale? fallbackLocale; | ||
93 | + final Iterable<LocalizationsDelegate<dynamic>>? localizationsDelegates; | ||
94 | + final LocaleListResolutionCallback? localeListResolutionCallback; | ||
95 | + final LocaleResolutionCallback? localeResolutionCallback; | ||
103 | final Iterable<Locale> supportedLocales; | 96 | final Iterable<Locale> supportedLocales; |
104 | final bool showPerformanceOverlay; | 97 | final bool showPerformanceOverlay; |
105 | final bool checkerboardRasterCacheImages; | 98 | final bool checkerboardRasterCacheImages; |
106 | final bool checkerboardOffscreenLayers; | 99 | final bool checkerboardOffscreenLayers; |
107 | final bool showSemanticsDebugger; | 100 | final bool showSemanticsDebugger; |
108 | final bool debugShowCheckedModeBanner; | 101 | final bool debugShowCheckedModeBanner; |
109 | - final Map<LogicalKeySet, Intent> shortcuts; | ||
110 | - final ThemeData highContrastTheme; | ||
111 | - final ThemeData highContrastDarkTheme; | ||
112 | - final Map<Type, Action<Intent>> actions; | 102 | + final Map<LogicalKeySet, Intent>? shortcuts; |
103 | + final ThemeData? highContrastTheme; | ||
104 | + final ThemeData? highContrastDarkTheme; | ||
105 | + final Map<Type, Action<Intent>>? actions; | ||
113 | final bool debugShowMaterialGrid; | 106 | final bool debugShowMaterialGrid; |
114 | - final ValueChanged<Routing> routingCallback; | ||
115 | - final Transition defaultTransition; | ||
116 | - final bool opaqueRoute; | ||
117 | - final VoidCallback onInit; | ||
118 | - final VoidCallback onReady; | ||
119 | - final VoidCallback onDispose; | ||
120 | - final bool enableLog; | ||
121 | - final LogWriterCallback logWriterCallback; | ||
122 | - final bool popGesture; | 107 | + final ValueChanged<Routing?>? routingCallback; |
108 | + final Transition? defaultTransition; | ||
109 | + final bool? opaqueRoute; | ||
110 | + final VoidCallback? onInit; | ||
111 | + final VoidCallback? onReady; | ||
112 | + final VoidCallback? onDispose; | ||
113 | + final bool? enableLog; | ||
114 | + final LogWriterCallback? logWriterCallback; | ||
115 | + final bool? popGesture; | ||
123 | final SmartManagement smartManagement; | 116 | final SmartManagement smartManagement; |
124 | - final Bindings initialBinding; | ||
125 | - final Duration transitionDuration; | ||
126 | - final bool defaultGlobalState; | ||
127 | - final List<GetPage> getPages; | ||
128 | - final GetPage unknownRoute; | ||
129 | - final RouteInformationProvider routeInformationProvider; | ||
130 | - final RouteInformationParser<Object> routeInformationParser; | ||
131 | - final RouterDelegate<Object> routerDelegate; | ||
132 | - final BackButtonDispatcher backButtonDispatcher; | 117 | + final Bindings? initialBinding; |
118 | + final Duration? transitionDuration; | ||
119 | + final bool? defaultGlobalState; | ||
120 | + final List<GetPage>? getPages; | ||
121 | + final GetPage? unknownRoute; | ||
122 | + final RouteInformationProvider? routeInformationProvider; | ||
123 | + final RouteInformationParser<Object>? routeInformationParser; | ||
124 | + final RouterDelegate<Object>? routerDelegate; | ||
125 | + final BackButtonDispatcher? backButtonDispatcher; | ||
133 | 126 | ||
134 | const GetMaterialApp.router({ | 127 | const GetMaterialApp.router({ |
135 | - Key key, | 128 | + Key? key, |
136 | this.routeInformationProvider, | 129 | this.routeInformationProvider, |
137 | - @required this.routeInformationParser, | ||
138 | - @required this.routerDelegate, | 130 | + required RouteInformationParser<Object> this.routeInformationParser, |
131 | + required RouterDelegate<Object> this.routerDelegate, | ||
139 | this.backButtonDispatcher, | 132 | this.backButtonDispatcher, |
140 | this.builder, | 133 | this.builder, |
141 | this.title = '', | 134 | this.title = '', |
@@ -179,16 +172,7 @@ class GetMaterialApp extends StatelessWidget { | @@ -179,16 +172,7 @@ class GetMaterialApp extends StatelessWidget { | ||
179 | this.defaultGlobalState, | 172 | this.defaultGlobalState, |
180 | this.getPages, | 173 | this.getPages, |
181 | this.unknownRoute, | 174 | this.unknownRoute, |
182 | - }) : assert(routeInformationParser != null), | ||
183 | - assert(routerDelegate != null), | ||
184 | - assert(title != null), | ||
185 | - assert(debugShowMaterialGrid != null), | ||
186 | - assert(showPerformanceOverlay != null), | ||
187 | - assert(checkerboardRasterCacheImages != null), | ||
188 | - assert(checkerboardOffscreenLayers != null), | ||
189 | - assert(showSemanticsDebugger != null), | ||
190 | - assert(debugShowCheckedModeBanner != null), | ||
191 | - navigatorObservers = null, | 175 | + }) : navigatorObservers = null, |
192 | navigatorKey = null, | 176 | navigatorKey = null, |
193 | onGenerateRoute = null, | 177 | onGenerateRoute = null, |
194 | home = null, | 178 | home = null, |
@@ -211,7 +195,7 @@ class GetMaterialApp extends StatelessWidget { | @@ -211,7 +195,7 @@ class GetMaterialApp extends StatelessWidget { | ||
211 | onDispose?.call(); | 195 | onDispose?.call(); |
212 | }, | 196 | }, |
213 | initState: (i) { | 197 | initState: (i) { |
214 | - Get.engine.addPostFrameCallback((timeStamp) { | 198 | + Get.engine!.addPostFrameCallback((timeStamp) { |
215 | onReady?.call(); | 199 | onReady?.call(); |
216 | }); | 200 | }); |
217 | if (locale != null) Get.locale = locale; | 201 | if (locale != null) Get.locale = locale; |
@@ -219,9 +203,9 @@ class GetMaterialApp extends StatelessWidget { | @@ -219,9 +203,9 @@ class GetMaterialApp extends StatelessWidget { | ||
219 | if (fallbackLocale != null) Get.fallbackLocale = fallbackLocale; | 203 | if (fallbackLocale != null) Get.fallbackLocale = fallbackLocale; |
220 | 204 | ||
221 | if (translations != null) { | 205 | if (translations != null) { |
222 | - Get.addTranslations(translations.keys); | 206 | + Get.addTranslations(translations!.keys); |
223 | } else if (translationsKeys != null) { | 207 | } else if (translationsKeys != null) { |
224 | - Get.addTranslations(translationsKeys); | 208 | + Get.addTranslations(translationsKeys!); |
225 | } | 209 | } |
226 | 210 | ||
227 | Get.customTransition = customTransition; | 211 | Get.customTransition = customTransition; |
@@ -243,8 +227,8 @@ class GetMaterialApp extends StatelessWidget { | @@ -243,8 +227,8 @@ class GetMaterialApp extends StatelessWidget { | ||
243 | }, | 227 | }, |
244 | builder: (_) => routerDelegate != null | 228 | builder: (_) => routerDelegate != null |
245 | ? MaterialApp.router( | 229 | ? MaterialApp.router( |
246 | - routerDelegate: routerDelegate, | ||
247 | - routeInformationParser: routeInformationParser, | 230 | + routerDelegate: routerDelegate!, |
231 | + routeInformationParser: routeInformationParser!, | ||
248 | backButtonDispatcher: backButtonDispatcher, | 232 | backButtonDispatcher: backButtonDispatcher, |
249 | routeInformationProvider: routeInformationProvider, | 233 | routeInformationProvider: routeInformationProvider, |
250 | key: _.unikey, | 234 | key: _.unikey, |
@@ -254,34 +238,32 @@ class GetMaterialApp extends StatelessWidget { | @@ -254,34 +238,32 @@ class GetMaterialApp extends StatelessWidget { | ||
254 | (rtlLanguages.contains(Get.locale?.languageCode) | 238 | (rtlLanguages.contains(Get.locale?.languageCode) |
255 | ? TextDirection.rtl | 239 | ? TextDirection.rtl |
256 | : TextDirection.ltr), | 240 | : TextDirection.ltr), |
257 | - child: builder == null ? child : builder(context, child), | 241 | + child: builder == null ? child! : builder!(context, child), |
258 | ); | 242 | ); |
259 | }, | 243 | }, |
260 | - title: title ?? '', | 244 | + title: title, |
261 | onGenerateTitle: onGenerateTitle, | 245 | onGenerateTitle: onGenerateTitle, |
262 | color: color, | 246 | color: color, |
263 | theme: _.theme ?? theme ?? ThemeData.fallback(), | 247 | theme: _.theme ?? theme ?? ThemeData.fallback(), |
264 | - darkTheme: darkTheme, | ||
265 | - themeMode: _.themeMode ?? themeMode ?? ThemeMode.system, | 248 | + darkTheme: _.darkTheme ?? darkTheme ?? ThemeData.fallback(), |
249 | + themeMode: _.themeMode ?? themeMode, | ||
266 | locale: Get.locale ?? locale, | 250 | locale: Get.locale ?? locale, |
267 | localizationsDelegates: localizationsDelegates, | 251 | localizationsDelegates: localizationsDelegates, |
268 | localeListResolutionCallback: localeListResolutionCallback, | 252 | localeListResolutionCallback: localeListResolutionCallback, |
269 | localeResolutionCallback: localeResolutionCallback, | 253 | localeResolutionCallback: localeResolutionCallback, |
270 | - supportedLocales: | ||
271 | - supportedLocales ?? const <Locale>[Locale('en', 'US')], | ||
272 | - debugShowMaterialGrid: debugShowMaterialGrid ?? false, | ||
273 | - showPerformanceOverlay: showPerformanceOverlay ?? false, | ||
274 | - checkerboardRasterCacheImages: | ||
275 | - checkerboardRasterCacheImages ?? false, | ||
276 | - checkerboardOffscreenLayers: checkerboardOffscreenLayers ?? false, | ||
277 | - showSemanticsDebugger: showSemanticsDebugger ?? false, | ||
278 | - debugShowCheckedModeBanner: debugShowCheckedModeBanner ?? true, | 254 | + supportedLocales: supportedLocales, |
255 | + debugShowMaterialGrid: debugShowMaterialGrid, | ||
256 | + showPerformanceOverlay: showPerformanceOverlay, | ||
257 | + checkerboardRasterCacheImages: checkerboardRasterCacheImages, | ||
258 | + checkerboardOffscreenLayers: checkerboardOffscreenLayers, | ||
259 | + showSemanticsDebugger: showSemanticsDebugger, | ||
260 | + debugShowCheckedModeBanner: debugShowCheckedModeBanner, | ||
279 | shortcuts: shortcuts, | 261 | shortcuts: shortcuts, |
280 | ) | 262 | ) |
281 | : MaterialApp( | 263 | : MaterialApp( |
282 | key: _.unikey, | 264 | key: _.unikey, |
283 | navigatorKey: | 265 | navigatorKey: |
284 | - (navigatorKey == null ? Get.key : Get.addKey(navigatorKey)), | 266 | + (navigatorKey == null ? Get.key : Get.addKey(navigatorKey!)), |
285 | home: home, | 267 | home: home, |
286 | routes: routes ?? const <String, WidgetBuilder>{}, | 268 | routes: routes ?? const <String, WidgetBuilder>{}, |
287 | initialRoute: initialRoute, | 269 | initialRoute: initialRoute, |
@@ -297,36 +279,95 @@ class GetMaterialApp extends StatelessWidget { | @@ -297,36 +279,95 @@ class GetMaterialApp extends StatelessWidget { | ||
297 | : <NavigatorObserver>[ | 279 | : <NavigatorObserver>[ |
298 | GetObserver(routingCallback, Get.routing) | 280 | GetObserver(routingCallback, Get.routing) |
299 | ] | 281 | ] |
300 | - ..addAll(navigatorObservers)), | 282 | + ..addAll(navigatorObservers!)), |
301 | builder: (context, child) { | 283 | builder: (context, child) { |
302 | return Directionality( | 284 | return Directionality( |
303 | textDirection: textDirection ?? | 285 | textDirection: textDirection ?? |
304 | (rtlLanguages.contains(Get.locale?.languageCode) | 286 | (rtlLanguages.contains(Get.locale?.languageCode) |
305 | ? TextDirection.rtl | 287 | ? TextDirection.rtl |
306 | : TextDirection.ltr), | 288 | : TextDirection.ltr), |
307 | - child: builder == null ? child : builder(context, child), | 289 | + child: builder == null ? child! : builder!(context, child), |
308 | ); | 290 | ); |
309 | }, | 291 | }, |
310 | - title: title ?? '', | 292 | + title: title, |
311 | onGenerateTitle: onGenerateTitle, | 293 | onGenerateTitle: onGenerateTitle, |
312 | color: color, | 294 | color: color, |
313 | theme: _.theme ?? theme ?? ThemeData.fallback(), | 295 | theme: _.theme ?? theme ?? ThemeData.fallback(), |
314 | - darkTheme: darkTheme, | ||
315 | - themeMode: _.themeMode ?? themeMode ?? ThemeMode.system, | 296 | + darkTheme: _.darkTheme ?? darkTheme ?? ThemeData.fallback(), |
297 | + themeMode: _.themeMode ?? themeMode, | ||
316 | locale: Get.locale ?? locale, | 298 | locale: Get.locale ?? locale, |
317 | localizationsDelegates: localizationsDelegates, | 299 | localizationsDelegates: localizationsDelegates, |
318 | localeListResolutionCallback: localeListResolutionCallback, | 300 | localeListResolutionCallback: localeListResolutionCallback, |
319 | localeResolutionCallback: localeResolutionCallback, | 301 | localeResolutionCallback: localeResolutionCallback, |
320 | - supportedLocales: | ||
321 | - supportedLocales ?? const <Locale>[Locale('en', 'US')], | ||
322 | - debugShowMaterialGrid: debugShowMaterialGrid ?? false, | ||
323 | - showPerformanceOverlay: showPerformanceOverlay ?? false, | ||
324 | - checkerboardRasterCacheImages: | ||
325 | - checkerboardRasterCacheImages ?? false, | ||
326 | - checkerboardOffscreenLayers: checkerboardOffscreenLayers ?? false, | ||
327 | - showSemanticsDebugger: showSemanticsDebugger ?? false, | ||
328 | - debugShowCheckedModeBanner: debugShowCheckedModeBanner ?? true, | 302 | + supportedLocales: supportedLocales, |
303 | + debugShowMaterialGrid: debugShowMaterialGrid, | ||
304 | + showPerformanceOverlay: showPerformanceOverlay, | ||
305 | + checkerboardRasterCacheImages: checkerboardRasterCacheImages, | ||
306 | + checkerboardOffscreenLayers: checkerboardOffscreenLayers, | ||
307 | + showSemanticsDebugger: showSemanticsDebugger, | ||
308 | + debugShowCheckedModeBanner: debugShowCheckedModeBanner, | ||
329 | shortcuts: shortcuts, | 309 | shortcuts: shortcuts, |
330 | // actions: actions, | 310 | // actions: actions, |
331 | )); | 311 | )); |
332 | } | 312 | } |
313 | + | ||
314 | +class GetNavigator extends StatelessWidget { | ||
315 | + final List<GetPage> getPages; | ||
316 | + | ||
317 | + const GetNavigator( | ||
318 | + {Key? key, | ||
319 | + required this.getPages, | ||
320 | + this.pages = const <Page<dynamic>>[], | ||
321 | + this.onPopPage, | ||
322 | + this.initialRoute, | ||
323 | + this.onGenerateInitialRoutes = Navigator.defaultGenerateInitialRoutes, | ||
324 | + this.onGenerateRoute, | ||
325 | + this.onUnknownRoute, | ||
326 | + this.transitionDelegate = const DefaultTransitionDelegate<dynamic>(), | ||
327 | + this.reportsRouteUpdateToEngine = false, | ||
328 | + this.observers = const <NavigatorObserver>[], | ||
329 | + this.restorationScopeId, | ||
330 | + this.unKnownRoute}) | ||
331 | + : super(key: key); | ||
332 | + | ||
333 | + final List<Page<dynamic>> pages; | ||
334 | + | ||
335 | + final GetPage? unKnownRoute; | ||
336 | + | ||
337 | + final PopPageCallback? onPopPage; | ||
338 | + | ||
339 | + final TransitionDelegate<dynamic> transitionDelegate; | ||
340 | + | ||
341 | + final String? initialRoute; | ||
342 | + | ||
343 | + final RouteFactory? onGenerateRoute; | ||
344 | + | ||
345 | + final RouteFactory? onUnknownRoute; | ||
346 | + | ||
347 | + final List<NavigatorObserver> observers; | ||
348 | + | ||
349 | + final String? restorationScopeId; | ||
350 | + | ||
351 | + static const String defaultRouteName = '/'; | ||
352 | + | ||
353 | + final RouteListFactory onGenerateInitialRoutes; | ||
354 | + | ||
355 | + final bool reportsRouteUpdateToEngine; | ||
356 | + | ||
357 | + @override | ||
358 | + Widget build(Object context) { | ||
359 | + return Navigator( | ||
360 | + pages: getPages, | ||
361 | + onPopPage: onPopPage, | ||
362 | + initialRoute: initialRoute, | ||
363 | + onGenerateInitialRoutes: onGenerateInitialRoutes, | ||
364 | + onGenerateRoute: onGenerateRoute, | ||
365 | + onUnknownRoute: onUnknownRoute, | ||
366 | + transitionDelegate: transitionDelegate, | ||
367 | + reportsRouteUpdateToEngine: reportsRouteUpdateToEngine, | ||
368 | + observers: observers, | ||
369 | + restorationScopeId: restorationScopeId, | ||
370 | + key: Get.nestedKey(key), | ||
371 | + ); | ||
372 | + } | ||
373 | +} |
-
Please register or login to post a comment