Nipodemos

Merge branch 'master' of git://github.com/jonataslaw/getx into fix-renamed-class

Showing 131 changed files with 1202 additions and 2647 deletions
... ... @@ -6,6 +6,7 @@ labels: ''
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.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
... ...
... ... @@ -29,6 +29,7 @@
- [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)
... ... @@ -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
... ...
... ... @@ -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
... ... @@ -478,7 +478,7 @@ GetMaterialApp(
// pamiętaj że nawet jeśli "enableLog: false" logi i tak będą wysłane w tym callbacku
// Musisz sprawdzić konfiguracje flag jeśli chcesz przez GetConfig.isLogEnable
}
```
## Video tłumaczące inne funkcjonalności GetX
... ...
... ... @@ -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
... ...
# 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 */
<?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);
});
}
... ... @@ -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;
... ...
... ... @@ -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,
... ...
# GetX codelab
In this example you will learn the basics of GetX. You will see how much easier it is to code with this framework, and you will know what problems GetX proposes to solve.
If the default Flutter application were rewritten with Getx, it would have only a few lines of code. The Getx state manager is easier than using setState. You just need to add a ".obs" at the end of your variable, and wrap the widget you want to change within a Obx().
```dart
void main() => runApp(MaterialApp(home: Home()));
class Home extends StatelessWidget {
var count = 0.obs;
@override
Widget build(context) => Scaffold(
appBar: AppBar(title: Text("counter")),
body: Center(
child: Obx(() => Text("$count")),
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: () => count ++,
));
}
```
However, this simple example deals with ephemeral state management. If you need to access this data in several places in your application, you will need global state management.
The most common way to do this is to separate the business logic from its visualization. I know, you've heard this concept before, and it might have been scary for you, but with Getx, it's stupidly simple.
Getx provides you with a class capable of initializing data, and removing it when it is no longer needed, and its use is very simple:
Just create a class by extending GetxController and insert ALL your variables and functions there.
```dart
class Controller extends GetxController {
var count = 0;
void increment() {
count++;
update();
}
}
```
Here you can choose between simple state management, or reactive state management.
The simple one will update its variable on the screen whenever update() is called. It is used with a widget called "GetBuilder".
```dart
class Home extends StatelessWidget {
final controller = Get.put(Controller());
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("counter")),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GetBuilder<Controller>(
builder: (_) => Text(
'clicks: ${controller.count}',
)),
RaisedButton(
child: Text('Next Route'),
onPressed: () {
Get.to(Second());
},
),
],
),
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: controller.increment(),
),
);
}
}
class Second extends StatelessWidget {
final Controller ctrl = Get.find();
@override
Widget build(context){
return Scaffold(body: Center(child: Text("${ctrl.count}")));
}
}
```
When instantiating your controller, you may have noticed that we use `Get.put(Controller())`. This is enough to make your controller available to other pages as long as it is in memory.
You may have noticed that you have a new button using `Get.to(Second())`. This is enough to navigate to another page. You don't need a
```dart
Navigator.of(context).push(context,
MaterialPageRoute(context, builder: (context){
return Second();
},
);
```
all that huge code, it's reduced to a simple `Get.to(Second())`. Isn't that incredible?
You may also have noticed that on the other page you simply used Get.find (), and the framework knows which controller you registered previously, and returns it effortlessly, you don't need to type the find with `Get.find<Controller>()` so that he knows what you need.
However, this is simple state management. You may want to control the output of each change of state, you may want to use and manipulate streams, you may want a variable to only be changed on the screen, when it definitely changes, you may need a debounce on changing the state, and to these and other needs, Getx has powerful, intelligent, and lightweight state management that can address any need, regardless of the size of your project. And its use is even easier than the previous one.
In your controller, you can remove the update method, Getx is reactive, so when a variable changes, it will automatically change on the screen.
You just need to add a ".obs" in front of your variable, and that's it, it's already reactive.
```dart
class Controller extends GetxController {
var count = 0.obs;
void increment() {
count++;
}
}
```
Now you just need to change GetBuilder for GetX and that's it
```dart
class Home extends StatelessWidget {
final controller = Get.put(Controller());
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("counter")),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GetX<Controller>(
builder: (_) => Text(
'clicks: ${controller.count}',
)),
RaisedButton(
child: Text('Next Route'),
onPressed: () {
Get.to(Second());
},
),
],
),
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: controller.increment(),
),
);
}
}
class Second extends StatelessWidget {
final Controller ctrl = Get.find();
@override
Widget build(context){
return Scaffold(body: Center(child: Text("${ctrl.count}")));
}
}
```
GetX is a useful widget when you want to inject the controller into the init property, or when you want to retrieve an instance of the controller within the widget itself. In other cases, you can insert your widget into an Obx, which receives a widget function. This looks much easier and clearer, just like the first example
```dart
class Home extends StatelessWidget {
final controller = Get.put(Controller());
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("counter")),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Obx(() => Text(
'clicks: ${controller.count}',
)),
RaisedButton(
child: Text('Next Route'),
onPressed: () {
Get.to(Second());
},
),
],
),
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: controller.increment(),
),
);
}
}
class Second extends StatelessWidget {
final Controller ctrl = Get.find();
@override
Widget build(context){
return Scaffold(body: Center(child: Text("${ctrl.count}")));
}
}
```
If you are a more demanding user, you must have said: BLoC separates the View from the business logic. But what about the presentation logic? Will I be obliged to attach it to the visualization? Will I be totally dependent on the context for everything I want to do? Will I have to insert a bunch of variables, TextEditingControllers in my view? If I need to hear the Scroll on my screen, do I need to insert an initState and a function into my view? If I need to trigger an action when this scroll reaches the end, do I insert it into the view, or in the bloc/changeNotifier class? Well, these are common architectural questions, and most of the time the solution to them is ugly.
With Getx you have no doubts when your architecture, if you need a function, it must be on your Controller, if you need to trigger an event, it needs to be on your controller, your view is generally a StatelessWidget free from any dirt.
This means that if someone has already done something you’re looking for, you can copy the controller entirely from someone else, and it will work for you, this level of standardization is what Flutter lacked, and it’s because of this that Getx has become so popular in the last few days. Flutter is amazing, and has minor one-off problems. Getx came to solve these specific problems. Flutter provides powerful APIs, and we turn them into an easy, clean, clear, and concise API for you to build applications in a fast, performance and highly scalable way.
If you have already asked yourself some of these questions above, you have certainly found the solution to your problems. Getx is able to completely separate any logic, be it presentation or business, and you will only have pure widgets in your visualization layer. No variables, no functions, just widgets. This will facilitate the work of your team working with the UI, as well as your team working with your logic. They won't depend on initState to do anything, their controller has onInit. Your code can be tested in isolation, the way it is.
But what about dependency injection? Will I have it attached to my visualization?
If you've used any state manager, you've probably heard of "multiAnything", or something like that.
You have probably already inserted dozens of ChangeNotifier or Blocs classes in a widget, just to have it all over the tree.
This level of coupling is yet another problem that Getx came to solve. For this, in this ecosystem we use BINDINGS.
Bindings are dependency injection classes. They are completely outside your widget tree, making your code cleaner, more organized, and allowing you to access it anywhere without context.
You can initialize dozens of controllers in your Bindings, when you need to know what is being injected into your view, just open the Bindings file on your page and that's it, you can clearly see what has been prepared to be initialized in your View.
Bindings is the first step towards having a scalable application, you can visualize what will be injected into your page, and decouple the dependency injection from your visualization layer.
To create a Binding, simply create a class and implement Bindings
```dart
class SampleBind extends Bindings {
@override
void dependencies() {
Get.lazyPut<Controller>(() => Controller());
Get.lazyPut<Controller2>(() => Controller2());
Get.lazyPut<Controller3>(() => Controller3());
}
}
```
You can use with named routes (preferred)
```dart
void main() {
runApp(GetMaterialApp(
initialRoute: '/home',
getPages: [
GetPage(name: '/home', page: () => First(), binding: SampleBind()),
],
));
}
```
Or unnamed
```dart
Get.to(Second(), binding: SampleBind());
```
There is a trick that can clear your View even more.
Instead of extending StatelessWidget, you can extend GetView, which is a StatelessWidget with a "controller" property.
See the example and see how clean your code can be using this approach.
The standard Flutter counter has almost 100 lines, it would be summarized to:
on main.dart
```dart
void main() {
runApp(GetMaterialApp(
initialRoute: '/home',
getPages: [
GetPage(name: '/home', page: () => HomeView(), binding: HomeBinding()),
],
));
}
```
on home_bindings.dart
```dart
class HomeBinding implements Bindings {
@override
void dependencies() {
Get.lazyPut(() => HomeController());
}
}
```
on home_controller.dart
```dart
class HomeController extends GetxController {
var count = 0.obs;
void increment() => count++;
}
```
on home_view.dart
```dart
class Home extends GetView<Controller> {
@override
Widget build(context) => Scaffold(
appBar: AppBar(title: Text("counter")),
body: Center(
child: Obx(() => Text("${controller.counter}")),
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: controller.increment,
));
}
```
What did you do:
He built an example of the counter, (with less code than the original), decoupling its visualization, its business logic, its dependency injection, in a clean, scalable way, facilitating code maintenance and reusability. If you need an accountant on another project, or your developer friend does, you can just share the content of the controller file with him, and everything will work perfectly.
As the view has only widgets, you can use a view for android, and another for iOS, taking advantage of 100% of your business logic, your view has only widgets! you can change them however you want, without affecting your application in any way.
However, some examples like internationalization, Snackbars without context, validators, responsiveness and other Getx resources, were not explored (and it would not even be possible to explore all resources in such a simple example), so below is an example not very complete, but trying demonstrate how to use internationalization, reactive custom classes, reactive lists, snackbars contextless, workers etc.
```dart
import 'package:flutter/material.dart';
import 'package:get/get.dart';
void main() {
runApp(GetMaterialApp(
// It is not mandatory to use named routes, but dynamic urls are interesting.
initialRoute: '/home',
defaultTransition: Transition.native,
translations: MyTranslations(),
locale: Locale('pt', 'BR'),
getPages: [
//Simple GetPage
GetPage(name: '/home', page: () => First()),
// GetPage with custom transitions and bindings
GetPage(
name: '/second',
page: () => Second(),
customTransition: SizeTransitions(),
binding: SampleBind(),
),
// GetPage with default transitions
GetPage(
name: '/third',
transition: Transition.cupertino,
page: () => Third(),
),
],
));
}
class MyTranslations extends Translations {
@override
Map<String, Map<String, String>> get keys => {
'en': {
'title': 'Hello World %s',
},
'en_US': {
'title': 'Hello World from US',
},
'pt': {
'title': 'Olá de Portugal',
},
'pt_BR': {
'title': 'Olá do Brasil',
},
};
}
class Controller extends GetxController {
int count = 0;
void increment() {
count++;
// use update method to update all count variables
update();
}
}
class First extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: IconButton(
icon: Icon(Icons.add),
onPressed: () {
Get.snackbar("Hi", "I'm modern snackbar");
},
),
title: Text("title".trArgs(['John'])),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GetBuilder<Controller>(
init: Controller(),
// You can initialize your controller here the first time. Don't use init in your other GetBuilders of same controller
builder: (_) => Text(
'clicks: ${_.count}',
)),
RaisedButton(
child: Text('Next Route'),
onPressed: () {
Get.toNamed('/second');
},
),
RaisedButton(
child: Text('Change locale to English'),
onPressed: () {
Get.updateLocale(Locale('en', 'UK'));
},
),
],
),
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: () {
Get.find<Controller>().increment();
}),
);
}
}
class Second extends GetView<ControllerX> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('second Route'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GetX<ControllerX>(
// Using bindings you don't need of init: method
// Using Getx you can take controller instance of "builder: (_)"
builder: (_) {
print("count1 rebuild");
return Text('${_.count1}');
},
),
GetX<ControllerX>(
builder: (_) {
print("count2 rebuild");
return Text('${controller.count2}');
},
),
GetX<ControllerX>(builder: (_) {
print("sum rebuild");
return Text('${_.sum}');
}),
GetX<ControllerX>(
builder: (_) => Text('Name: ${controller.user.value.name}'),
),
GetX<ControllerX>(
builder: (_) => Text('Age: ${_.user.value.age}'),
),
RaisedButton(
child: Text("Go to last page"),
onPressed: () {
Get.toNamed('/third', arguments: 'arguments of second');
},
),
RaisedButton(
child: Text("Back page and open snackbar"),
onPressed: () {
Get.back();
Get.snackbar(
'User 123',
'Successfully created',
);
},
),
RaisedButton(
child: Text("Increment"),
onPressed: () {
Get.find<ControllerX>().increment();
},
),
RaisedButton(
child: Text("Increment"),
onPressed: () {
Get.find<ControllerX>().increment2();
},
),
RaisedButton(
child: Text("Update name"),
onPressed: () {
Get.find<ControllerX>().updateUser();
},
),
RaisedButton(
child: Text("Dispose worker"),
onPressed: () {
Get.find<ControllerX>().disposeWorker();
},
),
],
),
),
);
}
}
class Third extends GetView<ControllerX> {
@override
Widget build(BuildContext context) {
return Scaffold(
floatingActionButton: FloatingActionButton(onPressed: () {
controller.incrementList();
}),
appBar: AppBar(
title: Text("Third ${Get.arguments}"),
),
body: Center(
child: Obx(() => ListView.builder(
itemCount: controller.list.length,
itemBuilder: (context, index) {
return Text("${controller.list[index]}");
}))),
);
}
}
class SampleBind extends Bindings {
@override
void dependencies() {
Get.lazyPut<ControllerX>(() => ControllerX());
}
}
class User {
User({this.name = 'Name', this.age = 0});
String name;
int age;
}
class ControllerX extends GetxController {
final count1 = 0.obs;
final count2 = 0.obs;
final list = [56].obs;
final user = User().obs;
updateUser() {
user.update((value) {
value.name = 'Jose';
value.age = 30;
});
}
/// Once the controller has entered memory, onInit will be called.
/// It is preferable to use onInit instead of class constructors or initState method.
/// Use onInit to trigger initial events like API searches, listeners registration
/// or Workers registration.
/// Workers are event handlers, they do not modify the final result,
/// but it allows you to listen to an event and trigger customized actions.
/// Here is an outline of how you can use them:
/// made this if you need cancel you worker
Worker _ever;
@override
onInit() {
/// Called every time the variable $_ is changed
_ever = ever(count1, (_) => print("$_ has been changed (ever)"));
everAll([count1, count2], (_) => print("$_ has been changed (everAll)"));
/// Called first time the variable $_ is changed
once(count1, (_) => print("$_ was changed once (once)"));
/// Anti DDos - Called every time the user stops typing for 1 second, for example.
debounce(count1, (_) => print("debouce$_ (debounce)"),
time: Duration(seconds: 1));
/// Ignore all changes within 1 second.
interval(count1, (_) => print("interval $_ (interval)"),
time: Duration(seconds: 1));
}
int get sum => count1.value + count2.value;
increment() => count1.value++;
increment2() => count2.value++;
disposeWorker() {
_ever.dispose();
// or _ever();
}
incrementList() => list.add(75);
}
class SizeTransitions extends CustomTransition {
@override
Widget buildTransition(
BuildContext context,
Curve curve,
Alignment alignment,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
return Align(
alignment: Alignment.center,
child: SizeTransition(
sizeFactor: CurvedAnimation(
parent: animation,
curve: curve,
),
child: child,
),
);
}
}
```
\ No newline at end of file
... ...
flutter/ephemeral
... ...
cmake_minimum_required(VERSION 3.10)
project(runner LANGUAGES CXX)
set(BINARY_NAME "example")
set(APPLICATION_ID "com.example.example")
cmake_policy(SET CMP0063 NEW)
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
# Configure build options.
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Debug" CACHE
STRING "Flutter build mode" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Profile" "Release")
endif()
# Compilation settings that should be applied to most targets.
function(APPLY_STANDARD_SETTINGS TARGET)
target_compile_features(${TARGET} PUBLIC cxx_std_14)
target_compile_options(${TARGET} PRIVATE -Wall -Werror)
target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
endfunction()
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
# Flutter library and tool build rules.
add_subdirectory(${FLUTTER_MANAGED_DIR})
# System-level dependencies.
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
# Application build
add_executable(${BINARY_NAME}
"main.cc"
"my_application.cc"
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
)
apply_standard_settings(${BINARY_NAME})
target_link_libraries(${BINARY_NAME} PRIVATE flutter)
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
add_dependencies(${BINARY_NAME} flutter_assemble)
# Generated plugin build rules, which manage building the plugins and adding
# them to the application.
include(flutter/generated_plugins.cmake)
# === Installation ===
# By default, "installing" just makes a relocatable bundle in the build
# directory.
set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
endif()
# Start with a clean build bundle directory every time.
install(CODE "
file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
" COMPONENT Runtime)
set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
COMPONENT Runtime)
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
COMPONENT Runtime)
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
if(PLUGIN_BUNDLED_LIBRARIES)
install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
endif()
# Fully re-copy the assets directory on each build to avoid having stale files
# from a previous install.
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
install(CODE "
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
" COMPONENT Runtime)
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
# Install the AOT library on non-Debug builds only.
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
endif()
... ...
cmake_minimum_required(VERSION 3.10)
set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
# Configuration provided via flutter tool.
include(${EPHEMERAL_DIR}/generated_config.cmake)
# TODO: Move the rest of this into files in ephemeral. See
# https://github.com/flutter/flutter/issues/57146.
# Serves the same purpose as list(TRANSFORM ... PREPEND ...),
# which isn't available in 3.10.
function(list_prepend LIST_NAME PREFIX)
set(NEW_LIST "")
foreach(element ${${LIST_NAME}})
list(APPEND NEW_LIST "${PREFIX}${element}")
endforeach(element)
set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
endfunction()
# === Flutter Library ===
# System-level dependencies.
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
pkg_check_modules(BLKID REQUIRED IMPORTED_TARGET blkid)
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
# Published to parent scope for install step.
set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
list(APPEND FLUTTER_LIBRARY_HEADERS
"fl_basic_message_channel.h"
"fl_binary_codec.h"
"fl_binary_messenger.h"
"fl_dart_project.h"
"fl_engine.h"
"fl_json_message_codec.h"
"fl_json_method_codec.h"
"fl_message_codec.h"
"fl_method_call.h"
"fl_method_channel.h"
"fl_method_codec.h"
"fl_method_response.h"
"fl_plugin_registrar.h"
"fl_plugin_registry.h"
"fl_standard_message_codec.h"
"fl_standard_method_codec.h"
"fl_string_codec.h"
"fl_value.h"
"fl_view.h"
"flutter_linux.h"
)
list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
add_library(flutter INTERFACE)
target_include_directories(flutter INTERFACE
"${EPHEMERAL_DIR}"
)
target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
target_link_libraries(flutter INTERFACE
PkgConfig::GTK
PkgConfig::GLIB
PkgConfig::GIO
PkgConfig::BLKID
)
add_dependencies(flutter flutter_assemble)
# === Flutter tool backend ===
# _phony_ is a non-existent file to force this command to run every time,
# since currently there's no way to get a full input/output list from the
# flutter tool.
add_custom_command(
OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
${CMAKE_CURRENT_BINARY_DIR}/_phony_
COMMAND ${CMAKE_COMMAND} -E env
${FLUTTER_TOOL_ENVIRONMENT}
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
linux-x64 ${CMAKE_BUILD_TYPE}
)
add_custom_target(flutter_assemble DEPENDS
"${FLUTTER_LIBRARY}"
${FLUTTER_LIBRARY_HEADERS}
)
... ...
... ... @@ -2,11 +2,8 @@
// Generated file. Do not edit.
//
#import "GeneratedPluginRegistrant.h"
#include "generated_plugin_registrant.h"
@implementation GeneratedPluginRegistrant
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry {
void fl_register_plugins(FlPluginRegistry* registry) {
}
@end
... ...
//
// Generated file. Do not edit.
//
#ifndef GENERATED_PLUGIN_REGISTRANT_
#define GENERATED_PLUGIN_REGISTRANT_
#include <flutter_linux/flutter_linux.h>
// Registers Flutter plugins.
void fl_register_plugins(FlPluginRegistry* registry);
#endif // GENERATED_PLUGIN_REGISTRANT_
... ...
#
# Generated file, do not edit.
#
list(APPEND FLUTTER_PLUGIN_LIST
)
set(PLUGIN_BUNDLED_LIBRARIES)
foreach(plugin ${FLUTTER_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin)
... ...
#include "my_application.h"
int main(int argc, char** argv) {
// Only X11 is currently supported.
// Wayland support is being developed: https://github.com/flutter/flutter/issues/57932.
gdk_set_allowed_backends("x11");
g_autoptr(MyApplication) app = my_application_new();
return g_application_run(G_APPLICATION(app), argc, argv);
}
... ...
#include "my_application.h"
#include <flutter_linux/flutter_linux.h>
#include "flutter/generated_plugin_registrant.h"
struct _MyApplication {
GtkApplication parent_instance;
};
G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
// Implements GApplication::activate.
static void my_application_activate(GApplication* application) {
GtkWindow* window =
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
GtkHeaderBar *header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
gtk_widget_show(GTK_WIDGET(header_bar));
gtk_header_bar_set_title(header_bar, "example");
gtk_header_bar_set_show_close_button(header_bar, TRUE);
gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
gtk_window_set_default_size(window, 1280, 720);
gtk_widget_show(GTK_WIDGET(window));
g_autoptr(FlDartProject) project = fl_dart_project_new();
FlView* view = fl_view_new(project);
gtk_widget_show(GTK_WIDGET(view));
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
fl_register_plugins(FL_PLUGIN_REGISTRY(view));
gtk_widget_grab_focus(GTK_WIDGET(view));
}
static void my_application_class_init(MyApplicationClass* klass) {
G_APPLICATION_CLASS(klass)->activate = my_application_activate;
}
static void my_application_init(MyApplication* self) {}
MyApplication* my_application_new() {
return MY_APPLICATION(g_object_new(my_application_get_type(),
"application-id", APPLICATION_ID,
nullptr));
}
... ...
#ifndef FLUTTER_MY_APPLICATION_H_
#define FLUTTER_MY_APPLICATION_H_
#include <gtk/gtk.h>
G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION,
GtkApplication)
/**
* my_application_new:
*
* Creates a new Flutter-based application.
*
* Returns: a new #MyApplication.
*/
MyApplication* my_application_new();
#endif // FLUTTER_MY_APPLICATION_H_
... ...
... ... @@ -73,7 +73,7 @@ packages:
path: ".."
relative: true
source: path
version: "3.6.3"
version: "3.7.0"
http_parser:
dependency: transitive
description:
... ...
... ... @@ -88,7 +88,7 @@ class GetObserver extends NavigatorObserver {
value.route = route;
value.isBack = false;
value.removed = '';
value.previous = '${previousRoute?.settings?.name}';
value.previous = previousRoute?.settings?.name ?? '';
value.isSnackbar = isSnackbar;
value.isBottomSheet = isBottomSheet;
value.isDialog = isDialog;
... ... @@ -119,12 +119,12 @@ class GetObserver extends NavigatorObserver {
_routeSend.update((value) {
if (previousRoute is PageRoute)
value.current = '${previousRoute?.settings?.name}';
value.current = previousRoute?.settings?.name ?? '';
value.args = route?.settings?.arguments;
value.route = previousRoute;
value.isBack = true;
value.removed = '';
value.previous = '${route?.settings?.name}';
value.previous = route?.settings?.name ?? '';
value.isSnackbar = false;
value.isBottomSheet = false;
value.isDialog = false;
... ... @@ -142,7 +142,7 @@ class GetObserver extends NavigatorObserver {
GetConfig.currentRoute = name(newRoute);
_routeSend.update((value) {
if (newRoute is PageRoute) value.current = '${newRoute?.settings?.name}';
if (newRoute is PageRoute) value.current = newRoute?.settings?.name ?? '';
value.args = newRoute?.settings?.arguments;
value.route = newRoute;
value.isBack = false;
... ... @@ -163,8 +163,8 @@ class GetObserver extends NavigatorObserver {
_routeSend.update((value) {
value.route = previousRoute;
value.isBack = false;
value.removed = '${route?.settings?.name}';
value.previous = '${route?.settings?.name}';
value.removed = route?.settings?.name ?? '';
value.previous = route?.settings?.name ?? '';
});
if (routing != null) routing(_routeSend);
}
... ...
... ... @@ -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,6 +3,8 @@ import 'package:flutter/widgets.dart';
import 'package:get/src/state_manager/rx/rx_core/rx_interface.dart';
import '../rx_core/rx_impl.dart';
typedef WidgetCallback = Widget Function();
/// The simplest reactive widget in GetX.
///
/// Just pass your Rx variable in the root scope of the callback to have it
... ... @@ -11,7 +13,7 @@ import '../rx_core/rx_impl.dart';
/// final _name = "GetX".obs;
/// Obx(() => Text( _name.value )),... ;
class Obx extends StatefulWidget {
final Widget Function() builder;
final WidgetCallback builder;
const Obx(this.builder);
_ObxState createState() => _ObxState();
... ...
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter/foundation.dart';
import 'package:get/get.dart';
extension ContextExtensionss on BuildContext {
/// The same of [MediaQuery.of(context).size]
... ... @@ -117,8 +117,7 @@ extension ContextExtensionss on BuildContext {
T watch,
}) {
double deviceWidth = mediaQuerySize.shortestSide;
if (kIsWeb) {
if (GetPlatform.isDesktop) {
deviceWidth = mediaQuerySize.width;
}
if (deviceWidth >= 1200 && desktop != null) return desktop;
... ...
... ... @@ -5,18 +5,4 @@ extension GetDynamicUtils on dynamic {
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);
}
... ...
... ... @@ -8,4 +8,7 @@ class GetPlatform {
static bool get isAndroid => GeneralPlatform.isAndroid;
static bool get isIOS => GeneralPlatform.isIOS;
static bool get isFuchsia => GeneralPlatform.isFuchsia;
static bool get isMobile => GetPlatform.isIOS || GetPlatform.isAndroid;
static bool get isDesktop =>
GetPlatform.isMacOS || GetPlatform.isWindows || GetPlatform.isLinux;
}
... ...
... ... @@ -8,4 +8,6 @@ class GeneralPlatform {
static bool get isAndroid => Platform.isAndroid;
static bool get isIOS => Platform.isIOS;
static bool get isFuchsia => Platform.isFuchsia;
static bool get isDesktop =>
Platform.isMacOS || Platform.isWindows || Platform.isLinux;
}
... ...
// TODO: resolve platform/desktop by JS browser agent.
// ignore: avoid_web_libraries_in_flutter
import 'dart:html' as html;
import 'package:get/utils.dart';
html.Navigator _navigator = html.window.navigator;
class GeneralPlatform {
static bool get isWeb => true;
static bool get isMacOS => false;
static bool get isWindows => false;
static bool get isLinux => false;
static bool get isAndroid => false;
static bool get isIOS => false;
static bool get isMacOS =>
_navigator.appVersion.contains('Mac OS') && !GeneralPlatform.isIOS;
static bool get isWindows => _navigator.appVersion.contains('Win');
static bool get isLinux =>
(_navigator.appVersion.contains('Linux') ||
_navigator.appVersion.contains('x11')) &&
!isAndroid;
// @check https://developer.chrome.com/multidevice/user-agent
static bool get isAndroid => _navigator.appVersion.contains('Android ');
static bool get isIOS {
// maxTouchPoints is needed to separate iPad iOS13 vs new MacOS
return GetUtils.hasMatch(_navigator.platform, r'/iPad|iPhone|iPod/') ||
(_navigator.platform == 'MacIntel' && _navigator.maxTouchPoints > 1);
}
static bool get isFuchsia => false;
static bool get isDesktop => isMacOS || isWindows || isLinux;
}
... ...
... ... @@ -2,6 +2,13 @@ class GetUtils {
/// Checks if data is null.
static bool isNull(dynamic s) => s == null;
/// 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.
static dynamic nil(dynamic s) => s == null ? null : s;
/// Checks if data is null or blank (empty or only contains whitespace).
static bool isNullOrBlank(dynamic s) {
if (isNull(s)) return true;
... ...
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);
});
}
... ...