Merge branch 'master' of git://github.com/jonataslaw/getx into fix-renamed-class
Showing
131 changed files
with
1202 additions
and
2647 deletions
@@ -6,6 +6,7 @@ labels: '' | @@ -6,6 +6,7 @@ labels: '' | ||
6 | assignees: jonataslaw | 6 | assignees: jonataslaw |
7 | 7 | ||
8 | --- | 8 | --- |
9 | +**ATTENTION: DO NOT USE THIS FIELD TO ASK SUPPORT QUESTIONS. USE THE PLATFORM CHANNELS FOR THIS. THIS SPACE IS DEDICATED ONLY FOR BUGS DESCRIPTION.** | ||
9 | **Fill in the template. Issues that do not respect the model will be closed.** | 10 | **Fill in the template. Issues that do not respect the model will be closed.** |
10 | 11 | ||
11 | **Describe the bug** | 12 | **Describe the bug** |
@@ -27,8 +28,8 @@ If applicable, add screenshots to help explain your problem. | @@ -27,8 +28,8 @@ If applicable, add screenshots to help explain your problem. | ||
27 | **Flutter Version:** | 28 | **Flutter Version:** |
28 | Enter the version of the Flutter you are using | 29 | Enter the version of the Flutter you are using |
29 | 30 | ||
30 | -**Get Version:** | ||
31 | -Enter the version of the Get you are using | 31 | +**Getx Version:** |
32 | +Enter the version of the Getx you are using | ||
32 | 33 | ||
33 | **Describe on which device you found the bug:** | 34 | **Describe on which device you found the bug:** |
34 | ex: Moto z2 - Android. | 35 | ex: Moto z2 - Android. |
@@ -6,6 +6,7 @@ labels: '' | @@ -6,6 +6,7 @@ labels: '' | ||
6 | assignees: '' | 6 | assignees: '' |
7 | 7 | ||
8 | --- | 8 | --- |
9 | +**ATTENTION: DO NOT USE THIS FIELD TO ASK SUPPORT QUESTIONS. USE THE PLATFORM CHANNELS FOR THIS. THIS SPACE IS DEDICATED ONLY FOR FEATURE REQUESTS** | ||
9 | 10 | ||
10 | **Is your feature request related to a problem? Please describe.** | 11 | **Is your feature request related to a problem? Please describe.** |
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | 12 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] |
1 | +## [3.7.0] | ||
2 | +- Added: RxSet. Sets can now also be reactive. | ||
3 | +- Added isDesktop/isMobile (@roipeker) | ||
4 | +- Improve GetPlatform: It is now possible to know which device the user is using if GetPlatform.isWeb is true. | ||
5 | +context.responsiveValue used device orientation based on web and non-web applications. Now it checks if it is a desktop application (web or desktop application) to do the responsiveness calculation. (@roipeker) | ||
6 | +- Change: The documentation previously stated that Iterables should not access the ".value" property. | ||
7 | +However, many users did not pay attention to this fact, and ended up generating unnecessary issues and bugs in their application. | ||
8 | +In this version, we focus on code security. Now ".value" is protected, so it cannot be accessed externally by Lists, Maps or Sets. | ||
9 | +- Change: Observable lists are now Dart Lists. | ||
10 | +There is no difference in your use: | ||
11 | +`RxList list = [].obs;` | ||
12 | +And you use | ||
13 | +`List list = [].obs;` | ||
14 | +- Change: You do not need to access the ".value" property of primitives. | ||
15 | +For Strings you need interpolation. | ||
16 | +For num, int, double, you will have the normal operators, and use it as dart types. | ||
17 | +This way, `.value` can be used exclusively in ModelClasses. | ||
18 | +Example: | ||
19 | + | ||
20 | +```dart | ||
21 | +var name = "Jonny" .obs; | ||
22 | +// usage: | ||
23 | +Text ("$name"); | ||
24 | + | ||
25 | +var count = 0.obs; | ||
26 | +// usage: | ||
27 | +increment() => count ++; | ||
28 | +Text("$count"); | ||
29 | +``` | ||
30 | + | ||
31 | +Thus: List, Map, Set, num, int, double and String, as of this release, will no longer use the .value property. | ||
32 | + | ||
33 | +NOTE: | ||
34 | +The changes were not break changes, however, you may have missed the details of the documentation, so if you faced the message: "The member 'value' can only be used within instance members of subclasses of 'rx_list.dart' "you just need to remove the" .value "property from your list, and everything will work as planned. | ||
35 | +The same goes for Maps and Sets. | ||
36 | + | ||
1 | ## [3.6.2] | 37 | ## [3.6.2] |
2 | - Fix more formatting issues | 38 | - Fix more formatting issues |
3 | 39 |
@@ -90,7 +90,7 @@ import 'package:get/get.dart'; | @@ -90,7 +90,7 @@ import 'package:get/get.dart'; | ||
90 | 90 | ||
91 | # Proyecto Counter no GetX | 91 | # Proyecto Counter no GetX |
92 | 92 | ||
93 | -Vea una explicación más detallada de la administración del estado [aquí](./docs/es_ES/state_management.md). Allí verá más ejemplos y también la diferencia entre el Gestión del Estado simple y el Gestión del Estado reactivo | 93 | +Vea una explicación más detallada de la administración del estado [aquí](./documentation/es_ES/state_management.md). Allí verá más ejemplos y también la diferencia entre el Gestión del Estado simple y el Gestión del Estado reactivo |
94 | 94 | ||
95 | El proyecto "contador" creado por defecto en un nuevo proyecto en Flutter tiene más de 100 líneas (con comentarios). Para mostrar el poder de GetX, demostraré cómo hacer un "contador" cambiando el estado con cada clic, cambiando de página y compartiendo el estado entre pantallas, todo de manera organizada, separando la vista de la lógica de negocio, SOLO 26 LÍNEAS DE CÓDIGO INCLUIDOS COMENTARIOS. | 95 | El proyecto "contador" creado por defecto en un nuevo proyecto en Flutter tiene más de 100 líneas (con comentarios). Para mostrar el poder de GetX, demostraré cómo hacer un "contador" cambiando el estado con cada clic, cambiando de página y compartiendo el estado entre pantallas, todo de manera organizada, separando la vista de la lógica de negocio, SOLO 26 LÍNEAS DE CÓDIGO INCLUIDOS COMENTARIOS. |
96 | 96 | ||
@@ -191,7 +191,7 @@ Obx(() => Text (controller.name)); | @@ -191,7 +191,7 @@ Obx(() => Text (controller.name)); | ||
191 | 191 | ||
192 | ### Más detalles sobre la gestión del estado. | 192 | ### Más detalles sobre la gestión del estado. |
193 | 193 | ||
194 | -**Vea una explicación más detallada de la administración del estado [aquí](./docs/es_ES/state_management.md). Allí verá más ejemplos y también la diferencia entre el Gestión del Estado simple y el Gestión del Estado reactivo** | 194 | +**Vea una explicación más detallada de la administración del estado [aquí](./documentation/es_ES/state_management.md). Allí verá más ejemplos y también la diferencia entre el Gestión del Estado simple y el Gestión del Estado reactivo** |
195 | 195 | ||
196 | ### Explicación en video sobre state management | 196 | ### Explicación en video sobre state management |
197 | 197 | ||
@@ -233,7 +233,7 @@ var data = await Get.to(Payment()); | @@ -233,7 +233,7 @@ var data = await Get.to(Payment()); | ||
233 | 233 | ||
234 | ### Más detalles sobre la gestión de rutas. | 234 | ### Más detalles sobre la gestión de rutas. |
235 | 235 | ||
236 | -**Vea una explicación más detallada de la Gestión de Rutas [aquí](./docs/es_ES/route_management.md).** | 236 | +**Vea una explicación más detallada de la Gestión de Rutas [aquí](./documentation/es_ES/route_management.md).** |
237 | 237 | ||
238 | ### Explicación del video | 238 | ### Explicación del video |
239 | 239 | ||
@@ -277,7 +277,7 @@ Get.lazyPut<Service>(()=> ApiMock()); | @@ -277,7 +277,7 @@ Get.lazyPut<Service>(()=> ApiMock()); | ||
277 | 277 | ||
278 | ### Más detalles sobre la gestión de dependencias. | 278 | ### Más detalles sobre la gestión de dependencias. |
279 | 279 | ||
280 | -**Vea una explicación más detallada de la Gestión de dependencias [aquí](./docs/es_ES/dependency_management.md).** | 280 | +**Vea una explicación más detallada de la Gestión de dependencias [aquí](./documentation/es_ES/dependency_management.md).** |
281 | 281 | ||
282 | # Utilidades | 282 | # Utilidades |
283 | 283 |
@@ -29,6 +29,7 @@ | @@ -29,6 +29,7 @@ | ||
29 | - [More details about dependency management](#more-details-about-dependency-management) | 29 | - [More details about dependency management](#more-details-about-dependency-management) |
30 | - [How to contribute](#how-to-contribute) | 30 | - [How to contribute](#how-to-contribute) |
31 | - [Utils](#utils) | 31 | - [Utils](#utils) |
32 | + - [Internationalization](#internationalization) | ||
32 | - [Change Theme](#change-theme) | 33 | - [Change Theme](#change-theme) |
33 | - [Other Advanced APIs](#other-advanced-apis) | 34 | - [Other Advanced APIs](#other-advanced-apis) |
34 | - [Optional Global Settings and Manual configurations](#optional-global-settings-and-manual-configurations) | 35 | - [Optional Global Settings and Manual configurations](#optional-global-settings-and-manual-configurations) |
@@ -191,7 +192,7 @@ That's all. It's *that* simple. | @@ -191,7 +192,7 @@ That's all. It's *that* simple. | ||
191 | 192 | ||
192 | ### More details about state management | 193 | ### More details about state management |
193 | 194 | ||
194 | -**See an more in-depth explanation of state management [here](./docs/en_US/state_management.md). There you will see more examples and also the difference between the simple stage manager and the reactive state manager** | 195 | +**See an more in-depth explanation of state management [here](./documentation/en_US/state_management.md). There you will see more examples and also the difference between the simple stage manager and the reactive state manager** |
195 | 196 | ||
196 | ### Video explanation about state management | 197 | ### Video explanation about state management |
197 | 198 | ||
@@ -240,7 +241,7 @@ Noticed that you didn't had to use context to do any of these things? That's one | @@ -240,7 +241,7 @@ Noticed that you didn't had to use context to do any of these things? That's one | ||
240 | 241 | ||
241 | ### More details about route management | 242 | ### More details about route management |
242 | 243 | ||
243 | -**Get work with named routes and also offer a lower level control over your routes! There is a in-depth documentation [here](./docs/en_US/route_management.md)** | 244 | +**Get work with named routes and also offer a lower level control over your routes! There is a in-depth documentation [here](./documentation/en_US/route_management.md)** |
244 | 245 | ||
245 | ### Video Explanation | 246 | ### Video Explanation |
246 | 247 | ||
@@ -281,7 +282,7 @@ Text(controller.textFromApi); | @@ -281,7 +282,7 @@ Text(controller.textFromApi); | ||
281 | 282 | ||
282 | ### More details about dependency management | 283 | ### More details about dependency management |
283 | 284 | ||
284 | -**See a more in-depth explanation of dependency management [here](./docs/en_US/dependency_management.md)** | 285 | +**See a more in-depth explanation of dependency management [here](./documentation/en_US/dependency_management.md)** |
285 | 286 | ||
286 | # How to contribute | 287 | # How to contribute |
287 | 288 | ||
@@ -296,6 +297,60 @@ Text(controller.textFromApi); | @@ -296,6 +297,60 @@ Text(controller.textFromApi); | ||
296 | Any contribution is welcome! | 297 | Any contribution is welcome! |
297 | 298 | ||
298 | # Utils | 299 | # Utils |
300 | +## Internationalization | ||
301 | +### Translations | ||
302 | +Translations are kept as a simple key-value dictionary map. | ||
303 | +To add custom translations, create a class and extend `Translations`. | ||
304 | +```dart | ||
305 | +import 'package:get/get.dart'; | ||
306 | + | ||
307 | +class Messages extends Translations { | ||
308 | + @override | ||
309 | + Map<String, Map<String, String>> get keys => { | ||
310 | + 'en_US': { | ||
311 | + 'hello': 'Hello World', | ||
312 | + }, | ||
313 | + 'de_DE': { | ||
314 | + 'hello': 'Hallo Welt', | ||
315 | + } | ||
316 | + }; | ||
317 | +} | ||
318 | +``` | ||
319 | + | ||
320 | +#### Using translations | ||
321 | +Just append `.tr` to the specified key and it will be translated, using the current value of `Get.locale` and `Get.fallbackLocale`. | ||
322 | +```dart | ||
323 | +Text('title'.tr); | ||
324 | +``` | ||
325 | + | ||
326 | +### Locales | ||
327 | +Pass parameters to `GetMaterialApp` to define the locale and translations. | ||
328 | + | ||
329 | +```dart | ||
330 | +return GetMaterialApp( | ||
331 | + translations: Messages(), // your translations | ||
332 | + locale: Locale('en', 'US'), // translations will be displayed in that locale | ||
333 | + fallbackLocale: Locale('en', 'UK'), // specify the fallback locale in case an invalid locale is selected. | ||
334 | + supportedLocales: <Locale>[Locale('en', 'UK'), Locale('en', 'US'), Locale('de','DE')] // specify the supported locales | ||
335 | +); | ||
336 | +``` | ||
337 | + | ||
338 | +#### Change locale | ||
339 | +Call `Get.updateLocale(locale)` to update the locale. Translations then automatically use the new locale. | ||
340 | +```dart | ||
341 | +var locale = Locale('en', 'US'); | ||
342 | +Get.updateLocale(locale); | ||
343 | +``` | ||
344 | + | ||
345 | +#### System locale | ||
346 | +To read the system locale, you could use `window.locale`. | ||
347 | +```dart | ||
348 | +import 'dart:ui' as ui; | ||
349 | + | ||
350 | +return GetMaterialApp( | ||
351 | + locale: ui.window.locale, | ||
352 | +); | ||
353 | +``` | ||
299 | 354 | ||
300 | ## Change Theme | 355 | ## Change Theme |
301 | 356 |
@@ -176,7 +176,7 @@ Obx (() => Text (controller.name)); | @@ -176,7 +176,7 @@ Obx (() => Text (controller.name)); | ||
176 | To wszystko. *Proste*, co nie? | 176 | To wszystko. *Proste*, co nie? |
177 | 177 | ||
178 | ### Bardziej szczegółowo o menadżerze stanu | 178 | ### Bardziej szczegółowo o menadżerze stanu |
179 | -**Zobacz bardziej szczegółowe wytłumaczenie menadz=żera sranu [tutaj](./docs/en_US/state_management.md). Znajdują się tam przykłady jak o różnice między prostym menadżerem stanu oraz reaktywnym** | 179 | +**Zobacz bardziej szczegółowe wytłumaczenie menadz=żera sranu [tutaj](./documentation/en_US/state_management.md). Znajdują się tam przykłady jak o różnice między prostym menadżerem stanu oraz reaktywnym** |
180 | 180 | ||
181 | ### Video tłumaczące użycie menadżera stanu | 181 | ### Video tłumaczące użycie menadżera stanu |
182 | 182 | ||
@@ -237,7 +237,7 @@ Zobacz, ze do żadnej z tych operacji nie potrzebowałeś contextu. Jest to jedn | @@ -237,7 +237,7 @@ Zobacz, ze do żadnej z tych operacji nie potrzebowałeś contextu. Jest to jedn | ||
237 | 237 | ||
238 | ### Więcej o routach | 238 | ### Więcej o routach |
239 | 239 | ||
240 | -**Get używa named routes i także oferuje niskopoziomową obsługę routów! Zobacz bardziej szczegółową dokumentacje [tutaj](./docs/en_US/route_management.md)** | 240 | +**Get używa named routes i także oferuje niskopoziomową obsługę routów! Zobacz bardziej szczegółową dokumentacje [tutaj](./documentation/en_US/route_management.md)** |
241 | 241 | ||
242 | ### Video tłumaczące użycie | 242 | ### Video tłumaczące użycie |
243 | 243 | ||
@@ -274,7 +274,7 @@ Text(controller.textFromApi); | @@ -274,7 +274,7 @@ Text(controller.textFromApi); | ||
274 | ``` | 274 | ``` |
275 | ### Bardziej szczegółowo o menadżerze dependencies | 275 | ### Bardziej szczegółowo o menadżerze dependencies |
276 | 276 | ||
277 | -**Zobzcz więcej w dokumentacji [tutaj](./docs/en_US/dependency_management.md)** | 277 | +**Zobzcz więcej w dokumentacji [tutaj](./documentation/en_US/dependency_management.md)** |
278 | 278 | ||
279 | # Jak włożyć coś od siebie | 279 | # Jak włożyć coś od siebie |
280 | 280 | ||
@@ -478,7 +478,7 @@ GetMaterialApp( | @@ -478,7 +478,7 @@ GetMaterialApp( | ||
478 | // pamiętaj że nawet jeśli "enableLog: false" logi i tak będą wysłane w tym callbacku | 478 | // pamiętaj że nawet jeśli "enableLog: false" logi i tak będą wysłane w tym callbacku |
479 | // Musisz sprawdzić konfiguracje flag jeśli chcesz przez GetConfig.isLogEnable | 479 | // Musisz sprawdzić konfiguracje flag jeśli chcesz przez GetConfig.isLogEnable |
480 | } | 480 | } |
481 | - | 481 | +``` |
482 | ## Video tłumaczące inne funkcjonalności GetX | 482 | ## Video tłumaczące inne funkcjonalności GetX |
483 | 483 | ||
484 | 484 |
@@ -191,7 +191,7 @@ Só isso. É *simples assim*; | @@ -191,7 +191,7 @@ Só isso. É *simples assim*; | ||
191 | 191 | ||
192 | ### Mais detalhes sobre gerenciamento de estado | 192 | ### Mais detalhes sobre gerenciamento de estado |
193 | 193 | ||
194 | -**Veja uma explicação mais completa do gerenciamento de estado [aqui](./docs/pt_BR/state_management.md). Lá terá mais exemplos e também a diferença do simple state manager do reactive state manager** | 194 | +**Veja uma explicação mais completa do gerenciamento de estado [aqui](./documentation/pt_BR/state_management.md). Lá terá mais exemplos e também a diferença do simple state manager do reactive state manager** |
195 | 195 | ||
196 | ### Explicação em video do gerenciamento de estado | 196 | ### Explicação em video do gerenciamento de estado |
197 | 197 | ||
@@ -235,7 +235,7 @@ Notou que você não precisou usar `context` para fazer nenhuma dessas coisas? E | @@ -235,7 +235,7 @@ Notou que você não precisou usar `context` para fazer nenhuma dessas coisas? E | ||
235 | 235 | ||
236 | ### Mais detalhes sobre gerenciamento de rotas | 236 | ### Mais detalhes sobre gerenciamento de rotas |
237 | 237 | ||
238 | -**GetX funciona com rotas nomeadas também! Veja uma explicação mais completa do gerenciamento de rotas [aqui](./docs/pt_BR/route_management.md)** | 238 | +**GetX funciona com rotas nomeadas também! Veja uma explicação mais completa do gerenciamento de rotas [aqui](./documentation/pt_BR/route_management.md)** |
239 | 239 | ||
240 | ### Explicação em video do gerenciamento de rotas | 240 | ### Explicação em video do gerenciamento de rotas |
241 | 241 | ||
@@ -283,7 +283,7 @@ Get.lazyPut<Service>(()=> ApiMock()); | @@ -283,7 +283,7 @@ Get.lazyPut<Service>(()=> ApiMock()); | ||
283 | 283 | ||
284 | ### Mais detalhes sobre gerenciamento de dependências | 284 | ### Mais detalhes sobre gerenciamento de dependências |
285 | 285 | ||
286 | -**Veja uma explicação mais completa do gerenciamento de dependência [aqui](./docs/pt_BR/dependency_management.md)** | 286 | +**Veja uma explicação mais completa do gerenciamento de dependência [aqui](./documentation/pt_BR/dependency_management.md)** |
287 | 287 | ||
288 | # Como contribuir | 288 | # Como contribuir |
289 | 289 |
benchmark/README.md
deleted
100644 → 0
1 | -# benchmarks | ||
2 | -A repository to benchmark Flutter libs. | ||
3 | -Creators of the tested libs can suggest improvements, as long as they follow the same design structure. | ||
4 | - | ||
5 | -# 1- State Managers | ||
6 | - | ||
7 | - | ||
8 | - | ||
9 | -The idle application consumes 4.288k of ram. | ||
10 | -Items were added dynamically to a ListView. | ||
11 | -The amount of RAM was measured after the test, and the following calculation was made: | ||
12 | -Number of RAM consumed by the app after testing with the state manager - RAM in idle state without any state manager. | ||
13 | - | ||
14 | -In addition to the RAM calculation, the size of the apk was also observed after compilation. And we had the following results: | ||
15 | - | ||
16 | -- flutter_bloc: 8.3mb | ||
17 | -- mobx: 8.3mb | ||
18 | -- provider: 8.3mb | ||
19 | -- redux: 8.2mb | ||
20 | -- get: 8.2mb | ||
21 | -- getx: 8.2mb | ||
22 | - | ||
23 | -The creators of flutter_bloc and provider made changes to use their library. If you want to make changes (within the scope of the project, without eliminating classes), you can do so by offering a PR. |
benchmark/benchmark.png
deleted
100644 → 0

32.5 KB
benchmark/state_managers/.gitignore
deleted
100644 → 0
1 | -# Miscellaneous | ||
2 | -*.class | ||
3 | -*.log | ||
4 | -*.pyc | ||
5 | -*.swp | ||
6 | -.DS_Store | ||
7 | -.atom/ | ||
8 | -.buildlog/ | ||
9 | -.history | ||
10 | -.svn/ | ||
11 | - | ||
12 | -# IntelliJ related | ||
13 | -*.iml | ||
14 | -*.ipr | ||
15 | -*.iws | ||
16 | -.idea/ | ||
17 | - | ||
18 | -# The .vscode folder contains launch configuration and tasks you configure in | ||
19 | -# VS Code which you may wish to be included in version control, so this line | ||
20 | -# is commented out by default. | ||
21 | -#.vscode/ | ||
22 | - | ||
23 | -# Flutter/Dart/Pub related | ||
24 | -**/doc/api/ | ||
25 | -**/ios/Flutter/.last_build_id | ||
26 | -.dart_tool/ | ||
27 | -.flutter-plugins | ||
28 | -.flutter-plugins-dependencies | ||
29 | -.packages | ||
30 | -.pub-cache/ | ||
31 | -.pub/ | ||
32 | -/build/ | ||
33 | - | ||
34 | -# Web related | ||
35 | -lib/generated_plugin_registrant.dart | ||
36 | - | ||
37 | -# Symbolication related | ||
38 | -app.*.symbols | ||
39 | - | ||
40 | -# Obfuscation related | ||
41 | -app.*.map.json | ||
42 | - | ||
43 | -# Exceptions to above rules. | ||
44 | -!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages |
benchmark/state_managers/README.md
deleted
100644 → 0
1 | -# Flutter State Management |
1 | -def localProperties = new Properties() | ||
2 | -def localPropertiesFile = rootProject.file('local.properties') | ||
3 | -if (localPropertiesFile.exists()) { | ||
4 | - localPropertiesFile.withReader('UTF-8') { reader -> | ||
5 | - localProperties.load(reader) | ||
6 | - } | ||
7 | -} | ||
8 | - | ||
9 | -def flutterRoot = localProperties.getProperty('flutter.sdk') | ||
10 | -if (flutterRoot == null) { | ||
11 | - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") | ||
12 | -} | ||
13 | - | ||
14 | -apply plugin: 'com.android.application' | ||
15 | -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" | ||
16 | - | ||
17 | -android { | ||
18 | - compileSdkVersion 29 | ||
19 | - | ||
20 | - lintOptions { | ||
21 | - disable 'InvalidPackage' | ||
22 | - } | ||
23 | - | ||
24 | - defaultConfig { | ||
25 | - // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). | ||
26 | - applicationId "de.udos.flutterstatemanagement" | ||
27 | - minSdkVersion 16 | ||
28 | - targetSdkVersion 29 | ||
29 | - versionCode 1 | ||
30 | - versionName "1.0" | ||
31 | - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
32 | - } | ||
33 | - | ||
34 | - buildTypes { | ||
35 | - release { | ||
36 | - // TODO: Add your own signing config for the release build. | ||
37 | - // Signing with the debug keys for now, so `flutter run --release` works. | ||
38 | - signingConfig signingConfigs.debug | ||
39 | - } | ||
40 | - } | ||
41 | -} | ||
42 | - | ||
43 | -flutter { | ||
44 | - source '../..' | ||
45 | -} | ||
46 | - | ||
47 | -dependencies { | ||
48 | - testImplementation 'junit:junit:4.12' | ||
49 | - androidTestImplementation 'androidx.test.ext:junit:1.1.1' | ||
50 | - androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | ||
51 | -} |
1 | -<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
2 | - package="de.udos.benchmarks"> | ||
3 | - <!-- Flutter needs it to communicate with the running application | ||
4 | - to allow setting breakpoints, to provide hot reload, etc. | ||
5 | - --> | ||
6 | - <uses-permission android:name="android.permission.INTERNET"/> | ||
7 | -</manifest> |
1 | -<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
2 | - package="de.udos.benchmarks"> | ||
3 | - | ||
4 | - <!-- The INTERNET permission is required for development. Specifically, | ||
5 | - flutter needs it to communicate with the running application | ||
6 | - to allow setting breakpoints, to provide hot reload, etc. | ||
7 | - --> | ||
8 | - <uses-permission android:name="android.permission.INTERNET"/> | ||
9 | - | ||
10 | - <!-- io.flutter.app.FlutterApplication is an android.app.Application that | ||
11 | - calls FlutterMain.startInitialization(this); in its onCreate method. | ||
12 | - In most cases you can leave this as-is, but you if you want to provide | ||
13 | - additional functionality it is fine to subclass or reimplement | ||
14 | - FlutterApplication and put your custom class here. --> | ||
15 | - <application | ||
16 | - android:name="io.flutter.app.FlutterApplication" | ||
17 | - android:label="benckmark" | ||
18 | - android:icon="@mipmap/ic_launcher"> | ||
19 | - <activity | ||
20 | - android:name=".MainActivity" | ||
21 | - android:launchMode="singleTop" | ||
22 | - android:theme="@style/LaunchTheme" | ||
23 | - android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density" | ||
24 | - android:hardwareAccelerated="true" | ||
25 | - android:windowSoftInputMode="adjustResize"> | ||
26 | - <!-- This keeps the window background of the activity showing | ||
27 | - until Flutter renders its first frame. It can be removed if | ||
28 | - there is no splash screen (such as the default splash screen | ||
29 | - defined in @style/LaunchTheme). --> | ||
30 | - <meta-data | ||
31 | - android:name="io.flutter.app.android.SplashScreenUntilFirstFrame" | ||
32 | - android:value="true" /> | ||
33 | - <intent-filter> | ||
34 | - <action android:name="android.intent.action.MAIN"/> | ||
35 | - <category android:name="android.intent.category.LAUNCHER"/> | ||
36 | - </intent-filter> | ||
37 | - </activity> | ||
38 | - </application> | ||
39 | -</manifest> |
benchmark/state_managers/android/app/src/main/java/de/udos/benchmarks/MainActivity.java
deleted
100644 → 0
1 | -package de.udos.benchmarks; | ||
2 | - | ||
3 | -import android.os.Bundle; | ||
4 | -import io.flutter.app.FlutterActivity; | ||
5 | -import io.flutter.plugins.GeneratedPluginRegistrant; | ||
6 | - | ||
7 | -public class MainActivity extends FlutterActivity { | ||
8 | - @Override | ||
9 | - protected void onCreate(Bundle savedInstanceState) { | ||
10 | - super.onCreate(savedInstanceState); | ||
11 | - GeneratedPluginRegistrant.registerWith(this); | ||
12 | - } | ||
13 | -} |
1 | -package io.flutter.plugins; | ||
2 | - | ||
3 | -import io.flutter.plugin.common.PluginRegistry; | ||
4 | - | ||
5 | -/** | ||
6 | - * Generated file. Do not edit. | ||
7 | - */ | ||
8 | -public final class GeneratedPluginRegistrant { | ||
9 | - public static void registerWith(PluginRegistry registry) { | ||
10 | - if (alreadyRegisteredWith(registry)) { | ||
11 | - return; | ||
12 | - } | ||
13 | - } | ||
14 | - | ||
15 | - private static boolean alreadyRegisteredWith(PluginRegistry registry) { | ||
16 | - final String key = GeneratedPluginRegistrant.class.getCanonicalName(); | ||
17 | - if (registry.hasPlugin(key)) { | ||
18 | - return true; | ||
19 | - } | ||
20 | - registry.registrarFor(key); | ||
21 | - return false; | ||
22 | - } | ||
23 | -} |
1 | -<?xml version="1.0" encoding="utf-8"?> | ||
2 | -<!-- Modify this file to customize your launch splash screen --> | ||
3 | -<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
4 | - <item android:drawable="@android:color/white" /> | ||
5 | - | ||
6 | - <!-- You can insert your own image assets here --> | ||
7 | - <!-- <item> | ||
8 | - <bitmap | ||
9 | - android:gravity="center" | ||
10 | - android:src="@mipmap/launch_image" /> | ||
11 | - </item> --> | ||
12 | -</layer-list> |

544 Bytes

442 Bytes

721 Bytes

1.01 KB

1.41 KB
1 | -<?xml version="1.0" encoding="utf-8"?> | ||
2 | -<resources> | ||
3 | - <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar"> | ||
4 | - <!-- Show a splash screen on the activity. Automatically removed when | ||
5 | - Flutter draws its first frame --> | ||
6 | - <item name="android:windowBackground">@drawable/launch_background</item> | ||
7 | - </style> | ||
8 | -</resources> |
1 | -<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
2 | - package="de.udos.benchmarks"> | ||
3 | - <!-- Flutter needs it to communicate with the running application | ||
4 | - to allow setting breakpoints, to provide hot reload, etc. | ||
5 | - --> | ||
6 | - <uses-permission android:name="android.permission.INTERNET"/> | ||
7 | -</manifest> |
1 | -buildscript { | ||
2 | - repositories { | ||
3 | - google() | ||
4 | - jcenter() | ||
5 | - } | ||
6 | - | ||
7 | - dependencies { | ||
8 | - classpath 'com.android.tools.build:gradle:3.5.3' | ||
9 | - } | ||
10 | -} | ||
11 | - | ||
12 | -allprojects { | ||
13 | - repositories { | ||
14 | - google() | ||
15 | - jcenter() | ||
16 | - } | ||
17 | -} | ||
18 | - | ||
19 | -rootProject.buildDir = '../build' | ||
20 | -subprojects { | ||
21 | - project.buildDir = "${rootProject.buildDir}/${project.name}" | ||
22 | -} | ||
23 | -subprojects { | ||
24 | - project.evaluationDependsOn(':app') | ||
25 | -} | ||
26 | - | ||
27 | -task clean(type: Delete) { | ||
28 | - delete rootProject.buildDir | ||
29 | -} |
No preview for this file type
1 | -#!/usr/bin/env bash | ||
2 | - | ||
3 | -############################################################################## | ||
4 | -## | ||
5 | -## Gradle start up script for UN*X | ||
6 | -## | ||
7 | -############################################################################## | ||
8 | - | ||
9 | -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | ||
10 | -DEFAULT_JVM_OPTS="" | ||
11 | - | ||
12 | -APP_NAME="Gradle" | ||
13 | -APP_BASE_NAME=`basename "$0"` | ||
14 | - | ||
15 | -# Use the maximum available, or set MAX_FD != -1 to use that value. | ||
16 | -MAX_FD="maximum" | ||
17 | - | ||
18 | -warn ( ) { | ||
19 | - echo "$*" | ||
20 | -} | ||
21 | - | ||
22 | -die ( ) { | ||
23 | - echo | ||
24 | - echo "$*" | ||
25 | - echo | ||
26 | - exit 1 | ||
27 | -} | ||
28 | - | ||
29 | -# OS specific support (must be 'true' or 'false'). | ||
30 | -cygwin=false | ||
31 | -msys=false | ||
32 | -darwin=false | ||
33 | -case "`uname`" in | ||
34 | - CYGWIN* ) | ||
35 | - cygwin=true | ||
36 | - ;; | ||
37 | - Darwin* ) | ||
38 | - darwin=true | ||
39 | - ;; | ||
40 | - MINGW* ) | ||
41 | - msys=true | ||
42 | - ;; | ||
43 | -esac | ||
44 | - | ||
45 | -# Attempt to set APP_HOME | ||
46 | -# Resolve links: $0 may be a link | ||
47 | -PRG="$0" | ||
48 | -# Need this for relative symlinks. | ||
49 | -while [ -h "$PRG" ] ; do | ||
50 | - ls=`ls -ld "$PRG"` | ||
51 | - link=`expr "$ls" : '.*-> \(.*\)$'` | ||
52 | - if expr "$link" : '/.*' > /dev/null; then | ||
53 | - PRG="$link" | ||
54 | - else | ||
55 | - PRG=`dirname "$PRG"`"/$link" | ||
56 | - fi | ||
57 | -done | ||
58 | -SAVED="`pwd`" | ||
59 | -cd "`dirname \"$PRG\"`/" >/dev/null | ||
60 | -APP_HOME="`pwd -P`" | ||
61 | -cd "$SAVED" >/dev/null | ||
62 | - | ||
63 | -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar | ||
64 | - | ||
65 | -# Determine the Java command to use to start the JVM. | ||
66 | -if [ -n "$JAVA_HOME" ] ; then | ||
67 | - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then | ||
68 | - # IBM's JDK on AIX uses strange locations for the executables | ||
69 | - JAVACMD="$JAVA_HOME/jre/sh/java" | ||
70 | - else | ||
71 | - JAVACMD="$JAVA_HOME/bin/java" | ||
72 | - fi | ||
73 | - if [ ! -x "$JAVACMD" ] ; then | ||
74 | - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME | ||
75 | - | ||
76 | -Please set the JAVA_HOME variable in your environment to match the | ||
77 | -location of your Java installation." | ||
78 | - fi | ||
79 | -else | ||
80 | - JAVACMD="java" | ||
81 | - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | ||
82 | - | ||
83 | -Please set the JAVA_HOME variable in your environment to match the | ||
84 | -location of your Java installation." | ||
85 | -fi | ||
86 | - | ||
87 | -# Increase the maximum file descriptors if we can. | ||
88 | -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then | ||
89 | - MAX_FD_LIMIT=`ulimit -H -n` | ||
90 | - if [ $? -eq 0 ] ; then | ||
91 | - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then | ||
92 | - MAX_FD="$MAX_FD_LIMIT" | ||
93 | - fi | ||
94 | - ulimit -n $MAX_FD | ||
95 | - if [ $? -ne 0 ] ; then | ||
96 | - warn "Could not set maximum file descriptor limit: $MAX_FD" | ||
97 | - fi | ||
98 | - else | ||
99 | - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" | ||
100 | - fi | ||
101 | -fi | ||
102 | - | ||
103 | -# For Darwin, add options to specify how the application appears in the dock | ||
104 | -if $darwin; then | ||
105 | - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" | ||
106 | -fi | ||
107 | - | ||
108 | -# For Cygwin, switch paths to Windows format before running java | ||
109 | -if $cygwin ; then | ||
110 | - APP_HOME=`cygpath --path --mixed "$APP_HOME"` | ||
111 | - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` | ||
112 | - JAVACMD=`cygpath --unix "$JAVACMD"` | ||
113 | - | ||
114 | - # We build the pattern for arguments to be converted via cygpath | ||
115 | - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` | ||
116 | - SEP="" | ||
117 | - for dir in $ROOTDIRSRAW ; do | ||
118 | - ROOTDIRS="$ROOTDIRS$SEP$dir" | ||
119 | - SEP="|" | ||
120 | - done | ||
121 | - OURCYGPATTERN="(^($ROOTDIRS))" | ||
122 | - # Add a user-defined pattern to the cygpath arguments | ||
123 | - if [ "$GRADLE_CYGPATTERN" != "" ] ; then | ||
124 | - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" | ||
125 | - fi | ||
126 | - # Now convert the arguments - kludge to limit ourselves to /bin/sh | ||
127 | - i=0 | ||
128 | - for arg in "$@" ; do | ||
129 | - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` | ||
130 | - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option | ||
131 | - | ||
132 | - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition | ||
133 | - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` | ||
134 | - else | ||
135 | - eval `echo args$i`="\"$arg\"" | ||
136 | - fi | ||
137 | - i=$((i+1)) | ||
138 | - done | ||
139 | - case $i in | ||
140 | - (0) set -- ;; | ||
141 | - (1) set -- "$args0" ;; | ||
142 | - (2) set -- "$args0" "$args1" ;; | ||
143 | - (3) set -- "$args0" "$args1" "$args2" ;; | ||
144 | - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; | ||
145 | - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; | ||
146 | - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; | ||
147 | - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; | ||
148 | - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; | ||
149 | - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; | ||
150 | - esac | ||
151 | -fi | ||
152 | - | ||
153 | -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules | ||
154 | -function splitJvmOpts() { | ||
155 | - JVM_OPTS=("$@") | ||
156 | -} | ||
157 | -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS | ||
158 | -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" | ||
159 | - | ||
160 | -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" |
1 | -@if "%DEBUG%" == "" @echo off | ||
2 | -@rem ########################################################################## | ||
3 | -@rem | ||
4 | -@rem Gradle startup script for Windows | ||
5 | -@rem | ||
6 | -@rem ########################################################################## | ||
7 | - | ||
8 | -@rem Set local scope for the variables with windows NT shell | ||
9 | -if "%OS%"=="Windows_NT" setlocal | ||
10 | - | ||
11 | -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | ||
12 | -set DEFAULT_JVM_OPTS= | ||
13 | - | ||
14 | -set DIRNAME=%~dp0 | ||
15 | -if "%DIRNAME%" == "" set DIRNAME=. | ||
16 | -set APP_BASE_NAME=%~n0 | ||
17 | -set APP_HOME=%DIRNAME% | ||
18 | - | ||
19 | -@rem Find java.exe | ||
20 | -if defined JAVA_HOME goto findJavaFromJavaHome | ||
21 | - | ||
22 | -set JAVA_EXE=java.exe | ||
23 | -%JAVA_EXE% -version >NUL 2>&1 | ||
24 | -if "%ERRORLEVEL%" == "0" goto init | ||
25 | - | ||
26 | -echo. | ||
27 | -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | ||
28 | -echo. | ||
29 | -echo Please set the JAVA_HOME variable in your environment to match the | ||
30 | -echo location of your Java installation. | ||
31 | - | ||
32 | -goto fail | ||
33 | - | ||
34 | -:findJavaFromJavaHome | ||
35 | -set JAVA_HOME=%JAVA_HOME:"=% | ||
36 | -set JAVA_EXE=%JAVA_HOME%/bin/java.exe | ||
37 | - | ||
38 | -if exist "%JAVA_EXE%" goto init | ||
39 | - | ||
40 | -echo. | ||
41 | -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% | ||
42 | -echo. | ||
43 | -echo Please set the JAVA_HOME variable in your environment to match the | ||
44 | -echo location of your Java installation. | ||
45 | - | ||
46 | -goto fail | ||
47 | - | ||
48 | -:init | ||
49 | -@rem Get command-line arguments, handling Windowz variants | ||
50 | - | ||
51 | -if not "%OS%" == "Windows_NT" goto win9xME_args | ||
52 | -if "%@eval[2+2]" == "4" goto 4NT_args | ||
53 | - | ||
54 | -:win9xME_args | ||
55 | -@rem Slurp the command line arguments. | ||
56 | -set CMD_LINE_ARGS= | ||
57 | -set _SKIP=2 | ||
58 | - | ||
59 | -:win9xME_args_slurp | ||
60 | -if "x%~1" == "x" goto execute | ||
61 | - | ||
62 | -set CMD_LINE_ARGS=%* | ||
63 | -goto execute | ||
64 | - | ||
65 | -:4NT_args | ||
66 | -@rem Get arguments from the 4NT Shell from JP Software | ||
67 | -set CMD_LINE_ARGS=%$ | ||
68 | - | ||
69 | -:execute | ||
70 | -@rem Setup the command line | ||
71 | - | ||
72 | -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar | ||
73 | - | ||
74 | -@rem Execute Gradle | ||
75 | -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% | ||
76 | - | ||
77 | -:end | ||
78 | -@rem End local scope for the variables with windows NT shell | ||
79 | -if "%ERRORLEVEL%"=="0" goto mainEnd | ||
80 | - | ||
81 | -:fail | ||
82 | -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of | ||
83 | -rem the _cmd.exe /c_ return code! | ||
84 | -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 | ||
85 | -exit /b 1 | ||
86 | - | ||
87 | -:mainEnd | ||
88 | -if "%OS%"=="Windows_NT" endlocal | ||
89 | - | ||
90 | -:omega |
1 | -include ':app' | ||
2 | - | ||
3 | -def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() | ||
4 | - | ||
5 | -def plugins = new Properties() | ||
6 | -def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') | ||
7 | -if (pluginsFile.exists()) { | ||
8 | - pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } | ||
9 | -} | ||
10 | - | ||
11 | -plugins.each { name, path -> | ||
12 | - def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() | ||
13 | - include ":$name" | ||
14 | - project(":$name").projectDir = pluginDirectory | ||
15 | -} |
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | -<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
3 | -<plist version="1.0"> | ||
4 | -<dict> | ||
5 | - <key>CFBundleDevelopmentRegion</key> | ||
6 | - <string>en</string> | ||
7 | - <key>CFBundleExecutable</key> | ||
8 | - <string>App</string> | ||
9 | - <key>CFBundleIdentifier</key> | ||
10 | - <string>io.flutter.flutter.app</string> | ||
11 | - <key>CFBundleInfoDictionaryVersion</key> | ||
12 | - <string>6.0</string> | ||
13 | - <key>CFBundleName</key> | ||
14 | - <string>App</string> | ||
15 | - <key>CFBundlePackageType</key> | ||
16 | - <string>FMWK</string> | ||
17 | - <key>CFBundleShortVersionString</key> | ||
18 | - <string>1.0</string> | ||
19 | - <key>CFBundleSignature</key> | ||
20 | - <string>????</string> | ||
21 | - <key>CFBundleVersion</key> | ||
22 | - <string>1.0</string> | ||
23 | - <key>MinimumOSVersion</key> | ||
24 | - <string>8.0</string> | ||
25 | -</dict> | ||
26 | -</plist> |
1 | -#include "Generated.xcconfig" |
1 | -// This is a generated file; do not edit or check into version control. | ||
2 | -FLUTTER_ROOT=/opt/flutter | ||
3 | -FLUTTER_APPLICATION_PATH=/home/jonny/Área de trabalho/getx/benchmark/state_managers | ||
4 | -FLUTTER_TARGET=lib/main.dart | ||
5 | -FLUTTER_BUILD_DIR=build | ||
6 | -SYMROOT=${SOURCE_ROOT}/../build/ios | ||
7 | -OTHER_LDFLAGS=$(inherited) -framework Flutter | ||
8 | -FLUTTER_FRAMEWORK_DIR=/opt/flutter/bin/cache/artifacts/engine/ios | ||
9 | -FLUTTER_BUILD_NAME=1.0.0 | ||
10 | -FLUTTER_BUILD_NUMBER=1 | ||
11 | -DART_OBFUSCATION=false | ||
12 | -TRACK_WIDGET_CREATION=false | ||
13 | -TREE_SHAKE_ICONS=false | ||
14 | -PACKAGE_CONFIG=.packages |
1 | -#include "Generated.xcconfig" |
1 | -#!/bin/sh | ||
2 | -# This is a generated file; do not edit or check into version control. | ||
3 | -export "FLUTTER_ROOT=/opt/flutter" | ||
4 | -export "FLUTTER_APPLICATION_PATH=/home/jonny/Área de trabalho/getx/benchmark/state_managers" | ||
5 | -export "FLUTTER_TARGET=lib/main.dart" | ||
6 | -export "FLUTTER_BUILD_DIR=build" | ||
7 | -export "SYMROOT=${SOURCE_ROOT}/../build/ios" | ||
8 | -export "OTHER_LDFLAGS=$(inherited) -framework Flutter" | ||
9 | -export "FLUTTER_FRAMEWORK_DIR=/opt/flutter/bin/cache/artifacts/engine/ios" | ||
10 | -export "FLUTTER_BUILD_NAME=1.0.0" | ||
11 | -export "FLUTTER_BUILD_NUMBER=1" | ||
12 | -export "DART_OBFUSCATION=false" | ||
13 | -export "TRACK_WIDGET_CREATION=false" | ||
14 | -export "TREE_SHAKE_ICONS=false" | ||
15 | -export "PACKAGE_CONFIG=.packages" |
benchmark/state_managers/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
deleted
100644 → 0
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | -<Scheme | ||
3 | - LastUpgradeVersion = "0910" | ||
4 | - version = "1.3"> | ||
5 | - <BuildAction | ||
6 | - parallelizeBuildables = "YES" | ||
7 | - buildImplicitDependencies = "YES"> | ||
8 | - <BuildActionEntries> | ||
9 | - <BuildActionEntry | ||
10 | - buildForTesting = "YES" | ||
11 | - buildForRunning = "YES" | ||
12 | - buildForProfiling = "YES" | ||
13 | - buildForArchiving = "YES" | ||
14 | - buildForAnalyzing = "YES"> | ||
15 | - <BuildableReference | ||
16 | - BuildableIdentifier = "primary" | ||
17 | - BlueprintIdentifier = "97C146ED1CF9000F007C117D" | ||
18 | - BuildableName = "Runner.app" | ||
19 | - BlueprintName = "Runner" | ||
20 | - ReferencedContainer = "container:Runner.xcodeproj"> | ||
21 | - </BuildableReference> | ||
22 | - </BuildActionEntry> | ||
23 | - </BuildActionEntries> | ||
24 | - </BuildAction> | ||
25 | - <TestAction | ||
26 | - buildConfiguration = "Debug" | ||
27 | - selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
28 | - selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
29 | - language = "" | ||
30 | - shouldUseLaunchSchemeArgsEnv = "YES"> | ||
31 | - <Testables> | ||
32 | - </Testables> | ||
33 | - <MacroExpansion> | ||
34 | - <BuildableReference | ||
35 | - BuildableIdentifier = "primary" | ||
36 | - BlueprintIdentifier = "97C146ED1CF9000F007C117D" | ||
37 | - BuildableName = "Runner.app" | ||
38 | - BlueprintName = "Runner" | ||
39 | - ReferencedContainer = "container:Runner.xcodeproj"> | ||
40 | - </BuildableReference> | ||
41 | - </MacroExpansion> | ||
42 | - <AdditionalOptions> | ||
43 | - </AdditionalOptions> | ||
44 | - </TestAction> | ||
45 | - <LaunchAction | ||
46 | - buildConfiguration = "Debug" | ||
47 | - selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
48 | - selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
49 | - language = "" | ||
50 | - launchStyle = "0" | ||
51 | - useCustomWorkingDirectory = "NO" | ||
52 | - ignoresPersistentStateOnLaunch = "NO" | ||
53 | - debugDocumentVersioning = "YES" | ||
54 | - debugServiceExtension = "internal" | ||
55 | - allowLocationSimulation = "YES"> | ||
56 | - <BuildableProductRunnable | ||
57 | - runnableDebuggingMode = "0"> | ||
58 | - <BuildableReference | ||
59 | - BuildableIdentifier = "primary" | ||
60 | - BlueprintIdentifier = "97C146ED1CF9000F007C117D" | ||
61 | - BuildableName = "Runner.app" | ||
62 | - BlueprintName = "Runner" | ||
63 | - ReferencedContainer = "container:Runner.xcodeproj"> | ||
64 | - </BuildableReference> | ||
65 | - </BuildableProductRunnable> | ||
66 | - <AdditionalOptions> | ||
67 | - </AdditionalOptions> | ||
68 | - </LaunchAction> | ||
69 | - <ProfileAction | ||
70 | - buildConfiguration = "Release" | ||
71 | - shouldUseLaunchSchemeArgsEnv = "YES" | ||
72 | - savedToolIdentifier = "" | ||
73 | - useCustomWorkingDirectory = "NO" | ||
74 | - debugDocumentVersioning = "YES"> | ||
75 | - <BuildableProductRunnable | ||
76 | - runnableDebuggingMode = "0"> | ||
77 | - <BuildableReference | ||
78 | - BuildableIdentifier = "primary" | ||
79 | - BlueprintIdentifier = "97C146ED1CF9000F007C117D" | ||
80 | - BuildableName = "Runner.app" | ||
81 | - BlueprintName = "Runner" | ||
82 | - ReferencedContainer = "container:Runner.xcodeproj"> | ||
83 | - </BuildableReference> | ||
84 | - </BuildableProductRunnable> | ||
85 | - </ProfileAction> | ||
86 | - <AnalyzeAction | ||
87 | - buildConfiguration = "Debug"> | ||
88 | - </AnalyzeAction> | ||
89 | - <ArchiveAction | ||
90 | - buildConfiguration = "Release" | ||
91 | - revealArchiveInOrganizer = "YES"> | ||
92 | - </ArchiveAction> | ||
93 | -</Scheme> |
1 | -#include "AppDelegate.h" | ||
2 | -#include "GeneratedPluginRegistrant.h" | ||
3 | - | ||
4 | -@implementation AppDelegate | ||
5 | - | ||
6 | -- (BOOL)application:(UIApplication *)application | ||
7 | - didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | ||
8 | - [GeneratedPluginRegistrant registerWithRegistry:self]; | ||
9 | - // Override point for customization after application launch. | ||
10 | - return [super application:application didFinishLaunchingWithOptions:launchOptions]; | ||
11 | -} | ||
12 | - | ||
13 | -@end |
1 | -import UIKit | ||
2 | -import Flutter | ||
3 | - | ||
4 | -@UIApplicationMain | ||
5 | -@objc class AppDelegate: FlutterAppDelegate { | ||
6 | - override func application( | ||
7 | - _ application: UIApplication, | ||
8 | - didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? | ||
9 | - ) -> Bool { | ||
10 | - GeneratedPluginRegistrant.register(with: self) | ||
11 | - return super.application(application, didFinishLaunchingWithOptions: launchOptions) | ||
12 | - } | ||
13 | -} |
benchmark/state_managers/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json
deleted
100644 → 0
1 | -{ | ||
2 | - "images" : [ | ||
3 | - { | ||
4 | - "size" : "20x20", | ||
5 | - "idiom" : "iphone", | ||
6 | - "filename" : "Icon-App-20x20@2x.png", | ||
7 | - "scale" : "2x" | ||
8 | - }, | ||
9 | - { | ||
10 | - "size" : "20x20", | ||
11 | - "idiom" : "iphone", | ||
12 | - "filename" : "Icon-App-20x20@3x.png", | ||
13 | - "scale" : "3x" | ||
14 | - }, | ||
15 | - { | ||
16 | - "size" : "29x29", | ||
17 | - "idiom" : "iphone", | ||
18 | - "filename" : "Icon-App-29x29@1x.png", | ||
19 | - "scale" : "1x" | ||
20 | - }, | ||
21 | - { | ||
22 | - "size" : "29x29", | ||
23 | - "idiom" : "iphone", | ||
24 | - "filename" : "Icon-App-29x29@2x.png", | ||
25 | - "scale" : "2x" | ||
26 | - }, | ||
27 | - { | ||
28 | - "size" : "29x29", | ||
29 | - "idiom" : "iphone", | ||
30 | - "filename" : "Icon-App-29x29@3x.png", | ||
31 | - "scale" : "3x" | ||
32 | - }, | ||
33 | - { | ||
34 | - "size" : "40x40", | ||
35 | - "idiom" : "iphone", | ||
36 | - "filename" : "Icon-App-40x40@2x.png", | ||
37 | - "scale" : "2x" | ||
38 | - }, | ||
39 | - { | ||
40 | - "size" : "40x40", | ||
41 | - "idiom" : "iphone", | ||
42 | - "filename" : "Icon-App-40x40@3x.png", | ||
43 | - "scale" : "3x" | ||
44 | - }, | ||
45 | - { | ||
46 | - "size" : "60x60", | ||
47 | - "idiom" : "iphone", | ||
48 | - "filename" : "Icon-App-60x60@2x.png", | ||
49 | - "scale" : "2x" | ||
50 | - }, | ||
51 | - { | ||
52 | - "size" : "60x60", | ||
53 | - "idiom" : "iphone", | ||
54 | - "filename" : "Icon-App-60x60@3x.png", | ||
55 | - "scale" : "3x" | ||
56 | - }, | ||
57 | - { | ||
58 | - "size" : "20x20", | ||
59 | - "idiom" : "ipad", | ||
60 | - "filename" : "Icon-App-20x20@1x.png", | ||
61 | - "scale" : "1x" | ||
62 | - }, | ||
63 | - { | ||
64 | - "size" : "20x20", | ||
65 | - "idiom" : "ipad", | ||
66 | - "filename" : "Icon-App-20x20@2x.png", | ||
67 | - "scale" : "2x" | ||
68 | - }, | ||
69 | - { | ||
70 | - "size" : "29x29", | ||
71 | - "idiom" : "ipad", | ||
72 | - "filename" : "Icon-App-29x29@1x.png", | ||
73 | - "scale" : "1x" | ||
74 | - }, | ||
75 | - { | ||
76 | - "size" : "29x29", | ||
77 | - "idiom" : "ipad", | ||
78 | - "filename" : "Icon-App-29x29@2x.png", | ||
79 | - "scale" : "2x" | ||
80 | - }, | ||
81 | - { | ||
82 | - "size" : "40x40", | ||
83 | - "idiom" : "ipad", | ||
84 | - "filename" : "Icon-App-40x40@1x.png", | ||
85 | - "scale" : "1x" | ||
86 | - }, | ||
87 | - { | ||
88 | - "size" : "40x40", | ||
89 | - "idiom" : "ipad", | ||
90 | - "filename" : "Icon-App-40x40@2x.png", | ||
91 | - "scale" : "2x" | ||
92 | - }, | ||
93 | - { | ||
94 | - "size" : "76x76", | ||
95 | - "idiom" : "ipad", | ||
96 | - "filename" : "Icon-App-76x76@1x.png", | ||
97 | - "scale" : "1x" | ||
98 | - }, | ||
99 | - { | ||
100 | - "size" : "76x76", | ||
101 | - "idiom" : "ipad", | ||
102 | - "filename" : "Icon-App-76x76@2x.png", | ||
103 | - "scale" : "2x" | ||
104 | - }, | ||
105 | - { | ||
106 | - "size" : "83.5x83.5", | ||
107 | - "idiom" : "ipad", | ||
108 | - "filename" : "Icon-App-83.5x83.5@2x.png", | ||
109 | - "scale" : "2x" | ||
110 | - }, | ||
111 | - { | ||
112 | - "size" : "1024x1024", | ||
113 | - "idiom" : "ios-marketing", | ||
114 | - "filename" : "Icon-App-1024x1024@1x.png", | ||
115 | - "scale" : "1x" | ||
116 | - } | ||
117 | - ], | ||
118 | - "info" : { | ||
119 | - "version" : 1, | ||
120 | - "author" : "xcode" | ||
121 | - } | ||
122 | -} |

10.9 KB
benchmark/state_managers/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
deleted
100644 → 0

564 Bytes
benchmark/state_managers/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
deleted
100644 → 0

1.25 KB
benchmark/state_managers/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
deleted
100644 → 0

1.55 KB
benchmark/state_managers/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
deleted
100644 → 0

1 KB
benchmark/state_managers/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
deleted
100644 → 0

1.68 KB
benchmark/state_managers/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
deleted
100644 → 0

1.88 KB
benchmark/state_managers/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
deleted
100644 → 0

1.25 KB
benchmark/state_managers/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
deleted
100644 → 0

1.85 KB
benchmark/state_managers/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
deleted
100644 → 0

2.6 KB
benchmark/state_managers/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
deleted
100644 → 0

2.6 KB
benchmark/state_managers/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
deleted
100644 → 0

3.74 KB
benchmark/state_managers/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
deleted
100644 → 0

1.84 KB
benchmark/state_managers/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
deleted
100644 → 0

3.22 KB

3.53 KB
benchmark/state_managers/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json
deleted
100644 → 0
1 | -{ | ||
2 | - "images" : [ | ||
3 | - { | ||
4 | - "idiom" : "universal", | ||
5 | - "filename" : "LaunchImage.png", | ||
6 | - "scale" : "1x" | ||
7 | - }, | ||
8 | - { | ||
9 | - "idiom" : "universal", | ||
10 | - "filename" : "LaunchImage@2x.png", | ||
11 | - "scale" : "2x" | ||
12 | - }, | ||
13 | - { | ||
14 | - "idiom" : "universal", | ||
15 | - "filename" : "LaunchImage@3x.png", | ||
16 | - "scale" : "3x" | ||
17 | - } | ||
18 | - ], | ||
19 | - "info" : { | ||
20 | - "version" : 1, | ||
21 | - "author" : "xcode" | ||
22 | - } | ||
23 | -} |
benchmark/state_managers/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
deleted
100644 → 0

68 Bytes
benchmark/state_managers/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
deleted
100644 → 0

68 Bytes
benchmark/state_managers/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
deleted
100644 → 0

68 Bytes
benchmark/state_managers/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md
deleted
100644 → 0
1 | -# Launch Screen Assets | ||
2 | - | ||
3 | -You can customize the launch screen with your own desired assets by replacing the image files in this directory. | ||
4 | - | ||
5 | -You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. |
1 | -<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
2 | -<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" colorMatched="YES" initialViewController="01J-lp-oVM"> | ||
3 | - <dependencies> | ||
4 | - <deployment identifier="iOS"/> | ||
5 | - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/> | ||
6 | - </dependencies> | ||
7 | - <scenes> | ||
8 | - <!--View Controller--> | ||
9 | - <scene sceneID="EHf-IW-A2E"> | ||
10 | - <objects> | ||
11 | - <viewController id="01J-lp-oVM" sceneMemberID="viewController"> | ||
12 | - <layoutGuides> | ||
13 | - <viewControllerLayoutGuide type="top" id="Ydg-fD-yQy"/> | ||
14 | - <viewControllerLayoutGuide type="bottom" id="xbc-2k-c8Z"/> | ||
15 | - </layoutGuides> | ||
16 | - <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3"> | ||
17 | - <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
18 | - <subviews> | ||
19 | - <imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4"> | ||
20 | - </imageView> | ||
21 | - </subviews> | ||
22 | - <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> | ||
23 | - <constraints> | ||
24 | - <constraint firstItem="YRO-k0-Ey4" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="1a2-6s-vTC"/> | ||
25 | - <constraint firstItem="YRO-k0-Ey4" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" id="4X2-HB-R7a"/> | ||
26 | - </constraints> | ||
27 | - </view> | ||
28 | - </viewController> | ||
29 | - <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/> | ||
30 | - </objects> | ||
31 | - <point key="canvasLocation" x="53" y="375"/> | ||
32 | - </scene> | ||
33 | - </scenes> | ||
34 | - <resources> | ||
35 | - <image name="LaunchImage" width="168" height="185"/> | ||
36 | - </resources> | ||
37 | -</document> |
1 | -<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
2 | -<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r"> | ||
3 | - <dependencies> | ||
4 | - <deployment identifier="iOS"/> | ||
5 | - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/> | ||
6 | - </dependencies> | ||
7 | - <scenes> | ||
8 | - <!--Flutter View Controller--> | ||
9 | - <scene sceneID="tne-QT-ifu"> | ||
10 | - <objects> | ||
11 | - <viewController id="BYZ-38-t0r" customClass="FlutterViewController" sceneMemberID="viewController"> | ||
12 | - <layoutGuides> | ||
13 | - <viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/> | ||
14 | - <viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/> | ||
15 | - </layoutGuides> | ||
16 | - <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC"> | ||
17 | - <rect key="frame" x="0.0" y="0.0" width="600" height="600"/> | ||
18 | - <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
19 | - <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> | ||
20 | - </view> | ||
21 | - </viewController> | ||
22 | - <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/> | ||
23 | - </objects> | ||
24 | - </scene> | ||
25 | - </scenes> | ||
26 | -</document> |
1 | -// | ||
2 | -// Generated file. Do not edit. | ||
3 | -// | ||
4 | - | ||
5 | -#ifndef GeneratedPluginRegistrant_h | ||
6 | -#define GeneratedPluginRegistrant_h | ||
7 | - | ||
8 | -#import <Flutter/Flutter.h> | ||
9 | - | ||
10 | -NS_ASSUME_NONNULL_BEGIN | ||
11 | - | ||
12 | -@interface GeneratedPluginRegistrant : NSObject | ||
13 | -+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry; | ||
14 | -@end | ||
15 | - | ||
16 | -NS_ASSUME_NONNULL_END | ||
17 | -#endif /* GeneratedPluginRegistrant_h */ |
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | -<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
3 | -<plist version="1.0"> | ||
4 | -<dict> | ||
5 | - <key>CFBundleDevelopmentRegion</key> | ||
6 | - <string>en</string> | ||
7 | - <key>CFBundleExecutable</key> | ||
8 | - <string>$(EXECUTABLE_NAME)</string> | ||
9 | - <key>CFBundleIdentifier</key> | ||
10 | - <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
11 | - <key>CFBundleInfoDictionaryVersion</key> | ||
12 | - <string>6.0</string> | ||
13 | - <key>CFBundleName</key> | ||
14 | - <string>benckmark</string> | ||
15 | - <key>CFBundlePackageType</key> | ||
16 | - <string>APPL</string> | ||
17 | - <key>CFBundleShortVersionString</key> | ||
18 | - <string>1.0</string> | ||
19 | - <key>CFBundleSignature</key> | ||
20 | - <string>????</string> | ||
21 | - <key>CFBundleVersion</key> | ||
22 | - <string>1</string> | ||
23 | - <key>LSRequiresIPhoneOS</key> | ||
24 | - <true/> | ||
25 | - <key>UILaunchStoryboardName</key> | ||
26 | - <string>LaunchScreen</string> | ||
27 | - <key>UIMainStoryboardFile</key> | ||
28 | - <string>Main</string> | ||
29 | - <key>UISupportedInterfaceOrientations</key> | ||
30 | - <array> | ||
31 | - <string>UIInterfaceOrientationPortrait</string> | ||
32 | - <string>UIInterfaceOrientationLandscapeLeft</string> | ||
33 | - <string>UIInterfaceOrientationLandscapeRight</string> | ||
34 | - </array> | ||
35 | - <key>UISupportedInterfaceOrientations~ipad</key> | ||
36 | - <array> | ||
37 | - <string>UIInterfaceOrientationPortrait</string> | ||
38 | - <string>UIInterfaceOrientationPortraitUpsideDown</string> | ||
39 | - <string>UIInterfaceOrientationLandscapeLeft</string> | ||
40 | - <string>UIInterfaceOrientationLandscapeRight</string> | ||
41 | - </array> | ||
42 | - <key>UIViewControllerBasedStatusBarAppearance</key> | ||
43 | - <false/> | ||
44 | -</dict> | ||
45 | -</plist> |
1 | -#import "GeneratedPluginRegistrant.h" |
1 | -import 'dart:async'; | ||
2 | - | ||
3 | -import 'package:bloc/bloc.dart'; | ||
4 | -import 'package:benckmark/item.dart'; | ||
5 | - | ||
6 | -part 'items_event.dart'; | ||
7 | - | ||
8 | -class ItemsBloc extends Bloc<ItemsEvent, List<Item>> { | ||
9 | - ItemsBloc() { | ||
10 | - Timer.periodic(const Duration(milliseconds: 500), (timer) { | ||
11 | - add(AddItemEvent(Item(title: DateTime.now().toString()))); | ||
12 | - if (state.length == 10) { | ||
13 | - timer.cancel(); | ||
14 | - print("It's done. Print now!"); | ||
15 | - } | ||
16 | - }); | ||
17 | - } | ||
18 | - | ||
19 | - @override | ||
20 | - List<Item> get initialState => sampleItems; | ||
21 | - | ||
22 | - @override | ||
23 | - Stream<List<Item>> mapEventToState(ItemsEvent event) async* { | ||
24 | - if (event is AddItemEvent) { | ||
25 | - yield List.from(state)..add(event.item); | ||
26 | - } | ||
27 | - } | ||
28 | -} |
1 | -import 'package:flutter/material.dart'; | ||
2 | -import 'package:flutter_bloc/flutter_bloc.dart'; | ||
3 | -import 'package:benckmark/item.dart'; | ||
4 | -import 'package:benckmark/_bloc_lib/_blocs/items/items_bloc.dart'; | ||
5 | - | ||
6 | -class App extends StatelessWidget { | ||
7 | - Widget build(BuildContext context) { | ||
8 | - return MaterialApp( | ||
9 | - title: 'BLoC Lib Sample', | ||
10 | - theme: ThemeData(primarySwatch: Colors.blue), | ||
11 | - home: BlocProvider( | ||
12 | - create: (_) => ItemsBloc(), | ||
13 | - child: Page(title: 'BLoC Lib Sample'), | ||
14 | - ), | ||
15 | - ); | ||
16 | - } | ||
17 | -} | ||
18 | - | ||
19 | -class Page extends StatelessWidget { | ||
20 | - const Page({Key key, this.title}) : super(key: key); | ||
21 | - | ||
22 | - final String title; | ||
23 | - | ||
24 | - @override | ||
25 | - Widget build(BuildContext context) { | ||
26 | - return Scaffold( | ||
27 | - appBar: AppBar(title: Text(title)), | ||
28 | - body: BlocBuilder<ItemsBloc, List<Item>>( | ||
29 | - builder: (context, items) { | ||
30 | - return ListView.builder( | ||
31 | - padding: EdgeInsets.fromLTRB(0.0, 8.0, 0.0, 8.0), | ||
32 | - itemCount: items.length, | ||
33 | - itemBuilder: (context, index) { | ||
34 | - return ListTile(title: Text(items[index].title)); | ||
35 | - }, | ||
36 | - ); | ||
37 | - }, | ||
38 | - ), | ||
39 | - ); | ||
40 | - } | ||
41 | -} |
1 | -import 'dart:async'; | ||
2 | - | ||
3 | -import 'package:benckmark/item.dart'; | ||
4 | -import 'package:rxdart/rxdart.dart'; | ||
5 | - | ||
6 | -class AddItemEvent { | ||
7 | - final Item item; | ||
8 | - | ||
9 | - AddItemEvent(this.item); | ||
10 | -} | ||
11 | - | ||
12 | -class ItemsBloc { | ||
13 | - final StreamController<dynamic> _itemsEventController = StreamController(); | ||
14 | - | ||
15 | - StreamSink<dynamic> get _itemsEventSink => _itemsEventController.sink; | ||
16 | - | ||
17 | - final BehaviorSubject<List<Item>> _itemsStateSubject = | ||
18 | - BehaviorSubject.seeded(sampleItems); | ||
19 | - | ||
20 | - StreamSink<List<Item>> get _itemsStateSink => _itemsStateSubject.sink; | ||
21 | - | ||
22 | - ValueStream<List<Item>> get items => _itemsStateSubject.stream; | ||
23 | - | ||
24 | - List<StreamSubscription<dynamic>> _subscriptions; | ||
25 | - | ||
26 | - ItemsBloc() { | ||
27 | - _subscriptions = <StreamSubscription<dynamic>>[ | ||
28 | - _itemsEventController.stream.listen(_mapEventToState) | ||
29 | - ]; | ||
30 | - } | ||
31 | - | ||
32 | - dispose() { | ||
33 | - _subscriptions.forEach((subscription) => subscription.cancel()); | ||
34 | - _itemsStateSubject.close(); | ||
35 | - _itemsEventController.close(); | ||
36 | - } | ||
37 | - | ||
38 | - void addItem(Item item) { | ||
39 | - _itemsEventSink.add(AddItemEvent(item)); | ||
40 | - } | ||
41 | - | ||
42 | - void _mapEventToState(dynamic event) { | ||
43 | - if (event is AddItemEvent) { | ||
44 | - _itemsStateSink.add([...items.value, event.item]); | ||
45 | - } | ||
46 | - } | ||
47 | -} |
1 | -import 'package:flutter/widgets.dart'; | ||
2 | - | ||
3 | -import '_bloc.dart'; | ||
4 | - | ||
5 | -class ItemsBlocProvider extends InheritedWidget { | ||
6 | - final ItemsBloc bloc; | ||
7 | - | ||
8 | - ItemsBlocProvider({ | ||
9 | - Key key, | ||
10 | - Widget child, | ||
11 | - @required this.bloc, | ||
12 | - }) : super(key: key, child: child); | ||
13 | - | ||
14 | - @override | ||
15 | - bool updateShouldNotify(InheritedWidget oldWidget) => true; | ||
16 | - | ||
17 | - static ItemsBloc of(BuildContext context) { | ||
18 | - final provider = | ||
19 | - context.dependOnInheritedWidgetOfExactType<ItemsBlocProvider>(); | ||
20 | - | ||
21 | - return provider.bloc; | ||
22 | - } | ||
23 | -} |
1 | -import 'package:flutter/material.dart'; | ||
2 | -import 'package:flutter/scheduler.dart'; | ||
3 | -import 'package:benckmark/item.dart'; | ||
4 | - | ||
5 | -import '_bloc.dart'; | ||
6 | -import '_provider.dart'; | ||
7 | - | ||
8 | -class App extends StatelessWidget { | ||
9 | - final ItemsBloc itemsBloc = ItemsBloc(); | ||
10 | - | ||
11 | - @override | ||
12 | - Widget build(BuildContext context) { | ||
13 | - return ItemsBlocProvider( | ||
14 | - bloc: itemsBloc, | ||
15 | - child: MaterialApp( | ||
16 | - title: 'BLoC Sample', | ||
17 | - theme: ThemeData( | ||
18 | - primarySwatch: Colors.blue, | ||
19 | - ), | ||
20 | - home: Page(title: 'BLoC Sample'), | ||
21 | - ), | ||
22 | - ); | ||
23 | - } | ||
24 | -} | ||
25 | - | ||
26 | -class Page extends StatefulWidget { | ||
27 | - Page({Key key, this.title}) : super(key: key); | ||
28 | - | ||
29 | - final String title; | ||
30 | - | ||
31 | - @override | ||
32 | - _PageState createState() => _PageState(); | ||
33 | -} | ||
34 | - | ||
35 | -class _PageState extends State<Page> { | ||
36 | - @override | ||
37 | - void initState() { | ||
38 | - SchedulerBinding.instance.addPostFrameCallback((timeStamp) async { | ||
39 | - for (int i = 0; i < 10; i++) { | ||
40 | - await Future.delayed(Duration(milliseconds: 500)); | ||
41 | - ItemsBlocProvider.of(context) | ||
42 | - .addItem(Item(title: DateTime.now().toString())); | ||
43 | - } | ||
44 | - print("It's done. Print now!"); | ||
45 | - }); | ||
46 | - | ||
47 | - super.initState(); | ||
48 | - } | ||
49 | - | ||
50 | - @override | ||
51 | - Widget build(BuildContext context) { | ||
52 | - return Scaffold( | ||
53 | - appBar: AppBar( | ||
54 | - title: Text(widget.title), | ||
55 | - ), | ||
56 | - body: ListViewWidget(), | ||
57 | - ); | ||
58 | - } | ||
59 | -} | ||
60 | - | ||
61 | -class ListViewWidget extends StatelessWidget { | ||
62 | - @override | ||
63 | - Widget build(BuildContext context) { | ||
64 | - final ItemsBloc itemsBloc = ItemsBlocProvider.of(context); | ||
65 | - | ||
66 | - return StreamBuilder<List<Item>>( | ||
67 | - stream: itemsBloc.items, | ||
68 | - builder: (context, snapshot) { | ||
69 | - final items = snapshot.data; | ||
70 | - return ListView.builder( | ||
71 | - padding: EdgeInsets.fromLTRB(0.0, 8.0, 0.0, 8.0), | ||
72 | - itemCount: items is List<Item> ? items.length : 0, | ||
73 | - itemBuilder: (context, index) { | ||
74 | - return ListTile( | ||
75 | - title: Text(items[index].title), | ||
76 | - ); | ||
77 | - }, | ||
78 | - ); | ||
79 | - }, | ||
80 | - ); | ||
81 | - } | ||
82 | -} |
1 | -import 'package:benckmark/item.dart'; | ||
2 | -import 'package:get/get.dart'; | ||
3 | - | ||
4 | -class Controller extends GetController { | ||
5 | - @override | ||
6 | - onInit() async { | ||
7 | - for (int i = 0; i < 10; i++) { | ||
8 | - await Future.delayed(Duration(milliseconds: 500)); | ||
9 | - addItem(Item(title: DateTime.now().toString())); | ||
10 | - } | ||
11 | - print("It's done. Print now!"); | ||
12 | - super.onInit(); | ||
13 | - } | ||
14 | - | ||
15 | - final items = List<Item>.of(sampleItems); | ||
16 | - | ||
17 | - void addItem(Item item) { | ||
18 | - items.add(item); | ||
19 | - update(); | ||
20 | - } | ||
21 | -} |
1 | -import 'package:flutter/material.dart'; | ||
2 | -import 'package:benckmark/_get/_store.dart'; | ||
3 | -import 'package:get/get.dart'; | ||
4 | - | ||
5 | -class App extends StatelessWidget { | ||
6 | - @override | ||
7 | - Widget build(BuildContext context) { | ||
8 | - return MaterialApp( | ||
9 | - title: 'Get Sample', | ||
10 | - theme: ThemeData( | ||
11 | - primarySwatch: Colors.blue, | ||
12 | - ), | ||
13 | - home: Page(title: 'Get Sample'), | ||
14 | - ); | ||
15 | - } | ||
16 | -} | ||
17 | - | ||
18 | -class Page extends StatelessWidget { | ||
19 | - Page({ | ||
20 | - Key key, | ||
21 | - this.title, | ||
22 | - }) : super(key: key); | ||
23 | - | ||
24 | - final String title; | ||
25 | - | ||
26 | - @override | ||
27 | - Widget build(BuildContext context) { | ||
28 | - return Scaffold( | ||
29 | - appBar: AppBar( | ||
30 | - title: Text(title), | ||
31 | - ), | ||
32 | - body: ListViewWidget(), | ||
33 | - ); | ||
34 | - } | ||
35 | -} | ||
36 | - | ||
37 | -class ListViewWidget extends StatelessWidget { | ||
38 | - @override | ||
39 | - Widget build(BuildContext context) { | ||
40 | - return GetBuilder<Controller>( | ||
41 | - init: Controller(), | ||
42 | - global: false, | ||
43 | - builder: (_) => ListView.builder( | ||
44 | - padding: EdgeInsets.fromLTRB(0.0, 8.0, 0.0, 8.0), | ||
45 | - itemCount: _.items.length, | ||
46 | - itemBuilder: (context, index) { | ||
47 | - return ListTile( | ||
48 | - title: Text(_.items[index].title), | ||
49 | - ); | ||
50 | - })); | ||
51 | - } | ||
52 | -} |
1 | -import 'package:benckmark/item.dart'; | ||
2 | -import 'package:get/get.dart'; | ||
3 | - | ||
4 | -class Controller extends RxController { | ||
5 | - Controller() { | ||
6 | - onInit(); | ||
7 | - } | ||
8 | - final items = sampleItems.obs; | ||
9 | - | ||
10 | - @override | ||
11 | - onInit() async { | ||
12 | - for (int i = 0; i < 10; i++) { | ||
13 | - await Future.delayed(Duration(milliseconds: 500)); | ||
14 | - addItem(Item(title: DateTime.now().toString())); | ||
15 | - } | ||
16 | - | ||
17 | - print("It's done. Print now!"); | ||
18 | - super.onInit(); | ||
19 | - } | ||
20 | - | ||
21 | - void addItem(Item item) { | ||
22 | - items.add(item); | ||
23 | - } | ||
24 | -} |
1 | -import 'package:benckmark/_get_rx/_store.dart'; | ||
2 | -import 'package:flutter/material.dart'; | ||
3 | -import 'package:get/get.dart'; | ||
4 | - | ||
5 | -class App extends StatelessWidget { | ||
6 | - @override | ||
7 | - Widget build(BuildContext context) { | ||
8 | - return MaterialApp( | ||
9 | - title: 'GetX Sample', | ||
10 | - theme: ThemeData( | ||
11 | - primarySwatch: Colors.blue, | ||
12 | - ), | ||
13 | - home: Page(title: 'GetX Sample'), | ||
14 | - ); | ||
15 | - } | ||
16 | -} | ||
17 | - | ||
18 | -class Page extends StatelessWidget { | ||
19 | - Page({ | ||
20 | - Key key, | ||
21 | - this.title, | ||
22 | - }) : super(key: key); | ||
23 | - | ||
24 | - final String title; | ||
25 | - | ||
26 | - @override | ||
27 | - Widget build(BuildContext context) { | ||
28 | - return Scaffold( | ||
29 | - appBar: AppBar( | ||
30 | - title: Text("GetX"), | ||
31 | - ), | ||
32 | - body: ListViewWidget(), | ||
33 | - ); | ||
34 | - } | ||
35 | -} | ||
36 | - | ||
37 | -class ListViewWidget extends StatelessWidget { | ||
38 | - final Controller c = Controller(); | ||
39 | - @override | ||
40 | - Widget build(BuildContext context) { | ||
41 | - return Obxx(() => ListView.builder( | ||
42 | - padding: EdgeInsets.fromLTRB(0.0, 8.0, 0.0, 8.0), | ||
43 | - itemCount: c.items.length, | ||
44 | - itemBuilder: (context, index) { | ||
45 | - return ListTile( | ||
46 | - title: Text(c.items[index].title), | ||
47 | - ); | ||
48 | - })); | ||
49 | - } | ||
50 | -} |
1 | -import 'package:benckmark/item.dart'; | ||
2 | -import 'package:mobx/mobx.dart'; | ||
3 | - | ||
4 | -part '_store.g.dart'; | ||
5 | - | ||
6 | -class AppStore = _AppStore with _$AppStore; | ||
7 | - | ||
8 | -abstract class _AppStore with Store { | ||
9 | - @observable | ||
10 | - ObservableList<Item> items = ObservableList<Item>.of(sampleItems); | ||
11 | - | ||
12 | - @observable | ||
13 | - ObservableSet<String> checkedItemIds = ObservableSet<String>(); | ||
14 | - | ||
15 | - @action | ||
16 | - void addItem(Item item) { | ||
17 | - items.add(item); | ||
18 | - } | ||
19 | -} |
1 | -// GENERATED CODE - DO NOT MODIFY BY HAND | ||
2 | - | ||
3 | -part of '_store.dart'; | ||
4 | - | ||
5 | -// ************************************************************************** | ||
6 | -// StoreGenerator | ||
7 | -// ************************************************************************** | ||
8 | - | ||
9 | -// ignore_for_file: non_constant_identifier_names, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic | ||
10 | - | ||
11 | -mixin _$AppStore on _AppStore, Store { | ||
12 | - final _$itemsAtom = Atom(name: '_AppStore.items'); | ||
13 | - | ||
14 | - @override | ||
15 | - ObservableList<Item> get items { | ||
16 | - _$itemsAtom.context.enforceReadPolicy(_$itemsAtom); | ||
17 | - _$itemsAtom.reportObserved(); | ||
18 | - return super.items; | ||
19 | - } | ||
20 | - | ||
21 | - @override | ||
22 | - set items(ObservableList<Item> value) { | ||
23 | - _$itemsAtom.context.conditionallyRunInAction(() { | ||
24 | - super.items = value; | ||
25 | - _$itemsAtom.reportChanged(); | ||
26 | - }, _$itemsAtom, name: '${_$itemsAtom.name}_set'); | ||
27 | - } | ||
28 | - | ||
29 | - final _$checkedItemIdsAtom = Atom(name: '_AppStore.checkedItemIds'); | ||
30 | - | ||
31 | - @override | ||
32 | - ObservableSet<String> get checkedItemIds { | ||
33 | - _$checkedItemIdsAtom.context.enforceReadPolicy(_$checkedItemIdsAtom); | ||
34 | - _$checkedItemIdsAtom.reportObserved(); | ||
35 | - return super.checkedItemIds; | ||
36 | - } | ||
37 | - | ||
38 | - @override | ||
39 | - set checkedItemIds(ObservableSet<String> value) { | ||
40 | - _$checkedItemIdsAtom.context.conditionallyRunInAction(() { | ||
41 | - super.checkedItemIds = value; | ||
42 | - _$checkedItemIdsAtom.reportChanged(); | ||
43 | - }, _$checkedItemIdsAtom, name: '${_$checkedItemIdsAtom.name}_set'); | ||
44 | - } | ||
45 | - | ||
46 | - final _$_AppStoreActionController = ActionController(name: '_AppStore'); | ||
47 | - | ||
48 | - @override | ||
49 | - void addItem(Item item) { | ||
50 | - final _$actionInfo = _$_AppStoreActionController.startAction(); | ||
51 | - try { | ||
52 | - return super.addItem(item); | ||
53 | - } finally { | ||
54 | - _$_AppStoreActionController.endAction(_$actionInfo); | ||
55 | - } | ||
56 | - } | ||
57 | -} |
1 | -import 'package:flutter/material.dart'; | ||
2 | -import 'package:flutter_mobx/flutter_mobx.dart'; | ||
3 | -import 'package:benckmark/_mobx/_store.dart'; | ||
4 | -import 'package:benckmark/item.dart'; | ||
5 | - | ||
6 | -final store = AppStore(); | ||
7 | - | ||
8 | -class App extends StatelessWidget { | ||
9 | - @override | ||
10 | - Widget build(BuildContext context) { | ||
11 | - return MaterialApp( | ||
12 | - title: 'MobX Sample', | ||
13 | - theme: ThemeData( | ||
14 | - primarySwatch: Colors.blue, | ||
15 | - ), | ||
16 | - home: Page(title: 'MobX Sample'), | ||
17 | - ); | ||
18 | - } | ||
19 | -} | ||
20 | - | ||
21 | -class Page extends StatefulWidget { | ||
22 | - Page({ | ||
23 | - Key key, | ||
24 | - this.title, | ||
25 | - }) : super(key: key); | ||
26 | - | ||
27 | - final String title; | ||
28 | - | ||
29 | - @override | ||
30 | - _PageState createState() => _PageState(); | ||
31 | -} | ||
32 | - | ||
33 | -class _PageState extends State<Page> { | ||
34 | - @override | ||
35 | - void initState() { | ||
36 | - fill(); | ||
37 | - super.initState(); | ||
38 | - } | ||
39 | - | ||
40 | - fill() async { | ||
41 | - for (int i = 0; i < 10; i++) { | ||
42 | - await Future.delayed(Duration(milliseconds: 500)); | ||
43 | - store.addItem(Item(title: DateTime.now().toString())); | ||
44 | - } | ||
45 | - print("It's done. Print now!"); | ||
46 | - } | ||
47 | - | ||
48 | - @override | ||
49 | - Widget build(BuildContext context) { | ||
50 | - return Scaffold( | ||
51 | - appBar: AppBar( | ||
52 | - title: Text(widget.title), | ||
53 | - ), | ||
54 | - body: ListViewWidget(), | ||
55 | - ); | ||
56 | - } | ||
57 | -} | ||
58 | - | ||
59 | -class ListViewWidget extends StatelessWidget { | ||
60 | - @override | ||
61 | - Widget build(BuildContext context) { | ||
62 | - return Observer( | ||
63 | - builder: (_) { | ||
64 | - return ListView.builder( | ||
65 | - padding: EdgeInsets.fromLTRB(0.0, 8.0, 0.0, 8.0), | ||
66 | - itemCount: store.items.length, | ||
67 | - itemBuilder: (context, index) { | ||
68 | - return ListTile( | ||
69 | - title: Text(store.items[index].title), | ||
70 | - ); | ||
71 | - }, | ||
72 | - ); | ||
73 | - }, | ||
74 | - ); | ||
75 | - } | ||
76 | -} |
1 | -import 'package:flutter/foundation.dart'; | ||
2 | -import 'package:benckmark/item.dart'; | ||
3 | -import 'package:flutter/scheduler.dart'; | ||
4 | - | ||
5 | -class AppState with ChangeNotifier { | ||
6 | - AppState() { | ||
7 | - SchedulerBinding.instance.addPostFrameCallback((timeStamp) async { | ||
8 | - for (int i = 0; i < 10; i++) { | ||
9 | - await Future.delayed(Duration(milliseconds: 500)); | ||
10 | - addItem(Item(title: DateTime.now().toString())); | ||
11 | - } | ||
12 | - print("It's done. Print now!"); | ||
13 | - }); | ||
14 | - } | ||
15 | - | ||
16 | - List<Item> _items = sampleItems; | ||
17 | - | ||
18 | - List<Item> get items => _items; | ||
19 | - | ||
20 | - void addItem(Item item) { | ||
21 | - _items.add(item); | ||
22 | - | ||
23 | - notifyListeners(); | ||
24 | - } | ||
25 | -} |
1 | -import 'package:flutter/material.dart'; | ||
2 | -import 'package:provider/provider.dart'; | ||
3 | - | ||
4 | -import '_state.dart'; | ||
5 | - | ||
6 | -class App extends StatelessWidget { | ||
7 | - @override | ||
8 | - Widget build(BuildContext context) { | ||
9 | - return ChangeNotifierProvider( | ||
10 | - create: (context) => AppState(), | ||
11 | - child: MaterialApp( | ||
12 | - title: 'Provider Sample', | ||
13 | - theme: ThemeData( | ||
14 | - primarySwatch: Colors.blue, | ||
15 | - ), | ||
16 | - home: Page(title: 'Provider Sample'), | ||
17 | - ), | ||
18 | - ); | ||
19 | - } | ||
20 | -} | ||
21 | - | ||
22 | -class Page extends StatelessWidget { | ||
23 | - Page({ | ||
24 | - Key key, | ||
25 | - this.title, | ||
26 | - }) : super(key: key); | ||
27 | - | ||
28 | - final String title; | ||
29 | - | ||
30 | - @override | ||
31 | - Widget build(BuildContext context) { | ||
32 | - return Scaffold( | ||
33 | - appBar: AppBar( | ||
34 | - title: Text(title), | ||
35 | - ), | ||
36 | - body: ListViewWidget(), | ||
37 | - ); | ||
38 | - } | ||
39 | -} | ||
40 | - | ||
41 | -class ListViewWidget extends StatelessWidget { | ||
42 | - @override | ||
43 | - Widget build(BuildContext context) { | ||
44 | - final state = context.watch<AppState>(); | ||
45 | - | ||
46 | - return ListView.builder( | ||
47 | - padding: EdgeInsets.fromLTRB(0.0, 8.0, 0.0, 8.0), | ||
48 | - itemCount: state.items.length, | ||
49 | - itemBuilder: (context, index) { | ||
50 | - return ListTile( | ||
51 | - title: Text(state.items[index].title), | ||
52 | - ); | ||
53 | - }, | ||
54 | - ); | ||
55 | - } | ||
56 | -} |
1 | -import 'package:benckmark/item.dart'; | ||
2 | -import 'package:meta/meta.dart'; | ||
3 | - | ||
4 | -@immutable | ||
5 | -class AppState { | ||
6 | - final List<Item> items; | ||
7 | - | ||
8 | - AppState({ | ||
9 | - this.items, | ||
10 | - }); | ||
11 | - | ||
12 | - AppState.initialState() : items = sampleItems; | ||
13 | -} | ||
14 | - | ||
15 | -class AddItemAction { | ||
16 | - Item payload; | ||
17 | - | ||
18 | - AddItemAction({ | ||
19 | - this.payload, | ||
20 | - }); | ||
21 | -} | ||
22 | - | ||
23 | -AppState appReducer(AppState state, dynamic action) { | ||
24 | - return AppState(items: itemsReducer(state.items, action)); | ||
25 | -} | ||
26 | - | ||
27 | -List<Item> itemsReducer(List<Item> state, dynamic action) { | ||
28 | - if (action is AddItemAction) { | ||
29 | - return [...state, action.payload]; | ||
30 | - } | ||
31 | - | ||
32 | - return state; | ||
33 | -} |
1 | -import 'package:flutter/material.dart'; | ||
2 | -import 'package:flutter_redux/flutter_redux.dart'; | ||
3 | -import 'package:benckmark/item.dart'; | ||
4 | -import 'package:redux/redux.dart'; | ||
5 | -import '_store.dart'; | ||
6 | - | ||
7 | -final store = | ||
8 | - Store<AppState>(appReducer, initialState: AppState.initialState()); | ||
9 | - | ||
10 | -class App extends StatelessWidget { | ||
11 | - @override | ||
12 | - Widget build(BuildContext context) { | ||
13 | - return StoreProvider<AppState>( | ||
14 | - store: store, | ||
15 | - child: MaterialApp( | ||
16 | - title: 'Redux Sample', | ||
17 | - theme: ThemeData( | ||
18 | - primarySwatch: Colors.blue, | ||
19 | - ), | ||
20 | - home: Page(title: 'Redux Sample'), | ||
21 | - ), | ||
22 | - ); | ||
23 | - } | ||
24 | -} | ||
25 | - | ||
26 | -class Page extends StatefulWidget { | ||
27 | - Page({ | ||
28 | - Key key, | ||
29 | - this.title, | ||
30 | - }) : super(key: key); | ||
31 | - | ||
32 | - final String title; | ||
33 | - | ||
34 | - @override | ||
35 | - _PageState createState() => _PageState(); | ||
36 | -} | ||
37 | - | ||
38 | -class _PageState extends State<Page> { | ||
39 | - @override | ||
40 | - void initState() { | ||
41 | - super.initState(); | ||
42 | - fill(); | ||
43 | - } | ||
44 | - | ||
45 | - fill() async { | ||
46 | - for (int i = 0; i < 10; i++) { | ||
47 | - await Future.delayed(Duration(milliseconds: 500)); | ||
48 | - store.dispatch( | ||
49 | - AddItemAction(payload: Item(title: DateTime.now().toString()))); | ||
50 | - } | ||
51 | - print("It's done. Print now!"); | ||
52 | - } | ||
53 | - | ||
54 | - @override | ||
55 | - Widget build(BuildContext context) { | ||
56 | - return Scaffold( | ||
57 | - appBar: AppBar( | ||
58 | - title: Text(widget.title), | ||
59 | - ), | ||
60 | - body: ListViewWidget(), | ||
61 | - ); | ||
62 | - } | ||
63 | -} | ||
64 | - | ||
65 | -class ListViewWidget extends StatelessWidget { | ||
66 | - @override | ||
67 | - Widget build(BuildContext context) { | ||
68 | - return StoreConnector<AppState, List<Item>>( | ||
69 | - converter: (store) => store.state.items, | ||
70 | - builder: (context, items) { | ||
71 | - return ListView.builder( | ||
72 | - padding: EdgeInsets.fromLTRB(0.0, 8.0, 0.0, 8.0), | ||
73 | - itemCount: items.length, | ||
74 | - itemBuilder: (context, index) { | ||
75 | - return ListTile( | ||
76 | - title: Text(items[index].title), | ||
77 | - ); | ||
78 | - }, | ||
79 | - ); | ||
80 | - }, | ||
81 | - ); | ||
82 | - } | ||
83 | -} |
1 | -import 'package:flutter/widgets.dart'; | ||
2 | - | ||
3 | -//import 'package:benckmark/_bloc_plain/app.dart'; | ||
4 | -//import 'package:benckmark/_bloc_lib/app.dart'; | ||
5 | -//import 'package:benckmark/_mobx/app.dart'; | ||
6 | -//import 'package:benckmark/_redux/app.dart'; | ||
7 | -//import 'package:benckmark/_get_rx/app.dart'; | ||
8 | - | ||
9 | -//import 'package:benckmark/_provider/app.dart'; | ||
10 | -import 'package:benckmark/_get/app.dart'; | ||
11 | - | ||
12 | -void main() => runApp(App()); |
1 | -# Generated by pub | ||
2 | -# See https://dart.dev/tools/pub/glossary#lockfile | ||
3 | -packages: | ||
4 | - _fe_analyzer_shared: | ||
5 | - dependency: transitive | ||
6 | - description: | ||
7 | - name: _fe_analyzer_shared | ||
8 | - url: "https://pub.dartlang.org" | ||
9 | - source: hosted | ||
10 | - version: "4.0.0" | ||
11 | - analyzer: | ||
12 | - dependency: transitive | ||
13 | - description: | ||
14 | - name: analyzer | ||
15 | - url: "https://pub.dartlang.org" | ||
16 | - source: hosted | ||
17 | - version: "0.39.10" | ||
18 | - args: | ||
19 | - dependency: transitive | ||
20 | - description: | ||
21 | - name: args | ||
22 | - url: "https://pub.dartlang.org" | ||
23 | - source: hosted | ||
24 | - version: "1.6.0" | ||
25 | - async: | ||
26 | - dependency: transitive | ||
27 | - description: | ||
28 | - name: async | ||
29 | - url: "https://pub.dartlang.org" | ||
30 | - source: hosted | ||
31 | - version: "2.5.0-nullsafety" | ||
32 | - bloc: | ||
33 | - dependency: "direct main" | ||
34 | - description: | ||
35 | - name: bloc | ||
36 | - url: "https://pub.dartlang.org" | ||
37 | - source: hosted | ||
38 | - version: "4.0.0" | ||
39 | - boolean_selector: | ||
40 | - dependency: transitive | ||
41 | - description: | ||
42 | - name: boolean_selector | ||
43 | - url: "https://pub.dartlang.org" | ||
44 | - source: hosted | ||
45 | - version: "2.1.0-nullsafety" | ||
46 | - build: | ||
47 | - dependency: transitive | ||
48 | - description: | ||
49 | - name: build | ||
50 | - url: "https://pub.dartlang.org" | ||
51 | - source: hosted | ||
52 | - version: "1.3.0" | ||
53 | - build_config: | ||
54 | - dependency: transitive | ||
55 | - description: | ||
56 | - name: build_config | ||
57 | - url: "https://pub.dartlang.org" | ||
58 | - source: hosted | ||
59 | - version: "0.4.2" | ||
60 | - build_daemon: | ||
61 | - dependency: transitive | ||
62 | - description: | ||
63 | - name: build_daemon | ||
64 | - url: "https://pub.dartlang.org" | ||
65 | - source: hosted | ||
66 | - version: "2.1.4" | ||
67 | - build_resolvers: | ||
68 | - dependency: transitive | ||
69 | - description: | ||
70 | - name: build_resolvers | ||
71 | - url: "https://pub.dartlang.org" | ||
72 | - source: hosted | ||
73 | - version: "1.3.9" | ||
74 | - build_runner: | ||
75 | - dependency: "direct dev" | ||
76 | - description: | ||
77 | - name: build_runner | ||
78 | - url: "https://pub.dartlang.org" | ||
79 | - source: hosted | ||
80 | - version: "1.10.0" | ||
81 | - build_runner_core: | ||
82 | - dependency: transitive | ||
83 | - description: | ||
84 | - name: build_runner_core | ||
85 | - url: "https://pub.dartlang.org" | ||
86 | - source: hosted | ||
87 | - version: "5.2.0" | ||
88 | - built_collection: | ||
89 | - dependency: transitive | ||
90 | - description: | ||
91 | - name: built_collection | ||
92 | - url: "https://pub.dartlang.org" | ||
93 | - source: hosted | ||
94 | - version: "4.3.2" | ||
95 | - built_value: | ||
96 | - dependency: transitive | ||
97 | - description: | ||
98 | - name: built_value | ||
99 | - url: "https://pub.dartlang.org" | ||
100 | - source: hosted | ||
101 | - version: "7.1.0" | ||
102 | - characters: | ||
103 | - dependency: transitive | ||
104 | - description: | ||
105 | - name: characters | ||
106 | - url: "https://pub.dartlang.org" | ||
107 | - source: hosted | ||
108 | - version: "1.1.0-nullsafety.2" | ||
109 | - charcode: | ||
110 | - dependency: transitive | ||
111 | - description: | ||
112 | - name: charcode | ||
113 | - url: "https://pub.dartlang.org" | ||
114 | - source: hosted | ||
115 | - version: "1.2.0-nullsafety" | ||
116 | - checked_yaml: | ||
117 | - dependency: transitive | ||
118 | - description: | ||
119 | - name: checked_yaml | ||
120 | - url: "https://pub.dartlang.org" | ||
121 | - source: hosted | ||
122 | - version: "1.0.2" | ||
123 | - clock: | ||
124 | - dependency: transitive | ||
125 | - description: | ||
126 | - name: clock | ||
127 | - url: "https://pub.dartlang.org" | ||
128 | - source: hosted | ||
129 | - version: "1.1.0-nullsafety" | ||
130 | - code_builder: | ||
131 | - dependency: transitive | ||
132 | - description: | ||
133 | - name: code_builder | ||
134 | - url: "https://pub.dartlang.org" | ||
135 | - source: hosted | ||
136 | - version: "3.3.0" | ||
137 | - collection: | ||
138 | - dependency: transitive | ||
139 | - description: | ||
140 | - name: collection | ||
141 | - url: "https://pub.dartlang.org" | ||
142 | - source: hosted | ||
143 | - version: "1.15.0-nullsafety.2" | ||
144 | - convert: | ||
145 | - dependency: transitive | ||
146 | - description: | ||
147 | - name: convert | ||
148 | - url: "https://pub.dartlang.org" | ||
149 | - source: hosted | ||
150 | - version: "2.1.1" | ||
151 | - crypto: | ||
152 | - dependency: transitive | ||
153 | - description: | ||
154 | - name: crypto | ||
155 | - url: "https://pub.dartlang.org" | ||
156 | - source: hosted | ||
157 | - version: "2.1.4" | ||
158 | - csslib: | ||
159 | - dependency: transitive | ||
160 | - description: | ||
161 | - name: csslib | ||
162 | - url: "https://pub.dartlang.org" | ||
163 | - source: hosted | ||
164 | - version: "0.16.1" | ||
165 | - cupertino_icons: | ||
166 | - dependency: "direct main" | ||
167 | - description: | ||
168 | - name: cupertino_icons | ||
169 | - url: "https://pub.dartlang.org" | ||
170 | - source: hosted | ||
171 | - version: "0.1.3" | ||
172 | - dart_style: | ||
173 | - dependency: transitive | ||
174 | - description: | ||
175 | - name: dart_style | ||
176 | - url: "https://pub.dartlang.org" | ||
177 | - source: hosted | ||
178 | - version: "1.3.6" | ||
179 | - equatable: | ||
180 | - dependency: "direct main" | ||
181 | - description: | ||
182 | - name: equatable | ||
183 | - url: "https://pub.dartlang.org" | ||
184 | - source: hosted | ||
185 | - version: "1.2.0" | ||
186 | - fake_async: | ||
187 | - dependency: transitive | ||
188 | - description: | ||
189 | - name: fake_async | ||
190 | - url: "https://pub.dartlang.org" | ||
191 | - source: hosted | ||
192 | - version: "1.1.0-nullsafety" | ||
193 | - fixnum: | ||
194 | - dependency: transitive | ||
195 | - description: | ||
196 | - name: fixnum | ||
197 | - url: "https://pub.dartlang.org" | ||
198 | - source: hosted | ||
199 | - version: "0.10.11" | ||
200 | - flutter: | ||
201 | - dependency: "direct main" | ||
202 | - description: flutter | ||
203 | - source: sdk | ||
204 | - version: "0.0.0" | ||
205 | - flutter_bloc: | ||
206 | - dependency: "direct main" | ||
207 | - description: | ||
208 | - name: flutter_bloc | ||
209 | - url: "https://pub.dartlang.org" | ||
210 | - source: hosted | ||
211 | - version: "4.0.1" | ||
212 | - flutter_mobx: | ||
213 | - dependency: "direct main" | ||
214 | - description: | ||
215 | - name: flutter_mobx | ||
216 | - url: "https://pub.dartlang.org" | ||
217 | - source: hosted | ||
218 | - version: "0.3.7" | ||
219 | - flutter_redux: | ||
220 | - dependency: "direct main" | ||
221 | - description: | ||
222 | - name: flutter_redux | ||
223 | - url: "https://pub.dartlang.org" | ||
224 | - source: hosted | ||
225 | - version: "0.6.0" | ||
226 | - flutter_test: | ||
227 | - dependency: "direct dev" | ||
228 | - description: flutter | ||
229 | - source: sdk | ||
230 | - version: "0.0.0" | ||
231 | - get: | ||
232 | - dependency: "direct main" | ||
233 | - description: | ||
234 | - name: get | ||
235 | - url: "https://pub.dartlang.org" | ||
236 | - source: hosted | ||
237 | - version: "2.12.5-beta" | ||
238 | - glob: | ||
239 | - dependency: transitive | ||
240 | - description: | ||
241 | - name: glob | ||
242 | - url: "https://pub.dartlang.org" | ||
243 | - source: hosted | ||
244 | - version: "1.2.0" | ||
245 | - graphs: | ||
246 | - dependency: transitive | ||
247 | - description: | ||
248 | - name: graphs | ||
249 | - url: "https://pub.dartlang.org" | ||
250 | - source: hosted | ||
251 | - version: "0.2.0" | ||
252 | - html: | ||
253 | - dependency: transitive | ||
254 | - description: | ||
255 | - name: html | ||
256 | - url: "https://pub.dartlang.org" | ||
257 | - source: hosted | ||
258 | - version: "0.14.0+3" | ||
259 | - http_multi_server: | ||
260 | - dependency: transitive | ||
261 | - description: | ||
262 | - name: http_multi_server | ||
263 | - url: "https://pub.dartlang.org" | ||
264 | - source: hosted | ||
265 | - version: "2.2.0" | ||
266 | - http_parser: | ||
267 | - dependency: transitive | ||
268 | - description: | ||
269 | - name: http_parser | ||
270 | - url: "https://pub.dartlang.org" | ||
271 | - source: hosted | ||
272 | - version: "3.1.4" | ||
273 | - io: | ||
274 | - dependency: transitive | ||
275 | - description: | ||
276 | - name: io | ||
277 | - url: "https://pub.dartlang.org" | ||
278 | - source: hosted | ||
279 | - version: "0.3.4" | ||
280 | - js: | ||
281 | - dependency: transitive | ||
282 | - description: | ||
283 | - name: js | ||
284 | - url: "https://pub.dartlang.org" | ||
285 | - source: hosted | ||
286 | - version: "0.6.2" | ||
287 | - json_annotation: | ||
288 | - dependency: transitive | ||
289 | - description: | ||
290 | - name: json_annotation | ||
291 | - url: "https://pub.dartlang.org" | ||
292 | - source: hosted | ||
293 | - version: "3.0.1" | ||
294 | - logging: | ||
295 | - dependency: transitive | ||
296 | - description: | ||
297 | - name: logging | ||
298 | - url: "https://pub.dartlang.org" | ||
299 | - source: hosted | ||
300 | - version: "0.11.4" | ||
301 | - matcher: | ||
302 | - dependency: transitive | ||
303 | - description: | ||
304 | - name: matcher | ||
305 | - url: "https://pub.dartlang.org" | ||
306 | - source: hosted | ||
307 | - version: "0.12.10-nullsafety" | ||
308 | - meta: | ||
309 | - dependency: "direct main" | ||
310 | - description: | ||
311 | - name: meta | ||
312 | - url: "https://pub.dartlang.org" | ||
313 | - source: hosted | ||
314 | - version: "1.3.0-nullsafety.2" | ||
315 | - mime: | ||
316 | - dependency: transitive | ||
317 | - description: | ||
318 | - name: mime | ||
319 | - url: "https://pub.dartlang.org" | ||
320 | - source: hosted | ||
321 | - version: "0.9.6+3" | ||
322 | - mobx: | ||
323 | - dependency: "direct main" | ||
324 | - description: | ||
325 | - name: mobx | ||
326 | - url: "https://pub.dartlang.org" | ||
327 | - source: hosted | ||
328 | - version: "0.4.0+4" | ||
329 | - mobx_codegen: | ||
330 | - dependency: "direct dev" | ||
331 | - description: | ||
332 | - name: mobx_codegen | ||
333 | - url: "https://pub.dartlang.org" | ||
334 | - source: hosted | ||
335 | - version: "0.4.2" | ||
336 | - nested: | ||
337 | - dependency: transitive | ||
338 | - description: | ||
339 | - name: nested | ||
340 | - url: "https://pub.dartlang.org" | ||
341 | - source: hosted | ||
342 | - version: "0.0.4" | ||
343 | - node_interop: | ||
344 | - dependency: transitive | ||
345 | - description: | ||
346 | - name: node_interop | ||
347 | - url: "https://pub.dartlang.org" | ||
348 | - source: hosted | ||
349 | - version: "1.1.1" | ||
350 | - node_io: | ||
351 | - dependency: transitive | ||
352 | - description: | ||
353 | - name: node_io | ||
354 | - url: "https://pub.dartlang.org" | ||
355 | - source: hosted | ||
356 | - version: "1.1.1" | ||
357 | - package_config: | ||
358 | - dependency: transitive | ||
359 | - description: | ||
360 | - name: package_config | ||
361 | - url: "https://pub.dartlang.org" | ||
362 | - source: hosted | ||
363 | - version: "1.9.3" | ||
364 | - path: | ||
365 | - dependency: transitive | ||
366 | - description: | ||
367 | - name: path | ||
368 | - url: "https://pub.dartlang.org" | ||
369 | - source: hosted | ||
370 | - version: "1.8.0-nullsafety" | ||
371 | - pedantic: | ||
372 | - dependency: transitive | ||
373 | - description: | ||
374 | - name: pedantic | ||
375 | - url: "https://pub.dartlang.org" | ||
376 | - source: hosted | ||
377 | - version: "1.9.0" | ||
378 | - pool: | ||
379 | - dependency: transitive | ||
380 | - description: | ||
381 | - name: pool | ||
382 | - url: "https://pub.dartlang.org" | ||
383 | - source: hosted | ||
384 | - version: "1.4.0" | ||
385 | - provider: | ||
386 | - dependency: "direct main" | ||
387 | - description: | ||
388 | - name: provider | ||
389 | - url: "https://pub.dartlang.org" | ||
390 | - source: hosted | ||
391 | - version: "4.1.3" | ||
392 | - pub_semver: | ||
393 | - dependency: transitive | ||
394 | - description: | ||
395 | - name: pub_semver | ||
396 | - url: "https://pub.dartlang.org" | ||
397 | - source: hosted | ||
398 | - version: "1.4.4" | ||
399 | - pubspec_parse: | ||
400 | - dependency: transitive | ||
401 | - description: | ||
402 | - name: pubspec_parse | ||
403 | - url: "https://pub.dartlang.org" | ||
404 | - source: hosted | ||
405 | - version: "0.1.5" | ||
406 | - quiver: | ||
407 | - dependency: transitive | ||
408 | - description: | ||
409 | - name: quiver | ||
410 | - url: "https://pub.dartlang.org" | ||
411 | - source: hosted | ||
412 | - version: "2.1.3" | ||
413 | - redux: | ||
414 | - dependency: "direct main" | ||
415 | - description: | ||
416 | - name: redux | ||
417 | - url: "https://pub.dartlang.org" | ||
418 | - source: hosted | ||
419 | - version: "4.0.0" | ||
420 | - rxdart: | ||
421 | - dependency: "direct main" | ||
422 | - description: | ||
423 | - name: rxdart | ||
424 | - url: "https://pub.dartlang.org" | ||
425 | - source: hosted | ||
426 | - version: "0.23.1" | ||
427 | - shelf: | ||
428 | - dependency: transitive | ||
429 | - description: | ||
430 | - name: shelf | ||
431 | - url: "https://pub.dartlang.org" | ||
432 | - source: hosted | ||
433 | - version: "0.7.5" | ||
434 | - shelf_web_socket: | ||
435 | - dependency: transitive | ||
436 | - description: | ||
437 | - name: shelf_web_socket | ||
438 | - url: "https://pub.dartlang.org" | ||
439 | - source: hosted | ||
440 | - version: "0.2.3" | ||
441 | - sky_engine: | ||
442 | - dependency: transitive | ||
443 | - description: flutter | ||
444 | - source: sdk | ||
445 | - version: "0.0.99" | ||
446 | - source_gen: | ||
447 | - dependency: transitive | ||
448 | - description: | ||
449 | - name: source_gen | ||
450 | - url: "https://pub.dartlang.org" | ||
451 | - source: hosted | ||
452 | - version: "0.9.5" | ||
453 | - source_span: | ||
454 | - dependency: transitive | ||
455 | - description: | ||
456 | - name: source_span | ||
457 | - url: "https://pub.dartlang.org" | ||
458 | - source: hosted | ||
459 | - version: "1.8.0-nullsafety" | ||
460 | - stack_trace: | ||
461 | - dependency: transitive | ||
462 | - description: | ||
463 | - name: stack_trace | ||
464 | - url: "https://pub.dartlang.org" | ||
465 | - source: hosted | ||
466 | - version: "1.10.0-nullsafety" | ||
467 | - stream_channel: | ||
468 | - dependency: transitive | ||
469 | - description: | ||
470 | - name: stream_channel | ||
471 | - url: "https://pub.dartlang.org" | ||
472 | - source: hosted | ||
473 | - version: "2.1.0-nullsafety" | ||
474 | - stream_transform: | ||
475 | - dependency: transitive | ||
476 | - description: | ||
477 | - name: stream_transform | ||
478 | - url: "https://pub.dartlang.org" | ||
479 | - source: hosted | ||
480 | - version: "1.2.0" | ||
481 | - string_scanner: | ||
482 | - dependency: transitive | ||
483 | - description: | ||
484 | - name: string_scanner | ||
485 | - url: "https://pub.dartlang.org" | ||
486 | - source: hosted | ||
487 | - version: "1.1.0-nullsafety" | ||
488 | - term_glyph: | ||
489 | - dependency: transitive | ||
490 | - description: | ||
491 | - name: term_glyph | ||
492 | - url: "https://pub.dartlang.org" | ||
493 | - source: hosted | ||
494 | - version: "1.2.0-nullsafety" | ||
495 | - test_api: | ||
496 | - dependency: transitive | ||
497 | - description: | ||
498 | - name: test_api | ||
499 | - url: "https://pub.dartlang.org" | ||
500 | - source: hosted | ||
501 | - version: "0.2.19-nullsafety" | ||
502 | - timing: | ||
503 | - dependency: transitive | ||
504 | - description: | ||
505 | - name: timing | ||
506 | - url: "https://pub.dartlang.org" | ||
507 | - source: hosted | ||
508 | - version: "0.1.1+2" | ||
509 | - typed_data: | ||
510 | - dependency: transitive | ||
511 | - description: | ||
512 | - name: typed_data | ||
513 | - url: "https://pub.dartlang.org" | ||
514 | - source: hosted | ||
515 | - version: "1.3.0-nullsafety.2" | ||
516 | - uuid: | ||
517 | - dependency: "direct main" | ||
518 | - description: | ||
519 | - name: uuid | ||
520 | - url: "https://pub.dartlang.org" | ||
521 | - source: hosted | ||
522 | - version: "2.1.0" | ||
523 | - vector_math: | ||
524 | - dependency: transitive | ||
525 | - description: | ||
526 | - name: vector_math | ||
527 | - url: "https://pub.dartlang.org" | ||
528 | - source: hosted | ||
529 | - version: "2.1.0-nullsafety.2" | ||
530 | - watcher: | ||
531 | - dependency: transitive | ||
532 | - description: | ||
533 | - name: watcher | ||
534 | - url: "https://pub.dartlang.org" | ||
535 | - source: hosted | ||
536 | - version: "0.9.7+15" | ||
537 | - web_socket_channel: | ||
538 | - dependency: transitive | ||
539 | - description: | ||
540 | - name: web_socket_channel | ||
541 | - url: "https://pub.dartlang.org" | ||
542 | - source: hosted | ||
543 | - version: "1.1.0" | ||
544 | - yaml: | ||
545 | - dependency: transitive | ||
546 | - description: | ||
547 | - name: yaml | ||
548 | - url: "https://pub.dartlang.org" | ||
549 | - source: hosted | ||
550 | - version: "2.2.1" | ||
551 | -sdks: | ||
552 | - dart: ">=2.10.0-0.0.dev <2.10.0" | ||
553 | - flutter: ">=1.16.0" |
1 | -name: benckmark | ||
2 | -description: A new Flutter application showing different kinds of state management. | ||
3 | - | ||
4 | -dependencies: | ||
5 | - flutter: | ||
6 | - sdk: flutter | ||
7 | - cupertino_icons: ^0.1.2 | ||
8 | - get: 2.12.5-beta | ||
9 | - bloc: ^4.0.0 | ||
10 | - equatable: ^1.0.2 | ||
11 | - flutter_bloc: ^4.0.0 | ||
12 | - flutter_mobx: ^0.3.6 | ||
13 | - flutter_redux: ^0.6.0 | ||
14 | - meta: | ||
15 | - mobx: ^0.4.0+1 | ||
16 | - provider: ^4.0.1 | ||
17 | - redux: ^4.0.0 | ||
18 | - rxdart: ^0.23.1 | ||
19 | - uuid: ^2.0.4 | ||
20 | - | ||
21 | -dev_dependencies: | ||
22 | - flutter_test: | ||
23 | - sdk: flutter | ||
24 | - | ||
25 | - build_runner: ^1.7.3 | ||
26 | - mobx_codegen: ^0.4.0+1 | ||
27 | - | ||
28 | - | ||
29 | -# For information on the generic Dart part of this file, see the | ||
30 | -# following page: https://www.dartlang.org/tools/pub/pubspec | ||
31 | - | ||
32 | -# The following section is specific to Flutter. | ||
33 | -flutter: | ||
34 | - | ||
35 | - # The following line ensures that the Material Icons font is | ||
36 | - # included with your application, so that you can use the icons in | ||
37 | - # the material Icons class. | ||
38 | - uses-material-design: true | ||
39 | - | ||
40 | - # To add assets to your application, add an assets section, like this: | ||
41 | - # assets: | ||
42 | - # - images/a_dot_burr.jpeg | ||
43 | - # - images/a_dot_ham.jpeg | ||
44 | - | ||
45 | - # An image asset can refer to one or more resolution-specific "variants", see | ||
46 | - # https://flutter.io/assets-and-images/#resolution-aware. | ||
47 | - | ||
48 | - # For details regarding adding assets from package dependencies, see | ||
49 | - # https://flutter.io/assets-and-images/#from-packages | ||
50 | - | ||
51 | - # To add custom fonts to your application, add a fonts section here, | ||
52 | - # in this "flutter" section. Each entry in this list should have a | ||
53 | - # "family" key with the font family name, and a "fonts" key with a | ||
54 | - # list giving the asset and other descriptors for the font. For | ||
55 | - # example: | ||
56 | - # fonts: | ||
57 | - # - family: Schyler | ||
58 | - # fonts: | ||
59 | - # - asset: fonts/Schyler-Regular.ttf | ||
60 | - # - asset: fonts/Schyler-Italic.ttf | ||
61 | - # style: italic | ||
62 | - # - family: Trajan Pro | ||
63 | - # fonts: | ||
64 | - # - asset: fonts/TrajanPro.ttf | ||
65 | - # - asset: fonts/TrajanPro_Bold.ttf | ||
66 | - # weight: 700 | ||
67 | - # | ||
68 | - # For details regarding fonts from package dependencies, | ||
69 | - # see https://flutter.io/custom-fonts/#from-packages |

240 KB

239 KB

241 KB

238 KB

241 KB

243 KB
1 | -// This is a basic Flutter widget test. | ||
2 | -// To perform an interaction with a widget in your test, use the WidgetTester utility that Flutter | ||
3 | -// provides. For example, you can send tap and scroll gestures. You can also use WidgetTester to | ||
4 | -// find child widgets in the widget tree, read text, and verify that the values of widget properties | ||
5 | -// are correct. | ||
6 | - | ||
7 | -import 'package:flutter/material.dart'; | ||
8 | -import 'package:benckmark/_redux/app.dart'; | ||
9 | -import 'package:flutter_test/flutter_test.dart'; | ||
10 | - | ||
11 | -void main() { | ||
12 | - testWidgets('Counter increments smoke test', (WidgetTester tester) async { | ||
13 | - // Build our app and trigger a frame. | ||
14 | - await tester.pumpWidget(App()); | ||
15 | - | ||
16 | - // Verify that our counter starts at 0. | ||
17 | - expect(find.text('0'), findsOneWidget); | ||
18 | - expect(find.text('1'), findsNothing); | ||
19 | - | ||
20 | - // Tap the '+' icon and trigger a frame. | ||
21 | - await tester.tap(find.byIcon(Icons.add)); | ||
22 | - await tester.pump(); | ||
23 | - | ||
24 | - // Verify that our counter has incremented. | ||
25 | - expect(find.text('0'), findsNothing); | ||
26 | - expect(find.text('1'), findsOneWidget); | ||
27 | - }); | ||
28 | -} |
@@ -130,8 +130,8 @@ final isLogged = false.obs; | @@ -130,8 +130,8 @@ final isLogged = false.obs; | ||
130 | final count = 0.obs; | 130 | final count = 0.obs; |
131 | final balance = 0.0.obs; | 131 | final balance = 0.0.obs; |
132 | final number = 0.obs; | 132 | final number = 0.obs; |
133 | -final items = <String>[]; | ||
134 | -final myMap = <String, int>{}; | 133 | +final items = <String>[].obs; |
134 | +final myMap = <String, int>{}.obs; | ||
135 | 135 | ||
136 | // Custom classes - it can be any class, literally | 136 | // Custom classes - it can be any class, literally |
137 | final user = User().obs; | 137 | final user = User().obs; |
@@ -8,8 +8,8 @@ This project is a starting point for a Flutter application. | @@ -8,8 +8,8 @@ This project is a starting point for a Flutter application. | ||
8 | 8 | ||
9 | A few resources to get you started if this is your first Flutter project: | 9 | A few resources to get you started if this is your first Flutter project: |
10 | 10 | ||
11 | -- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) | ||
12 | -- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) | 11 | +- [Lab: Write your first Flutter app](https://flutter.dev/documentation/get-started/codelab) |
12 | +- [Cookbook: Useful Flutter samples](https://flutter.dev/documentation/cookbook) | ||
13 | 13 | ||
14 | For help getting started with Flutter, view our | 14 | For help getting started with Flutter, view our |
15 | [online documentation](https://flutter.dev/docs), which offers tutorials, | 15 | [online documentation](https://flutter.dev/docs), which offers tutorials, |
example/example.md
0 → 100644
1 | +# GetX codelab | ||
2 | + | ||
3 | +In this example you will learn the basics of GetX. You will see how much easier it is to code with this framework, and you will know what problems GetX proposes to solve. | ||
4 | + | ||
5 | +If the default Flutter application were rewritten with Getx, it would have only a few lines of code. The Getx state manager is easier than using setState. You just need to add a ".obs" at the end of your variable, and wrap the widget you want to change within a Obx(). | ||
6 | + | ||
7 | +```dart | ||
8 | +void main() => runApp(MaterialApp(home: Home())); | ||
9 | + | ||
10 | +class Home extends StatelessWidget { | ||
11 | + var count = 0.obs; | ||
12 | + @override | ||
13 | + Widget build(context) => Scaffold( | ||
14 | + appBar: AppBar(title: Text("counter")), | ||
15 | + body: Center( | ||
16 | + child: Obx(() => Text("$count")), | ||
17 | + ), | ||
18 | + floatingActionButton: FloatingActionButton( | ||
19 | + child: Icon(Icons.add), | ||
20 | + onPressed: () => count ++, | ||
21 | + )); | ||
22 | +} | ||
23 | +``` | ||
24 | +However, this simple example deals with ephemeral state management. If you need to access this data in several places in your application, you will need global state management. | ||
25 | +The most common way to do this is to separate the business logic from its visualization. I know, you've heard this concept before, and it might have been scary for you, but with Getx, it's stupidly simple. | ||
26 | +Getx provides you with a class capable of initializing data, and removing it when it is no longer needed, and its use is very simple: | ||
27 | +Just create a class by extending GetxController and insert ALL your variables and functions there. | ||
28 | + | ||
29 | +```dart | ||
30 | +class Controller extends GetxController { | ||
31 | + var count = 0; | ||
32 | + void increment() { | ||
33 | + count++; | ||
34 | + update(); | ||
35 | + } | ||
36 | +} | ||
37 | +``` | ||
38 | +Here you can choose between simple state management, or reactive state management. | ||
39 | +The simple one will update its variable on the screen whenever update() is called. It is used with a widget called "GetBuilder". | ||
40 | + | ||
41 | +```dart | ||
42 | +class Home extends StatelessWidget { | ||
43 | + final controller = Get.put(Controller()); | ||
44 | + @override | ||
45 | + Widget build(BuildContext context) { | ||
46 | + return Scaffold( | ||
47 | + appBar: AppBar(title: Text("counter")), | ||
48 | + body: Center( | ||
49 | + child: Column( | ||
50 | + mainAxisAlignment: MainAxisAlignment.center, | ||
51 | + children: [ | ||
52 | + GetBuilder<Controller>( | ||
53 | + builder: (_) => Text( | ||
54 | + 'clicks: ${controller.count}', | ||
55 | + )), | ||
56 | + RaisedButton( | ||
57 | + child: Text('Next Route'), | ||
58 | + onPressed: () { | ||
59 | + Get.to(Second()); | ||
60 | + }, | ||
61 | + ), | ||
62 | + ], | ||
63 | + ), | ||
64 | + ), | ||
65 | + floatingActionButton: FloatingActionButton( | ||
66 | + child: Icon(Icons.add), | ||
67 | + onPressed: controller.increment(), | ||
68 | + ), | ||
69 | + ); | ||
70 | + } | ||
71 | +} | ||
72 | +class Second extends StatelessWidget { | ||
73 | + final Controller ctrl = Get.find(); | ||
74 | + @override | ||
75 | + Widget build(context){ | ||
76 | + return Scaffold(body: Center(child: Text("${ctrl.count}"))); | ||
77 | + } | ||
78 | +} | ||
79 | +``` | ||
80 | +When instantiating your controller, you may have noticed that we use `Get.put(Controller())`. This is enough to make your controller available to other pages as long as it is in memory. | ||
81 | +You may have noticed that you have a new button using `Get.to(Second())`. This is enough to navigate to another page. You don't need a | ||
82 | + | ||
83 | +```dart | ||
84 | +Navigator.of(context).push(context, | ||
85 | + MaterialPageRoute(context, builder: (context){ | ||
86 | + return Second(); | ||
87 | + }, | ||
88 | +); | ||
89 | +``` | ||
90 | +all that huge code, it's reduced to a simple `Get.to(Second())`. Isn't that incredible? | ||
91 | + | ||
92 | +You may also have noticed that on the other page you simply used Get.find (), and the framework knows which controller you registered previously, and returns it effortlessly, you don't need to type the find with `Get.find<Controller>()` so that he knows what you need. | ||
93 | + | ||
94 | +However, this is simple state management. You may want to control the output of each change of state, you may want to use and manipulate streams, you may want a variable to only be changed on the screen, when it definitely changes, you may need a debounce on changing the state, and to these and other needs, Getx has powerful, intelligent, and lightweight state management that can address any need, regardless of the size of your project. And its use is even easier than the previous one. | ||
95 | + | ||
96 | +In your controller, you can remove the update method, Getx is reactive, so when a variable changes, it will automatically change on the screen. | ||
97 | +You just need to add a ".obs" in front of your variable, and that's it, it's already reactive. | ||
98 | + | ||
99 | +```dart | ||
100 | +class Controller extends GetxController { | ||
101 | + var count = 0.obs; | ||
102 | + void increment() { | ||
103 | + count++; | ||
104 | + } | ||
105 | +} | ||
106 | +``` | ||
107 | +Now you just need to change GetBuilder for GetX and that's it | ||
108 | +```dart | ||
109 | +class Home extends StatelessWidget { | ||
110 | + final controller = Get.put(Controller()); | ||
111 | + @override | ||
112 | + Widget build(BuildContext context) { | ||
113 | + return Scaffold( | ||
114 | + appBar: AppBar(title: Text("counter")), | ||
115 | + body: Center( | ||
116 | + child: Column( | ||
117 | + mainAxisAlignment: MainAxisAlignment.center, | ||
118 | + children: [ | ||
119 | + GetX<Controller>( | ||
120 | + builder: (_) => Text( | ||
121 | + 'clicks: ${controller.count}', | ||
122 | + )), | ||
123 | + RaisedButton( | ||
124 | + child: Text('Next Route'), | ||
125 | + onPressed: () { | ||
126 | + Get.to(Second()); | ||
127 | + }, | ||
128 | + ), | ||
129 | + ], | ||
130 | + ), | ||
131 | + ), | ||
132 | + floatingActionButton: FloatingActionButton( | ||
133 | + child: Icon(Icons.add), | ||
134 | + onPressed: controller.increment(), | ||
135 | + ), | ||
136 | + ); | ||
137 | + } | ||
138 | +} | ||
139 | +class Second extends StatelessWidget { | ||
140 | + final Controller ctrl = Get.find(); | ||
141 | + @override | ||
142 | + Widget build(context){ | ||
143 | + return Scaffold(body: Center(child: Text("${ctrl.count}"))); | ||
144 | + } | ||
145 | +} | ||
146 | +``` | ||
147 | + | ||
148 | +GetX is a useful widget when you want to inject the controller into the init property, or when you want to retrieve an instance of the controller within the widget itself. In other cases, you can insert your widget into an Obx, which receives a widget function. This looks much easier and clearer, just like the first example | ||
149 | + | ||
150 | +```dart | ||
151 | +class Home extends StatelessWidget { | ||
152 | + final controller = Get.put(Controller()); | ||
153 | + @override | ||
154 | + Widget build(BuildContext context) { | ||
155 | + return Scaffold( | ||
156 | + appBar: AppBar(title: Text("counter")), | ||
157 | + body: Center( | ||
158 | + child: Column( | ||
159 | + mainAxisAlignment: MainAxisAlignment.center, | ||
160 | + children: [ | ||
161 | + Obx(() => Text( | ||
162 | + 'clicks: ${controller.count}', | ||
163 | + )), | ||
164 | + RaisedButton( | ||
165 | + child: Text('Next Route'), | ||
166 | + onPressed: () { | ||
167 | + Get.to(Second()); | ||
168 | + }, | ||
169 | + ), | ||
170 | + ], | ||
171 | + ), | ||
172 | + ), | ||
173 | + floatingActionButton: FloatingActionButton( | ||
174 | + child: Icon(Icons.add), | ||
175 | + onPressed: controller.increment(), | ||
176 | + ), | ||
177 | + ); | ||
178 | + } | ||
179 | +} | ||
180 | +class Second extends StatelessWidget { | ||
181 | + final Controller ctrl = Get.find(); | ||
182 | + @override | ||
183 | + Widget build(context){ | ||
184 | + return Scaffold(body: Center(child: Text("${ctrl.count}"))); | ||
185 | + } | ||
186 | +} | ||
187 | +``` | ||
188 | +If you are a more demanding user, you must have said: BLoC separates the View from the business logic. But what about the presentation logic? Will I be obliged to attach it to the visualization? Will I be totally dependent on the context for everything I want to do? Will I have to insert a bunch of variables, TextEditingControllers in my view? If I need to hear the Scroll on my screen, do I need to insert an initState and a function into my view? If I need to trigger an action when this scroll reaches the end, do I insert it into the view, or in the bloc/changeNotifier class? Well, these are common architectural questions, and most of the time the solution to them is ugly. | ||
189 | +With Getx you have no doubts when your architecture, if you need a function, it must be on your Controller, if you need to trigger an event, it needs to be on your controller, your view is generally a StatelessWidget free from any dirt. | ||
190 | +This means that if someone has already done something you’re looking for, you can copy the controller entirely from someone else, and it will work for you, this level of standardization is what Flutter lacked, and it’s because of this that Getx has become so popular in the last few days. Flutter is amazing, and has minor one-off problems. Getx came to solve these specific problems. Flutter provides powerful APIs, and we turn them into an easy, clean, clear, and concise API for you to build applications in a fast, performance and highly scalable way. | ||
191 | +If you have already asked yourself some of these questions above, you have certainly found the solution to your problems. Getx is able to completely separate any logic, be it presentation or business, and you will only have pure widgets in your visualization layer. No variables, no functions, just widgets. This will facilitate the work of your team working with the UI, as well as your team working with your logic. They won't depend on initState to do anything, their controller has onInit. Your code can be tested in isolation, the way it is. | ||
192 | +But what about dependency injection? Will I have it attached to my visualization? | ||
193 | +If you've used any state manager, you've probably heard of "multiAnything", or something like that. | ||
194 | +You have probably already inserted dozens of ChangeNotifier or Blocs classes in a widget, just to have it all over the tree. | ||
195 | +This level of coupling is yet another problem that Getx came to solve. For this, in this ecosystem we use BINDINGS. | ||
196 | +Bindings are dependency injection classes. They are completely outside your widget tree, making your code cleaner, more organized, and allowing you to access it anywhere without context. | ||
197 | +You can initialize dozens of controllers in your Bindings, when you need to know what is being injected into your view, just open the Bindings file on your page and that's it, you can clearly see what has been prepared to be initialized in your View. | ||
198 | +Bindings is the first step towards having a scalable application, you can visualize what will be injected into your page, and decouple the dependency injection from your visualization layer. | ||
199 | + | ||
200 | +To create a Binding, simply create a class and implement Bindings | ||
201 | + | ||
202 | +```dart | ||
203 | +class SampleBind extends Bindings { | ||
204 | + @override | ||
205 | + void dependencies() { | ||
206 | + Get.lazyPut<Controller>(() => Controller()); | ||
207 | + Get.lazyPut<Controller2>(() => Controller2()); | ||
208 | + Get.lazyPut<Controller3>(() => Controller3()); | ||
209 | + } | ||
210 | +} | ||
211 | +``` | ||
212 | +You can use with named routes (preferred) | ||
213 | +```dart | ||
214 | +void main() { | ||
215 | + runApp(GetMaterialApp( | ||
216 | + initialRoute: '/home', | ||
217 | + getPages: [ | ||
218 | + GetPage(name: '/home', page: () => First(), binding: SampleBind()), | ||
219 | + ], | ||
220 | + )); | ||
221 | +} | ||
222 | +``` | ||
223 | + | ||
224 | +Or unnamed | ||
225 | +```dart | ||
226 | +Get.to(Second(), binding: SampleBind()); | ||
227 | +``` | ||
228 | + | ||
229 | +There is a trick that can clear your View even more. | ||
230 | +Instead of extending StatelessWidget, you can extend GetView, which is a StatelessWidget with a "controller" property. | ||
231 | + | ||
232 | +See the example and see how clean your code can be using this approach. | ||
233 | +The standard Flutter counter has almost 100 lines, it would be summarized to: | ||
234 | + | ||
235 | +on main.dart | ||
236 | +```dart | ||
237 | +void main() { | ||
238 | + runApp(GetMaterialApp( | ||
239 | + initialRoute: '/home', | ||
240 | + getPages: [ | ||
241 | + GetPage(name: '/home', page: () => HomeView(), binding: HomeBinding()), | ||
242 | + ], | ||
243 | + )); | ||
244 | +} | ||
245 | +``` | ||
246 | +on home_bindings.dart | ||
247 | +```dart | ||
248 | +class HomeBinding implements Bindings { | ||
249 | + @override | ||
250 | + void dependencies() { | ||
251 | + Get.lazyPut(() => HomeController()); | ||
252 | + } | ||
253 | +} | ||
254 | +``` | ||
255 | + | ||
256 | +on home_controller.dart | ||
257 | +```dart | ||
258 | +class HomeController extends GetxController { | ||
259 | + var count = 0.obs; | ||
260 | + void increment() => count++; | ||
261 | +} | ||
262 | +``` | ||
263 | +on home_view.dart | ||
264 | +```dart | ||
265 | +class Home extends GetView<Controller> { | ||
266 | + @override | ||
267 | + Widget build(context) => Scaffold( | ||
268 | + appBar: AppBar(title: Text("counter")), | ||
269 | + body: Center( | ||
270 | + child: Obx(() => Text("${controller.counter}")), | ||
271 | + ), | ||
272 | + floatingActionButton: FloatingActionButton( | ||
273 | + child: Icon(Icons.add), | ||
274 | + onPressed: controller.increment, | ||
275 | + )); | ||
276 | +} | ||
277 | +``` | ||
278 | +What did you do: | ||
279 | +He built an example of the counter, (with less code than the original), decoupling its visualization, its business logic, its dependency injection, in a clean, scalable way, facilitating code maintenance and reusability. If you need an accountant on another project, or your developer friend does, you can just share the content of the controller file with him, and everything will work perfectly. | ||
280 | +As the view has only widgets, you can use a view for android, and another for iOS, taking advantage of 100% of your business logic, your view has only widgets! you can change them however you want, without affecting your application in any way. | ||
281 | + | ||
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 | + | ||
284 | +```dart | ||
285 | +import 'package:flutter/material.dart'; | ||
286 | +import 'package:get/get.dart'; | ||
287 | + | ||
288 | +void main() { | ||
289 | + runApp(GetMaterialApp( | ||
290 | + // It is not mandatory to use named routes, but dynamic urls are interesting. | ||
291 | + initialRoute: '/home', | ||
292 | + defaultTransition: Transition.native, | ||
293 | + translations: MyTranslations(), | ||
294 | + locale: Locale('pt', 'BR'), | ||
295 | + getPages: [ | ||
296 | + //Simple GetPage | ||
297 | + GetPage(name: '/home', page: () => First()), | ||
298 | + // GetPage with custom transitions and bindings | ||
299 | + GetPage( | ||
300 | + name: '/second', | ||
301 | + page: () => Second(), | ||
302 | + customTransition: SizeTransitions(), | ||
303 | + binding: SampleBind(), | ||
304 | + ), | ||
305 | + // GetPage with default transitions | ||
306 | + GetPage( | ||
307 | + name: '/third', | ||
308 | + transition: Transition.cupertino, | ||
309 | + page: () => Third(), | ||
310 | + ), | ||
311 | + ], | ||
312 | + )); | ||
313 | +} | ||
314 | + | ||
315 | +class MyTranslations extends Translations { | ||
316 | + @override | ||
317 | + Map<String, Map<String, String>> get keys => { | ||
318 | + 'en': { | ||
319 | + 'title': 'Hello World %s', | ||
320 | + }, | ||
321 | + 'en_US': { | ||
322 | + 'title': 'Hello World from US', | ||
323 | + }, | ||
324 | + 'pt': { | ||
325 | + 'title': 'Olá de Portugal', | ||
326 | + }, | ||
327 | + 'pt_BR': { | ||
328 | + 'title': 'Olá do Brasil', | ||
329 | + }, | ||
330 | + }; | ||
331 | +} | ||
332 | + | ||
333 | +class Controller extends GetxController { | ||
334 | + int count = 0; | ||
335 | + void increment() { | ||
336 | + count++; | ||
337 | + // use update method to update all count variables | ||
338 | + update(); | ||
339 | + } | ||
340 | +} | ||
341 | + | ||
342 | +class First extends StatelessWidget { | ||
343 | + @override | ||
344 | + Widget build(BuildContext context) { | ||
345 | + return Scaffold( | ||
346 | + appBar: AppBar( | ||
347 | + leading: IconButton( | ||
348 | + icon: Icon(Icons.add), | ||
349 | + onPressed: () { | ||
350 | + Get.snackbar("Hi", "I'm modern snackbar"); | ||
351 | + }, | ||
352 | + ), | ||
353 | + title: Text("title".trArgs(['John'])), | ||
354 | + ), | ||
355 | + body: Center( | ||
356 | + child: Column( | ||
357 | + mainAxisAlignment: MainAxisAlignment.center, | ||
358 | + children: [ | ||
359 | + GetBuilder<Controller>( | ||
360 | + init: Controller(), | ||
361 | + // You can initialize your controller here the first time. Don't use init in your other GetBuilders of same controller | ||
362 | + builder: (_) => Text( | ||
363 | + 'clicks: ${_.count}', | ||
364 | + )), | ||
365 | + RaisedButton( | ||
366 | + child: Text('Next Route'), | ||
367 | + onPressed: () { | ||
368 | + Get.toNamed('/second'); | ||
369 | + }, | ||
370 | + ), | ||
371 | + RaisedButton( | ||
372 | + child: Text('Change locale to English'), | ||
373 | + onPressed: () { | ||
374 | + Get.updateLocale(Locale('en', 'UK')); | ||
375 | + }, | ||
376 | + ), | ||
377 | + ], | ||
378 | + ), | ||
379 | + ), | ||
380 | + floatingActionButton: FloatingActionButton( | ||
381 | + child: Icon(Icons.add), | ||
382 | + onPressed: () { | ||
383 | + Get.find<Controller>().increment(); | ||
384 | + }), | ||
385 | + ); | ||
386 | + } | ||
387 | +} | ||
388 | + | ||
389 | +class Second extends GetView<ControllerX> { | ||
390 | + @override | ||
391 | + Widget build(BuildContext context) { | ||
392 | + return Scaffold( | ||
393 | + appBar: AppBar( | ||
394 | + title: Text('second Route'), | ||
395 | + ), | ||
396 | + body: Center( | ||
397 | + child: Column( | ||
398 | + mainAxisAlignment: MainAxisAlignment.center, | ||
399 | + 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: (_) { | ||
404 | + print("count1 rebuild"); | ||
405 | + return Text('${_.count1}'); | ||
406 | + }, | ||
407 | + ), | ||
408 | + GetX<ControllerX>( | ||
409 | + builder: (_) { | ||
410 | + print("count2 rebuild"); | ||
411 | + return Text('${controller.count2}'); | ||
412 | + }, | ||
413 | + ), | ||
414 | + GetX<ControllerX>(builder: (_) { | ||
415 | + print("sum rebuild"); | ||
416 | + return Text('${_.sum}'); | ||
417 | + }), | ||
418 | + GetX<ControllerX>( | ||
419 | + builder: (_) => Text('Name: ${controller.user.value.name}'), | ||
420 | + ), | ||
421 | + GetX<ControllerX>( | ||
422 | + builder: (_) => Text('Age: ${_.user.value.age}'), | ||
423 | + ), | ||
424 | + RaisedButton( | ||
425 | + child: Text("Go to last page"), | ||
426 | + onPressed: () { | ||
427 | + Get.toNamed('/third', arguments: 'arguments of second'); | ||
428 | + }, | ||
429 | + ), | ||
430 | + RaisedButton( | ||
431 | + child: Text("Back page and open snackbar"), | ||
432 | + onPressed: () { | ||
433 | + Get.back(); | ||
434 | + Get.snackbar( | ||
435 | + 'User 123', | ||
436 | + 'Successfully created', | ||
437 | + ); | ||
438 | + }, | ||
439 | + ), | ||
440 | + RaisedButton( | ||
441 | + child: Text("Increment"), | ||
442 | + onPressed: () { | ||
443 | + Get.find<ControllerX>().increment(); | ||
444 | + }, | ||
445 | + ), | ||
446 | + RaisedButton( | ||
447 | + child: Text("Increment"), | ||
448 | + onPressed: () { | ||
449 | + Get.find<ControllerX>().increment2(); | ||
450 | + }, | ||
451 | + ), | ||
452 | + RaisedButton( | ||
453 | + child: Text("Update name"), | ||
454 | + onPressed: () { | ||
455 | + Get.find<ControllerX>().updateUser(); | ||
456 | + }, | ||
457 | + ), | ||
458 | + RaisedButton( | ||
459 | + child: Text("Dispose worker"), | ||
460 | + onPressed: () { | ||
461 | + Get.find<ControllerX>().disposeWorker(); | ||
462 | + }, | ||
463 | + ), | ||
464 | + ], | ||
465 | + ), | ||
466 | + ), | ||
467 | + ); | ||
468 | + } | ||
469 | +} | ||
470 | + | ||
471 | +class Third extends GetView<ControllerX> { | ||
472 | + @override | ||
473 | + Widget build(BuildContext context) { | ||
474 | + return Scaffold( | ||
475 | + floatingActionButton: FloatingActionButton(onPressed: () { | ||
476 | + controller.incrementList(); | ||
477 | + }), | ||
478 | + appBar: AppBar( | ||
479 | + title: Text("Third ${Get.arguments}"), | ||
480 | + ), | ||
481 | + body: Center( | ||
482 | + child: Obx(() => ListView.builder( | ||
483 | + itemCount: controller.list.length, | ||
484 | + itemBuilder: (context, index) { | ||
485 | + return Text("${controller.list[index]}"); | ||
486 | + }))), | ||
487 | + ); | ||
488 | + } | ||
489 | +} | ||
490 | + | ||
491 | +class SampleBind extends Bindings { | ||
492 | + @override | ||
493 | + void dependencies() { | ||
494 | + Get.lazyPut<ControllerX>(() => ControllerX()); | ||
495 | + } | ||
496 | +} | ||
497 | + | ||
498 | +class User { | ||
499 | + User({this.name = 'Name', this.age = 0}); | ||
500 | + String name; | ||
501 | + int age; | ||
502 | +} | ||
503 | + | ||
504 | +class ControllerX extends GetxController { | ||
505 | + final count1 = 0.obs; | ||
506 | + final count2 = 0.obs; | ||
507 | + final list = [56].obs; | ||
508 | + final user = User().obs; | ||
509 | + | ||
510 | + updateUser() { | ||
511 | + user.update((value) { | ||
512 | + value.name = 'Jose'; | ||
513 | + value.age = 30; | ||
514 | + }); | ||
515 | + } | ||
516 | + | ||
517 | + /// Once the controller has entered memory, onInit will be called. | ||
518 | + /// It is preferable to use onInit instead of class constructors or initState method. | ||
519 | + /// Use onInit to trigger initial events like API searches, listeners registration | ||
520 | + /// or Workers registration. | ||
521 | + /// Workers are event handlers, they do not modify the final result, | ||
522 | + /// but it allows you to listen to an event and trigger customized actions. | ||
523 | + /// Here is an outline of how you can use them: | ||
524 | + | ||
525 | + /// made this if you need cancel you worker | ||
526 | + Worker _ever; | ||
527 | + | ||
528 | + @override | ||
529 | + onInit() { | ||
530 | + /// Called every time the variable $_ is changed | ||
531 | + _ever = ever(count1, (_) => print("$_ has been changed (ever)")); | ||
532 | + | ||
533 | + everAll([count1, count2], (_) => print("$_ has been changed (everAll)")); | ||
534 | + | ||
535 | + /// Called first time the variable $_ is changed | ||
536 | + once(count1, (_) => print("$_ was changed once (once)")); | ||
537 | + | ||
538 | + /// Anti DDos - Called every time the user stops typing for 1 second, for example. | ||
539 | + debounce(count1, (_) => print("debouce$_ (debounce)"), | ||
540 | + time: Duration(seconds: 1)); | ||
541 | + | ||
542 | + /// Ignore all changes within 1 second. | ||
543 | + interval(count1, (_) => print("interval $_ (interval)"), | ||
544 | + time: Duration(seconds: 1)); | ||
545 | + } | ||
546 | + | ||
547 | + int get sum => count1.value + count2.value; | ||
548 | + | ||
549 | + increment() => count1.value++; | ||
550 | + | ||
551 | + increment2() => count2.value++; | ||
552 | + | ||
553 | + disposeWorker() { | ||
554 | + _ever.dispose(); | ||
555 | + // or _ever(); | ||
556 | + } | ||
557 | + | ||
558 | + incrementList() => list.add(75); | ||
559 | +} | ||
560 | + | ||
561 | +class SizeTransitions extends CustomTransition { | ||
562 | + @override | ||
563 | + Widget buildTransition( | ||
564 | + BuildContext context, | ||
565 | + Curve curve, | ||
566 | + Alignment alignment, | ||
567 | + Animation<double> animation, | ||
568 | + Animation<double> secondaryAnimation, | ||
569 | + Widget child) { | ||
570 | + return Align( | ||
571 | + alignment: Alignment.center, | ||
572 | + child: SizeTransition( | ||
573 | + sizeFactor: CurvedAnimation( | ||
574 | + parent: animation, | ||
575 | + curve: curve, | ||
576 | + ), | ||
577 | + child: child, | ||
578 | + ), | ||
579 | + ); | ||
580 | + } | ||
581 | +} | ||
582 | +``` |
example/linux/.gitignore
0 → 100644
1 | +flutter/ephemeral |
example/linux/CMakeLists.txt
0 → 100644
1 | +cmake_minimum_required(VERSION 3.10) | ||
2 | +project(runner LANGUAGES CXX) | ||
3 | + | ||
4 | +set(BINARY_NAME "example") | ||
5 | +set(APPLICATION_ID "com.example.example") | ||
6 | + | ||
7 | +cmake_policy(SET CMP0063 NEW) | ||
8 | + | ||
9 | +set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") | ||
10 | + | ||
11 | +# Configure build options. | ||
12 | +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) | ||
13 | + set(CMAKE_BUILD_TYPE "Debug" CACHE | ||
14 | + STRING "Flutter build mode" FORCE) | ||
15 | + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS | ||
16 | + "Debug" "Profile" "Release") | ||
17 | +endif() | ||
18 | + | ||
19 | +# Compilation settings that should be applied to most targets. | ||
20 | +function(APPLY_STANDARD_SETTINGS TARGET) | ||
21 | + target_compile_features(${TARGET} PUBLIC cxx_std_14) | ||
22 | + target_compile_options(${TARGET} PRIVATE -Wall -Werror) | ||
23 | + target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>") | ||
24 | + target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>") | ||
25 | +endfunction() | ||
26 | + | ||
27 | +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") | ||
28 | + | ||
29 | +# Flutter library and tool build rules. | ||
30 | +add_subdirectory(${FLUTTER_MANAGED_DIR}) | ||
31 | + | ||
32 | +# System-level dependencies. | ||
33 | +find_package(PkgConfig REQUIRED) | ||
34 | +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) | ||
35 | + | ||
36 | +add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") | ||
37 | + | ||
38 | +# Application build | ||
39 | +add_executable(${BINARY_NAME} | ||
40 | + "main.cc" | ||
41 | + "my_application.cc" | ||
42 | + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" | ||
43 | +) | ||
44 | +apply_standard_settings(${BINARY_NAME}) | ||
45 | +target_link_libraries(${BINARY_NAME} PRIVATE flutter) | ||
46 | +target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) | ||
47 | +add_dependencies(${BINARY_NAME} flutter_assemble) | ||
48 | + | ||
49 | +# Generated plugin build rules, which manage building the plugins and adding | ||
50 | +# them to the application. | ||
51 | +include(flutter/generated_plugins.cmake) | ||
52 | + | ||
53 | + | ||
54 | +# === Installation === | ||
55 | +# By default, "installing" just makes a relocatable bundle in the build | ||
56 | +# directory. | ||
57 | +set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") | ||
58 | +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) | ||
59 | + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) | ||
60 | +endif() | ||
61 | + | ||
62 | +# Start with a clean build bundle directory every time. | ||
63 | +install(CODE " | ||
64 | + file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") | ||
65 | + " COMPONENT Runtime) | ||
66 | + | ||
67 | +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") | ||
68 | +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") | ||
69 | + | ||
70 | +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" | ||
71 | + COMPONENT Runtime) | ||
72 | + | ||
73 | +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" | ||
74 | + COMPONENT Runtime) | ||
75 | + | ||
76 | +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" | ||
77 | + COMPONENT Runtime) | ||
78 | + | ||
79 | +if(PLUGIN_BUNDLED_LIBRARIES) | ||
80 | + install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" | ||
81 | + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" | ||
82 | + COMPONENT Runtime) | ||
83 | +endif() | ||
84 | + | ||
85 | +# Fully re-copy the assets directory on each build to avoid having stale files | ||
86 | +# from a previous install. | ||
87 | +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") | ||
88 | +install(CODE " | ||
89 | + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") | ||
90 | + " COMPONENT Runtime) | ||
91 | +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" | ||
92 | + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) | ||
93 | + | ||
94 | +# Install the AOT library on non-Debug builds only. | ||
95 | +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") | ||
96 | + install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" | ||
97 | + COMPONENT Runtime) | ||
98 | +endif() |
example/linux/flutter/CMakeLists.txt
0 → 100644
1 | +cmake_minimum_required(VERSION 3.10) | ||
2 | + | ||
3 | +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") | ||
4 | + | ||
5 | +# Configuration provided via flutter tool. | ||
6 | +include(${EPHEMERAL_DIR}/generated_config.cmake) | ||
7 | + | ||
8 | +# TODO: Move the rest of this into files in ephemeral. See | ||
9 | +# https://github.com/flutter/flutter/issues/57146. | ||
10 | + | ||
11 | +# Serves the same purpose as list(TRANSFORM ... PREPEND ...), | ||
12 | +# which isn't available in 3.10. | ||
13 | +function(list_prepend LIST_NAME PREFIX) | ||
14 | + set(NEW_LIST "") | ||
15 | + foreach(element ${${LIST_NAME}}) | ||
16 | + list(APPEND NEW_LIST "${PREFIX}${element}") | ||
17 | + endforeach(element) | ||
18 | + set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) | ||
19 | +endfunction() | ||
20 | + | ||
21 | +# === Flutter Library === | ||
22 | +# System-level dependencies. | ||
23 | +find_package(PkgConfig REQUIRED) | ||
24 | +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) | ||
25 | +pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) | ||
26 | +pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) | ||
27 | +pkg_check_modules(BLKID REQUIRED IMPORTED_TARGET blkid) | ||
28 | + | ||
29 | +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") | ||
30 | + | ||
31 | +# Published to parent scope for install step. | ||
32 | +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) | ||
33 | +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) | ||
34 | +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) | ||
35 | +set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) | ||
36 | + | ||
37 | +list(APPEND FLUTTER_LIBRARY_HEADERS | ||
38 | + "fl_basic_message_channel.h" | ||
39 | + "fl_binary_codec.h" | ||
40 | + "fl_binary_messenger.h" | ||
41 | + "fl_dart_project.h" | ||
42 | + "fl_engine.h" | ||
43 | + "fl_json_message_codec.h" | ||
44 | + "fl_json_method_codec.h" | ||
45 | + "fl_message_codec.h" | ||
46 | + "fl_method_call.h" | ||
47 | + "fl_method_channel.h" | ||
48 | + "fl_method_codec.h" | ||
49 | + "fl_method_response.h" | ||
50 | + "fl_plugin_registrar.h" | ||
51 | + "fl_plugin_registry.h" | ||
52 | + "fl_standard_message_codec.h" | ||
53 | + "fl_standard_method_codec.h" | ||
54 | + "fl_string_codec.h" | ||
55 | + "fl_value.h" | ||
56 | + "fl_view.h" | ||
57 | + "flutter_linux.h" | ||
58 | +) | ||
59 | +list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") | ||
60 | +add_library(flutter INTERFACE) | ||
61 | +target_include_directories(flutter INTERFACE | ||
62 | + "${EPHEMERAL_DIR}" | ||
63 | +) | ||
64 | +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") | ||
65 | +target_link_libraries(flutter INTERFACE | ||
66 | + PkgConfig::GTK | ||
67 | + PkgConfig::GLIB | ||
68 | + PkgConfig::GIO | ||
69 | + PkgConfig::BLKID | ||
70 | +) | ||
71 | +add_dependencies(flutter flutter_assemble) | ||
72 | + | ||
73 | +# === Flutter tool backend === | ||
74 | +# _phony_ is a non-existent file to force this command to run every time, | ||
75 | +# since currently there's no way to get a full input/output list from the | ||
76 | +# flutter tool. | ||
77 | +add_custom_command( | ||
78 | + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} | ||
79 | + ${CMAKE_CURRENT_BINARY_DIR}/_phony_ | ||
80 | + COMMAND ${CMAKE_COMMAND} -E env | ||
81 | + ${FLUTTER_TOOL_ENVIRONMENT} | ||
82 | + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" | ||
83 | + linux-x64 ${CMAKE_BUILD_TYPE} | ||
84 | +) | ||
85 | +add_custom_target(flutter_assemble DEPENDS | ||
86 | + "${FLUTTER_LIBRARY}" | ||
87 | + ${FLUTTER_LIBRARY_HEADERS} | ||
88 | +) |
@@ -2,11 +2,8 @@ | @@ -2,11 +2,8 @@ | ||
2 | // Generated file. Do not edit. | 2 | // Generated file. Do not edit. |
3 | // | 3 | // |
4 | 4 | ||
5 | -#import "GeneratedPluginRegistrant.h" | 5 | +#include "generated_plugin_registrant.h" |
6 | 6 | ||
7 | -@implementation GeneratedPluginRegistrant | ||
8 | 7 | ||
9 | -+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry { | 8 | +void fl_register_plugins(FlPluginRegistry* registry) { |
10 | } | 9 | } |
11 | - | ||
12 | -@end |
1 | +// | ||
2 | +// Generated file. Do not edit. | ||
3 | +// | ||
4 | + | ||
5 | +#ifndef GENERATED_PLUGIN_REGISTRANT_ | ||
6 | +#define GENERATED_PLUGIN_REGISTRANT_ | ||
7 | + | ||
8 | +#include <flutter_linux/flutter_linux.h> | ||
9 | + | ||
10 | +// Registers Flutter plugins. | ||
11 | +void fl_register_plugins(FlPluginRegistry* registry); | ||
12 | + | ||
13 | +#endif // GENERATED_PLUGIN_REGISTRANT_ |
1 | +# | ||
2 | +# Generated file, do not edit. | ||
3 | +# | ||
4 | + | ||
5 | +list(APPEND FLUTTER_PLUGIN_LIST | ||
6 | +) | ||
7 | + | ||
8 | +set(PLUGIN_BUNDLED_LIBRARIES) | ||
9 | + | ||
10 | +foreach(plugin ${FLUTTER_PLUGIN_LIST}) | ||
11 | + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) | ||
12 | + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) | ||
13 | + list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>) | ||
14 | + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) | ||
15 | +endforeach(plugin) |
example/linux/main.cc
0 → 100644
1 | +#include "my_application.h" | ||
2 | + | ||
3 | +int main(int argc, char** argv) { | ||
4 | + // Only X11 is currently supported. | ||
5 | + // Wayland support is being developed: https://github.com/flutter/flutter/issues/57932. | ||
6 | + gdk_set_allowed_backends("x11"); | ||
7 | + | ||
8 | + g_autoptr(MyApplication) app = my_application_new(); | ||
9 | + return g_application_run(G_APPLICATION(app), argc, argv); | ||
10 | +} |
example/linux/my_application.cc
0 → 100644
1 | +#include "my_application.h" | ||
2 | + | ||
3 | +#include <flutter_linux/flutter_linux.h> | ||
4 | + | ||
5 | +#include "flutter/generated_plugin_registrant.h" | ||
6 | + | ||
7 | +struct _MyApplication { | ||
8 | + GtkApplication parent_instance; | ||
9 | +}; | ||
10 | + | ||
11 | +G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) | ||
12 | + | ||
13 | +// Implements GApplication::activate. | ||
14 | +static void my_application_activate(GApplication* application) { | ||
15 | + GtkWindow* window = | ||
16 | + GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); | ||
17 | + GtkHeaderBar *header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); | ||
18 | + gtk_widget_show(GTK_WIDGET(header_bar)); | ||
19 | + gtk_header_bar_set_title(header_bar, "example"); | ||
20 | + gtk_header_bar_set_show_close_button(header_bar, TRUE); | ||
21 | + gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); | ||
22 | + gtk_window_set_default_size(window, 1280, 720); | ||
23 | + gtk_widget_show(GTK_WIDGET(window)); | ||
24 | + | ||
25 | + g_autoptr(FlDartProject) project = fl_dart_project_new(); | ||
26 | + | ||
27 | + FlView* view = fl_view_new(project); | ||
28 | + gtk_widget_show(GTK_WIDGET(view)); | ||
29 | + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); | ||
30 | + | ||
31 | + fl_register_plugins(FL_PLUGIN_REGISTRY(view)); | ||
32 | + | ||
33 | + gtk_widget_grab_focus(GTK_WIDGET(view)); | ||
34 | +} | ||
35 | + | ||
36 | +static void my_application_class_init(MyApplicationClass* klass) { | ||
37 | + G_APPLICATION_CLASS(klass)->activate = my_application_activate; | ||
38 | +} | ||
39 | + | ||
40 | +static void my_application_init(MyApplication* self) {} | ||
41 | + | ||
42 | +MyApplication* my_application_new() { | ||
43 | + return MY_APPLICATION(g_object_new(my_application_get_type(), | ||
44 | + "application-id", APPLICATION_ID, | ||
45 | + nullptr)); | ||
46 | +} |
example/linux/my_application.h
0 → 100644
1 | +#ifndef FLUTTER_MY_APPLICATION_H_ | ||
2 | +#define FLUTTER_MY_APPLICATION_H_ | ||
3 | + | ||
4 | +#include <gtk/gtk.h> | ||
5 | + | ||
6 | +G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, | ||
7 | + GtkApplication) | ||
8 | + | ||
9 | +/** | ||
10 | + * my_application_new: | ||
11 | + * | ||
12 | + * Creates a new Flutter-based application. | ||
13 | + * | ||
14 | + * Returns: a new #MyApplication. | ||
15 | + */ | ||
16 | +MyApplication* my_application_new(); | ||
17 | + | ||
18 | +#endif // FLUTTER_MY_APPLICATION_H_ |
@@ -73,7 +73,7 @@ packages: | @@ -73,7 +73,7 @@ packages: | ||
73 | path: ".." | 73 | path: ".." |
74 | relative: true | 74 | relative: true |
75 | source: path | 75 | source: path |
76 | - version: "3.6.3" | 76 | + version: "3.7.0" |
77 | http_parser: | 77 | http_parser: |
78 | dependency: transitive | 78 | dependency: transitive |
79 | description: | 79 | description: |
@@ -88,7 +88,7 @@ class GetObserver extends NavigatorObserver { | @@ -88,7 +88,7 @@ class GetObserver extends NavigatorObserver { | ||
88 | value.route = route; | 88 | value.route = route; |
89 | value.isBack = false; | 89 | value.isBack = false; |
90 | value.removed = ''; | 90 | value.removed = ''; |
91 | - value.previous = '${previousRoute?.settings?.name}'; | 91 | + value.previous = previousRoute?.settings?.name ?? ''; |
92 | value.isSnackbar = isSnackbar; | 92 | value.isSnackbar = isSnackbar; |
93 | value.isBottomSheet = isBottomSheet; | 93 | value.isBottomSheet = isBottomSheet; |
94 | value.isDialog = isDialog; | 94 | value.isDialog = isDialog; |
@@ -119,12 +119,12 @@ class GetObserver extends NavigatorObserver { | @@ -119,12 +119,12 @@ class GetObserver extends NavigatorObserver { | ||
119 | 119 | ||
120 | _routeSend.update((value) { | 120 | _routeSend.update((value) { |
121 | if (previousRoute is PageRoute) | 121 | if (previousRoute is PageRoute) |
122 | - value.current = '${previousRoute?.settings?.name}'; | 122 | + value.current = previousRoute?.settings?.name ?? ''; |
123 | value.args = route?.settings?.arguments; | 123 | value.args = route?.settings?.arguments; |
124 | value.route = previousRoute; | 124 | value.route = previousRoute; |
125 | value.isBack = true; | 125 | value.isBack = true; |
126 | value.removed = ''; | 126 | value.removed = ''; |
127 | - value.previous = '${route?.settings?.name}'; | 127 | + value.previous = route?.settings?.name ?? ''; |
128 | value.isSnackbar = false; | 128 | value.isSnackbar = false; |
129 | value.isBottomSheet = false; | 129 | value.isBottomSheet = false; |
130 | value.isDialog = false; | 130 | value.isDialog = false; |
@@ -142,7 +142,7 @@ class GetObserver extends NavigatorObserver { | @@ -142,7 +142,7 @@ class GetObserver extends NavigatorObserver { | ||
142 | GetConfig.currentRoute = name(newRoute); | 142 | GetConfig.currentRoute = name(newRoute); |
143 | 143 | ||
144 | _routeSend.update((value) { | 144 | _routeSend.update((value) { |
145 | - if (newRoute is PageRoute) value.current = '${newRoute?.settings?.name}'; | 145 | + if (newRoute is PageRoute) value.current = newRoute?.settings?.name ?? ''; |
146 | value.args = newRoute?.settings?.arguments; | 146 | value.args = newRoute?.settings?.arguments; |
147 | value.route = newRoute; | 147 | value.route = newRoute; |
148 | value.isBack = false; | 148 | value.isBack = false; |
@@ -163,8 +163,8 @@ class GetObserver extends NavigatorObserver { | @@ -163,8 +163,8 @@ class GetObserver extends NavigatorObserver { | ||
163 | _routeSend.update((value) { | 163 | _routeSend.update((value) { |
164 | value.route = previousRoute; | 164 | value.route = previousRoute; |
165 | value.isBack = false; | 165 | value.isBack = false; |
166 | - value.removed = '${route?.settings?.name}'; | ||
167 | - value.previous = '${route?.settings?.name}'; | 166 | + value.removed = route?.settings?.name ?? ''; |
167 | + value.previous = route?.settings?.name ?? ''; | ||
168 | }); | 168 | }); |
169 | if (routing != null) routing(_routeSend); | 169 | if (routing != null) routing(_routeSend); |
170 | } | 170 | } |
@@ -30,18 +30,6 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | @@ -30,18 +30,6 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | ||
30 | StreamController<List<E>> subject = StreamController<List<E>>.broadcast(); | 30 | StreamController<List<E>> subject = StreamController<List<E>>.broadcast(); |
31 | Map<Stream<List<E>>, StreamSubscription> _subscriptions = Map(); | 31 | Map<Stream<List<E>>, StreamSubscription> _subscriptions = Map(); |
32 | 32 | ||
33 | - /// Adds [item] only if [condition] resolves to true. | ||
34 | - void addIf(condition, E item) { | ||
35 | - if (condition is Condition) condition = condition(); | ||
36 | - if (condition is bool && condition) add(item); | ||
37 | - } | ||
38 | - | ||
39 | - /// Adds all [items] only if [condition] resolves to true. | ||
40 | - void addAllIf(condition, Iterable<E> items) { | ||
41 | - if (condition is Condition) condition = condition(); | ||
42 | - if (condition is bool && condition) addAll(items); | ||
43 | - } | ||
44 | - | ||
45 | operator []=(int index, E val) { | 33 | operator []=(int index, E val) { |
46 | _list[index] = val; | 34 | _list[index] = val; |
47 | subject.add(_list); | 35 | subject.add(_list); |
@@ -64,31 +52,47 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | @@ -64,31 +52,47 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | ||
64 | subject.add(_list); | 52 | subject.add(_list); |
65 | } | 53 | } |
66 | 54 | ||
55 | + @override | ||
67 | void addAll(Iterable<E> item) { | 56 | void addAll(Iterable<E> item) { |
68 | _list.addAll(item); | 57 | _list.addAll(item); |
69 | subject.add(_list); | 58 | subject.add(_list); |
70 | } | 59 | } |
71 | 60 | ||
72 | - /// Adds only if [item] is not null. | 61 | + /// Add [item] to [List<E>] only if [item] is not null. |
73 | void addNonNull(E item) { | 62 | void addNonNull(E item) { |
74 | if (item != null) add(item); | 63 | if (item != null) add(item); |
75 | } | 64 | } |
76 | 65 | ||
77 | - /// Adds only if [item] is not null. | 66 | + /// Add [Iterable<E>] to [List<E>] only if [Iterable<E>] is not null. |
78 | void addAllNonNull(Iterable<E> item) { | 67 | void addAllNonNull(Iterable<E> item) { |
79 | if (item != null) addAll(item); | 68 | if (item != null) addAll(item); |
80 | } | 69 | } |
81 | 70 | ||
71 | + /// Add [item] to [List<E>] only if [condition] is true. | ||
72 | + void addIf(dynamic condition, E item) { | ||
73 | + if (condition is Condition) condition = condition(); | ||
74 | + if (condition is bool && condition) add(item); | ||
75 | + } | ||
76 | + | ||
77 | + /// Adds [Iterable<E>] to [List<E>] only if [condition] is true. | ||
78 | + void addAllIf(dynamic condition, Iterable<E> items) { | ||
79 | + if (condition is Condition) condition = condition(); | ||
80 | + if (condition is bool && condition) addAll(items); | ||
81 | + } | ||
82 | + | ||
83 | + @override | ||
82 | void insert(int index, E item) { | 84 | void insert(int index, E item) { |
83 | _list.insert(index, item); | 85 | _list.insert(index, item); |
84 | subject.add(_list); | 86 | subject.add(_list); |
85 | } | 87 | } |
86 | 88 | ||
89 | + @override | ||
87 | void insertAll(int index, Iterable<E> iterable) { | 90 | void insertAll(int index, Iterable<E> iterable) { |
88 | _list.insertAll(index, iterable); | 91 | _list.insertAll(index, iterable); |
89 | subject.add(_list); | 92 | subject.add(_list); |
90 | } | 93 | } |
91 | 94 | ||
95 | + @override | ||
92 | int get length => value.length; | 96 | int get length => value.length; |
93 | 97 | ||
94 | /// Removes an item from the list. | 98 | /// Removes an item from the list. |
@@ -96,6 +100,7 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | @@ -96,6 +100,7 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | ||
96 | /// This is O(N) in the number of items in the list. | 100 | /// This is O(N) in the number of items in the list. |
97 | /// | 101 | /// |
98 | /// Returns whether the item was present in the list. | 102 | /// Returns whether the item was present in the list. |
103 | + @override | ||
99 | bool remove(Object item) { | 104 | bool remove(Object item) { |
100 | bool hasRemoved = _list.remove(item); | 105 | bool hasRemoved = _list.remove(item); |
101 | if (hasRemoved) { | 106 | if (hasRemoved) { |
@@ -104,38 +109,45 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | @@ -104,38 +109,45 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | ||
104 | return hasRemoved; | 109 | return hasRemoved; |
105 | } | 110 | } |
106 | 111 | ||
112 | + @override | ||
107 | E removeAt(int index) { | 113 | E removeAt(int index) { |
108 | E item = _list.removeAt(index); | 114 | E item = _list.removeAt(index); |
109 | subject.add(_list); | 115 | subject.add(_list); |
110 | return item; | 116 | return item; |
111 | } | 117 | } |
112 | 118 | ||
119 | + @override | ||
113 | E removeLast() { | 120 | E removeLast() { |
114 | E item = _list.removeLast(); | 121 | E item = _list.removeLast(); |
115 | subject.add(_list); | 122 | subject.add(_list); |
116 | return item; | 123 | return item; |
117 | } | 124 | } |
118 | 125 | ||
126 | + @override | ||
119 | void removeRange(int start, int end) { | 127 | void removeRange(int start, int end) { |
120 | _list.removeRange(start, end); | 128 | _list.removeRange(start, end); |
121 | subject.add(_list); | 129 | subject.add(_list); |
122 | } | 130 | } |
123 | 131 | ||
132 | + @override | ||
124 | void removeWhere(bool Function(E) test) { | 133 | void removeWhere(bool Function(E) test) { |
125 | _list.removeWhere(test); | 134 | _list.removeWhere(test); |
126 | subject.add(_list); | 135 | subject.add(_list); |
127 | } | 136 | } |
128 | 137 | ||
138 | + @override | ||
129 | void clear() { | 139 | void clear() { |
130 | _list.clear(); | 140 | _list.clear(); |
131 | subject.add(_list); | 141 | subject.add(_list); |
132 | } | 142 | } |
133 | 143 | ||
144 | + @override | ||
134 | void sort([int compare(E a, E b)]) { | 145 | void sort([int compare(E a, E b)]) { |
135 | _list.sort(); | 146 | _list.sort(); |
136 | subject.add(_list); | 147 | subject.add(_list); |
137 | } | 148 | } |
138 | 149 | ||
150 | + @override | ||
139 | close() { | 151 | close() { |
140 | _subscriptions.forEach((observable, subscription) { | 152 | _subscriptions.forEach((observable, subscription) { |
141 | subscription.cancel(); | 153 | subscription.cancel(); |
@@ -196,210 +208,219 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | @@ -196,210 +208,219 @@ class RxList<E> implements List<E>, RxInterface<List<E>> { | ||
196 | stream.listen((va) => value = va); | 208 | stream.listen((va) => value = va); |
197 | 209 | ||
198 | @override | 210 | @override |
199 | - E get first => _list.first; | 211 | + E get first => value.first; |
200 | 212 | ||
201 | @override | 213 | @override |
202 | - E get last => _list.last; | 214 | + E get last => value.last; |
203 | 215 | ||
204 | @override | 216 | @override |
205 | bool any(bool Function(E) test) { | 217 | bool any(bool Function(E) test) { |
206 | - return _list.any(test); | 218 | + return value.any(test); |
207 | } | 219 | } |
208 | 220 | ||
209 | @override | 221 | @override |
210 | Map<int, E> asMap() { | 222 | Map<int, E> asMap() { |
211 | - return _list.asMap(); | 223 | + return value.asMap(); |
212 | } | 224 | } |
213 | 225 | ||
214 | @override | 226 | @override |
215 | List<R> cast<R>() { | 227 | List<R> cast<R>() { |
216 | - return _list.cast<R>(); | 228 | + return value.cast<R>(); |
217 | } | 229 | } |
218 | 230 | ||
219 | @override | 231 | @override |
220 | bool contains(Object element) { | 232 | bool contains(Object element) { |
221 | - return _list.contains(element); | 233 | + return value.contains(element); |
222 | } | 234 | } |
223 | 235 | ||
224 | @override | 236 | @override |
225 | E elementAt(int index) { | 237 | E elementAt(int index) { |
226 | - return _list.elementAt(index); | 238 | + return value.elementAt(index); |
227 | } | 239 | } |
228 | 240 | ||
229 | @override | 241 | @override |
230 | bool every(bool Function(E) test) { | 242 | bool every(bool Function(E) test) { |
231 | - return _list.every(test); | 243 | + return value.every(test); |
232 | } | 244 | } |
233 | 245 | ||
234 | @override | 246 | @override |
235 | Iterable<T> expand<T>(Iterable<T> Function(E) f) { | 247 | Iterable<T> expand<T>(Iterable<T> Function(E) f) { |
236 | - return _list.expand(f); | 248 | + return value.expand(f); |
237 | } | 249 | } |
238 | 250 | ||
239 | @override | 251 | @override |
240 | void fillRange(int start, int end, [E fillValue]) { | 252 | void fillRange(int start, int end, [E fillValue]) { |
241 | _list.fillRange(start, end, fillValue); | 253 | _list.fillRange(start, end, fillValue); |
254 | + subject.add(_list); | ||
242 | } | 255 | } |
243 | 256 | ||
244 | @override | 257 | @override |
245 | E firstWhere(bool Function(E) test, {E Function() orElse}) { | 258 | E firstWhere(bool Function(E) test, {E Function() orElse}) { |
246 | - return _list.firstWhere(test, orElse: orElse); | 259 | + return value.firstWhere(test, orElse: orElse); |
247 | } | 260 | } |
248 | 261 | ||
249 | @override | 262 | @override |
250 | T fold<T>(T initialValue, T Function(T, E) combine) { | 263 | T fold<T>(T initialValue, T Function(T, E) combine) { |
251 | - return _list.fold(initialValue, combine); | 264 | + return value.fold(initialValue, combine); |
252 | } | 265 | } |
253 | 266 | ||
254 | @override | 267 | @override |
255 | Iterable<E> followedBy(Iterable<E> other) { | 268 | Iterable<E> followedBy(Iterable<E> other) { |
256 | - return _list.followedBy(other); | 269 | + return value.followedBy(other); |
257 | } | 270 | } |
258 | 271 | ||
259 | @override | 272 | @override |
260 | void forEach(void Function(E) f) { | 273 | void forEach(void Function(E) f) { |
261 | - _list.forEach(f); | 274 | + value.forEach(f); |
262 | } | 275 | } |
263 | 276 | ||
264 | @override | 277 | @override |
265 | Iterable<E> getRange(int start, int end) { | 278 | Iterable<E> getRange(int start, int end) { |
266 | - return _list.getRange(start, end); | 279 | + return value.getRange(start, end); |
267 | } | 280 | } |
268 | 281 | ||
269 | @override | 282 | @override |
270 | int indexOf(E element, [int start = 0]) { | 283 | int indexOf(E element, [int start = 0]) { |
271 | - return _list.indexOf(element, start); | 284 | + return value.indexOf(element, start); |
272 | } | 285 | } |
273 | 286 | ||
274 | @override | 287 | @override |
275 | int indexWhere(bool Function(E) test, [int start = 0]) { | 288 | int indexWhere(bool Function(E) test, [int start = 0]) { |
276 | - return _list.indexWhere(test, start); | 289 | + return value.indexWhere(test, start); |
277 | } | 290 | } |
278 | 291 | ||
279 | @override | 292 | @override |
280 | String join([String separator = ""]) { | 293 | String join([String separator = ""]) { |
281 | - return _list.join(separator); | 294 | + return value.join(separator); |
282 | } | 295 | } |
283 | 296 | ||
284 | @override | 297 | @override |
285 | int lastIndexOf(E element, [int start]) { | 298 | int lastIndexOf(E element, [int start]) { |
286 | - return _list.lastIndexOf(element, start); | 299 | + return value.lastIndexOf(element, start); |
287 | } | 300 | } |
288 | 301 | ||
289 | @override | 302 | @override |
290 | int lastIndexWhere(bool Function(E) test, [int start]) { | 303 | int lastIndexWhere(bool Function(E) test, [int start]) { |
291 | - return _list.lastIndexWhere(test, start); | 304 | + return value.lastIndexWhere(test, start); |
292 | } | 305 | } |
293 | 306 | ||
294 | @override | 307 | @override |
295 | E lastWhere(bool Function(E) test, {E Function() orElse}) { | 308 | E lastWhere(bool Function(E) test, {E Function() orElse}) { |
296 | - return _list.lastWhere(test, orElse: orElse); | 309 | + return value.lastWhere(test, orElse: orElse); |
297 | } | 310 | } |
298 | 311 | ||
299 | @override | 312 | @override |
300 | set length(int newLength) { | 313 | set length(int newLength) { |
301 | _list.length = newLength; | 314 | _list.length = newLength; |
315 | + subject.add(_list); | ||
302 | } | 316 | } |
303 | 317 | ||
304 | @override | 318 | @override |
305 | Iterable<T> map<T>(T Function(E) f) { | 319 | Iterable<T> map<T>(T Function(E) f) { |
306 | - return _list.map(f); | 320 | + return value.map(f); |
307 | } | 321 | } |
308 | 322 | ||
309 | @override | 323 | @override |
310 | E reduce(E Function(E, E) combine) { | 324 | E reduce(E Function(E, E) combine) { |
311 | - return _list.reduce(combine); | 325 | + return value.reduce(combine); |
312 | } | 326 | } |
313 | 327 | ||
314 | @override | 328 | @override |
315 | void replaceRange(int start, int end, Iterable<E> replacement) { | 329 | void replaceRange(int start, int end, Iterable<E> replacement) { |
316 | _list.replaceRange(start, end, replacement); | 330 | _list.replaceRange(start, end, replacement); |
331 | + subject.add(_list); | ||
317 | } | 332 | } |
318 | 333 | ||
319 | @override | 334 | @override |
320 | void retainWhere(bool Function(E) test) { | 335 | void retainWhere(bool Function(E) test) { |
321 | _list.retainWhere(test); | 336 | _list.retainWhere(test); |
337 | + subject.add(_list); | ||
322 | } | 338 | } |
323 | 339 | ||
324 | @override | 340 | @override |
325 | - Iterable<E> get reversed => _list.reversed; | 341 | + Iterable<E> get reversed => value.reversed; |
326 | 342 | ||
327 | @override | 343 | @override |
328 | void setAll(int index, Iterable<E> iterable) { | 344 | void setAll(int index, Iterable<E> iterable) { |
329 | _list.setAll(index, iterable); | 345 | _list.setAll(index, iterable); |
346 | + subject.add(_list); | ||
330 | } | 347 | } |
331 | 348 | ||
332 | @override | 349 | @override |
333 | void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) { | 350 | void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) { |
334 | _list.setRange(start, end, iterable, skipCount); | 351 | _list.setRange(start, end, iterable, skipCount); |
352 | + subject.add(_list); | ||
335 | } | 353 | } |
336 | 354 | ||
337 | @override | 355 | @override |
338 | void shuffle([Random random]) { | 356 | void shuffle([Random random]) { |
339 | _list.shuffle(random); | 357 | _list.shuffle(random); |
358 | + subject.add(_list); | ||
340 | } | 359 | } |
341 | 360 | ||
342 | @override | 361 | @override |
343 | - E get single => _list.single; | 362 | + E get single => value.single; |
344 | 363 | ||
345 | @override | 364 | @override |
346 | E singleWhere(bool Function(E) test, {E Function() orElse}) { | 365 | E singleWhere(bool Function(E) test, {E Function() orElse}) { |
347 | - return _list.singleWhere(test, orElse: orElse); | 366 | + return value.singleWhere(test, orElse: orElse); |
348 | } | 367 | } |
349 | 368 | ||
350 | @override | 369 | @override |
351 | Iterable<E> skip(int count) { | 370 | Iterable<E> skip(int count) { |
352 | - return _list.skip(count); | 371 | + return value.skip(count); |
353 | } | 372 | } |
354 | 373 | ||
355 | @override | 374 | @override |
356 | Iterable<E> skipWhile(bool Function(E) test) { | 375 | Iterable<E> skipWhile(bool Function(E) test) { |
357 | - return _list.skipWhile(test); | 376 | + return value.skipWhile(test); |
358 | } | 377 | } |
359 | 378 | ||
360 | @override | 379 | @override |
361 | List<E> sublist(int start, [int end]) { | 380 | List<E> sublist(int start, [int end]) { |
362 | - return _list.sublist(start, end); | 381 | + return value.sublist(start, end); |
363 | } | 382 | } |
364 | 383 | ||
365 | @override | 384 | @override |
366 | Iterable<E> take(int count) { | 385 | Iterable<E> take(int count) { |
367 | - return _list.take(count); | 386 | + return value.take(count); |
368 | } | 387 | } |
369 | 388 | ||
370 | @override | 389 | @override |
371 | Iterable<E> takeWhile(bool Function(E) test) { | 390 | Iterable<E> takeWhile(bool Function(E) test) { |
372 | - return _list.takeWhile(test); | 391 | + return value.takeWhile(test); |
373 | } | 392 | } |
374 | 393 | ||
375 | @override | 394 | @override |
376 | List<E> toList({bool growable = true}) { | 395 | List<E> toList({bool growable = true}) { |
377 | - return _list.toList(growable: growable); | 396 | + return value.toList(growable: growable); |
378 | } | 397 | } |
379 | 398 | ||
380 | @override | 399 | @override |
381 | Set<E> toSet() { | 400 | Set<E> toSet() { |
382 | - return _list.toSet(); | 401 | + return value.toSet(); |
383 | } | 402 | } |
384 | 403 | ||
385 | @override | 404 | @override |
386 | Iterable<E> where(bool Function(E) test) { | 405 | Iterable<E> where(bool Function(E) test) { |
387 | - return _list.where(test); | 406 | + return value.where(test); |
388 | } | 407 | } |
389 | 408 | ||
390 | @override | 409 | @override |
391 | Iterable<T> whereType<T>() { | 410 | Iterable<T> whereType<T>() { |
392 | - return _list.whereType<T>(); | 411 | + return value.whereType<T>(); |
393 | } | 412 | } |
394 | 413 | ||
395 | @override | 414 | @override |
396 | set first(E value) { | 415 | set first(E value) { |
397 | _list.first = value; | 416 | _list.first = value; |
417 | + subject.add(_list); | ||
398 | } | 418 | } |
399 | 419 | ||
400 | @override | 420 | @override |
401 | set last(E value) { | 421 | set last(E value) { |
402 | _list.last = value; | 422 | _list.last = value; |
423 | + subject.add(_list); | ||
403 | } | 424 | } |
404 | } | 425 | } |
405 | 426 |
@@ -4,7 +4,7 @@ import '../../../../get.dart'; | @@ -4,7 +4,7 @@ import '../../../../get.dart'; | ||
4 | import '../rx_core/rx_interface.dart'; | 4 | import '../rx_core/rx_interface.dart'; |
5 | import '../rx_typedefs/rx_typedefs.dart'; | 5 | import '../rx_typedefs/rx_typedefs.dart'; |
6 | 6 | ||
7 | -class RxMap<K, V> extends RxInterface<Map<K, V>> implements Map<K, V> { | 7 | +class RxMap<K, V> implements RxInterface<Map<K, V>>, Map<K, V> { |
8 | RxMap([Map<K, V> initial]) { | 8 | RxMap([Map<K, V> initial]) { |
9 | _value = initial; | 9 | _value = initial; |
10 | } | 10 | } |
@@ -111,20 +111,20 @@ class RxMap<K, V> extends RxInterface<Map<K, V>> implements Map<K, V> { | @@ -111,20 +111,20 @@ class RxMap<K, V> extends RxInterface<Map<K, V>> implements Map<K, V> { | ||
111 | } | 111 | } |
112 | 112 | ||
113 | @override | 113 | @override |
114 | - Map<K2, V2> cast<K2, V2>() => _value.cast<K2, V2>(); | 114 | + Map<K2, V2> cast<K2, V2>() => value.cast<K2, V2>(); |
115 | 115 | ||
116 | @override | 116 | @override |
117 | - bool containsKey(Object key) => _value.containsKey(key); | 117 | + bool containsKey(Object key) => value.containsKey(key); |
118 | 118 | ||
119 | @override | 119 | @override |
120 | bool containsValue(Object value) => _value.containsValue(value); | 120 | bool containsValue(Object value) => _value.containsValue(value); |
121 | 121 | ||
122 | @override | 122 | @override |
123 | - Iterable<MapEntry<K, V>> get entries => _value.entries; | 123 | + Iterable<MapEntry<K, V>> get entries => value.entries; |
124 | 124 | ||
125 | @override | 125 | @override |
126 | void forEach(void Function(K, V) f) { | 126 | void forEach(void Function(K, V) f) { |
127 | - _value.forEach(f); | 127 | + value.forEach(f); |
128 | } | 128 | } |
129 | 129 | ||
130 | @override | 130 | @override |
@@ -134,7 +134,7 @@ class RxMap<K, V> extends RxInterface<Map<K, V>> implements Map<K, V> { | @@ -134,7 +134,7 @@ class RxMap<K, V> extends RxInterface<Map<K, V>> implements Map<K, V> { | ||
134 | bool get isNotEmpty => value.isNotEmpty; | 134 | bool get isNotEmpty => value.isNotEmpty; |
135 | 135 | ||
136 | @override | 136 | @override |
137 | - Iterable<K> get keys => _value.keys; | 137 | + Iterable<K> get keys => value.keys; |
138 | 138 | ||
139 | @override | 139 | @override |
140 | int get length => value.length; | 140 | int get length => value.length; |
@@ -8,10 +8,10 @@ import '../rx_typedefs/rx_typedefs.dart'; | @@ -8,10 +8,10 @@ import '../rx_typedefs/rx_typedefs.dart'; | ||
8 | 8 | ||
9 | class RxSet<E> implements Set<E>, RxInterface<Set<E>> { | 9 | class RxSet<E> implements Set<E>, RxInterface<Set<E>> { |
10 | RxSet([Set<E> initial]) { | 10 | RxSet([Set<E> initial]) { |
11 | - _list = initial; | 11 | + _set = initial; |
12 | } | 12 | } |
13 | 13 | ||
14 | - RxSet<E> _list = Set<E>(); | 14 | + RxSet<E> _set = Set<E>(); |
15 | 15 | ||
16 | @override | 16 | @override |
17 | Iterator<E> get iterator => value.iterator; | 17 | Iterator<E> get iterator => value.iterator; |
@@ -42,28 +42,28 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> { | @@ -42,28 +42,28 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> { | ||
42 | } | 42 | } |
43 | 43 | ||
44 | operator []=(int index, E val) { | 44 | operator []=(int index, E val) { |
45 | - _list[index] = val; | ||
46 | - subject.add(_list); | 45 | + _set[index] = val; |
46 | + subject.add(_set); | ||
47 | } | 47 | } |
48 | 48 | ||
49 | /// Special override to push() element(s) in a reactive way | 49 | /// Special override to push() element(s) in a reactive way |
50 | /// inside the List, | 50 | /// inside the List, |
51 | RxSet<E> operator +(Iterable<E> val) { | 51 | RxSet<E> operator +(Iterable<E> val) { |
52 | addAll(val); | 52 | addAll(val); |
53 | - subject.add(_list); | 53 | + subject.add(_set); |
54 | return this; | 54 | return this; |
55 | } | 55 | } |
56 | 56 | ||
57 | @override | 57 | @override |
58 | bool add(E value) { | 58 | bool add(E value) { |
59 | - final val = _list.add(value); | ||
60 | - subject.add(_list); | 59 | + final val = _set.add(value); |
60 | + subject.add(_set); | ||
61 | return val; | 61 | return val; |
62 | } | 62 | } |
63 | 63 | ||
64 | void addAll(Iterable<E> item) { | 64 | void addAll(Iterable<E> item) { |
65 | - _list.addAll(item); | ||
66 | - subject.add(_list); | 65 | + _set.addAll(item); |
66 | + subject.add(_set); | ||
67 | } | 67 | } |
68 | 68 | ||
69 | /// Adds only if [item] is not null. | 69 | /// Adds only if [item] is not null. |
@@ -77,13 +77,13 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> { | @@ -77,13 +77,13 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> { | ||
77 | } | 77 | } |
78 | 78 | ||
79 | void insert(int index, E item) { | 79 | void insert(int index, E item) { |
80 | - _list.insert(index, item); | ||
81 | - subject.add(_list); | 80 | + _set.insert(index, item); |
81 | + subject.add(_set); | ||
82 | } | 82 | } |
83 | 83 | ||
84 | void insertAll(int index, Iterable<E> iterable) { | 84 | void insertAll(int index, Iterable<E> iterable) { |
85 | - _list.insertAll(index, iterable); | ||
86 | - subject.add(_list); | 85 | + _set.insertAll(index, iterable); |
86 | + subject.add(_set); | ||
87 | } | 87 | } |
88 | 88 | ||
89 | int get length => value.length; | 89 | int get length => value.length; |
@@ -94,43 +94,43 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> { | @@ -94,43 +94,43 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> { | ||
94 | /// | 94 | /// |
95 | /// Returns whether the item was present in the list. | 95 | /// Returns whether the item was present in the list. |
96 | bool remove(Object item) { | 96 | bool remove(Object item) { |
97 | - bool hasRemoved = _list.remove(item); | 97 | + bool hasRemoved = _set.remove(item); |
98 | if (hasRemoved) { | 98 | if (hasRemoved) { |
99 | - subject.add(_list); | 99 | + subject.add(_set); |
100 | } | 100 | } |
101 | return hasRemoved; | 101 | return hasRemoved; |
102 | } | 102 | } |
103 | 103 | ||
104 | E removeAt(int index) { | 104 | E removeAt(int index) { |
105 | - E item = _list.removeAt(index); | ||
106 | - subject.add(_list); | 105 | + E item = _set.removeAt(index); |
106 | + subject.add(_set); | ||
107 | return item; | 107 | return item; |
108 | } | 108 | } |
109 | 109 | ||
110 | E removeLast() { | 110 | E removeLast() { |
111 | - E item = _list.removeLast(); | ||
112 | - subject.add(_list); | 111 | + E item = _set.removeLast(); |
112 | + subject.add(_set); | ||
113 | return item; | 113 | return item; |
114 | } | 114 | } |
115 | 115 | ||
116 | void removeRange(int start, int end) { | 116 | void removeRange(int start, int end) { |
117 | - _list.removeRange(start, end); | ||
118 | - subject.add(_list); | 117 | + _set.removeRange(start, end); |
118 | + subject.add(_set); | ||
119 | } | 119 | } |
120 | 120 | ||
121 | void removeWhere(bool Function(E) test) { | 121 | void removeWhere(bool Function(E) test) { |
122 | - _list.removeWhere(test); | ||
123 | - subject.add(_list); | 122 | + _set.removeWhere(test); |
123 | + subject.add(_set); | ||
124 | } | 124 | } |
125 | 125 | ||
126 | void clear() { | 126 | void clear() { |
127 | - _list.clear(); | ||
128 | - subject.add(_list); | 127 | + _set.clear(); |
128 | + subject.add(_set); | ||
129 | } | 129 | } |
130 | 130 | ||
131 | void sort([int compare(E a, E b)]) { | 131 | void sort([int compare(E a, E b)]) { |
132 | - _list.sort(); | ||
133 | - subject.add(_list); | 132 | + _set.sort(); |
133 | + subject.add(_set); | ||
134 | } | 134 | } |
135 | 135 | ||
136 | close() { | 136 | close() { |
@@ -149,7 +149,7 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> { | @@ -149,7 +149,7 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> { | ||
149 | 149 | ||
150 | void update(void fn(Iterable<E> value)) { | 150 | void update(void fn(Iterable<E> value)) { |
151 | fn(value); | 151 | fn(value); |
152 | - subject.add(_list); | 152 | + subject.add(_set); |
153 | } | 153 | } |
154 | 154 | ||
155 | /// Replaces all existing items of this list with [items] | 155 | /// Replaces all existing items of this list with [items] |
@@ -163,7 +163,7 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> { | @@ -163,7 +163,7 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> { | ||
163 | if (getObs != null) { | 163 | if (getObs != null) { |
164 | getObs.addListener(subject.stream); | 164 | getObs.addListener(subject.stream); |
165 | } | 165 | } |
166 | - return _list; | 166 | + return _set; |
167 | } | 167 | } |
168 | 168 | ||
169 | String get string => value.toString(); | 169 | String get string => value.toString(); |
@@ -178,9 +178,9 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> { | @@ -178,9 +178,9 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> { | ||
178 | } | 178 | } |
179 | 179 | ||
180 | set value(Iterable<E> val) { | 180 | set value(Iterable<E> val) { |
181 | - if (_list == val) return; | ||
182 | - _list = val; | ||
183 | - subject.add(_list); | 181 | + if (_set == val) return; |
182 | + _set = val; | ||
183 | + subject.add(_set); | ||
184 | } | 184 | } |
185 | 185 | ||
186 | Stream<Set<E>> get stream => subject.stream; | 186 | Stream<Set<E>> get stream => subject.stream; |
@@ -193,167 +193,170 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> { | @@ -193,167 +193,170 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> { | ||
193 | stream.listen((va) => value = va); | 193 | stream.listen((va) => value = va); |
194 | 194 | ||
195 | @override | 195 | @override |
196 | - E get first => _list.first; | 196 | + E get first => value.first; |
197 | 197 | ||
198 | @override | 198 | @override |
199 | - E get last => _list.last; | 199 | + E get last => value.last; |
200 | 200 | ||
201 | @override | 201 | @override |
202 | bool any(bool Function(E) test) { | 202 | bool any(bool Function(E) test) { |
203 | - return _list.any(test); | 203 | + return value.any(test); |
204 | } | 204 | } |
205 | 205 | ||
206 | @override | 206 | @override |
207 | Set<R> cast<R>() { | 207 | Set<R> cast<R>() { |
208 | - return _list.cast<R>(); | 208 | + return value.cast<R>(); |
209 | } | 209 | } |
210 | 210 | ||
211 | @override | 211 | @override |
212 | bool contains(Object element) { | 212 | bool contains(Object element) { |
213 | - return _list.contains(element); | 213 | + return value.contains(element); |
214 | } | 214 | } |
215 | 215 | ||
216 | @override | 216 | @override |
217 | E elementAt(int index) { | 217 | E elementAt(int index) { |
218 | - return _list.elementAt(index); | 218 | + return value.elementAt(index); |
219 | } | 219 | } |
220 | 220 | ||
221 | @override | 221 | @override |
222 | bool every(bool Function(E) test) { | 222 | bool every(bool Function(E) test) { |
223 | - return _list.every(test); | 223 | + return value.every(test); |
224 | } | 224 | } |
225 | 225 | ||
226 | @override | 226 | @override |
227 | Iterable<T> expand<T>(Iterable<T> Function(E) f) { | 227 | Iterable<T> expand<T>(Iterable<T> Function(E) f) { |
228 | - return _list.expand(f); | 228 | + return value.expand(f); |
229 | } | 229 | } |
230 | 230 | ||
231 | @override | 231 | @override |
232 | E firstWhere(bool Function(E) test, {E Function() orElse}) { | 232 | E firstWhere(bool Function(E) test, {E Function() orElse}) { |
233 | - return _list.firstWhere(test, orElse: orElse); | 233 | + return value.firstWhere(test, orElse: orElse); |
234 | } | 234 | } |
235 | 235 | ||
236 | @override | 236 | @override |
237 | T fold<T>(T initialValue, T Function(T, E) combine) { | 237 | T fold<T>(T initialValue, T Function(T, E) combine) { |
238 | - return _list.fold(initialValue, combine); | 238 | + return value.fold(initialValue, combine); |
239 | } | 239 | } |
240 | 240 | ||
241 | @override | 241 | @override |
242 | Iterable<E> followedBy(Iterable<E> other) { | 242 | Iterable<E> followedBy(Iterable<E> other) { |
243 | - return _list.followedBy(other); | 243 | + return value.followedBy(other); |
244 | } | 244 | } |
245 | 245 | ||
246 | @override | 246 | @override |
247 | void forEach(void Function(E) f) { | 247 | void forEach(void Function(E) f) { |
248 | - _list.forEach(f); | 248 | + value.forEach(f); |
249 | } | 249 | } |
250 | 250 | ||
251 | @override | 251 | @override |
252 | String join([String separator = ""]) { | 252 | String join([String separator = ""]) { |
253 | - return _list.join(separator); | 253 | + return value.join(separator); |
254 | } | 254 | } |
255 | 255 | ||
256 | @override | 256 | @override |
257 | E lastWhere(bool Function(E) test, {E Function() orElse}) { | 257 | E lastWhere(bool Function(E) test, {E Function() orElse}) { |
258 | - return _list.lastWhere(test, orElse: orElse); | 258 | + return value.lastWhere(test, orElse: orElse); |
259 | } | 259 | } |
260 | 260 | ||
261 | @override | 261 | @override |
262 | Iterable<T> map<T>(T Function(E) f) { | 262 | Iterable<T> map<T>(T Function(E) f) { |
263 | - return _list.map(f); | 263 | + return value.map(f); |
264 | } | 264 | } |
265 | 265 | ||
266 | @override | 266 | @override |
267 | E reduce(E Function(E, E) combine) { | 267 | E reduce(E Function(E, E) combine) { |
268 | - return _list.reduce(combine); | 268 | + return value.reduce(combine); |
269 | } | 269 | } |
270 | 270 | ||
271 | @override | 271 | @override |
272 | - E get single => _list.single; | 272 | + E get single => value.single; |
273 | 273 | ||
274 | @override | 274 | @override |
275 | E singleWhere(bool Function(E) test, {E Function() orElse}) { | 275 | E singleWhere(bool Function(E) test, {E Function() orElse}) { |
276 | - return _list.singleWhere(test, orElse: orElse); | 276 | + return value.singleWhere(test, orElse: orElse); |
277 | } | 277 | } |
278 | 278 | ||
279 | @override | 279 | @override |
280 | Iterable<E> skip(int count) { | 280 | Iterable<E> skip(int count) { |
281 | - return _list.skip(count); | 281 | + return value.skip(count); |
282 | } | 282 | } |
283 | 283 | ||
284 | @override | 284 | @override |
285 | Iterable<E> skipWhile(bool Function(E) test) { | 285 | Iterable<E> skipWhile(bool Function(E) test) { |
286 | - return _list.skipWhile(test); | 286 | + return value.skipWhile(test); |
287 | } | 287 | } |
288 | 288 | ||
289 | @override | 289 | @override |
290 | Iterable<E> take(int count) { | 290 | Iterable<E> take(int count) { |
291 | - return _list.take(count); | 291 | + return value.take(count); |
292 | } | 292 | } |
293 | 293 | ||
294 | @override | 294 | @override |
295 | Iterable<E> takeWhile(bool Function(E) test) { | 295 | Iterable<E> takeWhile(bool Function(E) test) { |
296 | - return _list.takeWhile(test); | 296 | + return value.takeWhile(test); |
297 | } | 297 | } |
298 | 298 | ||
299 | @override | 299 | @override |
300 | List<E> toList({bool growable = true}) { | 300 | List<E> toList({bool growable = true}) { |
301 | - return _list.toList(growable: growable); | 301 | + return value.toList(growable: growable); |
302 | } | 302 | } |
303 | 303 | ||
304 | @override | 304 | @override |
305 | Set<E> toSet() { | 305 | Set<E> toSet() { |
306 | - return _list.toSet(); | 306 | + return value.toSet(); |
307 | } | 307 | } |
308 | 308 | ||
309 | @override | 309 | @override |
310 | Iterable<E> where(bool Function(E) test) { | 310 | Iterable<E> where(bool Function(E) test) { |
311 | - return _list.where(test); | 311 | + return value.where(test); |
312 | } | 312 | } |
313 | 313 | ||
314 | @override | 314 | @override |
315 | Iterable<T> whereType<T>() { | 315 | Iterable<T> whereType<T>() { |
316 | - return _list.whereType<T>(); | 316 | + return value.whereType<T>(); |
317 | } | 317 | } |
318 | 318 | ||
319 | @override | 319 | @override |
320 | bool containsAll(Iterable<Object> other) { | 320 | bool containsAll(Iterable<Object> other) { |
321 | - return _list.containsAll(other); | 321 | + return value.containsAll(other); |
322 | } | 322 | } |
323 | 323 | ||
324 | @override | 324 | @override |
325 | Set<E> difference(Set<Object> other) { | 325 | Set<E> difference(Set<Object> other) { |
326 | - return _list.difference(other); | 326 | + return value.difference(other); |
327 | } | 327 | } |
328 | 328 | ||
329 | @override | 329 | @override |
330 | Set<E> intersection(Set<Object> other) { | 330 | Set<E> intersection(Set<Object> other) { |
331 | - return _list.intersection(other); | 331 | + return value.intersection(other); |
332 | } | 332 | } |
333 | 333 | ||
334 | @override | 334 | @override |
335 | E lookup(Object object) { | 335 | E lookup(Object object) { |
336 | - return _list.lookup(object); | 336 | + return value.lookup(object); |
337 | } | 337 | } |
338 | 338 | ||
339 | @override | 339 | @override |
340 | void removeAll(Iterable<Object> elements) { | 340 | void removeAll(Iterable<Object> elements) { |
341 | - _list.removeAll(elements); | 341 | + _set.removeAll(elements); |
342 | + subject.add(_set); | ||
342 | } | 343 | } |
343 | 344 | ||
344 | @override | 345 | @override |
345 | void retainAll(Iterable<Object> elements) { | 346 | void retainAll(Iterable<Object> elements) { |
346 | - _list.retainAll(elements); | 347 | + _set.retainAll(elements); |
348 | + subject.add(_set); | ||
347 | } | 349 | } |
348 | 350 | ||
349 | @override | 351 | @override |
350 | void retainWhere(bool Function(E) E) { | 352 | void retainWhere(bool Function(E) E) { |
351 | - _list.retainWhere(E); | 353 | + _set.retainWhere(E); |
354 | + subject.add(_set); | ||
352 | } | 355 | } |
353 | 356 | ||
354 | @override | 357 | @override |
355 | Set<E> union(Set<E> other) { | 358 | Set<E> union(Set<E> other) { |
356 | - return _list.union(other); | 359 | + return value.union(other); |
357 | } | 360 | } |
358 | } | 361 | } |
359 | 362 |
@@ -3,6 +3,8 @@ import 'package:flutter/widgets.dart'; | @@ -3,6 +3,8 @@ import 'package:flutter/widgets.dart'; | ||
3 | import 'package:get/src/state_manager/rx/rx_core/rx_interface.dart'; | 3 | import 'package:get/src/state_manager/rx/rx_core/rx_interface.dart'; |
4 | import '../rx_core/rx_impl.dart'; | 4 | import '../rx_core/rx_impl.dart'; |
5 | 5 | ||
6 | +typedef WidgetCallback = Widget Function(); | ||
7 | + | ||
6 | /// The simplest reactive widget in GetX. | 8 | /// The simplest reactive widget in GetX. |
7 | /// | 9 | /// |
8 | /// Just pass your Rx variable in the root scope of the callback to have it | 10 | /// Just pass your Rx variable in the root scope of the callback to have it |
@@ -11,7 +13,7 @@ import '../rx_core/rx_impl.dart'; | @@ -11,7 +13,7 @@ import '../rx_core/rx_impl.dart'; | ||
11 | /// final _name = "GetX".obs; | 13 | /// final _name = "GetX".obs; |
12 | /// Obx(() => Text( _name.value )),... ; | 14 | /// Obx(() => Text( _name.value )),... ; |
13 | class Obx extends StatefulWidget { | 15 | class Obx extends StatefulWidget { |
14 | - final Widget Function() builder; | 16 | + final WidgetCallback builder; |
15 | 17 | ||
16 | const Obx(this.builder); | 18 | const Obx(this.builder); |
17 | _ObxState createState() => _ObxState(); | 19 | _ObxState createState() => _ObxState(); |
1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
2 | import 'package:flutter/widgets.dart'; | 2 | import 'package:flutter/widgets.dart'; |
3 | -import 'package:flutter/foundation.dart'; | 3 | +import 'package:get/get.dart'; |
4 | 4 | ||
5 | extension ContextExtensionss on BuildContext { | 5 | extension ContextExtensionss on BuildContext { |
6 | /// The same of [MediaQuery.of(context).size] | 6 | /// The same of [MediaQuery.of(context).size] |
@@ -117,8 +117,7 @@ extension ContextExtensionss on BuildContext { | @@ -117,8 +117,7 @@ extension ContextExtensionss on BuildContext { | ||
117 | T watch, | 117 | T watch, |
118 | }) { | 118 | }) { |
119 | double deviceWidth = mediaQuerySize.shortestSide; | 119 | double deviceWidth = mediaQuerySize.shortestSide; |
120 | - | ||
121 | - if (kIsWeb) { | 120 | + if (GetPlatform.isDesktop) { |
122 | deviceWidth = mediaQuerySize.width; | 121 | deviceWidth = mediaQuerySize.width; |
123 | } | 122 | } |
124 | if (deviceWidth >= 1200 && desktop != null) return desktop; | 123 | if (deviceWidth >= 1200 && desktop != null) return desktop; |
@@ -5,18 +5,4 @@ extension GetDynamicUtils on dynamic { | @@ -5,18 +5,4 @@ extension GetDynamicUtils on dynamic { | ||
5 | 5 | ||
6 | bool get isNull => GetUtils.isNull(this); | 6 | bool get isNull => GetUtils.isNull(this); |
7 | bool get isNullOrBlank => GetUtils.isNullOrBlank(this); | 7 | bool get isNullOrBlank => GetUtils.isNullOrBlank(this); |
8 | - | ||
9 | - // bool get isOneAKind => GetUtils.isOneAKind(this); | ||
10 | - // bool isLengthLowerThan(int maxLength) => | ||
11 | - // GetUtils.isLengthLowerThan(this, maxLength); | ||
12 | - // bool isLengthGreaterThan(int maxLength) => | ||
13 | - // GetUtils.isLengthGreaterThan(this, maxLength); | ||
14 | - // bool isLengthGreaterOrEqual(int maxLength) => | ||
15 | - // GetUtils.isLengthGreaterOrEqual(this, maxLength); | ||
16 | - // bool isLengthLowerOrEqual(int maxLength) => | ||
17 | - // GetUtils.isLengthLowerOrEqual(this, maxLength); | ||
18 | - // bool isLengthEqualTo(int maxLength) => | ||
19 | - // GetUtils.isLengthEqualTo(this, maxLength); | ||
20 | - // bool isLengthBetween(int minLength, int maxLength) => | ||
21 | - // GetUtils.isLengthBetween(this, minLength, maxLength); | ||
22 | } | 8 | } |
@@ -8,4 +8,7 @@ class GetPlatform { | @@ -8,4 +8,7 @@ class GetPlatform { | ||
8 | static bool get isAndroid => GeneralPlatform.isAndroid; | 8 | static bool get isAndroid => GeneralPlatform.isAndroid; |
9 | static bool get isIOS => GeneralPlatform.isIOS; | 9 | static bool get isIOS => GeneralPlatform.isIOS; |
10 | static bool get isFuchsia => GeneralPlatform.isFuchsia; | 10 | static bool get isFuchsia => GeneralPlatform.isFuchsia; |
11 | + static bool get isMobile => GetPlatform.isIOS || GetPlatform.isAndroid; | ||
12 | + static bool get isDesktop => | ||
13 | + GetPlatform.isMacOS || GetPlatform.isWindows || GetPlatform.isLinux; | ||
11 | } | 14 | } |
@@ -8,4 +8,6 @@ class GeneralPlatform { | @@ -8,4 +8,6 @@ class GeneralPlatform { | ||
8 | static bool get isAndroid => Platform.isAndroid; | 8 | static bool get isAndroid => Platform.isAndroid; |
9 | static bool get isIOS => Platform.isIOS; | 9 | static bool get isIOS => Platform.isIOS; |
10 | static bool get isFuchsia => Platform.isFuchsia; | 10 | static bool get isFuchsia => Platform.isFuchsia; |
11 | + static bool get isDesktop => | ||
12 | + Platform.isMacOS || Platform.isWindows || Platform.isLinux; | ||
11 | } | 13 | } |
1 | +// TODO: resolve platform/desktop by JS browser agent. | ||
2 | +// ignore: avoid_web_libraries_in_flutter | ||
3 | +import 'dart:html' as html; | ||
4 | + | ||
5 | +import 'package:get/utils.dart'; | ||
6 | + | ||
7 | +html.Navigator _navigator = html.window.navigator; | ||
8 | + | ||
1 | class GeneralPlatform { | 9 | class GeneralPlatform { |
2 | static bool get isWeb => true; | 10 | static bool get isWeb => true; |
3 | - static bool get isMacOS => false; | ||
4 | - static bool get isWindows => false; | ||
5 | - static bool get isLinux => false; | ||
6 | - static bool get isAndroid => false; | ||
7 | - static bool get isIOS => false; | 11 | + |
12 | + static bool get isMacOS => | ||
13 | + _navigator.appVersion.contains('Mac OS') && !GeneralPlatform.isIOS; | ||
14 | + | ||
15 | + static bool get isWindows => _navigator.appVersion.contains('Win'); | ||
16 | + | ||
17 | + static bool get isLinux => | ||
18 | + (_navigator.appVersion.contains('Linux') || | ||
19 | + _navigator.appVersion.contains('x11')) && | ||
20 | + !isAndroid; | ||
21 | + | ||
22 | + // @check https://developer.chrome.com/multidevice/user-agent | ||
23 | + static bool get isAndroid => _navigator.appVersion.contains('Android '); | ||
24 | + | ||
25 | + static bool get isIOS { | ||
26 | + // maxTouchPoints is needed to separate iPad iOS13 vs new MacOS | ||
27 | + return GetUtils.hasMatch(_navigator.platform, r'/iPad|iPhone|iPod/') || | ||
28 | + (_navigator.platform == 'MacIntel' && _navigator.maxTouchPoints > 1); | ||
29 | + } | ||
30 | + | ||
8 | static bool get isFuchsia => false; | 31 | static bool get isFuchsia => false; |
32 | + static bool get isDesktop => isMacOS || isWindows || isLinux; | ||
9 | } | 33 | } |
@@ -2,6 +2,13 @@ class GetUtils { | @@ -2,6 +2,13 @@ class GetUtils { | ||
2 | /// Checks if data is null. | 2 | /// Checks if data is null. |
3 | static bool isNull(dynamic s) => s == null; | 3 | static bool isNull(dynamic s) => s == null; |
4 | 4 | ||
5 | + /// In dart2js (in flutter v1.17) a var by default is undefined. | ||
6 | + /// *Use this only if you are in version <- 1.17*. | ||
7 | + /// So we assure the null type in json convertions to avoid the "value":value==null?null:value; | ||
8 | + /// someVar.nil will force the null type if the var is null or undefined. | ||
9 | + /// `nil` taken from ObjC just to have a shorter sintax. | ||
10 | + static dynamic nil(dynamic s) => s == null ? null : s; | ||
11 | + | ||
5 | /// Checks if data is null or blank (empty or only contains whitespace). | 12 | /// Checks if data is null or blank (empty or only contains whitespace). |
6 | static bool isNullOrBlank(dynamic s) { | 13 | static bool isNullOrBlank(dynamic s) { |
7 | if (isNull(s)) return true; | 14 | if (isNull(s)) return true; |
1 | name: get | 1 | name: get |
2 | description: Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with GetX. | 2 | description: Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with GetX. |
3 | -version: 3.6.3 | 3 | +version: 3.7.0 |
4 | homepage: https://github.com/jonataslaw/get | 4 | homepage: https://github.com/jonataslaw/get |
5 | 5 | ||
6 | environment: | 6 | environment: |
1 | +@TestOn('vm') | ||
1 | import 'dart:io'; | 2 | import 'dart:io'; |
2 | - | ||
3 | import 'package:flutter_test/flutter_test.dart'; | 3 | import 'package:flutter_test/flutter_test.dart'; |
4 | -import 'package:get/get.dart'; | ||
5 | -import 'package:get/src/utils/platform/platform_web.dart'; | 4 | +import 'package:get/src/utils/platform/platform.dart'; |
6 | 5 | ||
7 | void main() { | 6 | void main() { |
8 | test('Platform test', () { | 7 | test('Platform test', () { |
@@ -13,12 +12,5 @@ void main() { | @@ -13,12 +12,5 @@ void main() { | ||
13 | expect(GetPlatform.isMacOS, Platform.isMacOS); | 12 | expect(GetPlatform.isMacOS, Platform.isMacOS); |
14 | expect(GetPlatform.isWindows, Platform.isWindows); | 13 | expect(GetPlatform.isWindows, Platform.isWindows); |
15 | expect(GetPlatform.isWeb, false); | 14 | expect(GetPlatform.isWeb, false); |
16 | - expect(GeneralPlatform.isWeb, true); | ||
17 | - expect(GeneralPlatform.isAndroid, false); | ||
18 | - expect(GeneralPlatform.isIOS, false); | ||
19 | - expect(GeneralPlatform.isFuchsia, false); | ||
20 | - expect(GeneralPlatform.isLinux, false); | ||
21 | - expect(GeneralPlatform.isMacOS, false); | ||
22 | - expect(GeneralPlatform.isWindows, false); | ||
23 | }); | 15 | }); |
24 | } | 16 | } |
test/platform_web_test.dart
0 → 100644
1 | +@TestOn('browser') | ||
2 | +import 'dart:io'; | ||
3 | +import 'package:flutter_test/flutter_test.dart'; | ||
4 | +import 'package:get/src/utils/platform/platform.dart'; | ||
5 | + | ||
6 | +void main() { | ||
7 | + test('Platform test', () { | ||
8 | + expect(GetPlatform.isAndroid, Platform.isAndroid); | ||
9 | + expect(GetPlatform.isIOS, Platform.isIOS); | ||
10 | + expect(GetPlatform.isFuchsia, Platform.isFuchsia); | ||
11 | + expect(GetPlatform.isLinux, Platform.isLinux); | ||
12 | + expect(GetPlatform.isMacOS, Platform.isMacOS); | ||
13 | + expect(GetPlatform.isWindows, Platform.isWindows); | ||
14 | + expect(GetPlatform.isWeb, true); | ||
15 | + }); | ||
16 | +} |
-
Please register or login to post a comment