roi peker

Merge remote-tracking branch 'upstream/master' into docs

Showing 126 changed files with 457 additions and 2734 deletions
... ... @@ -6,6 +6,7 @@ labels: ''
assignees: jonataslaw
---
**ATTENTION: DO NOT USE THIS FIELD TO ASK SUPPORT QUESTIONS. USE THE PLATFORM CHANNELS FOR THIS. THIS SPACE IS DEDICATED ONLY FOR BUGS DESCRIPTION.**
**Fill in the template. Issues that do not respect the model will be closed.**
**Describe the bug**
... ... @@ -27,8 +28,8 @@ If applicable, add screenshots to help explain your problem.
**Flutter Version:**
Enter the version of the Flutter you are using
**Get Version:**
Enter the version of the Get you are using
**Getx Version:**
Enter the version of the Getx you are using
**Describe on which device you found the bug:**
ex: Moto z2 - Android.
... ...
... ... @@ -6,6 +6,7 @@ labels: ''
assignees: ''
---
**ATTENTION: DO NOT USE THIS FIELD TO ASK SUPPORT QUESTIONS. USE THE PLATFORM CHANNELS FOR THIS. THIS SPACE IS DEDICATED ONLY FOR FEATURE REQUESTS**
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
... ...
## [3.6.3]
- Fix onStart called null on tests
## [3.7.0]
- Added: RxSet. Sets can now also be reactive.
- Added isDesktop/isMobile (@roipeker)
- Improve GetPlatform: It is now possible to know which device the user is using if GetPlatform.isWeb is true.
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)
- Change: The documentation previously stated that Iterables should not access the ".value" property.
However, many users did not pay attention to this fact, and ended up generating unnecessary issues and bugs in their application.
In this version, we focus on code security. Now ".value" is protected, so it cannot be accessed externally by Lists, Maps or Sets.
- Change: Observable lists are now Dart Lists.
There is no difference in your use:
`RxList list = [].obs;`
And you use
`List list = [].obs;`
- Change: You do not need to access the ".value" property of primitives.
For Strings you need interpolation.
For num, int, double, you will have the normal operators, and use it as dart types.
This way, `.value` can be used exclusively in ModelClasses.
Example:
```dart
var name = "Jonny" .obs;
// usage:
Text ("$name");
var count = 0.obs;
// usage:
increment() => count ++;
Text("$count");
```
Thus: List, Map, Set, num, int, double and String, as of this release, will no longer use the .value property.
NOTE:
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.
The same goes for Maps and Sets.
## [3.6.2]
- Fix more formatting issues
... ...
... ... @@ -90,7 +90,7 @@ import 'package:get/get.dart';
# Proyecto Counter no GetX
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
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
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.
... ... @@ -191,7 +191,7 @@ Obx(() => Text (controller.name));
### Más detalles sobre la gestión del estado.
**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**
**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**
### Explicación en video sobre state management
... ... @@ -233,7 +233,7 @@ var data = await Get.to(Payment());
### Más detalles sobre la gestión de rutas.
**Vea una explicación más detallada de la Gestión de Rutas [aquí](./docs/es_ES/route_management.md).**
**Vea una explicación más detallada de la Gestión de Rutas [aquí](./documentation/es_ES/route_management.md).**
### Explicación del video
... ... @@ -277,7 +277,7 @@ Get.lazyPut<Service>(()=> ApiMock());
### Más detalles sobre la gestión de dependencias.
**Vea una explicación más detallada de la Gestión de dependencias [aquí](./docs/es_ES/dependency_management.md).**
**Vea una explicación más detallada de la Gestión de dependencias [aquí](./documentation/es_ES/dependency_management.md).**
# Utilidades
... ... @@ -514,7 +514,7 @@ Ahora:
```dart
GetMaterialApp(
getPages: [
GetPage(name: '/', page:()=> Home()),
GetPage(name: '/', page: () => Home()),
]
)
```
... ...
... ... @@ -29,10 +29,11 @@
- [More details about dependency management](#more-details-about-dependency-management)
- [How to contribute](#how-to-contribute)
- [Utils](#utils)
- [Internationalization](#internationalization)
- [Change Theme](#change-theme)
- [Other Advanced APIs](#other-advanced-apis)
- [Optional Global Settings and Manual configurations](#optional-global-settings-and-manual-configurations)
- [Video explanation of Other GetX Features](#video-explanation-of-other-getx-features)
- [Video explanation of Other GetX Features](#video-explanation-of-other-getx-features)
- [Breaking changes from 2.0](#breaking-changes-from-20)
- [Why Getx?](#why-getx)
... ... @@ -191,7 +192,7 @@ That's all. It's *that* simple.
### More details about state management
**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**
**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**
### Video explanation about state management
... ... @@ -240,7 +241,7 @@ Noticed that you didn't had to use context to do any of these things? That's one
### More details about route management
**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)**
**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)**
### Video Explanation
... ... @@ -281,7 +282,7 @@ Text(controller.textFromApi);
### More details about dependency management
**See a more in-depth explanation of dependency management [here](./docs/en_US/dependency_management.md)**
**See a more in-depth explanation of dependency management [here](./documentation/en_US/dependency_management.md)**
# How to contribute
... ... @@ -296,6 +297,60 @@ Text(controller.textFromApi);
Any contribution is welcome!
# Utils
## Internationalization
### Translations
Translations are kept as a simple key-value dictionary map.
To add custom translations, create a class and extend `Translations`.
```dart
import 'package:get/get.dart';
class Messages extends Translations {
@override
Map<String, Map<String, String>> get keys => {
'en_US': {
'hello': 'Hello World',
},
'de_DE': {
'hello': 'Hallo Welt',
}
};
}
```
#### Using translations
Just append `.tr` to the specified key and it will be translated, using the current value of `Get.locale` and `Get.fallbackLocale`.
```dart
Text('title'.tr);
```
### Locales
Pass parameters to `GetMaterialApp` to define the locale and translations.
```dart
return GetMaterialApp(
translations: Messages(), // your translations
locale: Locale('en', 'US'), // translations will be displayed in that locale
fallbackLocale: Locale('en', 'UK'), // specify the fallback locale in case an invalid locale is selected.
supportedLocales: <Locale>[Locale('en', 'UK'), Locale('en', 'US'), Locale('de','DE')] // specify the supported locales
);
```
#### Change locale
Call `Get.updateLocale(locale)` to update the locale. Translations then automatically use the new locale.
```dart
var locale = Locale('en', 'US');
Get.updateLocale(locale);
```
#### System locale
To read the system locale, you could use `window.locale`.
```dart
import 'dart:ui' as ui;
return GetMaterialApp(
locale: ui.window.locale,
);
```
## Change Theme
... ... @@ -572,7 +627,7 @@ Now:
```dart
GetMaterialApp(
getPages: [
GetPage(name: '/', page:()=> Home()),
GetPage(name: '/', page: () => Home()),
]
)
```
... ...
... ... @@ -176,7 +176,7 @@ Obx (() => Text (controller.name));
To wszystko. *Proste*, co nie?
### Bardziej szczegółowo o menadżerze stanu
**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**
**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**
### Video tłumaczące użycie menadżera stanu
... ... @@ -237,7 +237,7 @@ Zobacz, ze do żadnej z tych operacji nie potrzebowałeś contextu. Jest to jedn
### Więcej o routach
**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)**
**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)**
### Video tłumaczące użycie
... ... @@ -274,7 +274,7 @@ Text(controller.textFromApi);
```
### Bardziej szczegółowo o menadżerze dependencies
**Zobzcz więcej w dokumentacji [tutaj](./docs/en_US/dependency_management.md)**
**Zobzcz więcej w dokumentacji [tutaj](./documentation/en_US/dependency_management.md)**
# Jak włożyć coś od siebie
... ... @@ -518,7 +518,7 @@ Teraz:
```dart
GetMaterialApp(
getPages: [
GetPage(name: '/', page:()=> Home()),
GetPage(name: '/', page: () => Home()),
]
)
```
... ...
... ... @@ -191,7 +191,7 @@ Só isso. É *simples assim*;
### Mais detalhes sobre gerenciamento de estado
**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**
**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**
### Explicação em video do gerenciamento de estado
... ... @@ -235,7 +235,7 @@ Notou que você não precisou usar `context` para fazer nenhuma dessas coisas? E
### Mais detalhes sobre gerenciamento de rotas
**GetX funciona com rotas nomeadas também! Veja uma explicação mais completa do gerenciamento de rotas [aqui](./docs/pt_BR/route_management.md)**
**GetX funciona com rotas nomeadas também! Veja uma explicação mais completa do gerenciamento de rotas [aqui](./documentation/pt_BR/route_management.md)**
### Explicação em video do gerenciamento de rotas
... ... @@ -283,7 +283,7 @@ Get.lazyPut<Service>(()=> ApiMock());
### Mais detalhes sobre gerenciamento de dependências
**Veja uma explicação mais completa do gerenciamento de dependência [aqui](./docs/pt_BR/dependency_management.md)**
**Veja uma explicação mais completa do gerenciamento de dependência [aqui](./documentation/pt_BR/dependency_management.md)**
# Como contribuir
... ... @@ -549,7 +549,7 @@ Agora:
```dart
GetMaterialApp(
getPages: [
GetPage(name: '/', page:()=> Home()),
GetPage(name: '/', page: () => Home()),
]
)
```
... ...
# benchmarks
A repository to benchmark Flutter libs.
Creators of the tested libs can suggest improvements, as long as they follow the same design structure.
# 1- State Managers
![](benchmark.png)
The idle application consumes 4.288k of ram.
Items were added dynamically to a ListView.
The amount of RAM was measured after the test, and the following calculation was made:
Number of RAM consumed by the app after testing with the state manager - RAM in idle state without any state manager.
In addition to the RAM calculation, the size of the apk was also observed after compilation. And we had the following results:
- flutter_bloc: 8.3mb
- mobx: 8.3mb
- provider: 8.3mb
- redux: 8.2mb
- get: 8.2mb
- getx: 8.2mb
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.
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/
# Web related
lib/generated_plugin_registrant.dart
# Symbolication related
app.*.symbols
# Obfuscation related
app.*.map.json
# Exceptions to above rules.
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 29
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "de.udos.flutterstatemanagement"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.udos.benchmarks">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.udos.benchmarks">
<!-- The INTERNET permission is required for development. Specifically,
flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="benckmark"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in @style/LaunchTheme). -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
package de.udos.benchmarks;
import android.os.Bundle;
import io.flutter.app.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;
public class MainActivity extends FlutterActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
}
}
package io.flutter.plugins;
import io.flutter.plugin.common.PluginRegistry;
/**
* Generated file. Do not edit.
*/
public final class GeneratedPluginRegistrant {
public static void registerWith(PluginRegistry registry) {
if (alreadyRegisteredWith(registry)) {
return;
}
}
private static boolean alreadyRegisteredWith(PluginRegistry registry) {
final String key = GeneratedPluginRegistrant.class.getCanonicalName();
if (registry.hasPlugin(key)) {
return true;
}
registry.registrarFor(key);
return false;
}
}
package de.udos.benchmarks
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
}
package de.udos.benchs
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
}
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
</resources>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.udos.benchmarks">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
#Sat Jan 11 20:55:27 CET 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
sdk.dir=/home/jonny/Android/Sdk
flutter.sdk=/opt/flutter
flutter.buildMode=profile
\ No newline at end of file
include ':app'
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}
plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
include ":$name"
project(":$name").projectDir = pluginDirectory
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>App</string>
<key>CFBundleIdentifier</key>
<string>io.flutter.flutter.app</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>App</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>8.0</string>
</dict>
</plist>
// This is a generated file; do not edit or check into version control.
FLUTTER_ROOT=/opt/flutter
FLUTTER_APPLICATION_PATH=/home/jonny/Área de trabalho/getx/benchmark/state_managers
FLUTTER_TARGET=lib/main.dart
FLUTTER_BUILD_DIR=build
SYMROOT=${SOURCE_ROOT}/../build/ios
OTHER_LDFLAGS=$(inherited) -framework Flutter
FLUTTER_FRAMEWORK_DIR=/opt/flutter/bin/cache/artifacts/engine/ios
FLUTTER_BUILD_NAME=1.0.0
FLUTTER_BUILD_NUMBER=1
DART_OBFUSCATION=false
TRACK_WIDGET_CREATION=false
TREE_SHAKE_ICONS=false
PACKAGE_CONFIG=.packages
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/opt/flutter"
export "FLUTTER_APPLICATION_PATH=/home/jonny/Área de trabalho/getx/benchmark/state_managers"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
export "OTHER_LDFLAGS=$(inherited) -framework Flutter"
export "FLUTTER_FRAMEWORK_DIR=/opt/flutter/bin/cache/artifacts/engine/ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=false"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.packages"
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:Runner.xcodeproj">
</FileRef>
</Workspace>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreviewsEnabled</key>
<false/>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0910"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:Runner.xcodeproj">
</FileRef>
</Workspace>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreviewsEnabled</key>
<false/>
</dict>
</plist>
#import <Flutter/Flutter.h>
#import <UIKit/UIKit.h>
@interface AppDelegate : FlutterAppDelegate
@end
#include "AppDelegate.h"
#include "GeneratedPluginRegistrant.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[GeneratedPluginRegistrant registerWithRegistry:self];
// Override point for customization after application launch.
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
@end
import UIKit
import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
{
"images" : [
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-App-20x20@2x.png",
"scale" : "2x"
},
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-App-20x20@3x.png",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@1x.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@3x.png",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-App-40x40@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-App-40x40@3x.png",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-App-60x60@2x.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-App-60x60@3x.png",
"scale" : "3x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-App-20x20@1x.png",
"scale" : "1x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-App-20x20@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-App-29x29@1x.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-App-29x29@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-App-40x40@1x.png",
"scale" : "1x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-App-40x40@2x.png",
"scale" : "2x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-App-76x76@1x.png",
"scale" : "1x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-App-76x76@2x.png",
"scale" : "2x"
},
{
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "Icon-App-83.5x83.5@2x.png",
"scale" : "2x"
},
{
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "Icon-App-1024x1024@1x.png",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
{
"images" : [
{
"idiom" : "universal",
"filename" : "LaunchImage.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "LaunchImage@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "LaunchImage@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
# Launch Screen Assets
You can customize the launch screen with your own desired assets by replacing the image files in this directory.
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.
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Ydg-fD-yQy"/>
<viewControllerLayoutGuide type="bottom" id="xbc-2k-c8Z"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4">
</imageView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="YRO-k0-Ey4" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="1a2-6s-vTC"/>
<constraint firstItem="YRO-k0-Ey4" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" id="4X2-HB-R7a"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
<resources>
<image name="LaunchImage" width="168" height="185"/>
</resources>
</document>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<scenes>
<!--Flutter View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="FlutterViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>
//
// Generated file. Do not edit.
//
#ifndef GeneratedPluginRegistrant_h
#define GeneratedPluginRegistrant_h
#import <Flutter/Flutter.h>
NS_ASSUME_NONNULL_BEGIN
@interface GeneratedPluginRegistrant : NSObject
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry;
@end
NS_ASSUME_NONNULL_END
#endif /* GeneratedPluginRegistrant_h */
//
// Generated file. Do not edit.
//
#import "GeneratedPluginRegistrant.h"
@implementation GeneratedPluginRegistrant
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry {
}
@end
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>benckmark</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>
</plist>
#import <Flutter/Flutter.h>
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char* argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
import 'dart:async';
import 'package:bloc/bloc.dart';
import 'package:benckmark/item.dart';
part 'items_event.dart';
class ItemsBloc extends Bloc<ItemsEvent, List<Item>> {
ItemsBloc() {
Timer.periodic(const Duration(milliseconds: 500), (timer) {
add(AddItemEvent(Item(title: DateTime.now().toString())));
if (state.length == 10) {
timer.cancel();
print("It's done. Print now!");
}
});
}
@override
List<Item> get initialState => sampleItems;
@override
Stream<List<Item>> mapEventToState(ItemsEvent event) async* {
if (event is AddItemEvent) {
yield List.from(state)..add(event.item);
}
}
}
part of 'items_bloc.dart';
abstract class ItemsEvent {}
class AddItemEvent extends ItemsEvent {
AddItemEvent(this.item);
final Item item;
}
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:benckmark/item.dart';
import 'package:benckmark/_bloc_lib/_blocs/items/items_bloc.dart';
class App extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
title: 'BLoC Lib Sample',
theme: ThemeData(primarySwatch: Colors.blue),
home: BlocProvider(
create: (_) => ItemsBloc(),
child: Page(title: 'BLoC Lib Sample'),
),
);
}
}
class Page extends StatelessWidget {
const Page({Key key, this.title}) : super(key: key);
final String title;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(title)),
body: BlocBuilder<ItemsBloc, List<Item>>(
builder: (context, items) {
return ListView.builder(
padding: EdgeInsets.fromLTRB(0.0, 8.0, 0.0, 8.0),
itemCount: items.length,
itemBuilder: (context, index) {
return ListTile(title: Text(items[index].title));
},
);
},
),
);
}
}
import 'dart:async';
import 'package:benckmark/item.dart';
import 'package:rxdart/rxdart.dart';
class AddItemEvent {
final Item item;
AddItemEvent(this.item);
}
class ItemsBloc {
final StreamController<dynamic> _itemsEventController = StreamController();
StreamSink<dynamic> get _itemsEventSink => _itemsEventController.sink;
final BehaviorSubject<List<Item>> _itemsStateSubject =
BehaviorSubject.seeded(sampleItems);
StreamSink<List<Item>> get _itemsStateSink => _itemsStateSubject.sink;
ValueStream<List<Item>> get items => _itemsStateSubject.stream;
List<StreamSubscription<dynamic>> _subscriptions;
ItemsBloc() {
_subscriptions = <StreamSubscription<dynamic>>[
_itemsEventController.stream.listen(_mapEventToState)
];
}
dispose() {
_subscriptions.forEach((subscription) => subscription.cancel());
_itemsStateSubject.close();
_itemsEventController.close();
}
void addItem(Item item) {
_itemsEventSink.add(AddItemEvent(item));
}
void _mapEventToState(dynamic event) {
if (event is AddItemEvent) {
_itemsStateSink.add([...items.value, event.item]);
}
}
}
import 'package:flutter/widgets.dart';
import '_bloc.dart';
class ItemsBlocProvider extends InheritedWidget {
final ItemsBloc bloc;
ItemsBlocProvider({
Key key,
Widget child,
@required this.bloc,
}) : super(key: key, child: child);
@override
bool updateShouldNotify(InheritedWidget oldWidget) => true;
static ItemsBloc of(BuildContext context) {
final provider =
context.dependOnInheritedWidgetOfExactType<ItemsBlocProvider>();
return provider.bloc;
}
}
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:benckmark/item.dart';
import '_bloc.dart';
import '_provider.dart';
class App extends StatelessWidget {
final ItemsBloc itemsBloc = ItemsBloc();
@override
Widget build(BuildContext context) {
return ItemsBlocProvider(
bloc: itemsBloc,
child: MaterialApp(
title: 'BLoC Sample',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Page(title: 'BLoC Sample'),
),
);
}
}
class Page extends StatefulWidget {
Page({Key key, this.title}) : super(key: key);
final String title;
@override
_PageState createState() => _PageState();
}
class _PageState extends State<Page> {
@override
void initState() {
SchedulerBinding.instance.addPostFrameCallback((timeStamp) async {
for (int i = 0; i < 10; i++) {
await Future.delayed(Duration(milliseconds: 500));
ItemsBlocProvider.of(context)
.addItem(Item(title: DateTime.now().toString()));
}
print("It's done. Print now!");
});
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: ListViewWidget(),
);
}
}
class ListViewWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final ItemsBloc itemsBloc = ItemsBlocProvider.of(context);
return StreamBuilder<List<Item>>(
stream: itemsBloc.items,
builder: (context, snapshot) {
final items = snapshot.data;
return ListView.builder(
padding: EdgeInsets.fromLTRB(0.0, 8.0, 0.0, 8.0),
itemCount: items is List<Item> ? items.length : 0,
itemBuilder: (context, index) {
return ListTile(
title: Text(items[index].title),
);
},
);
},
);
}
}
import 'package:benckmark/item.dart';
import 'package:get/get.dart';
class Controller extends GetController {
@override
onInit() async {
for (int i = 0; i < 10; i++) {
await Future.delayed(Duration(milliseconds: 500));
addItem(Item(title: DateTime.now().toString()));
}
print("It's done. Print now!");
super.onInit();
}
final items = List<Item>.of(sampleItems);
void addItem(Item item) {
items.add(item);
update();
}
}
import 'package:flutter/material.dart';
import 'package:benckmark/_get/_store.dart';
import 'package:get/get.dart';
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Get Sample',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Page(title: 'Get Sample'),
);
}
}
class Page extends StatelessWidget {
Page({
Key key,
this.title,
}) : super(key: key);
final String title;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(title),
),
body: ListViewWidget(),
);
}
}
class ListViewWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GetBuilder<Controller>(
init: Controller(),
global: false,
builder: (_) => ListView.builder(
padding: EdgeInsets.fromLTRB(0.0, 8.0, 0.0, 8.0),
itemCount: _.items.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(_.items[index].title),
);
}));
}
}
import 'package:benckmark/item.dart';
import 'package:get/get.dart';
class Controller extends RxController {
Controller() {
onInit();
}
final items = sampleItems.obs;
@override
onInit() async {
for (int i = 0; i < 10; i++) {
await Future.delayed(Duration(milliseconds: 500));
addItem(Item(title: DateTime.now().toString()));
}
print("It's done. Print now!");
super.onInit();
}
void addItem(Item item) {
items.add(item);
}
}
import 'package:benckmark/_get_rx/_store.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'GetX Sample',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Page(title: 'GetX Sample'),
);
}
}
class Page extends StatelessWidget {
Page({
Key key,
this.title,
}) : super(key: key);
final String title;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("GetX"),
),
body: ListViewWidget(),
);
}
}
class ListViewWidget extends StatelessWidget {
final Controller c = Controller();
@override
Widget build(BuildContext context) {
return Obxx(() => ListView.builder(
padding: EdgeInsets.fromLTRB(0.0, 8.0, 0.0, 8.0),
itemCount: c.items.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(c.items[index].title),
);
}));
}
}
import 'package:benckmark/item.dart';
import 'package:mobx/mobx.dart';
part '_store.g.dart';
class AppStore = _AppStore with _$AppStore;
abstract class _AppStore with Store {
@observable
ObservableList<Item> items = ObservableList<Item>.of(sampleItems);
@observable
ObservableSet<String> checkedItemIds = ObservableSet<String>();
@action
void addItem(Item item) {
items.add(item);
}
}
// GENERATED CODE - DO NOT MODIFY BY HAND
part of '_store.dart';
// **************************************************************************
// StoreGenerator
// **************************************************************************
// ignore_for_file: non_constant_identifier_names, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic
mixin _$AppStore on _AppStore, Store {
final _$itemsAtom = Atom(name: '_AppStore.items');
@override
ObservableList<Item> get items {
_$itemsAtom.context.enforceReadPolicy(_$itemsAtom);
_$itemsAtom.reportObserved();
return super.items;
}
@override
set items(ObservableList<Item> value) {
_$itemsAtom.context.conditionallyRunInAction(() {
super.items = value;
_$itemsAtom.reportChanged();
}, _$itemsAtom, name: '${_$itemsAtom.name}_set');
}
final _$checkedItemIdsAtom = Atom(name: '_AppStore.checkedItemIds');
@override
ObservableSet<String> get checkedItemIds {
_$checkedItemIdsAtom.context.enforceReadPolicy(_$checkedItemIdsAtom);
_$checkedItemIdsAtom.reportObserved();
return super.checkedItemIds;
}
@override
set checkedItemIds(ObservableSet<String> value) {
_$checkedItemIdsAtom.context.conditionallyRunInAction(() {
super.checkedItemIds = value;
_$checkedItemIdsAtom.reportChanged();
}, _$checkedItemIdsAtom, name: '${_$checkedItemIdsAtom.name}_set');
}
final _$_AppStoreActionController = ActionController(name: '_AppStore');
@override
void addItem(Item item) {
final _$actionInfo = _$_AppStoreActionController.startAction();
try {
return super.addItem(item);
} finally {
_$_AppStoreActionController.endAction(_$actionInfo);
}
}
}
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:benckmark/_mobx/_store.dart';
import 'package:benckmark/item.dart';
final store = AppStore();
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'MobX Sample',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Page(title: 'MobX Sample'),
);
}
}
class Page extends StatefulWidget {
Page({
Key key,
this.title,
}) : super(key: key);
final String title;
@override
_PageState createState() => _PageState();
}
class _PageState extends State<Page> {
@override
void initState() {
fill();
super.initState();
}
fill() async {
for (int i = 0; i < 10; i++) {
await Future.delayed(Duration(milliseconds: 500));
store.addItem(Item(title: DateTime.now().toString()));
}
print("It's done. Print now!");
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: ListViewWidget(),
);
}
}
class ListViewWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Observer(
builder: (_) {
return ListView.builder(
padding: EdgeInsets.fromLTRB(0.0, 8.0, 0.0, 8.0),
itemCount: store.items.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(store.items[index].title),
);
},
);
},
);
}
}
import 'package:flutter/foundation.dart';
import 'package:benckmark/item.dart';
import 'package:flutter/scheduler.dart';
class AppState with ChangeNotifier {
AppState() {
SchedulerBinding.instance.addPostFrameCallback((timeStamp) async {
for (int i = 0; i < 10; i++) {
await Future.delayed(Duration(milliseconds: 500));
addItem(Item(title: DateTime.now().toString()));
}
print("It's done. Print now!");
});
}
List<Item> _items = sampleItems;
List<Item> get items => _items;
void addItem(Item item) {
_items.add(item);
notifyListeners();
}
}
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '_state.dart';
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider(
create: (context) => AppState(),
child: MaterialApp(
title: 'Provider Sample',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Page(title: 'Provider Sample'),
),
);
}
}
class Page extends StatelessWidget {
Page({
Key key,
this.title,
}) : super(key: key);
final String title;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(title),
),
body: ListViewWidget(),
);
}
}
class ListViewWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final state = context.watch<AppState>();
return ListView.builder(
padding: EdgeInsets.fromLTRB(0.0, 8.0, 0.0, 8.0),
itemCount: state.items.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(state.items[index].title),
);
},
);
}
}
import 'package:benckmark/item.dart';
import 'package:meta/meta.dart';
@immutable
class AppState {
final List<Item> items;
AppState({
this.items,
});
AppState.initialState() : items = sampleItems;
}
class AddItemAction {
Item payload;
AddItemAction({
this.payload,
});
}
AppState appReducer(AppState state, dynamic action) {
return AppState(items: itemsReducer(state.items, action));
}
List<Item> itemsReducer(List<Item> state, dynamic action) {
if (action is AddItemAction) {
return [...state, action.payload];
}
return state;
}
import 'package:flutter/material.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:benckmark/item.dart';
import 'package:redux/redux.dart';
import '_store.dart';
final store =
Store<AppState>(appReducer, initialState: AppState.initialState());
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return StoreProvider<AppState>(
store: store,
child: MaterialApp(
title: 'Redux Sample',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Page(title: 'Redux Sample'),
),
);
}
}
class Page extends StatefulWidget {
Page({
Key key,
this.title,
}) : super(key: key);
final String title;
@override
_PageState createState() => _PageState();
}
class _PageState extends State<Page> {
@override
void initState() {
super.initState();
fill();
}
fill() async {
for (int i = 0; i < 10; i++) {
await Future.delayed(Duration(milliseconds: 500));
store.dispatch(
AddItemAction(payload: Item(title: DateTime.now().toString())));
}
print("It's done. Print now!");
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: ListViewWidget(),
);
}
}
class ListViewWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return StoreConnector<AppState, List<Item>>(
converter: (store) => store.state.items,
builder: (context, items) {
return ListView.builder(
padding: EdgeInsets.fromLTRB(0.0, 8.0, 0.0, 8.0),
itemCount: items.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(items[index].title),
);
},
);
},
);
}
}
class Item {
final String title;
Item({
this.title,
});
}
final List<Item> sampleItems = [
Item(title: 'Item 1'),
Item(title: 'Item 2'),
Item(title: 'Item 3')
];
import 'package:flutter/widgets.dart';
//import 'package:benckmark/_bloc_plain/app.dart';
//import 'package:benckmark/_bloc_lib/app.dart';
//import 'package:benckmark/_mobx/app.dart';
//import 'package:benckmark/_redux/app.dart';
//import 'package:benckmark/_get_rx/app.dart';
//import 'package:benckmark/_provider/app.dart';
import 'package:benckmark/_get/app.dart';
void main() => runApp(App());
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
_fe_analyzer_shared:
dependency: transitive
description:
name: _fe_analyzer_shared
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
version: "0.39.10"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.0"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0-nullsafety"
bloc:
dependency: "direct main"
description:
name: bloc
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety"
build:
dependency: transitive
description:
name: build
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
build_config:
dependency: transitive
description:
name: build_config
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.2"
build_daemon:
dependency: transitive
description:
name: build_daemon
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
build_resolvers:
dependency: transitive
description:
name: build_resolvers
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.9"
build_runner:
dependency: "direct dev"
description:
name: build_runner
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0"
build_runner_core:
dependency: transitive
description:
name: build_runner_core
url: "https://pub.dartlang.org"
source: hosted
version: "5.2.0"
built_collection:
dependency: transitive
description:
name: built_collection
url: "https://pub.dartlang.org"
source: hosted
version: "4.3.2"
built_value:
dependency: transitive
description:
name: built_value
url: "https://pub.dartlang.org"
source: hosted
version: "7.1.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.2"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety"
checked_yaml:
dependency: transitive
description:
name: checked_yaml
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety"
code_builder:
dependency: transitive
description:
name: code_builder
url: "https://pub.dartlang.org"
source: hosted
version: "3.3.0"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0-nullsafety.2"
convert:
dependency: transitive
description:
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
csslib:
dependency: transitive
description:
name: csslib
url: "https://pub.dartlang.org"
source: hosted
version: "0.16.1"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
dart_style:
dependency: transitive
description:
name: dart_style
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.6"
equatable:
dependency: "direct main"
description:
name: equatable
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety"
fixnum:
dependency: transitive
description:
name: fixnum
url: "https://pub.dartlang.org"
source: hosted
version: "0.10.11"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_bloc:
dependency: "direct main"
description:
name: flutter_bloc
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.1"
flutter_mobx:
dependency: "direct main"
description:
name: flutter_mobx
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.7"
flutter_redux:
dependency: "direct main"
description:
name: flutter_redux
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.0"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
get:
dependency: "direct main"
description:
name: get
url: "https://pub.dartlang.org"
source: hosted
version: "2.12.5-beta"
glob:
dependency: transitive
description:
name: glob
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
graphs:
dependency: transitive
description:
name: graphs
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0"
html:
dependency: transitive
description:
name: html
url: "https://pub.dartlang.org"
source: hosted
version: "0.14.0+3"
http_multi_server:
dependency: transitive
description:
name: http_multi_server
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.0"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.4"
io:
dependency: transitive
description:
name: io
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.4"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.2"
json_annotation:
dependency: transitive
description:
name: json_annotation
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
logging:
dependency: transitive
description:
name: logging
url: "https://pub.dartlang.org"
source: hosted
version: "0.11.4"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10-nullsafety"
meta:
dependency: "direct main"
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.2"
mime:
dependency: transitive
description:
name: mime
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.6+3"
mobx:
dependency: "direct main"
description:
name: mobx
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.0+4"
mobx_codegen:
dependency: "direct dev"
description:
name: mobx_codegen
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.2"
nested:
dependency: transitive
description:
name: nested
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.4"
node_interop:
dependency: transitive
description:
name: node_interop
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
node_io:
dependency: transitive
description:
name: node_io
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
package_config:
dependency: transitive
description:
name: package_config
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.3"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.0"
pool:
dependency: transitive
description:
name: pool
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.0"
provider:
dependency: "direct main"
description:
name: provider
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.3"
pub_semver:
dependency: transitive
description:
name: pub_semver
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.4"
pubspec_parse:
dependency: transitive
description:
name: pubspec_parse
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.5"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
redux:
dependency: "direct main"
description:
name: redux
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
rxdart:
dependency: "direct main"
description:
name: rxdart
url: "https://pub.dartlang.org"
source: hosted
version: "0.23.1"
shelf:
dependency: transitive
description:
name: shelf
url: "https://pub.dartlang.org"
source: hosted
version: "0.7.5"
shelf_web_socket:
dependency: transitive
description:
name: shelf_web_socket
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.3"
sky_engine:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
source_gen:
dependency: transitive
description:
name: source_gen
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.5"
source_span:
dependency: transitive
description:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0-nullsafety"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety"
stream_transform:
dependency: transitive
description:
name: stream_transform
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19-nullsafety"
timing:
dependency: transitive
description:
name: timing
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.1+2"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.2"
uuid:
dependency: "direct main"
description:
name: uuid
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.2"
watcher:
dependency: transitive
description:
name: watcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.7+15"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
yaml:
dependency: transitive
description:
name: yaml
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.1"
sdks:
dart: ">=2.10.0-0.0.dev <2.10.0"
flutter: ">=1.16.0"
name: benckmark
description: A new Flutter application showing different kinds of state management.
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
get: 2.12.5-beta
bloc: ^4.0.0
equatable: ^1.0.2
flutter_bloc: ^4.0.0
flutter_mobx: ^0.3.6
flutter_redux: ^0.6.0
meta:
mobx: ^0.4.0+1
provider: ^4.0.1
redux: ^4.0.0
rxdart: ^0.23.1
uuid: ^2.0.4
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: ^1.7.3
mobx_codegen: ^0.4.0+1
# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.io/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.io/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.io/custom-fonts/#from-packages
\ No newline at end of file
// This is a basic Flutter widget test.
// To perform an interaction with a widget in your test, use the WidgetTester utility that Flutter
// provides. For example, you can send tap and scroll gestures. You can also use WidgetTester to
// find child widgets in the widget tree, read text, and verify that the values of widget properties
// are correct.
import 'package:flutter/material.dart';
import 'package:benckmark/_redux/app.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(App());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
- [Simple Instance Manager](#simple-instance-manager)
- [Options](#options)
- [Bindings](#bindings)
- [How to use](#how-to-use)
- [SmartManagement](#smartmanagement)
## Simple Instance Manager
# Dependency Management
- [Dependency Management](#dependency-management)
- [Usage](#usage)
- [Instancing methods](#instancing-methods)
- [Get.put()](#getput)
- [Get.lazyPut](#getlazyput)
- [Get.putAsync](#getputasync)
- [Get.create](#getcreate)
- [Differences between methods:](#differences-between-methods)
- [Bindings](#bindings)
- [How to use](#how-to-use)
- [BindingsBuilder](#bindingsbuilder)
- [SmartManagement](#smartmanagement)
- [SmartManagement.full](#smartmanagementfull)
- [SmartManagement.onlyBuilders](#smartmanagementonlybuilders)
- [SmartManagement.keepFactory](#smartmanagementkeepfactory)
- [How bindings work under the hood](#how-bindings-work-under-the-hood)
- [Notes](#notes)
Get has a simple and powerful dependency manager that allows you to retrieve the same class as your Bloc or Controller with just 1 lines of code, no Provider context, no inheritedWidget:
... ... @@ -12,21 +23,13 @@ Get has a simple and powerful dependency manager that allows you to retrieve the
Controller controller = Get.put(Controller()); // Rather Controller controller = Controller();
```
- Note: If you are using Get's State Manager, pay more attention to the bindings api, which will make easier to connect your view to your controller.
Instead of instantiating your class within the class you are using, you are instantiating it within the Get instance, which will make it available throughout your App.
So you can use your controller (or Bloc class) normally
**Tip:** Get dependency management is decloupled from other parts of the package, so if for example your app is already using a state manager (any one, it doesn't matter), you don't need to rewrite it all, you can use this dependency injection with no problems at all
```dart
controller.fetchApi();
```
Imagine that you have navigated through numerous routes, and you need a data that was left behind in your controller, you would need a state manager combined with the Provider or Get_it, correct? Not with Get. You just need to ask Get to "find" for your controller, you don't need any additional dependencies:
```dart
Controller controller = Get.find();
Controller controller = Get.find(); // or final controller = Get.find<Controlelr>();
//Yes, it looks like Magic, Get will find your controller, and will deliver it to you. You can have 1 million controllers instantiated, Get will always give you the right controller.
```
... ... @@ -36,24 +39,27 @@ And then you will be able to recover your controller data that was obtained back
Text(controller.textFromApi);
```
Looking for lazy loading? You can declare all your controllers, and it will be called only when someone needs it. You can do this with:
It is possible to lazyLoad a dependency so that it will be instantiated only when is used. Very useful for computational expensive classes or when you know you will not gonna use that class at that time.
```dart
Get.lazyPut<Service>(()=> ApiMock());
/// ApiMock will only be called when someone uses Get.find<Service> for the first time
Get.lazyPut<ApiMock>(() => ApiMock());
/// ApiMock will only be called when someone uses Get.find<ApiMock> for the first time
```
If you want to register an asynchronous instance, you can use Get.putAsync.
If you want to register an asynchronous instance, you can use `Get.putAsync`:
```dart
Get.putAsync<SharedPreferences>(() async {
final prefs = await SharedPreferences.getInstance();
await prefs.setInt('counter', 12345);
return prefs;
final prefs = await SharedPreferences.getInstance();
await prefs.setInt('counter', 12345);
return prefs;
});
```
usage:
- Note: If you are using Get's State Manager, pay more attention to the [Bindings](#bindings) api, which will make easier to connect your view to your controller.
- Note²: Get dependency management is decloupled from other parts of the package, so if for example your app is already using a state manager (any one, it doesn't matter), you don't need to change that, you can use this dependency injection manager with no problems at all
## Usage
```dart
int count = Get.find<SharedPreferences>().getInt('counter');
... ... @@ -70,12 +76,14 @@ Get.delete<Controller>();
Although Getx already delivers very good settings for use, it is possible to refine them even more so that it become more useful to the programmer. The methods and it's configurable parameters are:
- Get.put():
### Get.put()
The most common way of inserting a dependency. Good for the controllers of your views for example.
```dart
Get.put<S>(
// mandatory: the class that you want to get to save, like a controller or anything
// note: that "S" means that it can be anything
// note: "S" means that it can be a class of any type
S dependency
// optional: this is for when you want multiple classess that are of the same type
... ... @@ -96,16 +104,22 @@ Get.put<S>(
bool overrideAbstract = false,
// optional: allows you to create the dependency using function instead of the dependency itself.
// this one is not commonly used
InstanceBuilderCallback<S> builder,
)
// Example:
Get.put<LoginController>(LoginController(), permanent: true)
```
- Get.lazyPut:
### Get.lazyPut
With lazyPut, the dependency will be only instantiated when it's called. This is particularly useful if you want to instantiate several classes in just one place, but don't need that instances immediatly
```dart
Get.lazyPut<S>(
// mandatory: a method that will be executed when your class is called for the first time
// Example: Get.lazyPut<Controller>( () => Controller() )
InstanceBuilderCallback builder,
// optional: same as Get.put(), it is used for when you want multiple different instance of a same class
... ... @@ -119,15 +133,29 @@ Get.lazyPut<S>(
bool fenix = false
)
// example
Get.lazyPut<FirebaseAuth>(
() => {
// ... some logic if needed
return FirebaseAuth()
},
tag: Math.random().toString(),
fenix: true
)
// example 2:
Get.lazyPut<Controller>( () => Controller() )
```
- Get.putAsync:
### Get.putAsync
Since `Get.put()` does not support async methods/classes, you need to use Get.putAsync. The way of declare is equal to Get.lazyPut
```dart
Get.putAsync<S>(
// mandatory: an async method that will be executed to instantiate your class
// Example: Get.putAsync<YourAsyncClass>( () async => await YourAsyncClass() )
AsyncInstanceBuilderCallback<S> builder,
// optional: same as Get.put(), it is used for when you want multiple different instance of a same class
... ... @@ -137,9 +165,15 @@ Get.putAsync<S>(
// optional: same as in Get.put(), used when you need to maintain that instance alive in the entire app
// defaults to false
bool permanent = false
)
// Example
Get.putAsync<YourAsyncClass>( () async => await YourAsyncClass() )
```
- Get.create:
### Get.create
This one is tricky. A detailed explanation of what this is and the differences between the other one can be found on [Differences between methods:](#differences-between-methods) section
```dart
Get.create<S>(
... ... @@ -160,19 +194,19 @@ Get.create<S>(
bool permanent = true
```
### Diferences between methods:
## Differences between methods
First, let's of the `fenix` of Get.lazyPut and the `permanent` of the other methods.
The fundamental difference between `permanent` and `fenix` is how you want to store your instances.
Reinforcing: by default, GetX deletes instances when they are not is use.
It means that: If screen 1 has controller 1 and screen 2 has controller 2 and you remove the first route from stack, (like if you use `Get.off()` or `Get.offName()`) the controller 1 lost it's use so it will be erased.
But if you want to opt to `permanent:true`, then the controller will not be lost in this transition - which is very usefult for services that you want to keep alive thoughout the entire application.
`fenix` in the other hand is for services that you don't worry in losing between screen changes, but when you need that service, you expect that it is alive. So basically, it will dispose the unused controller/service/class, but when you need that, it will "recreate from the ashes" a new instance.
But if you want to opt for using `permanent:true`, then the controller will not be lost in this transition - which is very useful for services that you want to keep alive throughout the entire application.
`fenix` in the other hand is for services that you don't worry in losing between screen changes, but when you need that service, you expect that it is alive. So basically, it will dispose the unused controller/service/class, but when you need it, it will "recreate from the ashes" a new instance.
Proceeding with the differences between methods:
Proceeding with the differences between methods:
- Get.put and Get.putAsync follow the same creation order, with the difference that asyn opt for applying a asynchronous method: those two methods create and initialize the instance. That one is inserted directly in the memory, using the internal method `insert` with the parameters `permanent: false` and `isSingleton: true` (this isSingleton parameter only porpuse is to tell if it is to use the dependency on `dependency` or if it is to use the dependency on `FcBuilderFunc`). After that, `Get.find()` is called that immediately initialize the instances that are on memory.
- Get.put and Get.putAsync follow the same creation order, with the difference that the second uses an asynchronous method: those two methods create and initialize the instance. That one is inserted directly in the memory, using the internal method `insert` with the parameters `permanent: false` and `isSingleton: true` (this isSingleton parameter only porpuse is to tell if it is to use the dependency on `dependency` or if it is to use the dependency on `FcBuilderFunc`). After that, `Get.find()` is called that immediately initialize the instances that are on memory.
- Get.create: As the name implies, it will "create" your dependency! Similar to `Get.put()`, it also call the internal method `insert` to instancing. But `permanent` became true and `isSingleton` became false (since we are "creating" our dependency, there is no way for it to be a singleton instace, that's why is false). And because it has `permanent: true`, we have by default the benefit of not losing it between screens! Also, `Get.find()` is not called immediately, it wait to be used in the screen to be called. It is created this way to make use of the parameter `permanent`, since then, worth noticing, `Get.create()` was made with the goal of create not shared instances, but don't get disposed, like for example a button in a listView, that you want a unique instance for that list - because of that, Get.create must be used together with GetWidget.
... ... @@ -193,19 +227,24 @@ In addition, the Binding class will allow you to have SmartManager configuration
- Create a class and implements Binding
```dart
class HomeBinding implements Bindings {
}
class HomeBinding implements Bindings {}
```
Your IDE will automatically ask you to override the "dependencies" method, and you just need to click on the lamp, override the method, and insert all the classes you are going to use on that route:
```dart
class HomeBinding implements Bindings{
class HomeBinding implements Bindings {
@override
void dependencies() {
Get.lazyPut<ControllerX>(() => ControllerX());
Get.lazyPut<Service>(()=> Api());
Get.lazyPut<HomeController>(() => HomeController());
Get.put<Service>(()=> Api());
}
}
class DetailsBinding implements Bindings {
@override
void dependencies() {
Get.lazyPut<DetailsController>(() => DetailsController());
}
}
```
... ... @@ -215,15 +254,25 @@ Now you just need to inform your route, that you will use that binding to make t
- Using named routes:
```dart
namedRoutes: {
'/': GetRoute(Home(), binding: HomeBinding())
}
getPages: [
GetPage(
name: '/',
page: () => HomeView(),
binding: HomeBinding(),
),
GetPage(
name: '/details',
page: () => DetailsView(),
binding: DetailsBinding(),
),
];
```
- Using normal routes:
```dart
Get.to(Home(), binding: HomeBinding());
Get.to(DetailsView(), binding: DetailsBinding())
```
There, you don't have to worry about memory management of your application anymore, Get will do it for you.
... ... @@ -237,17 +286,69 @@ GetMaterialApp(
);
```
## SmartManagement
### BindingsBuilder
The default way of creating a binding creating a class that implements Bindings.
But alternatively, you can use `BindingsBuilder` callback so that you can simply use a function to instantiate whatever you desire.
Example:
```dart
getPages: [
GetPage(
name: '/',
page: () => HomeView(),
binding: BindingsBuilder(() => {
Get.lazyPut<ControllerX>(() => ControllerX());
Get.put<Service>(()=> Api());
}),
),
GetPage(
name: '/details',
page: () => DetailsView(),
binding: BindingsBuilder(() => {
Get.lazyPut<DetailsController>(() => DetailsController());
}),
),
];
```
That way you can avoid to create one Binding class for each route making this even simpler.
Both ways of doing work perfectly fine and we want you to use what most suit your tastes.
### SmartManagement
GetX by default disposes unused controllers from memory, even if a failure occurs and a widget that uses it is not properly disposed.
This is what is called the `full` mode of dependency management.
But if you want to change the way GetX controls the disposal of classes, you have `SmartManagement` class that you can set different behaviors.
#### SmartManagement.full
It is the default one. Dispose classes that are not being used and were not set to be permanent. In the majority of the cases you will want to keep this config untouched. If you new to GetX then don't change this.
#### SmartManagement.onlyBuilders
With this option, only controllers started in `init:` or loaded into a Binding with `Get.lazyPut` will be disposed.
If you use `Get.put()` or `Get.putAsync()` or any other approach, SmartManagement will not have permissions to exclude this dependency.
Always prefer to use standard SmartManagement (full), you do not need to configure anything for that, Get already gives it to you by default. It will surely eliminate all your disused controllers from memory, as its refined control removes the dependency, even if a failure occurs and a widget that uses it is not properly disposed.
The "full" mode is also safe enough to be used with StatelessWidget, as it has numerous security callbacks that will prevent a controller from remaining in memory if it is not being used by any widget, and disposition is not important here. However, if you are bothered by the default behavior, or just don't want it to happen, Get offers other, more lenient options for intelligent memory management, such as SmartManagement.onlyBuilders, which will depend on the effective removal of widgets using the controller. tree to remove it, and you can prevent a controller from being deployed using "autoRemove: false" in your GetBuilder/GetX.
With this option, only controllers started in "init:" or loaded into a Binding with "Get.lazyPut" will be disposed, if you use Get.put or any other approach, SmartManagement will not have permissions to exclude this dependency.
With the default behavior, even widgets instantiated with "Get.put" will be removed, unlike SmartManagement.onlyBuilders.
SmartManagement.keepFactory is like SmartManagement.full, with one difference. SmartManagement.full purges the factories from the premises, so that Get.lazyPut() will only be able to be called once and your factory and references will be self-destructing. SmartManagement.keepFactory will remove its dependencies when necessary, however, it will keep the "shape" of these, to make an equal one if you need an instance of that again.
Instead of using SmartManagement.keepFactory you can use Bindings.
Bindings creates transitory factories, which are created the moment you click to go to another screen, and will be destroyed as soon as the screen-changing animation happens. It is so little time that the analyzer will not even be able to register it. When you navigate to this screen again, a new temporary factory will be called, so this is preferable to using SmartManagement.keepFactory, but if you don't want to create Bindings, or want to keep all your dependencies on the same Binding, it will certainly help you . Factories take up little memory, they don't hold instances, but a function with the "shape" of that class you want. This is very little, but since the purpose of this lib is to get the maximum performance possible using the minimum resources, Get removes even the factories by default. Use whichever is most convenient for you.
- NOTE: DO NOT USE SmartManagement.keepFactory if you are using multiple Bindings. It was designed to be used without Bindings, or with a single Binding linked in the GetMaterialApp's initialBinding.
#### SmartManagement.keepFactory
Just like SmartManagement.full, it will remove it's dependencies when it's not being used anymore. However, it will keep the their factory, which means it will recreate the dependency if you need that instance again.
### How bindings work under the hood
Bindings creates transitory factories, which are created the moment you click to go to another screen, and will be destroyed as soon as the screen-changing animation happens.
This happens so fast that the analyzer will not even be able to register it.
When you navigate to this screen again, a new temporary factory will be called, so this is preferable to using SmartManagement.keepFactory, but if you don't want to create Bindings, or want to keep all your dependencies on the same Binding, it will certainly help you.
Factories take up little memory, they don't hold instances, but a function with the "shape" of that class you want.
This has a very low cost in memory, but since the purpose of this lib is to get the maximum performance possible using the minimum resources, Get removes even the factories by default.
Use whichever is most convenient for you.
## Notes
- DO NOT USE SmartManagement.keepFactory if you are using multiple Bindings. It was designed to be used without Bindings, or with a single Binding linked in the GetMaterialApp's initialBinding.
- NOTE2: Using Bindings is completely optional, you can use Get.put() and Get.find() on classes that use a given controller without any problem.
However, if you work with Services or any other abstraction, I recommend using Bindings for a larger organization.
- Using Bindings is completely optional, if you want you can use `Get.put()` and `Get.find()` on classes that use a given controller without any problem.
However, if you work with Services or any other abstraction, I recommend using Bindings for a better organization.
... ...
... ... @@ -130,8 +130,8 @@ final isLogged = false.obs;
final count = 0.obs;
final balance = 0.0.obs;
final number = 0.obs;
final items = <String>[];
final myMap = <String, int>{};
final items = <String>[].obs;
final myMap = <String, int>{}.obs;
// Custom classes - it can be any class, literally
final user = User().obs;
... ...
... ... @@ -221,9 +221,9 @@ Ahora solo necesita informar su ruta, que utilizará ese binding para establecer
- Uso de rutas nombradas:
```dart
namedRoutes: {
'/': GetRoute(Home(), binding: HomeBinding())
}
getPages: [
GetPage(name: '/', page: () => Home(), binding: HomeBinding()),
]
```
- Usando rutas normales:
... ...
... ... @@ -215,9 +215,9 @@ Agora você só precisa informar sua rota que você vai usar esse binding para f
Usando rotas nomeadas
```dart
namedRoutes: {
'/': GetRoute(Home(), binding: HomeBinding())
}
getPages: [
GetPage(name: '/', page: () => Home(), binding: HomeBinding()),
]
```
Usando rotas normais:
... ...
... ... @@ -237,11 +237,11 @@ void main() {
runApp(
GetMaterialApp(
initialRoute: '/',
namedRoutes: {
'/': GetRoute(page: MyHomePage()),
'/login': GetRoute(page: Login()),
'/cadastro': GetRoute(page: Cadastro(),transition: Transition.cupertino);
},
getPages: [
GetPage(name: '/', page: () => Home()),
GetPage(name: '/login', page: () => Login()),
GetPage(name: '/cadastro', page: () => Cadastro(), transition: Transition.cupertino),
]
)
);
}
... ... @@ -283,15 +283,15 @@ Você também pode receber parâmetros nomeados com o Get facilmente:
void main() => runApp(
GetMaterialApp(
initialRoute: '/',
namedRoutes: {
'/': GetRoute(page: MyHomePage()),
getPages: [
GetPage(name: '/', page: () => Home()),
/// Importante! ':user' não é uma nova rota, é somente uma
/// especificação do parâmentro. Não use '/segunda/:user/' e '/segunda'
/// se você precisa de uma nova rota para o user, então
/// use '/segunda/user/:user' se '/segunda' for uma rota
'/segunda/:user': GetRoute(page: Segunda()), // recebe a ID
'/terceira': GetRoute(page: Terceira(),transition: Transition.cupertino);
},
GetPage(name: '/segunda/:user', page: () => Segunda()), // recebe a ID
GetPage(name: '/terceira', page: () => Terceira(), transition: Transition.cupertino),
]
),
);
```
... ... @@ -489,7 +489,7 @@ Navigator(
initialRoute: '/',
onGenerateRoute: (settings) {
if (settings.name == '/') {
return GetRouteBase(
return GetPageRoute(
page: Scaffold(
appBar: AppBar(
title: Text("Principal"),
... ... @@ -506,7 +506,7 @@ Navigator(
),
);
} else if (settings.name == '/segunda') {
return GetRouteBase(
return GetPageRoute(
page: Center(
child: Scaffold(
appBar: AppBar(
... ...
... ... @@ -8,8 +8,8 @@ This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
- [Lab: Write your first Flutter app](https://flutter.dev/documentation/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/documentation/cookbook)
For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
... ...
sdk.dir=/home/jonny/Android/Sdk
flutter.sdk=/opt/flutter
flutter.buildMode=debug
flutter.versionName=1.0.0
flutter.versionCode=1
\ No newline at end of file
... ... @@ -73,7 +73,7 @@ packages:
path: ".."
relative: true
source: path
version: "3.6.3"
version: "3.7.0"
http_parser:
dependency: transitive
description:
... ...
... ... @@ -30,18 +30,6 @@ class RxList<E> implements List<E>, RxInterface<List<E>> {
StreamController<List<E>> subject = StreamController<List<E>>.broadcast();
Map<Stream<List<E>>, StreamSubscription> _subscriptions = Map();
/// Adds [item] only if [condition] resolves to true.
void addIf(condition, E item) {
if (condition is Condition) condition = condition();
if (condition is bool && condition) add(item);
}
/// Adds all [items] only if [condition] resolves to true.
void addAllIf(condition, Iterable<E> items) {
if (condition is Condition) condition = condition();
if (condition is bool && condition) addAll(items);
}
operator []=(int index, E val) {
_list[index] = val;
subject.add(_list);
... ... @@ -64,31 +52,47 @@ class RxList<E> implements List<E>, RxInterface<List<E>> {
subject.add(_list);
}
@override
void addAll(Iterable<E> item) {
_list.addAll(item);
subject.add(_list);
}
/// Adds only if [item] is not null.
/// Add [item] to [List<E>] only if [item] is not null.
void addNonNull(E item) {
if (item != null) add(item);
}
/// Adds only if [item] is not null.
/// Add [Iterable<E>] to [List<E>] only if [Iterable<E>] is not null.
void addAllNonNull(Iterable<E> item) {
if (item != null) addAll(item);
}
/// Add [item] to [List<E>] only if [condition] is true.
void addIf(dynamic condition, E item) {
if (condition is Condition) condition = condition();
if (condition is bool && condition) add(item);
}
/// Adds [Iterable<E>] to [List<E>] only if [condition] is true.
void addAllIf(dynamic condition, Iterable<E> items) {
if (condition is Condition) condition = condition();
if (condition is bool && condition) addAll(items);
}
@override
void insert(int index, E item) {
_list.insert(index, item);
subject.add(_list);
}
@override
void insertAll(int index, Iterable<E> iterable) {
_list.insertAll(index, iterable);
subject.add(_list);
}
@override
int get length => value.length;
/// Removes an item from the list.
... ... @@ -96,6 +100,7 @@ class RxList<E> implements List<E>, RxInterface<List<E>> {
/// This is O(N) in the number of items in the list.
///
/// Returns whether the item was present in the list.
@override
bool remove(Object item) {
bool hasRemoved = _list.remove(item);
if (hasRemoved) {
... ... @@ -104,38 +109,45 @@ class RxList<E> implements List<E>, RxInterface<List<E>> {
return hasRemoved;
}
@override
E removeAt(int index) {
E item = _list.removeAt(index);
subject.add(_list);
return item;
}
@override
E removeLast() {
E item = _list.removeLast();
subject.add(_list);
return item;
}
@override
void removeRange(int start, int end) {
_list.removeRange(start, end);
subject.add(_list);
}
@override
void removeWhere(bool Function(E) test) {
_list.removeWhere(test);
subject.add(_list);
}
@override
void clear() {
_list.clear();
subject.add(_list);
}
@override
void sort([int compare(E a, E b)]) {
_list.sort();
subject.add(_list);
}
@override
close() {
_subscriptions.forEach((observable, subscription) {
subscription.cancel();
... ... @@ -196,210 +208,219 @@ class RxList<E> implements List<E>, RxInterface<List<E>> {
stream.listen((va) => value = va);
@override
E get first => _list.first;
E get first => value.first;
@override
E get last => _list.last;
E get last => value.last;
@override
bool any(bool Function(E) test) {
return _list.any(test);
return value.any(test);
}
@override
Map<int, E> asMap() {
return _list.asMap();
return value.asMap();
}
@override
List<R> cast<R>() {
return _list.cast<R>();
return value.cast<R>();
}
@override
bool contains(Object element) {
return _list.contains(element);
return value.contains(element);
}
@override
E elementAt(int index) {
return _list.elementAt(index);
return value.elementAt(index);
}
@override
bool every(bool Function(E) test) {
return _list.every(test);
return value.every(test);
}
@override
Iterable<T> expand<T>(Iterable<T> Function(E) f) {
return _list.expand(f);
return value.expand(f);
}
@override
void fillRange(int start, int end, [E fillValue]) {
_list.fillRange(start, end, fillValue);
subject.add(_list);
}
@override
E firstWhere(bool Function(E) test, {E Function() orElse}) {
return _list.firstWhere(test, orElse: orElse);
return value.firstWhere(test, orElse: orElse);
}
@override
T fold<T>(T initialValue, T Function(T, E) combine) {
return _list.fold(initialValue, combine);
return value.fold(initialValue, combine);
}
@override
Iterable<E> followedBy(Iterable<E> other) {
return _list.followedBy(other);
return value.followedBy(other);
}
@override
void forEach(void Function(E) f) {
_list.forEach(f);
value.forEach(f);
}
@override
Iterable<E> getRange(int start, int end) {
return _list.getRange(start, end);
return value.getRange(start, end);
}
@override
int indexOf(E element, [int start = 0]) {
return _list.indexOf(element, start);
return value.indexOf(element, start);
}
@override
int indexWhere(bool Function(E) test, [int start = 0]) {
return _list.indexWhere(test, start);
return value.indexWhere(test, start);
}
@override
String join([String separator = ""]) {
return _list.join(separator);
return value.join(separator);
}
@override
int lastIndexOf(E element, [int start]) {
return _list.lastIndexOf(element, start);
return value.lastIndexOf(element, start);
}
@override
int lastIndexWhere(bool Function(E) test, [int start]) {
return _list.lastIndexWhere(test, start);
return value.lastIndexWhere(test, start);
}
@override
E lastWhere(bool Function(E) test, {E Function() orElse}) {
return _list.lastWhere(test, orElse: orElse);
return value.lastWhere(test, orElse: orElse);
}
@override
set length(int newLength) {
_list.length = newLength;
subject.add(_list);
}
@override
Iterable<T> map<T>(T Function(E) f) {
return _list.map(f);
return value.map(f);
}
@override
E reduce(E Function(E, E) combine) {
return _list.reduce(combine);
return value.reduce(combine);
}
@override
void replaceRange(int start, int end, Iterable<E> replacement) {
_list.replaceRange(start, end, replacement);
subject.add(_list);
}
@override
void retainWhere(bool Function(E) test) {
_list.retainWhere(test);
subject.add(_list);
}
@override
Iterable<E> get reversed => _list.reversed;
Iterable<E> get reversed => value.reversed;
@override
void setAll(int index, Iterable<E> iterable) {
_list.setAll(index, iterable);
subject.add(_list);
}
@override
void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) {
_list.setRange(start, end, iterable, skipCount);
subject.add(_list);
}
@override
void shuffle([Random random]) {
_list.shuffle(random);
subject.add(_list);
}
@override
E get single => _list.single;
E get single => value.single;
@override
E singleWhere(bool Function(E) test, {E Function() orElse}) {
return _list.singleWhere(test, orElse: orElse);
return value.singleWhere(test, orElse: orElse);
}
@override
Iterable<E> skip(int count) {
return _list.skip(count);
return value.skip(count);
}
@override
Iterable<E> skipWhile(bool Function(E) test) {
return _list.skipWhile(test);
return value.skipWhile(test);
}
@override
List<E> sublist(int start, [int end]) {
return _list.sublist(start, end);
return value.sublist(start, end);
}
@override
Iterable<E> take(int count) {
return _list.take(count);
return value.take(count);
}
@override
Iterable<E> takeWhile(bool Function(E) test) {
return _list.takeWhile(test);
return value.takeWhile(test);
}
@override
List<E> toList({bool growable = true}) {
return _list.toList(growable: growable);
return value.toList(growable: growable);
}
@override
Set<E> toSet() {
return _list.toSet();
return value.toSet();
}
@override
Iterable<E> where(bool Function(E) test) {
return _list.where(test);
return value.where(test);
}
@override
Iterable<T> whereType<T>() {
return _list.whereType<T>();
return value.whereType<T>();
}
@override
set first(E value) {
_list.first = value;
subject.add(_list);
}
@override
set last(E value) {
_list.last = value;
subject.add(_list);
}
}
... ...
... ... @@ -4,7 +4,7 @@ import '../../../../get.dart';
import '../rx_core/rx_interface.dart';
import '../rx_typedefs/rx_typedefs.dart';
class RxMap<K, V> extends RxInterface<Map<K, V>> implements Map<K, V> {
class RxMap<K, V> implements RxInterface<Map<K, V>>, Map<K, V> {
RxMap([Map<K, V> initial]) {
_value = initial;
}
... ... @@ -111,20 +111,20 @@ class RxMap<K, V> extends RxInterface<Map<K, V>> implements Map<K, V> {
}
@override
Map<K2, V2> cast<K2, V2>() => _value.cast<K2, V2>();
Map<K2, V2> cast<K2, V2>() => value.cast<K2, V2>();
@override
bool containsKey(Object key) => _value.containsKey(key);
bool containsKey(Object key) => value.containsKey(key);
@override
bool containsValue(Object value) => _value.containsValue(value);
@override
Iterable<MapEntry<K, V>> get entries => _value.entries;
Iterable<MapEntry<K, V>> get entries => value.entries;
@override
void forEach(void Function(K, V) f) {
_value.forEach(f);
value.forEach(f);
}
@override
... ... @@ -134,7 +134,7 @@ class RxMap<K, V> extends RxInterface<Map<K, V>> implements Map<K, V> {
bool get isNotEmpty => value.isNotEmpty;
@override
Iterable<K> get keys => _value.keys;
Iterable<K> get keys => value.keys;
@override
int get length => value.length;
... ...
... ... @@ -8,10 +8,10 @@ import '../rx_typedefs/rx_typedefs.dart';
class RxSet<E> implements Set<E>, RxInterface<Set<E>> {
RxSet([Set<E> initial]) {
_list = initial;
_set = initial;
}
RxSet<E> _list = Set<E>();
RxSet<E> _set = Set<E>();
@override
Iterator<E> get iterator => value.iterator;
... ... @@ -42,28 +42,28 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> {
}
operator []=(int index, E val) {
_list[index] = val;
subject.add(_list);
_set[index] = val;
subject.add(_set);
}
/// Special override to push() element(s) in a reactive way
/// inside the List,
RxSet<E> operator +(Iterable<E> val) {
addAll(val);
subject.add(_list);
subject.add(_set);
return this;
}
@override
bool add(E value) {
final val = _list.add(value);
subject.add(_list);
final val = _set.add(value);
subject.add(_set);
return val;
}
void addAll(Iterable<E> item) {
_list.addAll(item);
subject.add(_list);
_set.addAll(item);
subject.add(_set);
}
/// Adds only if [item] is not null.
... ... @@ -77,13 +77,13 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> {
}
void insert(int index, E item) {
_list.insert(index, item);
subject.add(_list);
_set.insert(index, item);
subject.add(_set);
}
void insertAll(int index, Iterable<E> iterable) {
_list.insertAll(index, iterable);
subject.add(_list);
_set.insertAll(index, iterable);
subject.add(_set);
}
int get length => value.length;
... ... @@ -94,43 +94,43 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> {
///
/// Returns whether the item was present in the list.
bool remove(Object item) {
bool hasRemoved = _list.remove(item);
bool hasRemoved = _set.remove(item);
if (hasRemoved) {
subject.add(_list);
subject.add(_set);
}
return hasRemoved;
}
E removeAt(int index) {
E item = _list.removeAt(index);
subject.add(_list);
E item = _set.removeAt(index);
subject.add(_set);
return item;
}
E removeLast() {
E item = _list.removeLast();
subject.add(_list);
E item = _set.removeLast();
subject.add(_set);
return item;
}
void removeRange(int start, int end) {
_list.removeRange(start, end);
subject.add(_list);
_set.removeRange(start, end);
subject.add(_set);
}
void removeWhere(bool Function(E) test) {
_list.removeWhere(test);
subject.add(_list);
_set.removeWhere(test);
subject.add(_set);
}
void clear() {
_list.clear();
subject.add(_list);
_set.clear();
subject.add(_set);
}
void sort([int compare(E a, E b)]) {
_list.sort();
subject.add(_list);
_set.sort();
subject.add(_set);
}
close() {
... ... @@ -149,7 +149,7 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> {
void update(void fn(Iterable<E> value)) {
fn(value);
subject.add(_list);
subject.add(_set);
}
/// Replaces all existing items of this list with [items]
... ... @@ -163,7 +163,7 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> {
if (getObs != null) {
getObs.addListener(subject.stream);
}
return _list;
return _set;
}
String get string => value.toString();
... ... @@ -178,9 +178,9 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> {
}
set value(Iterable<E> val) {
if (_list == val) return;
_list = val;
subject.add(_list);
if (_set == val) return;
_set = val;
subject.add(_set);
}
Stream<Set<E>> get stream => subject.stream;
... ... @@ -193,167 +193,170 @@ class RxSet<E> implements Set<E>, RxInterface<Set<E>> {
stream.listen((va) => value = va);
@override
E get first => _list.first;
E get first => value.first;
@override
E get last => _list.last;
E get last => value.last;
@override
bool any(bool Function(E) test) {
return _list.any(test);
return value.any(test);
}
@override
Set<R> cast<R>() {
return _list.cast<R>();
return value.cast<R>();
}
@override
bool contains(Object element) {
return _list.contains(element);
return value.contains(element);
}
@override
E elementAt(int index) {
return _list.elementAt(index);
return value.elementAt(index);
}
@override
bool every(bool Function(E) test) {
return _list.every(test);
return value.every(test);
}
@override
Iterable<T> expand<T>(Iterable<T> Function(E) f) {
return _list.expand(f);
return value.expand(f);
}
@override
E firstWhere(bool Function(E) test, {E Function() orElse}) {
return _list.firstWhere(test, orElse: orElse);
return value.firstWhere(test, orElse: orElse);
}
@override
T fold<T>(T initialValue, T Function(T, E) combine) {
return _list.fold(initialValue, combine);
return value.fold(initialValue, combine);
}
@override
Iterable<E> followedBy(Iterable<E> other) {
return _list.followedBy(other);
return value.followedBy(other);
}
@override
void forEach(void Function(E) f) {
_list.forEach(f);
value.forEach(f);
}
@override
String join([String separator = ""]) {
return _list.join(separator);
return value.join(separator);
}
@override
E lastWhere(bool Function(E) test, {E Function() orElse}) {
return _list.lastWhere(test, orElse: orElse);
return value.lastWhere(test, orElse: orElse);
}
@override
Iterable<T> map<T>(T Function(E) f) {
return _list.map(f);
return value.map(f);
}
@override
E reduce(E Function(E, E) combine) {
return _list.reduce(combine);
return value.reduce(combine);
}
@override
E get single => _list.single;
E get single => value.single;
@override
E singleWhere(bool Function(E) test, {E Function() orElse}) {
return _list.singleWhere(test, orElse: orElse);
return value.singleWhere(test, orElse: orElse);
}
@override
Iterable<E> skip(int count) {
return _list.skip(count);
return value.skip(count);
}
@override
Iterable<E> skipWhile(bool Function(E) test) {
return _list.skipWhile(test);
return value.skipWhile(test);
}
@override
Iterable<E> take(int count) {
return _list.take(count);
return value.take(count);
}
@override
Iterable<E> takeWhile(bool Function(E) test) {
return _list.takeWhile(test);
return value.takeWhile(test);
}
@override
List<E> toList({bool growable = true}) {
return _list.toList(growable: growable);
return value.toList(growable: growable);
}
@override
Set<E> toSet() {
return _list.toSet();
return value.toSet();
}
@override
Iterable<E> where(bool Function(E) test) {
return _list.where(test);
return value.where(test);
}
@override
Iterable<T> whereType<T>() {
return _list.whereType<T>();
return value.whereType<T>();
}
@override
bool containsAll(Iterable<Object> other) {
return _list.containsAll(other);
return value.containsAll(other);
}
@override
Set<E> difference(Set<Object> other) {
return _list.difference(other);
return value.difference(other);
}
@override
Set<E> intersection(Set<Object> other) {
return _list.intersection(other);
return value.intersection(other);
}
@override
E lookup(Object object) {
return _list.lookup(object);
return value.lookup(object);
}
@override
void removeAll(Iterable<Object> elements) {
_list.removeAll(elements);
_set.removeAll(elements);
subject.add(_set);
}
@override
void retainAll(Iterable<Object> elements) {
_list.retainAll(elements);
_set.retainAll(elements);
subject.add(_set);
}
@override
void retainWhere(bool Function(E) E) {
_list.retainWhere(E);
_set.retainWhere(E);
subject.add(_set);
}
@override
Set<E> union(Set<E> other) {
return _list.union(other);
return value.union(other);
}
}
... ...
... ... @@ -3,26 +3,6 @@ import '../regex/get_utils.dart';
extension GetDynamicUtils on dynamic {
/// It's This is overloading the IDE's options. Only the most useful and popular options will stay here.
/// In dart2js (in flutter v1.17) a var by default is undefined.
/// *Use this only if you are in version <- 1.17*.
/// So we assure the null type in json convertions to avoid the "value":value==null?null:value;
/// someVar.nil will force the null type if the var is null or undefined.
/// `nil` taken from ObjC just to have a shorter sintax.
dynamic get nil => GetUtils.nil(this);
bool get isNull => GetUtils.isNull(this);
bool get isNullOrBlank => GetUtils.isNullOrBlank(this);
// bool get isOneAKind => GetUtils.isOneAKind(this);
// bool isLengthLowerThan(int maxLength) =>
// GetUtils.isLengthLowerThan(this, maxLength);
// bool isLengthGreaterThan(int maxLength) =>
// GetUtils.isLengthGreaterThan(this, maxLength);
// bool isLengthGreaterOrEqual(int maxLength) =>
// GetUtils.isLengthGreaterOrEqual(this, maxLength);
// bool isLengthLowerOrEqual(int maxLength) =>
// GetUtils.isLengthLowerOrEqual(this, maxLength);
// bool isLengthEqualTo(int maxLength) =>
// GetUtils.isLengthEqualTo(this, maxLength);
// bool isLengthBetween(int minLength, int maxLength) =>
// GetUtils.isLengthBetween(this, minLength, maxLength);
}
... ...
... ... @@ -482,6 +482,4 @@ class GetUtils {
static bool hasMatch(String s, Pattern p) =>
(s == null) ? false : RegExp(p).hasMatch(s);
}
... ...
name: get
description: Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with GetX.
version: 3.6.3
version: 3.7.0
homepage: https://github.com/jonataslaw/get
environment:
... ...
@TestOn('vm')
import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
import 'package:get/src/utils/platform/platform_web.dart';
import 'package:get/src/utils/platform/platform.dart';
void main() {
test('Platform test', () {
... ... @@ -13,12 +12,5 @@ void main() {
expect(GetPlatform.isMacOS, Platform.isMacOS);
expect(GetPlatform.isWindows, Platform.isWindows);
expect(GetPlatform.isWeb, false);
expect(GeneralPlatform.isWeb, true);
expect(GeneralPlatform.isAndroid, false);
expect(GeneralPlatform.isIOS, false);
expect(GeneralPlatform.isFuchsia, false);
expect(GeneralPlatform.isLinux, false);
expect(GeneralPlatform.isMacOS, false);
expect(GeneralPlatform.isWindows, false);
});
}
... ...
@TestOn('browser')
import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/src/utils/platform/platform.dart';
void main() {
test('Platform test', () {
expect(GetPlatform.isAndroid, Platform.isAndroid);
expect(GetPlatform.isIOS, Platform.isIOS);
expect(GetPlatform.isFuchsia, Platform.isFuchsia);
expect(GetPlatform.isLinux, Platform.isLinux);
expect(GetPlatform.isMacOS, Platform.isMacOS);
expect(GetPlatform.isWindows, Platform.isWindows);
expect(GetPlatform.isWeb, true);
});
}
... ...
... ... @@ -11,7 +11,7 @@ void main() {
);
testWidgets(
"GetRoute maintainState null",
"GetPage maintainState null",
(WidgetTester testr) async {
expect(
() => GetPage(page: () => Scaffold(), maintainState: null, name: '/'),
... ... @@ -20,7 +20,7 @@ void main() {
);
testWidgets(
"GetRoute name null",
"GetPage name null",
(WidgetTester testr) async {
expect(
() =>
... ... @@ -30,7 +30,7 @@ void main() {
);
testWidgets(
"GetRoute fullscreenDialog null",
"GetPage fullscreenDialog null",
(WidgetTester testr) async {
expect(
() => GetPage(
... ...