diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml
index 25edb9a..aa3e020 100644
--- a/.idea/libraries/Dart_Packages.xml
+++ b/.idea/libraries/Dart_Packages.xml
@@ -5,190 +5,190 @@
-
+
-
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml
index 321b902..dcbe109 100644
--- a/.idea/libraries/Dart_SDK.xml
+++ b/.idea/libraries/Dart_SDK.xml
@@ -1,25 +1,26 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 6e2e466..5d9d602 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -6,50 +6,12 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -99,6 +61,14 @@
+
+
+
+
+
+
+
+
@@ -159,9 +129,13 @@
+
+
+
+
@@ -199,10 +173,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -210,100 +199,87 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -312,6 +288,7 @@
+
@@ -322,6 +299,10 @@
1526739255792
+
+
+
+
@@ -400,8 +381,19 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -413,13 +405,14 @@
-
-
-
+
-
+
+
+
+
diff --git a/analysis_options.yaml b/analysis_options.yaml
new file mode 100644
index 0000000..d4fcc1a
--- /dev/null
+++ b/analysis_options.yaml
@@ -0,0 +1 @@
+include: package:pedantic/analysis_options.yaml
\ No newline at end of file
diff --git a/example/.gitignore b/example/.gitignore
index dee655c..0fa6b67 100644
--- a/example/.gitignore
+++ b/example/.gitignore
@@ -1,9 +1,46 @@
+# Miscellaneous
+*.class
+*.log
+*.pyc
+*.swp
.DS_Store
-.dart_tool/
+.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/
-build/
+# Web related
+lib/generated_plugin_registrant.dart
-.flutter-plugins
+# Symbolication related
+app.*.symbols
+
+# Obfuscation related
+app.*.map.json
+
+# Android Studio will place build artifacts here
+/android/app/debug
+/android/app/profile
+/android/app/release
diff --git a/example/.idea/codeStyles/Project.xml b/example/.idea/codeStyles/Project.xml
deleted file mode 100644
index 30aa626..0000000
--- a/example/.idea/codeStyles/Project.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/example/.idea/libraries/Dart_Packages.xml b/example/.idea/libraries/Dart_Packages.xml
deleted file mode 100644
index 7fe55be..0000000
--- a/example/.idea/libraries/Dart_Packages.xml
+++ /dev/null
@@ -1,476 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/example/.idea/libraries/Dart_SDK.xml b/example/.idea/libraries/Dart_SDK.xml
deleted file mode 100644
index 198919e..0000000
--- a/example/.idea/libraries/Dart_SDK.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/example/.idea/libraries/Flutter_Plugins.xml b/example/.idea/libraries/Flutter_Plugins.xml
deleted file mode 100644
index b0f6971..0000000
--- a/example/.idea/libraries/Flutter_Plugins.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/example/.idea/libraries/Flutter_for_Android.xml b/example/.idea/libraries/Flutter_for_Android.xml
deleted file mode 100644
index ac24036..0000000
--- a/example/.idea/libraries/Flutter_for_Android.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/example/.idea/misc.xml b/example/.idea/misc.xml
deleted file mode 100644
index b3d52f2..0000000
--- a/example/.idea/misc.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/example/.idea/modules.xml b/example/.idea/modules.xml
deleted file mode 100644
index bd4a393..0000000
--- a/example/.idea/modules.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/example/.idea/runConfigurations/main_dart.xml b/example/.idea/runConfigurations/main_dart.xml
deleted file mode 100644
index aab7b5c..0000000
--- a/example/.idea/runConfigurations/main_dart.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/example/.idea/workspace.xml b/example/.idea/workspace.xml
deleted file mode 100644
index d85b166..0000000
--- a/example/.idea/workspace.xml
+++ /dev/null
@@ -1,343 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1526740633725
-
-
- 1526740633725
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/example/.metadata b/example/.metadata
index 8cab361..80206eb 100644
--- a/example/.metadata
+++ b/example/.metadata
@@ -4,5 +4,7 @@
# This file should be version controlled and should not be manually edited.
version:
- revision: 44b7e7d3f42f050a79712daab253af06e9daf530
- channel: beta
+ revision: c5a4b4029c0798f37c4a39b479d7cb75daa7b05c
+ channel: stable
+
+project_type: app
diff --git a/example/android/.gitignore b/example/android/.gitignore
index 65b7315..0a741cb 100644
--- a/example/android/.gitignore
+++ b/example/android/.gitignore
@@ -1,10 +1,11 @@
-*.iml
-*.class
-.gradle
+gradle-wrapper.jar
+/.gradle
+/captures/
+/gradlew
+/gradlew.bat
/local.properties
-/.idea/workspace.xml
-/.idea/libraries
-.DS_Store
-/build
-/captures
GeneratedPluginRegistrant.java
+
+# Remember to never publicly share your keystore.
+# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
+key.properties
diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle
index 595a771..6ca2344 100644
--- a/example/android/app/build.gradle
+++ b/example/android/app/build.gradle
@@ -11,24 +11,34 @@ if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
+def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
+if (flutterVersionCode == null) {
+ flutterVersionCode = '1'
+}
+
+def flutterVersionName = localProperties.getProperty('flutter.versionName')
+if (flutterVersionName == null) {
+ flutterVersionName = '1.0'
+}
+
apply plugin: 'com.android.application'
+apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
- compileSdkVersion 27
+ compileSdkVersion 30
- lintOptions {
- disable 'InvalidPackage'
+ sourceSets {
+ main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.example"
minSdkVersion 16
- targetSdkVersion 27
- versionCode 1
- versionName "1.0"
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ targetSdkVersion 30
+ versionCode flutterVersionCode.toInteger()
+ versionName flutterVersionName
}
buildTypes {
@@ -45,7 +55,5 @@ flutter {
}
dependencies {
- testImplementation 'junit:junit:4.12'
- androidTestImplementation 'com.android.support.test:runner:1.0.1'
- androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml
new file mode 100644
index 0000000..c208884
--- /dev/null
+++ b/example/android/app/src/debug/AndroidManifest.xml
@@ -0,0 +1,7 @@
+
+
+
+
diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml
index 1b515f8..34dd77e 100644
--- a/example/android/app/src/main/AndroidManifest.xml
+++ b/example/android/app/src/main/AndroidManifest.xml
@@ -1,39 +1,41 @@
-
-
-
-
-
-
-
+
+ android:name="io.flutter.embedding.android.NormalTheme"
+ android:resource="@style/NormalTheme"
+ />
+
+
+
+
diff --git a/example/android/app/src/main/java/com/example/example/MainActivity.java b/example/android/app/src/main/java/com/example/example/MainActivity.java
deleted file mode 100644
index a313e78..0000000
--- a/example/android/app/src/main/java/com/example/example/MainActivity.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.example.example;
-
-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);
- }
-}
diff --git a/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt b/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt
new file mode 100644
index 0000000..e793a00
--- /dev/null
+++ b/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt
@@ -0,0 +1,6 @@
+package com.example.example
+
+import io.flutter.embedding.android.FlutterActivity
+
+class MainActivity: FlutterActivity() {
+}
diff --git a/example/android/app/src/main/res/drawable-v21/launch_background.xml b/example/android/app/src/main/res/drawable-v21/launch_background.xml
new file mode 100644
index 0000000..f74085f
--- /dev/null
+++ b/example/android/app/src/main/res/drawable-v21/launch_background.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
diff --git a/example/android/app/src/main/res/values-night/styles.xml b/example/android/app/src/main/res/values-night/styles.xml
new file mode 100644
index 0000000..449a9f9
--- /dev/null
+++ b/example/android/app/src/main/res/values-night/styles.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
diff --git a/example/android/app/src/main/res/values/styles.xml b/example/android/app/src/main/res/values/styles.xml
index 00fa441..d74aa35 100644
--- a/example/android/app/src/main/res/values/styles.xml
+++ b/example/android/app/src/main/res/values/styles.xml
@@ -1,8 +1,18 @@
-
+
+
diff --git a/example/android/app/src/profile/AndroidManifest.xml b/example/android/app/src/profile/AndroidManifest.xml
new file mode 100644
index 0000000..c208884
--- /dev/null
+++ b/example/android/app/src/profile/AndroidManifest.xml
@@ -0,0 +1,7 @@
+
+
+
+
diff --git a/example/android/build.gradle b/example/android/build.gradle
index 4476887..c505a86 100644
--- a/example/android/build.gradle
+++ b/example/android/build.gradle
@@ -1,11 +1,13 @@
buildscript {
+ ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.0.1'
+ classpath 'com.android.tools.build:gradle:4.1.0'
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
diff --git a/example/android/gradle.properties b/example/android/gradle.properties
index 8bd86f6..94adc3a 100644
--- a/example/android/gradle.properties
+++ b/example/android/gradle.properties
@@ -1 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
+android.useAndroidX=true
+android.enableJetifier=true
diff --git a/example/android/gradle/wrapper/gradle-wrapper.jar b/example/android/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 13372ae..0000000
Binary files a/example/android/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties
index aa901e1..bc6a58a 100644
--- a/example/android/gradle/wrapper/gradle-wrapper.properties
+++ b/example/android/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
diff --git a/example/android/gradlew b/example/android/gradlew
deleted file mode 100755
index 9d82f78..0000000
--- a/example/android/gradlew
+++ /dev/null
@@ -1,160 +0,0 @@
-#!/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 "$@"
diff --git a/example/android/gradlew.bat b/example/android/gradlew.bat
deleted file mode 100644
index aec9973..0000000
--- a/example/android/gradlew.bat
+++ /dev/null
@@ -1,90 +0,0 @@
-@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
diff --git a/example/android/settings.gradle b/example/android/settings.gradle
index 5a2f14f..44e62bc 100644
--- a/example/android/settings.gradle
+++ b/example/android/settings.gradle
@@ -1,15 +1,11 @@
include ':app'
-def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
+def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
+def properties = new Properties()
-def plugins = new Properties()
-def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
-if (pluginsFile.exists()) {
- pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
-}
+assert localPropertiesFile.exists()
+localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
-plugins.each { name, path ->
- def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
- include ":$name"
- project(":$name").projectDir = pluginDirectory
-}
+def flutterSdkPath = properties.getProperty("flutter.sdk")
+assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
+apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
diff --git a/example/example.iml b/example/example.iml
deleted file mode 100644
index e5c8371..0000000
--- a/example/example.iml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/example/example_android.iml b/example/example_android.iml
deleted file mode 100644
index b050030..0000000
--- a/example/example_android.iml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/example/ios/.gitignore b/example/ios/.gitignore
index 2a8c8b6..e96ef60 100644
--- a/example/ios/.gitignore
+++ b/example/ios/.gitignore
@@ -1,44 +1,32 @@
-.idea/
-.vagrant/
-.sconsign.dblite
-.svn/
-
-.DS_Store
-*.swp
-profile
-
-DerivedData/
-build/
-GeneratedPluginRegistrant.h
-GeneratedPluginRegistrant.m
-
-.generated/
-
-*.pbxuser
*.mode1v3
*.mode2v3
+*.moved-aside
+*.pbxuser
*.perspectivev3
-
-!default.pbxuser
+**/*sync/
+.sconsign.dblite
+.tags*
+**/.vagrant/
+**/DerivedData/
+Icon?
+**/Pods/
+**/.symlinks/
+profile
+xcuserdata
+**/.generated/
+Flutter/App.framework
+Flutter/Flutter.framework
+Flutter/Flutter.podspec
+Flutter/Generated.xcconfig
+Flutter/app.flx
+Flutter/app.zip
+Flutter/flutter_assets/
+Flutter/flutter_export_environment.sh
+ServiceDefinitions.json
+Runner/GeneratedPluginRegistrant.*
+
+# Exceptions to above rules.
!default.mode1v3
!default.mode2v3
+!default.pbxuser
!default.perspectivev3
-
-xcuserdata
-
-*.moved-aside
-
-*.pyc
-*sync/
-Icon?
-.tags*
-
-/Flutter/app.flx
-/Flutter/app.zip
-/Flutter/flutter_assets/
-/Flutter/App.framework
-/Flutter/Flutter.framework
-/Flutter/Generated.xcconfig
-/ServiceDefinitions.json
-
-Pods/
diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist
index 6c2de80..9367d48 100644
--- a/example/ios/Flutter/AppFrameworkInfo.plist
+++ b/example/ios/Flutter/AppFrameworkInfo.plist
@@ -20,10 +20,6 @@
????
CFBundleVersion
1.0
- UIRequiredDeviceCapabilities
-
- arm64
-
MinimumOSVersion
8.0
diff --git a/example/ios/MyLaunch.jpg b/example/ios/MyLaunch.jpg
deleted file mode 100644
index bc3b521..0000000
Binary files a/example/ios/MyLaunch.jpg and /dev/null differ
diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj
index fd76eac..c6759a6 100644
--- a/example/ios/Runner.xcodeproj/project.pbxproj
+++ b/example/ios/Runner.xcodeproj/project.pbxproj
@@ -8,20 +8,11 @@
/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
- 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
- 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
- 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
- 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
- 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
- 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; };
- 9740EEB51CF90195004384FC /* Generated.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB31CF90195004384FC /* Generated.xcconfig */; };
- 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
- 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
+ 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
- D57DA1A0215230B4005D4B7F /* MyLaunch.jpg in Resources */ = {isa = PBXBuildFile; fileRef = D57DA19F215230B4005D4B7F /* MyLaunch.jpg */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@@ -31,8 +22,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
- 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
- 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
@@ -42,22 +31,17 @@
/* Begin PBXFileReference section */
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; };
- 2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; };
- 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; };
+ 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; };
+ 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; };
- 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
- 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; };
- 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
- 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
- D57DA19F215230B4005D4B7F /* MyLaunch.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = MyLaunch.jpg; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -65,8 +49,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
- 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
- 3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -76,10 +58,7 @@
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
- 2D5378251FAA1A9400D5DBA9 /* flutter_assets */,
- 3B80C3931E831B6300D905FE /* App.framework */,
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
- 9740EEBA1CF902C7004384FC /* Flutter.framework */,
9740EEB21CF90195004384FC /* Debug.xcconfig */,
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
9740EEB31CF90195004384FC /* Generated.xcconfig */,
@@ -90,7 +69,6 @@
97C146E51CF9000F007C117D = {
isa = PBXGroup;
children = (
- D57DA19F215230B4005D4B7F /* MyLaunch.jpg */,
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
@@ -108,27 +86,18 @@
97C146F01CF9000F007C117D /* Runner */ = {
isa = PBXGroup;
children = (
- 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */,
- 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */,
97C146FA1CF9000F007C117D /* Main.storyboard */,
97C146FD1CF9000F007C117D /* Assets.xcassets */,
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
97C147021CF9000F007C117D /* Info.plist */,
- 97C146F11CF9000F007C117D /* Supporting Files */,
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
+ 74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
+ 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
);
path = Runner;
sourceTree = "";
};
- 97C146F11CF9000F007C117D /* Supporting Files */ = {
- isa = PBXGroup;
- children = (
- 97C146F21CF9000F007C117D /* main.m */,
- );
- name = "Supporting Files";
- sourceTree = "";
- };
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -158,18 +127,18 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
- LastUpgradeCheck = 0910;
- ORGANIZATIONNAME = "The Chromium Authors";
+ LastUpgradeCheck = 1020;
+ ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
CreatedOnToolsVersion = 7.3.1;
- DevelopmentTeam = 23T2HFANR5;
+ LastSwiftMigration = 1100;
};
};
};
buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
- compatibilityVersion = "Xcode 3.2";
- developmentRegion = English;
+ compatibilityVersion = "Xcode 9.3";
+ developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
@@ -191,12 +160,8 @@
buildActionMask = 2147483647;
files = (
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
- 9740EEB51CF90195004384FC /* Generated.xcconfig in Resources */,
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
- 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
- D57DA1A0215230B4005D4B7F /* MyLaunch.jpg in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
- 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -216,7 +181,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
+ shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
@@ -239,8 +204,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */,
- 97C146F31CF9000F007C117D /* main.m in Sources */,
+ 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -267,9 +231,76 @@
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
+ 249021D3217E4FDB00AE95B9 /* Profile */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 9.0;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ SDKROOT = iphoneos;
+ SUPPORTED_PLATFORMS = iphoneos;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Profile;
+ };
+ 249021D4217E4FDB00AE95B9 /* Profile */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ CLANG_ENABLE_MODULES = YES;
+ CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
+ ENABLE_BITCODE = NO;
+ INFOPLIST_FILE = Runner/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = com.example.example;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
+ SWIFT_VERSION = 5.0;
+ VERSIONING_SYSTEM = "apple-generic";
+ };
+ name = Profile;
+ };
97C147031CF9000F007C117D /* Debug */ = {
isa = XCBuildConfiguration;
- baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
@@ -281,12 +312,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -313,7 +346,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@@ -323,7 +356,6 @@
};
97C147041CF9000F007C117D /* Release */ = {
isa = XCBuildConfiguration;
- baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
@@ -335,12 +367,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -361,9 +395,11 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
+ SUPPORTED_PLATFORMS = iphoneos;
+ SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
@@ -373,24 +409,17 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = {
- ARCHS = arm64;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
- CURRENT_PROJECT_VERSION = 1;
- DEVELOPMENT_TEAM = 23T2HFANR5;
+ CLANG_ENABLE_MODULES = YES;
+ CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
ENABLE_BITCODE = NO;
- FRAMEWORK_SEARCH_PATHS = (
- "$(inherited)",
- "$(PROJECT_DIR)/Flutter",
- );
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
- LIBRARY_SEARCH_PATHS = (
- "$(inherited)",
- "$(PROJECT_DIR)/Flutter",
- );
PRODUCT_BUNDLE_IDENTIFIER = com.example.example;
PRODUCT_NAME = "$(TARGET_NAME)";
- TARGETED_DEVICE_FAMILY = 1;
+ SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
};
name = Debug;
@@ -399,24 +428,16 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
- ARCHS = arm64;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
- CURRENT_PROJECT_VERSION = 1;
- DEVELOPMENT_TEAM = 23T2HFANR5;
+ CLANG_ENABLE_MODULES = YES;
+ CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
ENABLE_BITCODE = NO;
- FRAMEWORK_SEARCH_PATHS = (
- "$(inherited)",
- "$(PROJECT_DIR)/Flutter",
- );
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
- LIBRARY_SEARCH_PATHS = (
- "$(inherited)",
- "$(PROJECT_DIR)/Flutter",
- );
PRODUCT_BUNDLE_IDENTIFIER = com.example.example;
PRODUCT_NAME = "$(TARGET_NAME)";
- TARGETED_DEVICE_FAMILY = 1;
+ SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
+ SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
};
name = Release;
@@ -429,6 +450,7 @@
buildConfigurations = (
97C147031CF9000F007C117D /* Debug */,
97C147041CF9000F007C117D /* Release */,
+ 249021D3217E4FDB00AE95B9 /* Profile */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
@@ -438,6 +460,7 @@
buildConfigurations = (
97C147061CF9000F007C117D /* Debug */,
97C147071CF9000F007C117D /* Release */,
+ 249021D4217E4FDB00AE95B9 /* Profile */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata
index 1d526a1..919434a 100644
--- a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata
+++ b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -2,6 +2,6 @@
+ location = "self:">
diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
new file mode 100644
index 0000000..f9b0d7c
--- /dev/null
+++ b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
@@ -0,0 +1,8 @@
+
+
+
+
+ PreviewsEnabled
+
+
+
diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
index 1263ac8..a28140c 100644
--- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
+++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
@@ -1,6 +1,6 @@
@@ -46,7 +45,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
- language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
@@ -67,7 +65,7 @@
- BuildSystemType
- Original
+ PreviewsEnabled
+
diff --git a/example/ios/Runner/AppDelegate.h b/example/ios/Runner/AppDelegate.h
deleted file mode 100644
index cf210d2..0000000
--- a/example/ios/Runner/AppDelegate.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#import
-#import
-
-@interface AppDelegate : FlutterAppDelegate
-
-@end
diff --git a/example/ios/Runner/AppDelegate.m b/example/ios/Runner/AppDelegate.m
deleted file mode 100644
index 112becd..0000000
--- a/example/ios/Runner/AppDelegate.m
+++ /dev/null
@@ -1,12 +0,0 @@
-#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
diff --git a/example/ios/Runner/AppDelegate.swift b/example/ios/Runner/AppDelegate.swift
new file mode 100644
index 0000000..70693e4
--- /dev/null
+++ b/example/ios/Runner/AppDelegate.swift
@@ -0,0 +1,13 @@
+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)
+ }
+}
diff --git a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
index 3d43d11..dc9ada4 100644
Binary files a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png and b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ
diff --git a/example/ios/Runner/Base.lproj/LaunchScreen.storyboard b/example/ios/Runner/Base.lproj/LaunchScreen.storyboard
index e30dfce..f2e259c 100644
--- a/example/ios/Runner/Base.lproj/LaunchScreen.storyboard
+++ b/example/ios/Runner/Base.lproj/LaunchScreen.storyboard
@@ -1,12 +1,8 @@
-
-
-
-
-
+
+
-
-
+
@@ -18,19 +14,15 @@
-
-
-
+
-
-
-
-
+
+
@@ -40,6 +32,6 @@
-
+
diff --git a/example/ios/Runner/Base.lproj/Main.storyboard b/example/ios/Runner/Base.lproj/Main.storyboard
index 5e371ac..f3c2851 100644
--- a/example/ios/Runner/Base.lproj/Main.storyboard
+++ b/example/ios/Runner/Base.lproj/Main.storyboard
@@ -1,12 +1,8 @@
-
-
-
-
-
+
+
-
-
+
@@ -18,9 +14,9 @@
-
+
-
+
diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist
index ccd04df..a060db6 100644
--- a/example/ios/Runner/Info.plist
+++ b/example/ios/Runner/Info.plist
@@ -3,7 +3,7 @@
CFBundleDevelopmentRegion
- en
+ $(DEVELOPMENT_LANGUAGE)
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
@@ -15,24 +15,22 @@
CFBundlePackageType
APPL
CFBundleShortVersionString
- 1.0
+ $(FLUTTER_BUILD_NAME)
CFBundleSignature
????
CFBundleVersion
- 1
+ $(FLUTTER_BUILD_NUMBER)
LSRequiresIPhoneOS
UILaunchStoryboardName
LaunchScreen
UIMainStoryboardFile
Main
- UIRequiredDeviceCapabilities
-
- arm64
-
UISupportedInterfaceOrientations
UIInterfaceOrientationPortrait
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
UISupportedInterfaceOrientations~ipad
diff --git a/example/ios/Runner/Runner-Bridging-Header.h b/example/ios/Runner/Runner-Bridging-Header.h
new file mode 100644
index 0000000..308a2a5
--- /dev/null
+++ b/example/ios/Runner/Runner-Bridging-Header.h
@@ -0,0 +1 @@
+#import "GeneratedPluginRegistrant.h"
diff --git a/example/ios/Runner/main.m b/example/ios/Runner/main.m
deleted file mode 100644
index 0ccc450..0000000
--- a/example/ios/Runner/main.m
+++ /dev/null
@@ -1,9 +0,0 @@
-#import
-#import
-#import "AppDelegate.h"
-
-int main(int argc, char * argv[]) {
- @autoreleasepool {
- return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
- }
-}
diff --git a/example/lib/InnerSwiper.dart b/example/lib/InnerSwiper.dart
index ccf32a6..59b6377 100644
--- a/example/lib/InnerSwiper.dart
+++ b/example/lib/InnerSwiper.dart
@@ -1,13 +1,13 @@
import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
-void main() => runApp(new MyApp());
+void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return new MaterialApp(
- home: new InnerSwiper(),
+ return MaterialApp(
+ home: InnerSwiper(),
);
}
}
@@ -15,72 +15,68 @@ class MyApp extends StatelessWidget {
class InnerSwiper extends StatefulWidget {
@override
State createState() {
- return new _InnerSwiperState();
+ return _InnerSwiperState();
}
}
class _InnerSwiperState extends State {
- SwiperController controller;
+ late SwiperController controller;
- List autoplayes;
+ late List autoPlayer;
- List controllers;
+ late List controllers;
@override
void initState() {
- controller = new SwiperController();
- autoplayes = new List()
- ..length = 10
- ..fillRange(0, 10, false);
- controllers = new List()
- ..length = 10
- ..fillRange(0, 10, new SwiperController());
+ controller = SwiperController();
+ autoPlayer = List.generate(10, (index) => false);
+ controllers = List.generate(10, (index) => SwiperController());
super.initState();
}
@override
Widget build(BuildContext context) {
- return new Scaffold(
- body: new Swiper(
+ return Scaffold(
+ body: Swiper(
loop: false,
itemCount: 10,
controller: controller,
- pagination: new SwiperPagination(),
+ pagination: SwiperPagination(),
itemBuilder: (BuildContext context, int index) {
- return new Column(
+ return Column(
children: [
- new SizedBox(
- child: new Swiper(
+ SizedBox(
+ child: Swiper(
controller: controllers[index],
- pagination: new SwiperPagination(),
+ pagination: SwiperPagination(),
itemCount: 4,
itemBuilder: (BuildContext context, int index) {
- return new Container(
+ return Container(
color: Colors.greenAccent,
- child: new Text("jkfjkldsfjd"),
+ child: Text('jkfjkldsfjd'),
);
},
- autoplay: autoplayes[index],
+ autoplay: autoPlayer[index],
),
height: 300.0,
),
- new RaisedButton(
+ ElevatedButton(
onPressed: () {
setState(() {
- autoplayes[index] = true;
+ autoPlayer[index] = true;
});
},
- child: new Text("Start autoplay"),
+ child: Text('Start autoplay'),
),
- new RaisedButton(
+ ElevatedButton(
onPressed: () {
setState(() {
- autoplayes[index] = false;
+ autoPlayer[index] = false;
});
},
- child: new Text("End autoplay"),
+ child: Text('End autoplay'),
),
- new Text("is autoplay: ${autoplayes[index]}")
+ Text('is autoplay: ${autoPlayer[index]}')
],
);
},
diff --git a/example/lib/listener_test.dart b/example/lib/listener_test.dart
index a81ca60..c4ba71c 100644
--- a/example/lib/listener_test.dart
+++ b/example/lib/listener_test.dart
@@ -1,10 +1,5 @@
import 'package:flutter/material.dart';
-
import 'package:flutter_swiper/flutter_swiper.dart';
-import 'src/ExampleCustom.dart';
-import 'src/config.dart';
-import 'src/ExampleSwiperInScrollView.dart';
-
import 'package:flutter/cupertino.dart';
void main() => runApp(new MyApp());
@@ -24,7 +19,7 @@ class MyApp extends StatelessWidget {
}
class MyHomePage extends StatefulWidget {
- MyHomePage({Key key, this.title}) : super(key: key);
+ MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
diff --git a/example/lib/main.dart b/example/lib/main.dart
index 6f05be1..4f6c05e 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -1,36 +1,31 @@
+import 'package:example/src/ExampleCustom.dart';
+import 'package:example/src/ExampleSwiperInScrollView.dart';
+import 'package:example/src/config.dart';
import 'package:flutter/material.dart';
-import 'package:flutter_page_indicator/flutter_page_indicator.dart';
-
import 'package:flutter_swiper/flutter_swiper.dart';
-import 'src/ExampleCustom.dart';
-import 'src/config.dart';
-import 'src/ExampleSwiperInScrollView.dart';
-
-import 'package:flutter/cupertino.dart';
-void main() => runApp(new MyApp());
+void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
- return new MaterialApp(
+ return MaterialApp(
title: 'Flutter Demo',
- theme: ThemeData(
- primarySwatch: Colors.blue,
- ),
- home: new MyHomePage(title: 'Flutter Swiper'),
- //home: buildHome(),
+ theme: ThemeData.light(),
+ home: MyHomePage(title: 'Flutter Swiper'),
routes: {
- '/example01': (BuildContext context) => new ExampleHorizontal(),
- '/example02': (BuildContext context) => new ExampleVertical(),
- '/example03': (BuildContext context) => new ExampleFraction(),
- '/example04': (BuildContext context) => new ExampleCustomPagination(),
- '/example05': (BuildContext context) => new ExamplePhone(),
- '/example06': (BuildContext context) => new ScaffoldWidget(
- child: new ExampleSwiperInScrollView(), title: "ScrollView"),
- '/example07': (BuildContext context) => new ScaffoldWidget(
- child: new ExampleCustom(),
+ '/example01': (BuildContext context) => ExampleHorizontal(),
+ '/example02': (BuildContext context) => ExampleVertical(),
+ '/example03': (BuildContext context) => ExampleFraction(),
+ '/example04': (BuildContext context) => ExampleCustomPagination(),
+ '/example05': (BuildContext context) => ExamplePhone(),
+ '/example06': (BuildContext context) => ScaffoldWidget(
+ child: ExampleSwiperInScrollView(),
+ title: "ScrollView",
+ ),
+ '/example07': (BuildContext context) => ScaffoldWidget(
+ child: ExampleCustom(),
title: "Custom All",
)
},
@@ -39,12 +34,12 @@ class MyApp extends StatelessWidget {
}
class MyHomePage extends StatefulWidget {
- MyHomePage({Key key, this.title}) : super(key: key);
+ MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
- _MyHomePageState createState() => new _MyHomePageState();
+ _MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State {
@@ -58,16 +53,16 @@ class _MyHomePageState extends State {
Widget buildListTile(
BuildContext context, String title, String subtitle, String url) {
- return new ListTile(
+ return ListTile(
onTap: () {
Navigator.of(context).pushNamed(url);
},
isThreeLine: true,
dense: false,
leading: null,
- title: new Text(title),
- subtitle: new Text(subtitle),
- trailing: new Icon(
+ title: Text(title),
+ subtitle: Text(subtitle),
+ trailing: Icon(
Icons.arrow_right,
color: Colors.blueAccent,
),
@@ -78,11 +73,11 @@ class _MyHomePageState extends State {
Widget build(BuildContext context) {
// DateTime moonLanding = DateTime.parse("1969-07-20");
- return new Scaffold(
- appBar: new AppBar(
+ return Scaffold(
+ appBar: AppBar(
title: Text(widget.title),
),
- body: new ListView(
+ body: ListView(
children: render(context, [
["Horizontal", "Scroll Horizontal", "/example01"],
["Vertical", "Scroll Vertical", "/example02"],
@@ -98,45 +93,45 @@ class _MyHomePageState extends State {
}
const List titles = [
- "Flutter Swiper is awosome",
+ "Flutter Swiper is awesome",
"Really nice",
- "Yeap"
+ "Yeah"
];
class ExampleHorizontal extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return new Scaffold(
- appBar: AppBar(
- title: Text("ExampleHorizontal"),
- ),
- body: new Swiper(
- itemBuilder: (BuildContext context, int index) {
- return new Image.asset(
- images[index],
- fit: BoxFit.fill,
- );
- },
-
- indicatorLayout: PageIndicatorLayout.COLOR,
- autoplay: true,
- itemCount: images.length,
- pagination: new SwiperPagination(),
- control: new SwiperControl(),
- ));
+ return Scaffold(
+ appBar: AppBar(
+ title: Text("ExampleHorizontal"),
+ ),
+ body: Swiper(
+ itemBuilder: (BuildContext context, int index) {
+ return Image.asset(
+ images[index],
+ fit: BoxFit.fill,
+ );
+ },
+ indicatorLayout: PageIndicatorLayout.COLOR,
+ autoplay: true,
+ itemCount: images.length,
+ pagination: SwiperPagination(),
+ control: SwiperControl(),
+ ),
+ );
}
}
class ExampleVertical extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return new Scaffold(
+ return Scaffold(
appBar: AppBar(
title: Text("ExampleVertical"),
),
- body: new Swiper(
+ body: Swiper(
itemBuilder: (BuildContext context, int index) {
- return new Image.asset(
+ return Image.asset(
images[index],
fit: BoxFit.fill,
);
@@ -144,8 +139,8 @@ class ExampleVertical extends StatelessWidget {
autoplay: true,
itemCount: images.length,
scrollDirection: Axis.vertical,
- pagination: new SwiperPagination(alignment: Alignment.centerRight),
- control: new SwiperControl(),
+ pagination: SwiperPagination(alignment: Alignment.centerRight),
+ control: SwiperControl(),
));
}
}
@@ -153,30 +148,29 @@ class ExampleVertical extends StatelessWidget {
class ExampleFraction extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return new Scaffold(
- appBar: new AppBar(
+ return Scaffold(
+ appBar: AppBar(
title: Text("ExampleFraction"),
),
- body: new Column(
+ body: Column(
children: [
Expanded(
- child: new Swiper(
+ child: Swiper(
itemBuilder: (BuildContext context, int index) {
- return new Image.asset(
+ return Image.asset(
images[index],
fit: BoxFit.fill,
);
},
autoplay: true,
itemCount: images.length,
- pagination:
- new SwiperPagination(builder: SwiperPagination.fraction),
- control: new SwiperControl(),
+ pagination: SwiperPagination(builder: SwiperPagination.fraction),
+ control: SwiperControl(),
)),
Expanded(
- child: new Swiper(
+ child: Swiper(
itemBuilder: (BuildContext context, int index) {
- return new Image.asset(
+ return Image.asset(
images[index],
fit: BoxFit.fill,
);
@@ -184,7 +178,7 @@ class ExampleFraction extends StatelessWidget {
autoplay: true,
itemCount: images.length,
scrollDirection: Axis.vertical,
- pagination: new SwiperPagination(
+ pagination: SwiperPagination(
alignment: Alignment.centerRight,
builder: SwiperPagination.fraction),
))
@@ -196,64 +190,68 @@ class ExampleFraction extends StatelessWidget {
class ExampleCustomPagination extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return new Scaffold(
- appBar: new AppBar(
- title: new Text("Custom Pagination"),
+ return Scaffold(
+ appBar: AppBar(
+ title: Text("Custom Pagination"),
),
- body: new Column(
+ body: Column(
children: [
- new Expanded(
- child: new Swiper(
+ Expanded(
+ child: Swiper(
itemBuilder: (BuildContext context, int index) {
- return new Image.asset(
+ return Image.asset(
images[index],
fit: BoxFit.fill,
);
},
autoplay: true,
itemCount: images.length,
- pagination: new SwiperPagination(
- margin: new EdgeInsets.all(0.0),
- builder: new SwiperCustomPagination(builder:
- (BuildContext context, SwiperPluginConfig config) {
- return new ConstrainedBox(
- child: new Container(
- color: Colors.white,
- child: new Text(
- "${titles[config.activeIndex]} ${config.activeIndex + 1}/${config.itemCount}",
- style: new TextStyle(fontSize: 20.0),
- )),
- constraints: new BoxConstraints.expand(height: 50.0),
+ pagination: SwiperPagination(
+ margin: EdgeInsets.all(0.0),
+ builder: SwiperCustomPagination(builder:
+ (BuildContext context, SwiperPluginConfig? config) {
+ return ConstrainedBox(
+ child: Container(
+ color: Colors.white,
+ child: config != null
+ ? Text(
+ "${titles[config.activeIndex!]} ${config.activeIndex! + 1}/${config.itemCount}",
+ style: TextStyle(fontSize: 20.0),
+ )
+ : Offstage(),
+ ),
+ constraints: BoxConstraints.expand(height: 50.0),
);
})),
- control: new SwiperControl(),
+ control: SwiperControl(),
),
),
- new Expanded(
- child: new Swiper(
+ Expanded(
+ child: Swiper(
itemBuilder: (BuildContext context, int index) {
- return new Image.asset(
+ return Image.asset(
images[index],
fit: BoxFit.fill,
);
},
autoplay: true,
itemCount: images.length,
- pagination: new SwiperPagination(
- margin: new EdgeInsets.all(0.0),
- builder: new SwiperCustomPagination(builder:
- (BuildContext context, SwiperPluginConfig config) {
- return new ConstrainedBox(
- child: new Row(
+ pagination: SwiperPagination(
+ margin: EdgeInsets.all(0.0),
+ builder: SwiperCustomPagination(builder:
+ (BuildContext context, SwiperPluginConfig? config) {
+ return ConstrainedBox(
+ child: Row(
children: [
- new Text(
- "${titles[config.activeIndex]} ${config.activeIndex + 1}/${config.itemCount}",
- style: TextStyle(fontSize: 20.0),
- ),
- new Expanded(
- child: new Align(
+ if (config != null)
+ Text(
+ "${titles[config.activeIndex!]} ${config.activeIndex! + 1}/${config.itemCount}",
+ style: TextStyle(fontSize: 20.0),
+ ),
+ Expanded(
+ child: Align(
alignment: Alignment.centerRight,
- child: new DotSwiperPaginationBuilder(
+ child: DotSwiperPaginationBuilder(
color: Colors.black12,
activeColor: Colors.black,
size: 10.0,
@@ -263,10 +261,10 @@ class ExampleCustomPagination extends StatelessWidget {
)
],
),
- constraints: new BoxConstraints.expand(height: 50.0),
+ constraints: BoxConstraints.expand(height: 50.0),
);
})),
- control: new SwiperControl(color: Colors.redAccent),
+ control: SwiperControl(color: Colors.redAccent),
),
)
],
@@ -277,38 +275,38 @@ class ExampleCustomPagination extends StatelessWidget {
class ExamplePhone extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return new Scaffold(
- appBar: new AppBar(
- title: new Text("Phone"),
+ return Scaffold(
+ appBar: AppBar(
+ title: Text("Phone"),
),
- body: new Stack(
+ body: Stack(
children: [
ConstrainedBox(
- constraints: new BoxConstraints.expand(),
- child: new Image.asset(
+ constraints: BoxConstraints.expand(),
+ child: Image.asset(
"images/bg.jpeg",
fit: BoxFit.fill,
),
),
- new Swiper.children(
+ Swiper.children(
autoplay: false,
- pagination: new SwiperPagination(
- margin: new EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 30.0),
- builder: new DotSwiperPaginationBuilder(
+ pagination: SwiperPagination(
+ margin: EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 30.0),
+ builder: DotSwiperPaginationBuilder(
color: Colors.white30,
activeColor: Colors.white,
size: 20.0,
activeSize: 20.0)),
children: [
- new Image.asset(
+ Image.asset(
"images/1.png",
fit: BoxFit.contain,
),
- new Image.asset(
+ Image.asset(
"images/2.png",
fit: BoxFit.contain,
),
- new Image.asset("images/3.png", fit: BoxFit.contain)
+ Image.asset("images/3.png", fit: BoxFit.contain)
],
)
],
@@ -320,15 +318,15 @@ class ExamplePhone extends StatelessWidget {
class ScaffoldWidget extends StatelessWidget {
final Widget child;
final String title;
- final List actions;
+ final List? actions;
- ScaffoldWidget({this.child, this.title, this.actions});
+ ScaffoldWidget({required this.child, required this.title, this.actions});
@override
Widget build(BuildContext context) {
- return new Scaffold(
- appBar: new AppBar(
- title: new Text(title),
+ return Scaffold(
+ appBar: AppBar(
+ title: Text(title),
actions: actions,
),
body: child,
diff --git a/example/lib/src/ExampleCustom.dart b/example/lib/src/ExampleCustom.dart
index 3b65a43..f58d4ba 100644
--- a/example/lib/src/ExampleCustom.dart
+++ b/example/lib/src/ExampleCustom.dart
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
-import 'package:flutter_page_indicator/flutter_page_indicator.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'config.dart';
import 'forms/form_widget.dart';
@@ -7,48 +6,52 @@ import 'forms/form_widget.dart';
class ExampleCustom extends StatefulWidget {
@override
State createState() {
- return new _ExampleCustomState();
+ return _ExampleCustomState();
}
}
class _ExampleCustomState extends State {
//properties want to custom
- int _itemCount;
+ late int _itemCount;
- bool _loop;
+ late bool _loop;
- bool _autoplay;
+ late bool _autoplay;
- int _autoplayDely;
+ late int _autoplayDelay;
- double _padding;
+ late double _padding;
- bool _outer;
+ late bool _outer;
- double _radius;
+ late double _radius;
- double _viewportFraction;
+ late double _viewportFraction;
- SwiperLayout _layout;
+ late SwiperLayout _layout;
- int _currentIndex;
+ late int _currentIndex;
- double _scale;
+ late double _scale;
- Axis _scrollDirection;
+ late Axis _scrollDirection;
- Curve _curve;
+ late Curve _curve;
- double _fade;
+ late double _fade;
- bool _autoplayDisableOnInteraction;
+ late bool _autoplayDisableOnInteraction;
- CustomLayoutOption customLayoutOption;
+ late CustomLayoutOption customLayoutOption;
+
+ late SwiperController _controller;
+
+ TextEditingController numberController = TextEditingController();
Widget _buildItem(BuildContext context, int index) {
return ClipRRect(
- borderRadius: new BorderRadius.all(new Radius.circular(_radius)),
- child: new Image.asset(
+ borderRadius: BorderRadius.all(Radius.circular(_radius)),
+ child: Image.asset(
images[index % images.length],
fit: BoxFit.fill,
),
@@ -57,35 +60,29 @@ class _ExampleCustomState extends State {
@override
void didUpdateWidget(ExampleCustom oldWidget) {
- customLayoutOption = new CustomLayoutOption(startIndex: -1, stateCount: 3)
- .addRotate([-45.0 / 180, 0.0, 45.0 / 180]).addTranslate([
- new Offset(-370.0, -40.0),
- new Offset(0.0, 0.0),
- new Offset(370.0, -40.0)
- ]);
+ customLayoutOption = CustomLayoutOption(startIndex: -1, stateCount: 3)
+ .addRotate([-45.0 / 180, 0.0, 45.0 / 180]).addTranslate(
+ [Offset(-370.0, -40.0), Offset(0.0, 0.0), Offset(370.0, -40.0)]);
super.didUpdateWidget(oldWidget);
}
@override
void initState() {
- customLayoutOption = new CustomLayoutOption(startIndex: -1, stateCount: 3)
- .addRotate([-25.0 / 180, 0.0, 25.0 / 180]).addTranslate([
- new Offset(-350.0, 0.0),
- new Offset(0.0, 0.0),
- new Offset(350.0, 0.0)
- ]);
+ customLayoutOption = CustomLayoutOption(startIndex: -1, stateCount: 3)
+ .addRotate([-25.0 / 180, 0.0, 25.0 / 180]).addTranslate(
+ [Offset(-350.0, 0.0), Offset(0.0, 0.0), Offset(350.0, 0.0)]);
_fade = 1.0;
_currentIndex = 0;
_curve = Curves.ease;
_scale = 0.8;
- _controller = new SwiperController();
+ _controller = SwiperController();
_layout = SwiperLayout.TINDER;
_radius = 10.0;
_padding = 0.0;
_loop = true;
_itemCount = 3;
_autoplay = false;
- _autoplayDely = 3000;
+ _autoplayDelay = 3000;
_viewportFraction = 0.8;
_outer = false;
_scrollDirection = Axis.horizontal;
@@ -96,13 +93,13 @@ class _ExampleCustomState extends State {
// maintain the index
Widget buildSwiper() {
- return new Swiper(
+ return Swiper(
onTap: (int index) {
Navigator.of(context)
- .push(new MaterialPageRoute(builder: (BuildContext context) {
+ .push(MaterialPageRoute(builder: (BuildContext context) {
return Scaffold(
appBar: AppBar(
- title: Text("New page"),
+ title: Text('New page'),
),
body: Container(),
);
@@ -124,7 +121,7 @@ class _ExampleCustomState extends State {
outer: _outer,
itemHeight: 200.0,
viewportFraction: _viewportFraction,
- autoplayDelay: _autoplayDely,
+ autoplayDelay: _autoplayDelay,
loop: _loop,
autoplay: _autoplay,
itemBuilder: _buildItem,
@@ -132,108 +129,108 @@ class _ExampleCustomState extends State {
scrollDirection: _scrollDirection,
indicatorLayout: PageIndicatorLayout.COLOR,
autoplayDisableOnInteraction: _autoplayDisableOnInteraction,
- pagination: new SwiperPagination(
+ pagination: SwiperPagination(
builder: const DotSwiperPaginationBuilder(
size: 20.0, activeSize: 20.0, space: 10.0)),
);
}
- SwiperController _controller;
- TextEditingController numberController = new TextEditingController();
@override
Widget build(BuildContext context) {
- return new Column(children: [
- new Container(
+ return Column(children: [
+ Container(
color: Colors.black87,
- child: new SizedBox(
+ child: SizedBox(
height: 300.0, width: double.infinity, child: buildSwiper()),
),
- new Expanded(
- child: new ListView(
+ Expanded(
+ child: ListView(
children: [
- new Text("Index:$_currentIndex"),
- new Row(
+ Text('Index:$_currentIndex'),
+ Row(
children: [
- new RaisedButton(
+ ElevatedButton(
onPressed: () {
_controller.previous(animation: true);
},
- child: new Text("Prev"),
+ child: Text('Prev'),
),
- new RaisedButton(
+ ElevatedButton(
onPressed: () {
_controller.next(animation: true);
},
- child: new Text("Next"),
+ child: Text('Next'),
),
- new Expanded(
- child: new TextField(
+ Expanded(
+ child: TextField(
controller: numberController,
)),
- new RaisedButton(
+ ElevatedButton(
onPressed: () {
var text = numberController.text;
setState(() {
_currentIndex = int.parse(text);
});
},
- child: new Text("Update"),
+ child: Text('Update'),
),
],
),
- new FormWidget(
- label: "layout",
- child: new FormSelect(
- placeholder: "Select layout",
- value: _layout,
- values: [
- SwiperLayout.DEFAULT,
- SwiperLayout.STACK,
- SwiperLayout.TINDER,
- SwiperLayout.CUSTOM
- ],
- valueChanged: (value) {
- _layout = value;
- setState(() {});
- })),
- new FormWidget(
- label: "scrollDirection",
- child: new Switch(
+ FormWidget(
+ label: 'layout',
+ child: FormSelect(
+ placeholder: 'Select layout',
+ value: _layout,
+ values: [
+ SwiperLayout.DEFAULT,
+ SwiperLayout.STACK,
+ SwiperLayout.TINDER,
+ SwiperLayout.CUSTOM
+ ],
+ valueChanged: (SwiperLayout value) {
+ _layout = value;
+ setState(() {});
+ },
+ ),
+ ),
+ FormWidget(
+ label: 'scrollDirection',
+ child: Switch(
value: _scrollDirection == Axis.horizontal,
onChanged: (bool value) => setState(() => _scrollDirection =
value ? Axis.horizontal : Axis.vertical)),
),
- new FormWidget(
- label: "autoplayDisableOnInteractio",
- child: new Switch(
+ FormWidget(
+ label: 'autoplayDisableOnInteraction',
+ child: Switch(
value: _autoplayDisableOnInteraction,
onChanged: (bool value) =>
setState(() => _autoplayDisableOnInteraction = value)),
),
//Pannel Begin
- new FormWidget(
- label: "loop",
- child: new Switch(
+ FormWidget(
+ label: 'loop',
+ child: Switch(
value: _loop,
onChanged: (bool value) => setState(() => _loop = value)),
),
- new FormWidget(
- label: "outer",
- child: new Switch(
+ FormWidget(
+ label: 'outer',
+ child: Switch(
value: _outer,
onChanged: (bool value) => setState(() => _outer = value)),
),
//Pannel Begin
- new FormWidget(
- label: "autoplay",
- child: new Switch(
+ FormWidget(
+ label: 'autoplay',
+ child: Switch(
value: _autoplay,
onChanged: (bool value) => setState(() => _autoplay = value)),
),
- new FormWidget(
- label: "padding",
- child: new NumberPad(
+ FormWidget(
+ label: 'padding',
+ child: NumberPad(
number: _padding,
step: 5.0,
min: 0.0,
@@ -244,9 +241,9 @@ class _ExampleCustomState extends State {
},
),
),
- new FormWidget(
- label: "scale",
- child: new NumberPad(
+ FormWidget(
+ label: 'scale',
+ child: NumberPad(
number: _scale,
step: 0.1,
min: 0.0,
@@ -257,9 +254,9 @@ class _ExampleCustomState extends State {
},
),
),
- new FormWidget(
- label: "fade",
- child: new NumberPad(
+ FormWidget(
+ label: 'fade',
+ child: NumberPad(
number: _fade,
step: 0.1,
min: 0.0,
@@ -270,9 +267,9 @@ class _ExampleCustomState extends State {
},
),
),
- new FormWidget(
- label: "itemCount",
- child: new NumberPad(
+ FormWidget(
+ label: 'itemCount',
+ child: NumberPad(
number: _itemCount,
step: 1,
min: 0,
@@ -284,9 +281,9 @@ class _ExampleCustomState extends State {
),
),
- new FormWidget(
- label: "radius",
- child: new NumberPad(
+ FormWidget(
+ label: 'radius',
+ child: NumberPad(
number: _radius,
step: 1.0,
min: 0.0,
@@ -298,9 +295,9 @@ class _ExampleCustomState extends State {
),
),
- new FormWidget(
- label: "viewportFraction",
- child: new NumberPad(
+ FormWidget(
+ label: 'viewportFraction',
+ child: NumberPad(
number: _viewportFraction,
step: 0.1,
max: 1.0,
@@ -312,23 +309,25 @@ class _ExampleCustomState extends State {
),
),
- new FormWidget(
- label: "curve",
- child: new FormSelect(
- placeholder: "Select curve",
- value: _layout,
- values: [
- Curves.easeInOut,
- Curves.ease,
- Curves.bounceInOut,
- Curves.bounceOut,
- Curves.bounceIn,
- Curves.fastOutSlowIn
- ],
- valueChanged: (value) {
- _curve = value;
- setState(() {});
- })),
+ FormWidget(
+ label: 'curve',
+ child: FormSelect(
+ placeholder: 'Select curve',
+ value: _layout,
+ values: [
+ Curves.easeInOut,
+ Curves.ease,
+ Curves.bounceInOut,
+ Curves.bounceOut,
+ Curves.bounceIn,
+ Curves.fastOutSlowIn
+ ],
+ valueChanged: (Curve value) {
+ _curve = value;
+ setState(() {});
+ },
+ ),
+ ),
],
))
]);
diff --git a/example/lib/src/ExampleSwiperInScrollView.dart b/example/lib/src/ExampleSwiperInScrollView.dart
index e15339f..f061668 100644
--- a/example/lib/src/ExampleSwiperInScrollView.dart
+++ b/example/lib/src/ExampleSwiperInScrollView.dart
@@ -4,17 +4,17 @@ import 'package:flutter_swiper/flutter_swiper.dart';
class ExampleSwiperInScrollView extends StatefulWidget {
@override
State createState() {
- return new _ExampleState();
+ return _ExampleState();
}
}
class _ExampleState extends State
with TickerProviderStateMixin {
- AnimationController controller;
- Animation _animation10;
- Animation _animation11;
- Animation _animation12;
- Animation _animation13;
+ late AnimationController controller;
+ late Animation _animation10;
+ late Animation _animation11;
+ late Animation _animation12;
+ late Animation _animation13;
_ExampleState();
@@ -27,20 +27,20 @@ class _ExampleState extends State
@override
void initState() {
- controller = new AnimationController(vsync: this);
- _animation10 = new Tween(begin: 0.0, end: 1.0).animate(controller);
- _animation11 = new Tween(begin: 0.0, end: 1.0).animate(controller);
- _animation12 = new Tween(begin: 0.0, end: 1.0).animate(controller);
- _animation13 = new Tween(begin: 0.0, end: 1.0).animate(controller);
- controller.animateTo(1.0, duration: new Duration(seconds: 3));
+ controller = AnimationController(vsync: this);
+ _animation10 = Tween(begin: 0.0, end: 1.0).animate(controller);
+ _animation11 = Tween(begin: 0.0, end: 1.0).animate(controller);
+ _animation12 = Tween(begin: 0.0, end: 1.0).animate(controller);
+ _animation13 = Tween(begin: 0.0, end: 1.0).animate(controller);
+ controller.animateTo(1.0, duration: Duration(seconds: 3));
super.initState();
}
Widget _buildDynamicCard() {
- return new Card(
+ return Card(
elevation: 2.0,
color: Colors.white,
- child: new Stack(
+ child: Stack(
children: [
Column(
children: [
@@ -49,9 +49,9 @@ class _ExampleState extends State
),
],
),
- new Column(
+ Column(
children: [
- new Row(
+ Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Column(
@@ -59,18 +59,18 @@ class _ExampleState extends State
Container(
padding: const EdgeInsets.only(top: 40.0),
),
- new ScaleTransition(
+ ScaleTransition(
scale: _animation10,
alignment: FractionalOffset.center,
),
],
),
- new Column(
+ Column(
children: [
Container(
padding: const EdgeInsets.only(top: 160.0),
),
- new ScaleTransition(
+ ScaleTransition(
scale: _animation11,
alignment: FractionalOffset.center,
),
@@ -84,7 +84,7 @@ class _ExampleState extends State
Container(
padding: const EdgeInsets.only(top: 160.0),
),
- new ScaleTransition(
+ ScaleTransition(
scale: _animation12,
alignment: FractionalOffset.center,
),
@@ -95,7 +95,7 @@ class _ExampleState extends State
Container(
padding: const EdgeInsets.only(top: 40.0),
),
- new ScaleTransition(
+ ScaleTransition(
scale: _animation13,
alignment: FractionalOffset.center,
),
@@ -114,109 +114,108 @@ class _ExampleState extends State
@override
Widget build(BuildContext context) {
- double screenWidth = MediaQuery.of(context).size.width;
- return new Container(
+ return Container(
color: Theme.of(context).primaryColorLight,
child: CustomScrollView(
slivers: [
SliverList(
- delegate: new SliverChildBuilderDelegate((c, i) {
- return new Column(
+ delegate: SliverChildBuilderDelegate((c, i) {
+ return Column(
mainAxisSize: MainAxisSize.min,
children: [
- new SizedBox(
+ SizedBox(
height: 100.0,
child: Swiper(
- scale:0.8,
- fade:0.8,
+ scale: 0.8,
+ fade: 0.8,
itemBuilder: (c, i) {
return Container(
color: Colors.grey,
- child: Text("$i"),
+ child: Text('$i'),
);
},
itemCount: 10,
- pagination: new SwiperPagination(),
+ pagination: SwiperPagination(),
),
),
- new SizedBox(
+ SizedBox(
height: 100.0,
child: Swiper(
- scale:0.8,
- fade:0.8,
+ scale: 0.8,
+ fade: 0.8,
itemBuilder: (c, i) {
return Container(
color: Colors.grey,
- child: Text("$i"),
+ child: Text('$i'),
);
},
- pagination: new SwiperPagination(
- builder: SwiperPagination.fraction),
+ pagination:
+ SwiperPagination(builder: SwiperPagination.fraction),
itemCount: 0),
),
- new SizedBox(
+ SizedBox(
height: 100.0,
child: Swiper(
- scale:0.8,
- fade:0.8,
+ scale: 0.8,
+ fade: 0.8,
itemBuilder: (c, i) {
return Container(
color: Colors.grey,
- child: Text("$i"),
+ child: Text('$i'),
);
},
- pagination: new SwiperPagination(
- builder: SwiperPagination.fraction),
+ pagination:
+ SwiperPagination(builder: SwiperPagination.fraction),
itemCount: 10000),
),
- new SizedBox(
+ SizedBox(
height: 100.0,
child: Swiper(
outer: true,
- scale:0.8,
- fade:0.8,
+ scale: 0.8,
+ fade: 0.8,
itemBuilder: (c, i) {
- return new Container(
+ return Container(
color: Colors.grey,
- child: Text("$i"),
+ child: Text('$i'),
);
},
pagination: SwiperPagination(),
itemCount: 10),
),
- new Text("Image from network"),
- new SizedBox(
+ Text('Image from network'),
+ SizedBox(
height: 300.0,
- child: new Swiper(
+ child: Swiper(
itemCount: 10,
itemBuilder: (BuildContext context, int index) {
- return new Image.network(
- "https://ss3.baidu.com/9fo3dSag_xI4khGko9WTAnF6hhy/image/h%3D300/sign=87d6daed02f41bd5c553eef461d881a0/f9198618367adab4b025268587d4b31c8601e47b.jpg");
+ return Image.network(
+ 'https://ss3.baidu.com/9fo3dSag_xI4khGko9WTAnF6hhy/image/h%3D300/sign=87d6daed02f41bd5c553eef461d881a0/f9198618367adab4b025268587d4b31c8601e47b.jpg');
},
),
),
- new SizedBox(
+ SizedBox(
height: 100.0,
- child: new Swiper(
+ child: Swiper(
outer: true,
- scale:0.8,
- fade:0.8,
+ scale: 0.8,
+ fade: 0.8,
itemBuilder: (c, i) {
- return new Card(
+ return Card(
elevation: 2.0,
- child: new Stack(
+ child: Stack(
alignment: AlignmentDirectional.center,
children: [
- new Container(
- child: new Image.network(
- "https://ss3.baidu.com/9fo3dSag_xI4khGko9WTAnF6hhy/image/h%3D300/sign=87d6daed02f41bd5c553eef461d881a0/f9198618367adab4b025268587d4b31c8601e47b.jpg"),
+ Container(
+ child: Image.network(
+ 'https://ss3.baidu.com/9fo3dSag_xI4khGko9WTAnF6hhy/image/h%3D300/sign=87d6daed02f41bd5c553eef461d881a0/f9198618367adab4b025268587d4b31c8601e47b.jpg'),
),
FractionalTranslation(
translation: Offset(0.0, 0.0),
- child: new Container(
- alignment: new FractionalOffset(0.0, 0.0),
- decoration: new BoxDecoration(
- border: new Border.all(
+ child: Container(
+ alignment: FractionalOffset(0.0, 0.0),
+ decoration: BoxDecoration(
+ border: Border.all(
color: Colors.lightBlue.withOpacity(0.5),
width: 100.0,
),
@@ -224,9 +223,9 @@ class _ExampleState extends State
),
),
),
- new Container(
+ Container(
//padding: const EdgeInsets.only(bottom:10.0),
- margin: new EdgeInsets.all(140.0),
+ margin: EdgeInsets.all(140.0),
child: Icon(Icons.location_on,
color: Colors.white, size: 25.0),
@@ -236,35 +235,35 @@ class _ExampleState extends State
);
},
pagination:
- new SwiperPagination(alignment: Alignment.topCenter),
+ SwiperPagination(alignment: Alignment.topCenter),
itemCount: 10),
),
- new SizedBox(
+ SizedBox(
height: 400.0,
- child: new Swiper(
+ child: Swiper(
outer: true,
itemBuilder: (c, i) {
return _buildDynamicCard();
},
pagination:
- new SwiperPagination(alignment: Alignment.topCenter),
+ SwiperPagination(alignment: Alignment.topCenter),
itemCount: 10),
),
- new SizedBox(
+ SizedBox(
height: 100.0,
- child: new Swiper(
+ child: Swiper(
outer: true,
- fade:0.8,
+ fade: 0.8,
viewportFraction: 0.8,
scale: 0.8,
itemBuilder: (c, i) {
return Container(
color: Colors.grey,
- child: Text("$i"),
+ child: Text('$i'),
);
},
pagination:
- new SwiperPagination(alignment: Alignment.topCenter),
+ SwiperPagination(alignment: Alignment.topCenter),
itemCount: 10),
),
],
diff --git a/example/lib/src/forms/form_widget.dart b/example/lib/src/forms/form_widget.dart
index 2cba7de..b50e291 100644
--- a/example/lib/src/forms/form_widget.dart
+++ b/example/lib/src/forms/form_widget.dart
@@ -6,30 +6,41 @@ class FormWidget extends StatelessWidget {
final Widget child;
- FormWidget({this.label, this.child});
+ FormWidget({
+ required this.label,
+ required this.child,
+ });
@override
Widget build(BuildContext context) {
- return new Padding(
- padding: new EdgeInsets.all(5.0),
- child: new Row(
+ return Padding(
+ padding: EdgeInsets.all(5.0),
+ child: Row(
children: [
- new Text(label, style: new TextStyle(fontSize: 14.0)),
- new Expanded(
- child:
- new Align(alignment: Alignment.centerRight, child: child))
+ Text(label, style: TextStyle(fontSize: 14.0)),
+ Expanded(
+ child: Align(
+ alignment: Alignment.centerRight,
+ child: child,
+ ),
+ )
],
- ));
+ ),);
}
}
class FormSelect extends StatefulWidget {
final String placeholder;
final ValueChanged valueChanged;
- final List values;
- final dynamic value;
+ final List values;
+ final Object value;
- FormSelect({this.placeholder, this.valueChanged, this.value, this.values});
+ FormSelect({
+ required this.placeholder,
+ required this.valueChanged,
+ required this.value,
+ required this.values,
+ });
@override
State createState() {
@@ -55,11 +66,11 @@ class _FormSelectState extends State {
@override
Widget build(BuildContext context) {
String placeholder = widget.placeholder;
- List values = widget.values;
+ List values = widget.values;
- return new Container(
- child: new InkWell(
- child: new Text(_selectedIndex < 0
+ return Container(
+ child: InkWell(
+ child: Text(_selectedIndex < 0
? placeholder
: values[_selectedIndex].toString()),
onTap: () {
@@ -67,36 +78,37 @@ class _FormSelectState extends State {
showBottomSheet(
context: context,
builder: (BuildContext context) {
- return new SizedBox(
+ return SizedBox(
height: values.length * 30.0 + 200.0,
- child: new Column(
+ child: Column(
mainAxisSize: MainAxisSize.min,
children: [
- new SizedBox(
+ SizedBox(
height: values.length * 30.0 + 70.0,
- child: new CupertinoPicker(
+ child: CupertinoPicker(
itemExtent: 30.0,
- children: values.map((dynamic value) {
- return new Text(value.toString());
+ children: values.map((Object value) {
+ return Text(value.toString());
}).toList(),
onSelectedItemChanged: (int index) {
_selectedIndex = index;
},
),
),
- new Center(
- child: new RaisedButton(
+ Center(
+ child: ElevatedButton(
onPressed: () {
if (_selectedIndex >= 0) {
- widget
- .valueChanged(widget.values[_selectedIndex]);
+ widget.valueChanged(
+ widget.values[_selectedIndex],
+ );
}
setState(() {});
Navigator.of(context).pop();
},
- child: new Text("ok"),
+ child: Text('ok'),
),
)
],
@@ -116,7 +128,13 @@ class NumberPad extends StatelessWidget {
final num min;
final ValueChanged onChangeValue;
- NumberPad({this.number, this.step, this.onChangeValue, this.max, this.min});
+ NumberPad({
+ required this.number,
+ required this.step,
+ required this.onChangeValue,
+ required this.max,
+ required this.min,
+ });
void onAdd() {
onChangeValue(number + step > max ? max : number + step);
@@ -128,15 +146,15 @@ class NumberPad extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return new Row(
+ return Row(
mainAxisSize: MainAxisSize.min,
children: [
- new IconButton(icon: new Icon(Icons.exposure_neg_1), onPressed: onSub),
- new Text(
+ IconButton(icon: Icon(Icons.exposure_neg_1), onPressed: onSub),
+ Text(
number is int ? number.toString() : number.toStringAsFixed(1),
- style: new TextStyle(fontSize: 14.0),
+ style: TextStyle(fontSize: 14.0),
),
- new IconButton(icon: new Icon(Icons.exposure_plus_1), onPressed: onAdd)
+ IconButton(icon: Icon(Icons.exposure_plus_1), onPressed: onAdd)
],
);
}
diff --git a/example/pubspec.lock b/example/pubspec.lock
index 5aa195f..0745960 100644
--- a/example/pubspec.lock
+++ b/example/pubspec.lock
@@ -1,60 +1,74 @@
# Generated by pub
-# See https://www.dartlang.org/tools/pub/glossary#lockfile
+# See https://dart.dev/tools/pub/glossary#lockfile
packages:
async:
dependency: transitive
description:
name: async
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.8"
+ version: "2.5.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.0.4"
+ version: "2.1.0"
+ characters:
+ dependency: transitive
+ description:
+ name: characters
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.1.0"
charcode:
dependency: transitive
description:
name: charcode
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.2.0"
+ clock:
+ dependency: transitive
+ description:
+ name: clock
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.2"
+ version: "1.1.0"
collection:
dependency: transitive
description:
name: collection
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.14.11"
+ version: "1.15.0"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "0.1.2"
+ version: "1.0.2"
+ fake_async:
+ dependency: transitive
+ description:
+ name: fake_async
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.2.0"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
- flutter_page_indicator:
- dependency: transitive
- description:
- name: flutter_page_indicator
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "0.0.3"
flutter_swiper:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
- version: "1.1.5"
+ version: "1.1.6"
flutter_test:
dependency: "direct dev"
description: flutter
@@ -64,37 +78,23 @@ packages:
dependency: transitive
description:
name: matcher
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "0.12.3+1"
+ version: "0.12.10"
meta:
dependency: transitive
description:
name: meta
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.6"
+ version: "1.3.0"
path:
dependency: transitive
description:
name: path
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.6.2"
- percent_indicator:
- dependency: "direct main"
- description:
- name: percent_indicator
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.0.9"
- quiver:
- dependency: transitive
- description:
- name: quiver
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.1"
+ version: "1.8.0"
sky_engine:
dependency: transitive
description: flutter
@@ -104,65 +104,58 @@ packages:
dependency: transitive
description:
name: source_span
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.4.1"
+ version: "1.8.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.9.3"
+ version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.6.8"
+ version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.0.4"
+ version: "1.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.0.1"
+ version: "1.2.0"
test_api:
dependency: transitive
description:
name: test_api
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "0.2.1"
- transformer_page_view:
- dependency: transitive
- description:
- name: transformer_page_view
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "0.1.5"
+ version: "0.2.19"
typed_data:
dependency: transitive
description:
name: typed_data
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.6"
+ version: "1.3.0"
vector_math:
dependency: transitive
description:
name: vector_math
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.8"
+ version: "2.1.0"
sdks:
- dart: ">=2.0.0 <3.0.0"
- flutter: ">=0.1.4 <3.0.0"
+ dart: ">=2.12.0 <3.0.0"
+ flutter: ">=0.1.4"
diff --git a/example/pubspec.yaml b/example/pubspec.yaml
index 48d87fa..4425fe1 100644
--- a/example/pubspec.yaml
+++ b/example/pubspec.yaml
@@ -1,19 +1,23 @@
name: example
description: A new Flutter project.
+publish_to: 'none' # Remove this line if you wish to publish to pub.dev
+
+version: 1.0.0+1
+
+environment:
+ sdk: ">=2.12.0 <3.0.0"
+
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
- cupertino_icons: ^0.1.0
-
+ cupertino_icons: ^1.0.2
flutter_swiper:
path: ../
- percent_indicator:
-
dev_dependencies:
flutter_test:
sdk: flutter
@@ -21,7 +25,6 @@ dev_dependencies:
flutter:
uses-material-design: true
-
assets:
- images/bg0.jpeg
- images/bg1.jpeg
diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart
index 63d397c..747db1d 100644
--- a/example/test/widget_test.dart
+++ b/example/test/widget_test.dart
@@ -1,8 +1,9 @@
// 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.
+//
+// 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:flutter_test/flutter_test.dart';
@@ -12,7 +13,7 @@ import 'package:example/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
- await tester.pumpWidget(new MyApp());
+ await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
diff --git a/example/web/favicon.png b/example/web/favicon.png
new file mode 100644
index 0000000..8aaa46a
Binary files /dev/null and b/example/web/favicon.png differ
diff --git a/example/web/icons/Icon-192.png b/example/web/icons/Icon-192.png
new file mode 100644
index 0000000..b749bfe
Binary files /dev/null and b/example/web/icons/Icon-192.png differ
diff --git a/example/web/icons/Icon-512.png b/example/web/icons/Icon-512.png
new file mode 100644
index 0000000..88cfd48
Binary files /dev/null and b/example/web/icons/Icon-512.png differ
diff --git a/example/web/index.html b/example/web/index.html
new file mode 100644
index 0000000..1460b5e
--- /dev/null
+++ b/example/web/index.html
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ example
+
+
+
+
+
+
+
+
diff --git a/example/web/manifest.json b/example/web/manifest.json
new file mode 100644
index 0000000..8c01291
--- /dev/null
+++ b/example/web/manifest.json
@@ -0,0 +1,23 @@
+{
+ "name": "example",
+ "short_name": "example",
+ "start_url": ".",
+ "display": "standalone",
+ "background_color": "#0175C2",
+ "theme_color": "#0175C2",
+ "description": "A new Flutter project.",
+ "orientation": "portrait-primary",
+ "prefer_related_applications": false,
+ "icons": [
+ {
+ "src": "icons/Icon-192.png",
+ "sizes": "192x192",
+ "type": "image/png"
+ },
+ {
+ "src": "icons/Icon-512.png",
+ "sizes": "512x512",
+ "type": "image/png"
+ }
+ ]
+}
diff --git a/lib/flutter_swiper.dart b/lib/flutter_swiper.dart
index 5f19cad..a61f403 100644
--- a/lib/flutter_swiper.dart
+++ b/lib/flutter_swiper.dart
@@ -5,3 +5,5 @@ export 'src/swiper_pagination.dart';
export 'src/swiper_control.dart';
export 'src/swiper_controller.dart';
export 'src/swiper_plugin.dart';
+export 'src/flutter_page_indicator/flutter_page_indicator.dart';
+export 'src/transformer_page_view/index_controller.dart';
\ No newline at end of file
diff --git a/lib/src/custom_layout.dart b/lib/src/custom_layout.dart
index 8ce77f2..e71a515 100644
--- a/lib/src/custom_layout.dart
+++ b/lib/src/custom_layout.dart
@@ -2,34 +2,35 @@ part of 'swiper.dart';
abstract class _CustomLayoutStateBase extends State
with SingleTickerProviderStateMixin {
- double _swiperWidth;
- double _swiperHeight;
- Animation _animation;
- AnimationController _animationController;
- int _startIndex;
- int _animationCount;
+ double? _swiperWidth;
+ double? _swiperHeight;
+ late Animation _animation;
+ AnimationController? _animationController;
+ late int _startIndex;
+ int? _animationCount;
@override
void initState() {
if (widget.itemWidth == null) {
- throw new Exception(
- "==============\n\nwidget.itemWith must not be null when use stack layout.\n========\n");
+ throw Exception(
+ '==============\n\nwidget.itemWith must not be null when use stack layout.\n========\n',
+ );
}
_createAnimationController();
- widget.controller.addListener(_onController);
+ widget.controller!.addListener(_onController);
super.initState();
}
void _createAnimationController() {
- _animationController = new AnimationController(vsync: this, value: 0.5);
- Tween tween = new Tween(begin: 0.0, end: 1.0);
- _animation = tween.animate(_animationController);
+ _animationController = AnimationController(vsync: this, value: 0.5);
+ final tween = Tween(begin: 0.0, end: 1.0);
+ _animation = tween.animate(_animationController!);
}
@override
void didChangeDependencies() {
- WidgetsBinding.instance.addPostFrameCallback(_getSize);
+ WidgetsBinding.instance!.addPostFrameCallback(_getSize);
super.didChangeDependencies();
}
@@ -39,8 +40,8 @@ abstract class _CustomLayoutStateBase extends State
@mustCallSuper
void afterRender() {
- RenderObject renderObject = context.findRenderObject();
- Size size = renderObject.paintBounds.size;
+ final renderObject = context.findRenderObject()!;
+ final size = renderObject.paintBounds.size;
_swiperWidth = size.width;
_swiperHeight = size.height;
setState(() {});
@@ -49,12 +50,12 @@ abstract class _CustomLayoutStateBase extends State
@override
void didUpdateWidget(T oldWidget) {
if (widget.controller != oldWidget.controller) {
- oldWidget.controller.removeListener(_onController);
- widget.controller.addListener(_onController);
+ oldWidget.controller!.removeListener(_onController);
+ widget.controller!.addListener(_onController);
}
if (widget.loop != oldWidget.loop) {
- if (!widget.loop) {
+ if (!widget.loop!) {
_currentIndex = _ensureIndex(_currentIndex);
}
}
@@ -63,16 +64,16 @@ abstract class _CustomLayoutStateBase extends State
}
int _ensureIndex(int index) {
- index = index % widget.itemCount;
+ index = index % widget.itemCount!;
if (index < 0) {
- index += widget.itemCount;
+ index += widget.itemCount!;
}
return index;
}
@override
void dispose() {
- widget.controller.removeListener(_onController);
+ widget.controller!.removeListener(_onController);
_animationController?.dispose();
super.dispose();
}
@@ -80,33 +81,33 @@ abstract class _CustomLayoutStateBase extends State
Widget _buildItem(int i, int realIndex, double animationValue);
Widget _buildContainer(List list) {
- return new Stack(
+ return Stack(
children: list,
);
}
- Widget _buildAnimation(BuildContext context, Widget w) {
- List list = [];
+ Widget _buildAnimation(BuildContext context, Widget? w) {
+ var list = [];
- double animationValue = _animation.value;
+ final animationValue = _animation.value;
- for (int i = 0; i < _animationCount; ++i) {
- int realIndex = _currentIndex + i + _startIndex;
- realIndex = realIndex % widget.itemCount;
+ for (var i = 0; i < _animationCount!; ++i) {
+ var realIndex = _currentIndex + i + _startIndex;
+ realIndex = realIndex % widget.itemCount!;
if (realIndex < 0) {
- realIndex += widget.itemCount;
+ realIndex += widget.itemCount!;
}
list.add(_buildItem(i, realIndex, animationValue));
}
- return new GestureDetector(
+ return GestureDetector(
behavior: HitTestBehavior.opaque,
onPanStart: _onPanStart,
onPanEnd: _onPanEnd,
onPanUpdate: _onPanUpdate,
- child: new ClipRect(
- child: new Center(
+ child: ClipRect(
+ child: Center(
child: _buildContainer(list),
),
),
@@ -116,33 +117,33 @@ abstract class _CustomLayoutStateBase extends State
@override
Widget build(BuildContext context) {
if (_animationCount == null) {
- return new Container();
+ return Container();
}
- return new AnimatedBuilder(
- animation: _animationController, builder: _buildAnimation);
+ return AnimatedBuilder(
+ animation: _animationController!, builder: _buildAnimation);
}
- double _currentValue;
- double _currentPos;
+ late double _currentValue;
+ late double _currentPos;
bool _lockScroll = false;
- void _move(double position, {int nextIndex}) async {
+ void _move(double position, {int? nextIndex}) async {
if (_lockScroll) return;
try {
_lockScroll = true;
- await _animationController.animateTo(position,
- duration: new Duration(milliseconds: widget.duration),
- curve: widget.curve);
+ await _animationController!.animateTo(position,
+ duration: Duration(milliseconds: widget.duration!),
+ curve: widget.curve!);
if (nextIndex != null) {
- widget.onIndexChanged(widget.getCorrectIndex(nextIndex));
+ widget.onIndexChanged!(widget.getCorrectIndex(nextIndex));
}
} catch (e) {
print(e);
} finally {
if (nextIndex != null) {
try {
- _animationController.value = 0.5;
+ _animationController!.value = 0.5;
} catch (e) {
print(e);
}
@@ -154,36 +155,36 @@ abstract class _CustomLayoutStateBase extends State
}
int _nextIndex() {
- int index = _currentIndex + 1;
- if (!widget.loop && index >= widget.itemCount - 1) {
- return widget.itemCount - 1;
+ final index = _currentIndex + 1;
+ if (!widget.loop! && index >= widget.itemCount! - 1) {
+ return widget.itemCount! - 1;
}
return index;
}
int _prevIndex() {
- int index = _currentIndex - 1;
- if (!widget.loop && index < 0) {
+ final index = _currentIndex - 1;
+ if (!widget.loop! && index < 0) {
return 0;
}
return index;
}
void _onController() {
- switch (widget.controller.event) {
+ switch (widget.controller!.event) {
case IndexController.PREVIOUS:
- int prevIndex = _prevIndex();
+ final prevIndex = _prevIndex();
if (prevIndex == _currentIndex) return;
_move(1.0, nextIndex: prevIndex);
break;
case IndexController.NEXT:
- int nextIndex = _nextIndex();
+ final nextIndex = _nextIndex();
if (nextIndex == _currentIndex) return;
_move(0.0, nextIndex: nextIndex);
break;
case IndexController.MOVE:
- throw new Exception(
- "Custom layout does not support SwiperControllerEvent.MOVE_INDEX yet!");
+ throw Exception(
+ 'Custom layout does not support SwiperControllerEvent.MOVE_INDEX yet!');
case SwiperController.STOP_AUTOPLAY:
case SwiperController.START_AUTOPLAY:
break;
@@ -193,17 +194,17 @@ abstract class _CustomLayoutStateBase extends State
void _onPanEnd(DragEndDetails details) {
if (_lockScroll) return;
- double velocity = widget.scrollDirection == Axis.horizontal
+ final velocity = widget.scrollDirection == Axis.horizontal
? details.velocity.pixelsPerSecond.dx
: details.velocity.pixelsPerSecond.dy;
- if (_animationController.value >= 0.75 || velocity > 500.0) {
- if (_currentIndex <= 0 && !widget.loop) {
+ if (_animationController!.value >= 0.75 || velocity > 500.0) {
+ if (_currentIndex <= 0 && !widget.loop!) {
return;
}
_move(1.0, nextIndex: _currentIndex - 1);
- } else if (_animationController.value < 0.25 || velocity < -500.0) {
- if (_currentIndex >= widget.itemCount - 1 && !widget.loop) {
+ } else if (_animationController!.value < 0.25 || velocity < -500.0) {
+ if (_currentIndex >= widget.itemCount! - 1 && !widget.loop!) {
return;
}
_move(0.0, nextIndex: _currentIndex + 1);
@@ -214,7 +215,7 @@ abstract class _CustomLayoutStateBase extends State
void _onPanStart(DragStartDetails details) {
if (_lockScroll) return;
- _currentValue = _animationController.value;
+ _currentValue = _animationController!.value;
_currentPos = widget.scrollDirection == Axis.horizontal
? details.globalPosition.dx
: details.globalPosition.dy;
@@ -222,16 +223,16 @@ abstract class _CustomLayoutStateBase extends State
void _onPanUpdate(DragUpdateDetails details) {
if (_lockScroll) return;
- double value = _currentValue +
+ var value = _currentValue +
((widget.scrollDirection == Axis.horizontal
? details.globalPosition.dx
: details.globalPosition.dy) -
_currentPos) /
- _swiperWidth /
+ _swiperWidth! /
2;
// no loop ?
- if (!widget.loop) {
- if (_currentIndex >= widget.itemCount - 1) {
+ if (!widget.loop!) {
+ if (_currentIndex >= widget.itemCount! - 1) {
if (value < 0.5) {
value = 0.5;
}
@@ -242,30 +243,30 @@ abstract class _CustomLayoutStateBase extends State
}
}
- _animationController.value = value;
+ _animationController!.value = value;
}
int _currentIndex = 0;
}
-double _getValue(List values, double animationValue, int index) {
- double s = values[index];
+double? _getValue(List values, double animationValue, int index) {
+ var s = values[index];
if (animationValue >= 0.5) {
if (index < values.length - 1) {
- s = s + (values[index + 1] - s) * (animationValue - 0.5) * 2.0;
+ s = s! + (values[index + 1]! - s) * (animationValue - 0.5) * 2.0;
}
} else {
if (index != 0) {
- s = s - (s - values[index - 1]) * (0.5 - animationValue) * 2.0;
+ s = s! - (s - values[index - 1]!) * (0.5 - animationValue) * 2.0;
}
}
return s;
}
Offset _getOffsetValue(List values, double animationValue, int index) {
- Offset s = values[index];
- double dx = s.dx;
- double dy = s.dy;
+ final s = values[index];
+ var dx = s.dx;
+ var dy = s.dy;
if (animationValue >= 0.5) {
if (index < values.length - 1) {
dx = dx + (values[index + 1].dx - dx) * (animationValue - 0.5) * 2.0;
@@ -277,32 +278,38 @@ Offset _getOffsetValue(List values, double animationValue, int index) {
dy = dy - (dy - values[index - 1].dy) * (0.5 - animationValue) * 2.0;
}
}
- return new Offset(dx, dy);
+ return Offset(dx, dy);
}
abstract class TransformBuilder {
- List values;
+ List? values;
+
TransformBuilder({this.values});
+
Widget build(int i, double animationValue, Widget widget);
}
class ScaleTransformBuilder extends TransformBuilder {
final Alignment alignment;
- ScaleTransformBuilder({List values, this.alignment: Alignment.center})
+
+ ScaleTransformBuilder(
+ {List? values, this.alignment = Alignment.center})
: super(values: values);
+ @override
Widget build(int i, double animationValue, Widget widget) {
- double s = _getValue(values, animationValue, i);
- return new Transform.scale(scale: s, child: widget);
+ final s = _getValue(values!, animationValue, i)!;
+ return Transform.scale(scale: s, child: widget);
}
}
class OpacityTransformBuilder extends TransformBuilder {
- OpacityTransformBuilder({List values}) : super(values: values);
+ OpacityTransformBuilder({List? values}) : super(values: values);
+ @override
Widget build(int i, double animationValue, Widget widget) {
- double v = _getValue(values, animationValue, i);
- return new Opacity(
+ final v = _getValue(values!, animationValue, i)!;
+ return Opacity(
opacity: v,
child: widget,
);
@@ -310,11 +317,12 @@ class OpacityTransformBuilder extends TransformBuilder {
}
class RotateTransformBuilder extends TransformBuilder {
- RotateTransformBuilder({List values}) : super(values: values);
+ RotateTransformBuilder({List? values}) : super(values: values);
+ @override
Widget build(int i, double animationValue, Widget widget) {
- double v = _getValue(values, animationValue, i);
- return new Transform.rotate(
+ final v = _getValue(values!, animationValue, i)!;
+ return Transform.rotate(
angle: v,
child: widget,
);
@@ -322,12 +330,12 @@ class RotateTransformBuilder extends TransformBuilder {
}
class TranslateTransformBuilder extends TransformBuilder {
- TranslateTransformBuilder({List values}) : super(values: values);
+ TranslateTransformBuilder({List? values}) : super(values: values);
@override
Widget build(int i, double animationValue, Widget widget) {
- Offset s = _getOffsetValue(values, animationValue, i);
- return new Transform.translate(
+ final s = _getOffsetValue(values!, animationValue, i);
+ return Transform.translate(
offset: s,
child: widget,
);
@@ -337,29 +345,27 @@ class TranslateTransformBuilder extends TransformBuilder {
class CustomLayoutOption {
final List builders = [];
final int startIndex;
- final int stateCount;
+ final int? stateCount;
- CustomLayoutOption({this.stateCount, this.startIndex})
- : assert(startIndex != null, stateCount != null);
+ CustomLayoutOption({this.stateCount, required this.startIndex});
CustomLayoutOption addOpacity(List values) {
- builders.add(new OpacityTransformBuilder(values: values));
+ builders.add(OpacityTransformBuilder(values: values));
return this;
}
CustomLayoutOption addTranslate(List values) {
- builders.add(new TranslateTransformBuilder(values: values));
+ builders.add(TranslateTransformBuilder(values: values));
return this;
}
CustomLayoutOption addScale(List values, Alignment alignment) {
- builders
- .add(new ScaleTransformBuilder(values: values, alignment: alignment));
+ builders.add(ScaleTransformBuilder(values: values, alignment: alignment));
return this;
}
CustomLayoutOption addRotate(List values) {
- builders.add(new RotateTransformBuilder(values: values));
+ builders.add(RotateTransformBuilder(values: values));
return this;
}
}
@@ -367,22 +373,21 @@ class CustomLayoutOption {
class _CustomLayoutSwiper extends _SubSwiper {
final CustomLayoutOption option;
- _CustomLayoutSwiper(
- {this.option,
- double itemWidth,
- bool loop,
- double itemHeight,
- ValueChanged onIndexChanged,
- Key key,
- IndexedWidgetBuilder itemBuilder,
- Curve curve,
- int duration,
- int index,
- int itemCount,
- Axis scrollDirection,
- SwiperController controller})
- : assert(option != null),
- super(
+ _CustomLayoutSwiper({
+ required this.option,
+ double? itemWidth,
+ bool? loop,
+ double? itemHeight,
+ ValueChanged? onIndexChanged,
+ Key? key,
+ IndexedWidgetBuilder? itemBuilder,
+ Curve? curve,
+ int? duration,
+ int? index,
+ int? itemCount,
+ Axis? scrollDirection,
+ SwiperController? controller,
+ }) : super(
loop: loop,
onIndexChanged: onIndexChanged,
itemWidth: itemWidth,
@@ -398,7 +403,7 @@ class _CustomLayoutSwiper extends _SubSwiper {
@override
State createState() {
- return new _CustomLayoutState();
+ return _CustomLayoutState();
}
}
@@ -419,15 +424,15 @@ class _CustomLayoutState extends _CustomLayoutStateBase<_CustomLayoutSwiper> {
@override
Widget _buildItem(int index, int realIndex, double animationValue) {
- List builders = widget.option.builders;
+ final builders = widget.option.builders;
- Widget child = new SizedBox(
+ Widget child = SizedBox(
width: widget.itemWidth ?? double.infinity,
height: widget.itemHeight ?? double.infinity,
- child: widget.itemBuilder(context, realIndex));
+ child: widget.itemBuilder!(context, realIndex));
- for (int i = builders.length - 1; i >= 0; --i) {
- TransformBuilder builder = builders[i];
+ for (var i = builders.length - 1; i >= 0; --i) {
+ var builder = builders[i];
child = builder.build(index, animationValue, child);
}
diff --git a/lib/src/flutter_page_indicator/flutter_page_indicator.dart b/lib/src/flutter_page_indicator/flutter_page_indicator.dart
new file mode 100644
index 0000000..47d20d9
--- /dev/null
+++ b/lib/src/flutter_page_indicator/flutter_page_indicator.dart
@@ -0,0 +1,350 @@
+library flutter_page_indicator;
+
+import 'package:flutter/material.dart';
+import 'package:flutter/widgets.dart';
+
+class WarmPainter extends BasePainter {
+ WarmPainter(PageIndicator widget, double page, int index, Paint paint)
+ : super(widget, page, index, paint);
+
+ @override
+ void draw(Canvas canvas, double space, double size, double radius) {
+ var progress = page - index;
+ var distance = size + space;
+ var start = index * (size + space);
+
+ if (progress > 0.5) {
+ final right = start + size + distance;
+ //progress=>0.5-1.0
+ //left:0.0=>distance
+
+ final left = index * distance + distance * (progress - 0.5) * 2;
+ canvas.drawRRect(
+ RRect.fromLTRBR(left, 0.0, right, size, Radius.circular(radius)),
+ _paint);
+ } else {
+ final right = start + size + distance * progress * 2;
+
+ canvas.drawRRect(
+ RRect.fromLTRBR(start, 0.0, right, size, Radius.circular(radius)),
+ _paint);
+ }
+ }
+}
+
+class DropPainter extends BasePainter {
+ DropPainter(PageIndicator widget, double page, int index, Paint paint)
+ : super(widget, page, index, paint);
+
+ @override
+ void draw(Canvas canvas, double space, double size, double radius) {
+ final progress = page - index;
+ final dropHeight = widget.dropHeight;
+ final rate = (0.5 - progress).abs() * 2;
+ final scale = widget.scale;
+
+ //lerp(begin, end, progress)
+
+ canvas.drawCircle(
+ Offset(radius + ((page) * (size + space)),
+ radius - dropHeight * (1 - rate)),
+ radius * (scale + rate * (1.0 - scale)),
+ _paint);
+ }
+}
+
+class NonePainter extends BasePainter {
+ NonePainter(PageIndicator widget, double page, int index, Paint paint)
+ : super(widget, page, index, paint);
+
+ @override
+ void draw(Canvas canvas, double space, double size, double radius) {
+ final progress = page - index;
+ final secondOffset = index == widget.count - 1
+ ? radius
+ : radius + ((index + 1) * (size + space));
+
+ if (progress > 0.5) {
+ canvas.drawCircle(Offset(secondOffset, radius), radius, _paint);
+ } else {
+ canvas.drawCircle(
+ Offset(radius + (index * (size + space)), radius), radius, _paint);
+ }
+ }
+}
+
+class SlidePainter extends BasePainter {
+ SlidePainter(PageIndicator widget, double page, int index, Paint paint)
+ : super(widget, page, index, paint);
+
+ @override
+ void draw(Canvas canvas, double space, double size, double radius) {
+ canvas.drawCircle(
+ Offset(radius + (page * (size + space)), radius), radius, _paint);
+ }
+}
+
+class ScalePainter extends BasePainter {
+ ScalePainter(PageIndicator widget, double page, int index, Paint paint)
+ : super(widget, page, index, paint);
+
+ // 连续的两个点,含有最后一个和第一个
+ @override
+ bool _shouldSkip(int i) {
+ if (index == widget.count - 1) {
+ return i == 0 || i == index;
+ }
+ return (i == index || i == index + 1);
+ }
+
+ @override
+ void paint(Canvas canvas, Size size) {
+ _paint.color = widget.color;
+ final space = widget.space;
+ final size = widget.size;
+ final radius = size / 2;
+ for (var i = 0, c = widget.count; i < c; ++i) {
+ if (_shouldSkip(i)) {
+ continue;
+ }
+ canvas.drawCircle(Offset(i * (size + space) + radius, radius),
+ radius * widget.scale, _paint);
+ }
+
+ _paint.color = widget.activeColor;
+ draw(canvas, space, size, radius);
+ }
+
+ @override
+ void draw(Canvas canvas, double space, double size, double radius) {
+ final secondOffset = index == widget.count - 1
+ ? radius
+ : radius + ((index + 1) * (size + space));
+
+ final progress = page - index;
+ _paint.color = Color.lerp(widget.activeColor, widget.color, progress)!;
+ //last
+ canvas.drawCircle(Offset(radius + (index * (size + space)), radius),
+ lerp(radius, radius * widget.scale, progress), _paint);
+ //first
+ _paint.color = Color.lerp(widget.color, widget.activeColor, progress)!;
+ canvas.drawCircle(Offset(secondOffset, radius),
+ lerp(radius * widget.scale, radius, progress), _paint);
+ }
+}
+
+class ColorPainter extends BasePainter {
+ ColorPainter(PageIndicator widget, double page, int index, Paint paint)
+ : super(widget, page, index, paint);
+
+ // 连续的两个点,含有最后一个和第一个
+ @override
+ bool _shouldSkip(int i) {
+ if (index == widget.count - 1) {
+ return i == 0 || i == index;
+ }
+ return (i == index || i == index + 1);
+ }
+
+ @override
+ void draw(Canvas canvas, double space, double size, double radius) {
+ final progress = page - index;
+ final secondOffset = index == widget.count - 1
+ ? radius
+ : radius + ((index + 1) * (size + space));
+
+ _paint.color = Color.lerp(widget.activeColor, widget.color, progress)!;
+ //left
+ canvas.drawCircle(
+ Offset(radius + (index * (size + space)), radius), radius, _paint);
+ //right
+ _paint.color = Color.lerp(widget.color, widget.activeColor, progress)!;
+ canvas.drawCircle(Offset(secondOffset, radius), radius, _paint);
+ }
+}
+
+abstract class BasePainter extends CustomPainter {
+ final PageIndicator widget;
+ final double page;
+ final int index;
+ final Paint _paint;
+
+ double lerp(double begin, double end, double progress) {
+ return begin + (end - begin) * progress;
+ }
+
+ BasePainter(this.widget, this.page, this.index, this._paint);
+
+ void draw(Canvas canvas, double space, double size, double radius);
+
+ bool _shouldSkip(int index) {
+ return false;
+ }
+
+ //double secondOffset = index == widget.count-1 ? radius : radius + ((index + 1) * (size + space));
+
+ @override
+ void paint(Canvas canvas, Size size) {
+ _paint.color = widget.color;
+ final space = widget.space;
+ final size = widget.size;
+ final radius = size / 2;
+ for (var i = 0, c = widget.count; i < c; ++i) {
+ if (_shouldSkip(i)) {
+ continue;
+ }
+ canvas.drawCircle(
+ Offset(i * (size + space) + radius, radius), radius, _paint);
+ }
+
+ var page = this.page;
+ if (page < index) {
+ page = 0.0;
+ }
+ _paint.color = widget.activeColor;
+ draw(canvas, space, size, radius);
+ }
+
+ @override
+ bool shouldRepaint(BasePainter oldDelegate) {
+ return oldDelegate.page != page;
+ }
+}
+
+class _PageIndicatorState extends State {
+ int index = 0;
+ final _paint = Paint();
+
+ BasePainter _createPainter() {
+ switch (widget.layout) {
+ case PageIndicatorLayout.NONE:
+ return NonePainter(
+ widget, widget.controller.page ?? 0.0, index, _paint);
+ case PageIndicatorLayout.SLIDE:
+ return SlidePainter(
+ widget, widget.controller.page ?? 0.0, index, _paint);
+ case PageIndicatorLayout.WARM:
+ return WarmPainter(
+ widget, widget.controller.page ?? 0.0, index, _paint);
+ case PageIndicatorLayout.COLOR:
+ return ColorPainter(
+ widget, widget.controller.page ?? 0.0, index, _paint);
+ case PageIndicatorLayout.SCALE:
+ return ScalePainter(
+ widget, widget.controller.page ?? 0.0, index, _paint);
+ case PageIndicatorLayout.DROP:
+ return DropPainter(
+ widget, widget.controller.page ?? 0.0, index, _paint);
+ default:
+ throw Exception('Not a valid layout');
+ }
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ Widget child = SizedBox(
+ width: widget.count * widget.size + (widget.count - 1) * widget.space,
+ height: widget.size,
+ child: CustomPaint(
+ painter: _createPainter(),
+ ),
+ );
+
+ if (widget.layout == PageIndicatorLayout.SCALE ||
+ widget.layout == PageIndicatorLayout.COLOR) {
+ child = ClipRect(
+ child: child,
+ );
+ }
+
+ return IgnorePointer(
+ child: child,
+ );
+ }
+
+ void _onController() {
+ final page = widget.controller.page ?? 0.0;
+ index = page.floor();
+
+ setState(() {});
+ }
+
+ @override
+ void initState() {
+ widget.controller.addListener(_onController);
+ super.initState();
+ }
+
+ @override
+ void didUpdateWidget(PageIndicator oldWidget) {
+ if (widget.controller != oldWidget.controller) {
+ oldWidget.controller.removeListener(_onController);
+ widget.controller.addListener(_onController);
+ }
+ super.didUpdateWidget(oldWidget);
+ }
+
+ @override
+ void dispose() {
+ widget.controller.removeListener(_onController);
+ super.dispose();
+ }
+}
+
+enum PageIndicatorLayout {
+ NONE,
+ SLIDE,
+ WARM,
+ COLOR,
+ SCALE,
+ DROP,
+}
+
+class PageIndicator extends StatefulWidget {
+ /// size of the dots
+ final double size;
+
+ /// space between dots.
+ final double space;
+
+ /// count of dots
+ final int count;
+
+ /// active color
+ final Color activeColor;
+
+ /// normal color
+ final Color color;
+
+ /// layout of the dots,default is [PageIndicatorLayout.SLIDE]
+ final PageIndicatorLayout? layout;
+
+ // Only valid when layout==PageIndicatorLayout.scale
+ final double scale;
+
+ // Only valid when layout==PageIndicatorLayout.drop
+ final double dropHeight;
+
+ final PageController controller;
+
+ final double activeSize;
+
+ PageIndicator({
+ Key? key,
+ this.size = 20.0,
+ this.space = 5.0,
+ required this.count,
+ this.activeSize = 20.0,
+ required this.controller,
+ this.color = Colors.white30,
+ this.layout = PageIndicatorLayout.SLIDE,
+ this.activeColor = Colors.white,
+ this.scale = 0.6,
+ this.dropHeight = 20.0,
+ }) : super(key: key);
+
+ @override
+ State createState() {
+ return _PageIndicatorState();
+ }
+}
diff --git a/lib/src/swiper.dart b/lib/src/swiper.dart
index 9783740..8d43652 100644
--- a/lib/src/swiper.dart
+++ b/lib/src/swiper.dart
@@ -1,16 +1,18 @@
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
-import 'package:flutter_page_indicator/flutter_page_indicator.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
+import 'package:flutter_swiper/src/flutter_page_indicator/flutter_page_indicator.dart';
+import 'package:flutter_swiper/src/transformer_page_view/index_controller.dart';
import 'dart:async';
-import 'package:transformer_page_view/transformer_page_view.dart';
+import 'package:flutter_swiper/src/transformer_page_view/transformer_page_view.dart';
part 'custom_layout.dart';
-typedef void SwiperOnTap(int index);
+typedef SwiperOnTap = Function(int index);
-typedef Widget SwiperDataBuilder(BuildContext context, dynamic data, int index);
+typedef SwiperDataBuilder = Function(
+ BuildContext context, dynamic data, int index);
/// default auto play delay
const int kDefaultAutoplayDelayMs = 3000;
@@ -28,27 +30,28 @@ class Swiper extends StatefulWidget {
final bool outer;
/// Inner item height, this property is valid if layout=STACK or layout=TINDER or LAYOUT=CUSTOM,
- final double itemHeight;
+ final double? itemHeight;
/// Inner item width, this property is valid if layout=STACK or layout=TINDER or LAYOUT=CUSTOM,
- final double itemWidth;
+ final double? itemWidth;
// height of the inside container,this property is valid when outer=true,otherwise the inside container size is controlled by parent widget
- final double containerHeight;
+ final double? containerHeight;
+
// width of the inside container,this property is valid when outer=true,otherwise the inside container size is controlled by parent widget
- final double containerWidth;
+ final double? containerWidth;
/// Build item on index
- final IndexedWidgetBuilder itemBuilder;
+ final IndexedWidgetBuilder? itemBuilder;
/// Support transform like Android PageView did
/// `itemBuilder` and `transformItemBuilder` must have one not null
- final PageTransformer transformer;
+ final PageTransformer? transformer;
/// count of the display items
final int itemCount;
- final ValueChanged onIndexChanged;
+ final ValueChanged? onIndexChanged;
///auto play config
final bool autoplay;
@@ -74,24 +77,24 @@ class Swiper extends StatefulWidget {
///Index number of initial slide.
///If not set , the `Swiper` is 'uncontrolled', which means manage index by itself
///If set , the `Swiper` is 'controlled', which means the index is fully managed by parent widget.
- final int index;
+ final int? index;
///Called when tap
- final SwiperOnTap onTap;
+ final SwiperOnTap? onTap;
///The swiper pagination plugin
- final SwiperPlugin pagination;
+ final SwiperPlugin? pagination;
///the swiper control button plugin
- final SwiperPlugin control;
+ final SwiperPlugin? control;
///other plugins, you can custom your own plugin
- final List plugins;
+ final List? plugins;
///
- final SwiperController controller;
+ final SwiperController? controller;
- final ScrollPhysics physics;
+ final ScrollPhysics? physics;
///
final double viewportFraction;
@@ -100,53 +103,55 @@ class Swiper extends StatefulWidget {
final SwiperLayout layout;
/// this value is valid when layout == SwiperLayout.CUSTOM
- final CustomLayoutOption customLayoutOption;
+ final CustomLayoutOption? customLayoutOption;
// This value is valid when viewportFraction is set and < 1.0
- final double scale;
+ final double? scale;
// This value is valid when viewportFraction is set and < 1.0
- final double fade;
+ final double? fade;
final PageIndicatorLayout indicatorLayout;
Swiper({
this.itemBuilder,
- this.indicatorLayout: PageIndicatorLayout.NONE,
+ this.indicatorLayout = PageIndicatorLayout.NONE,
///
this.transformer,
- @required this.itemCount,
- this.autoplay: false,
- this.layout: SwiperLayout.DEFAULT,
- this.autoplayDelay: kDefaultAutoplayDelayMs,
- this.autoplayDisableOnInteraction: true,
- this.duration: kDefaultAutoplayTransactionDuration,
+ required this.itemCount,
+ this.autoplay = false,
+ this.layout = SwiperLayout.DEFAULT,
+ this.autoplayDelay = kDefaultAutoplayDelayMs,
+ this.autoplayDisableOnInteraction = true,
+ this.duration = kDefaultAutoplayTransactionDuration,
this.onIndexChanged,
this.index,
this.onTap,
this.control,
- this.loop: true,
- this.curve: Curves.ease,
- this.scrollDirection: Axis.horizontal,
+ this.loop = true,
+ this.curve = Curves.ease,
+ this.scrollDirection = Axis.horizontal,
this.pagination,
this.plugins,
this.physics,
- Key key,
+ Key? key,
this.controller,
this.customLayoutOption,
/// since v1.0.0
this.containerHeight,
this.containerWidth,
- this.viewportFraction: 1.0,
+ this.viewportFraction = 1.0,
this.itemHeight,
this.itemWidth,
- this.outer: false,
+ this.outer = false,
this.scale,
this.fade,
- }) : assert(itemBuilder != null || transformer != null,
- "itemBuilder and transformItemBuilder must not be both null"),
+ }) : assert(
+ itemBuilder != null || transformer != null,
+ 'itemBuilder and transformItemBuilder must not be both null',
+ ),
assert(
!loop ||
((loop &&
@@ -155,41 +160,41 @@ class Swiper extends StatefulWidget {
indicatorLayout == PageIndicatorLayout.COLOR ||
indicatorLayout == PageIndicatorLayout.NONE)) ||
(loop && layout != SwiperLayout.DEFAULT)),
- "Only support `PageIndicatorLayout.SCALE` and `PageIndicatorLayout.COLOR`when layout==SwiperLayout.DEFAULT in loop mode"),
+ 'Only support `PageIndicatorLayout.SCALE` and `PageIndicatorLayout.COLOR`when layout==SwiperLayout.DEFAULT in loop mode'),
super(key: key);
factory Swiper.children({
- List children,
- bool autoplay: false,
- PageTransformer transformer,
- int autoplayDelay: kDefaultAutoplayDelayMs,
- bool reverse: false,
- bool autoplayDisableOnInteraction: true,
- int duration: kDefaultAutoplayTransactionDuration,
- ValueChanged onIndexChanged,
- int index,
- SwiperOnTap onTap,
- bool loop: true,
- Curve curve: Curves.ease,
- Axis scrollDirection: Axis.horizontal,
- SwiperPlugin pagination,
- SwiperPlugin control,
- List plugins,
- SwiperController controller,
- Key key,
- CustomLayoutOption customLayoutOption,
- ScrollPhysics physics,
- double containerHeight,
- double containerWidth,
- double viewportFraction: 1.0,
- double itemHeight,
- double itemWidth,
- bool outer: false,
- double scale: 1.0,
+ required List children,
+ bool autoplay = false,
+ PageTransformer? transformer,
+ int autoplayDelay = kDefaultAutoplayDelayMs,
+ bool reverse = false,
+ bool autoplayDisableOnInteraction = true,
+ int duration = kDefaultAutoplayTransactionDuration,
+ ValueChanged? onIndexChanged,
+ int? index,
+ SwiperOnTap? onTap,
+ bool loop = true,
+ Curve curve = Curves.ease,
+ Axis scrollDirection = Axis.horizontal,
+ SwiperPlugin? pagination,
+ SwiperPlugin? control,
+ List? plugins,
+ SwiperController? controller,
+ Key? key,
+ CustomLayoutOption? customLayoutOption,
+ ScrollPhysics? physics,
+ double? containerHeight,
+ double? containerWidth,
+ double viewportFraction = 1.0,
+ double? itemHeight,
+ double? itemWidth,
+ bool outer = false,
+ double scale = 1.0,
}) {
- assert(children != null, "children must not be null");
+ // assert(children != null, "children must not be null");
- return new Swiper(
+ return Swiper(
transformer: transformer,
customLayoutOption: customLayoutOption,
containerHeight: containerHeight,
@@ -222,36 +227,36 @@ class Swiper extends StatefulWidget {
}
factory Swiper.list({
- PageTransformer transformer,
- List list,
- CustomLayoutOption customLayoutOption,
- SwiperDataBuilder builder,
- bool autoplay: false,
- int autoplayDelay: kDefaultAutoplayDelayMs,
- bool reverse: false,
- bool autoplayDisableOnInteraction: true,
- int duration: kDefaultAutoplayTransactionDuration,
- ValueChanged onIndexChanged,
- int index,
- SwiperOnTap onTap,
- bool loop: true,
- Curve curve: Curves.ease,
- Axis scrollDirection: Axis.horizontal,
- SwiperPlugin pagination,
- SwiperPlugin control,
- List plugins,
- SwiperController controller,
- Key key,
- ScrollPhysics physics,
- double containerHeight,
- double containerWidth,
- double viewportFraction: 1.0,
- double itemHeight,
- double itemWidth,
- bool outer: false,
- double scale: 1.0,
+ PageTransformer? transformer,
+ List? list,
+ CustomLayoutOption? customLayoutOption,
+ SwiperDataBuilder? builder,
+ bool autoplay = false,
+ int autoplayDelay = kDefaultAutoplayDelayMs,
+ bool reverse = false,
+ bool autoplayDisableOnInteraction = true,
+ int duration = kDefaultAutoplayTransactionDuration,
+ ValueChanged? onIndexChanged,
+ int? index,
+ SwiperOnTap? onTap,
+ bool loop = true,
+ Curve curve = Curves.ease,
+ Axis scrollDirection = Axis.horizontal,
+ SwiperPlugin? pagination,
+ SwiperPlugin? control,
+ List? plugins,
+ SwiperController? controller,
+ Key? key,
+ ScrollPhysics? physics,
+ double? containerHeight,
+ double? containerWidth,
+ double viewportFraction = 1.0,
+ double? itemHeight,
+ double? itemWidth,
+ bool outer = false,
+ double scale = 1.0,
}) {
- return new Swiper(
+ return Swiper(
transformer: transformer,
customLayoutOption: customLayoutOption,
containerHeight: containerHeight,
@@ -278,35 +283,33 @@ class Swiper extends StatefulWidget {
plugins: plugins,
physics: physics,
itemBuilder: (BuildContext context, int index) {
- return builder(context, list[index], index);
+ return builder!(context, list![index], index);
},
- itemCount: list.length);
+ itemCount: list!.length);
}
@override
State createState() {
- return new _SwiperState();
+ return _SwiperState();
}
}
abstract class _SwiperTimerMixin extends State {
- Timer _timer;
+ Timer? _timer;
- SwiperController _controller;
+ SwiperController? _controller;
@override
void initState() {
- _controller = widget.controller;
- if (_controller == null) {
- _controller = new SwiperController();
- }
- _controller.addListener(_onController);
+ _controller = widget.controller ?? SwiperController();
+
+ _controller!.addListener(_onController);
_handleAutoplay();
super.initState();
}
void _onController() {
- switch (_controller.event) {
+ switch (_controller!.event) {
case SwiperController.START_AUTOPLAY:
{
if (_timer == null) {
@@ -328,9 +331,9 @@ abstract class _SwiperTimerMixin extends State {
void didUpdateWidget(Swiper oldWidget) {
if (_controller != oldWidget.controller) {
if (oldWidget.controller != null) {
- oldWidget.controller.removeListener(_onController);
+ oldWidget.controller!.removeListener(_onController);
_controller = oldWidget.controller;
- _controller.addListener(_onController);
+ _controller!.addListener(_onController);
}
}
_handleAutoplay();
@@ -340,7 +343,7 @@ abstract class _SwiperTimerMixin extends State {
@override
void dispose() {
if (_controller != null) {
- _controller.removeListener(_onController);
+ _controller!.removeListener(_onController);
// _controller.dispose();
}
@@ -349,7 +352,7 @@ abstract class _SwiperTimerMixin extends State {
}
bool _autoplayEnabled() {
- return _controller.autoplay ?? widget.autoplay;
+ return _controller!.autoplay ?? widget.autoplay;
}
void _handleAutoplay() {
@@ -361,35 +364,33 @@ abstract class _SwiperTimerMixin extends State {
}
void _startAutoplay() {
- assert(_timer == null, "Timer must be stopped before start!");
+ assert(_timer == null, 'Timer must be stopped before start!');
_timer =
Timer.periodic(Duration(milliseconds: widget.autoplayDelay), _onTimer);
}
void _onTimer(Timer timer) {
- _controller.next(animation: true);
+ _controller!.next(animation: true);
}
void _stopAutoplay() {
if (_timer != null) {
- _timer.cancel();
+ _timer!.cancel();
_timer = null;
}
}
}
class _SwiperState extends _SwiperTimerMixin {
- int _activeIndex;
+ int? _activeIndex;
- TransformerPageController _pageController;
+ TransformerPageController? _pageController;
Widget _wrapTap(BuildContext context, int index) {
- return new GestureDetector(
+ return GestureDetector(
behavior: HitTestBehavior.opaque,
- onTap: () {
- this.widget.onTap(index);
- },
- child: widget.itemBuilder(context, index),
+ onTap: () => widget.onTap!(index),
+ child: widget.itemBuilder!(context, index),
);
}
@@ -397,19 +398,19 @@ class _SwiperState extends _SwiperTimerMixin {
void initState() {
_activeIndex = widget.index ?? 0;
if (_isPageViewLayout()) {
- _pageController = new TransformerPageController(
- initialPage: widget.index,
+ _pageController = TransformerPageController(
+ initialPage: widget.index ?? 0,
loop: widget.loop,
itemCount: widget.itemCount,
reverse:
- widget.transformer == null ? false : widget.transformer.reverse,
+ widget.transformer == null ? false : widget.transformer!.reverse,
viewportFraction: widget.viewportFraction);
}
super.initState();
}
bool _isPageViewLayout() {
- return widget.layout == null || widget.layout == SwiperLayout.DEFAULT;
+ return widget.layout == SwiperLayout.DEFAULT;
}
@override
@@ -418,7 +419,7 @@ class _SwiperState extends _SwiperTimerMixin {
}
bool _getReverse(Swiper widget) =>
- widget.transformer == null ? false : widget.transformer.reverse;
+ widget.transformer == null ? false : widget.transformer!.reverse;
@override
void didUpdateWidget(Swiper oldWidget) {
@@ -430,8 +431,8 @@ class _SwiperState extends _SwiperTimerMixin {
widget.itemCount != oldWidget.itemCount ||
widget.viewportFraction != oldWidget.viewportFraction ||
_getReverse(widget) != _getReverse(oldWidget))) {
- _pageController = new TransformerPageController(
- initialPage: widget.index,
+ _pageController = TransformerPageController(
+ initialPage: widget.index ?? 0,
loop: widget.loop,
itemCount: widget.itemCount,
reverse: _getReverse(widget),
@@ -441,7 +442,7 @@ class _SwiperState extends _SwiperTimerMixin {
scheduleMicrotask(() {
// So that we have a chance to do `removeListener` in child widgets.
if (_pageController != null) {
- _pageController.dispose();
+ _pageController!.dispose();
_pageController = null;
}
});
@@ -451,17 +452,17 @@ class _SwiperState extends _SwiperTimerMixin {
}
}
- void _onIndexChanged(int index) {
+ void _onIndexChanged(int? index) {
setState(() {
_activeIndex = index;
});
if (widget.onIndexChanged != null) {
- widget.onIndexChanged(index);
+ widget.onIndexChanged!(index!);
}
}
Widget _buildSwiper() {
- IndexedWidgetBuilder itemBuilder;
+ IndexedWidgetBuilder? itemBuilder;
if (widget.onTap != null) {
itemBuilder = _wrapTap;
} else {
@@ -469,7 +470,7 @@ class _SwiperState extends _SwiperTimerMixin {
}
if (widget.layout == SwiperLayout.STACK) {
- return new _StackSwiper(
+ return _StackSwiper(
loop: widget.loop,
itemWidth: widget.itemWidth,
itemHeight: widget.itemHeight,
@@ -483,13 +484,13 @@ class _SwiperState extends _SwiperTimerMixin {
scrollDirection: widget.scrollDirection,
);
} else if (_isPageViewLayout()) {
- PageTransformer transformer = widget.transformer;
+ var transformer = widget.transformer;
if (widget.scale != null || widget.fade != null) {
transformer =
- new ScaleAndFadeTransformer(scale: widget.scale, fade: widget.fade);
+ ScaleAndFadeTransformer(scale: widget.scale, fade: widget.fade);
}
- Widget child = new TransformerPageView(
+ Widget child = TransformerPageView(
pageController: _pageController,
loop: widget.loop,
itemCount: widget.itemCount,
@@ -497,7 +498,7 @@ class _SwiperState extends _SwiperTimerMixin {
transformer: transformer,
viewportFraction: widget.viewportFraction,
index: _activeIndex,
- duration: new Duration(milliseconds: widget.duration),
+ duration: Duration(milliseconds: widget.duration),
scrollDirection: widget.scrollDirection,
onPageChanged: _onIndexChanged,
curve: widget.curve,
@@ -505,8 +506,7 @@ class _SwiperState extends _SwiperTimerMixin {
controller: _controller,
);
if (widget.autoplayDisableOnInteraction && widget.autoplay) {
- return new NotificationListener(
- child: child,
+ return NotificationListener(
onNotification: (ScrollNotification notification) {
if (notification is ScrollStartNotification) {
if (notification.dragDetails != null) {
@@ -519,12 +519,13 @@ class _SwiperState extends _SwiperTimerMixin {
return false;
},
+ child: child,
);
}
return child;
} else if (widget.layout == SwiperLayout.TINDER) {
- return new _TinderSwiper(
+ return _TinderSwiper(
loop: widget.loop,
itemWidth: widget.itemWidth,
itemHeight: widget.itemHeight,
@@ -538,9 +539,9 @@ class _SwiperState extends _SwiperTimerMixin {
scrollDirection: widget.scrollDirection,
);
} else if (widget.layout == SwiperLayout.CUSTOM) {
- return new _CustomLayoutSwiper(
+ return _CustomLayoutSwiper(
loop: widget.loop,
- option: widget.customLayoutOption,
+ option: widget.customLayoutOption!,
itemWidth: widget.itemWidth,
itemHeight: widget.itemHeight,
itemCount: widget.itemCount,
@@ -553,28 +554,27 @@ class _SwiperState extends _SwiperTimerMixin {
scrollDirection: widget.scrollDirection,
);
} else {
- return new Container();
+ return SizedBox.shrink();
}
}
- SwiperPluginConfig _ensureConfig(SwiperPluginConfig config) {
- if (config == null) {
- config = new SwiperPluginConfig(
- outer: widget.outer,
- itemCount: widget.itemCount,
- layout: widget.layout,
- indicatorLayout: widget.indicatorLayout,
- pageController: _pageController,
- activeIndex: _activeIndex,
- scrollDirection: widget.scrollDirection,
- controller: _controller,
- loop: widget.loop);
- }
+ SwiperPluginConfig _ensureConfig(SwiperPluginConfig? config) {
+ config ??= SwiperPluginConfig(
+ outer: widget.outer,
+ itemCount: widget.itemCount,
+ layout: widget.layout,
+ indicatorLayout: widget.indicatorLayout,
+ pageController: _pageController,
+ activeIndex: _activeIndex,
+ scrollDirection: widget.scrollDirection,
+ controller: _controller!,
+ loop: widget.loop);
+
return config;
}
- List _ensureListForStack(
- Widget swiper, List listForStack, Widget widget) {
+ List? _ensureListForStack(
+ Widget swiper, List? listForStack, Widget widget) {
if (listForStack == null) {
listForStack = [swiper, widget];
} else {
@@ -585,19 +585,19 @@ class _SwiperState extends _SwiperTimerMixin {
@override
Widget build(BuildContext context) {
- Widget swiper = _buildSwiper();
- List listForStack;
- SwiperPluginConfig config;
+ var swiper = _buildSwiper();
+ List? listForStack;
+ SwiperPluginConfig? config;
if (widget.control != null) {
//Stack
config = _ensureConfig(config);
listForStack = _ensureListForStack(
- swiper, listForStack, widget.control.build(context, config));
+ swiper, listForStack, widget.control!.build(context, config));
}
if (widget.plugins != null) {
config = _ensureConfig(config);
- for (SwiperPlugin plugin in widget.plugins) {
+ for (final plugin in widget.plugins!) {
listForStack = _ensureListForStack(
swiper, listForStack, plugin.build(context, config));
}
@@ -606,17 +606,17 @@ class _SwiperState extends _SwiperTimerMixin {
config = _ensureConfig(config);
if (widget.outer) {
return _buildOuterPagination(
- widget.pagination,
- listForStack == null ? swiper : new Stack(children: listForStack),
+ widget.pagination as SwiperPagination,
+ listForStack == null ? swiper : Stack(children: listForStack),
config);
} else {
listForStack = _ensureListForStack(
- swiper, listForStack, widget.pagination.build(context, config));
+ swiper, listForStack, widget.pagination!.build(context, config));
}
}
if (listForStack != null) {
- return new Stack(
+ return Stack(
children: listForStack,
);
}
@@ -626,42 +626,42 @@ class _SwiperState extends _SwiperTimerMixin {
Widget _buildOuterPagination(
SwiperPagination pagination, Widget swiper, SwiperPluginConfig config) {
- List list = [];
+ var list = [];
//Only support bottom yet!
if (widget.containerHeight != null || widget.containerWidth != null) {
list.add(swiper);
} else {
- list.add(new Expanded(child: swiper));
+ list.add(Expanded(child: swiper));
}
- list.add(new Align(
+ list.add(Align(
alignment: Alignment.center,
child: pagination.build(context, config),
));
- return new Column(
- children: list,
+ return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
+ children: list,
);
}
}
abstract class _SubSwiper extends StatefulWidget {
- final IndexedWidgetBuilder itemBuilder;
- final int itemCount;
- final int index;
- final ValueChanged onIndexChanged;
- final SwiperController controller;
- final int duration;
- final Curve curve;
- final double itemWidth;
- final double itemHeight;
- final bool loop;
- final Axis scrollDirection;
+ final IndexedWidgetBuilder? itemBuilder;
+ final int? itemCount;
+ final int? index;
+ final ValueChanged? onIndexChanged;
+ final SwiperController? controller;
+ final int? duration;
+ final Curve? curve;
+ final double? itemWidth;
+ final double? itemHeight;
+ final bool? loop;
+ final Axis? scrollDirection;
_SubSwiper(
- {Key key,
+ {Key? key,
this.loop,
this.itemHeight,
this.itemWidth,
@@ -671,7 +671,7 @@ abstract class _SubSwiper extends StatefulWidget {
this.controller,
this.index,
this.itemCount,
- this.scrollDirection: Axis.horizontal,
+ this.scrollDirection = Axis.horizontal,
this.onIndexChanged})
: super(key: key);
@@ -680,9 +680,9 @@ abstract class _SubSwiper extends StatefulWidget {
int getCorrectIndex(int indexNeedsFix) {
if (itemCount == 0) return 0;
- int value = indexNeedsFix % itemCount;
+ var value = indexNeedsFix % itemCount!;
if (value < 0) {
- value += itemCount;
+ value += itemCount!;
}
return value;
}
@@ -690,18 +690,18 @@ abstract class _SubSwiper extends StatefulWidget {
class _TinderSwiper extends _SubSwiper {
_TinderSwiper({
- Key key,
- Curve curve,
- int duration,
- SwiperController controller,
- ValueChanged onIndexChanged,
- double itemHeight,
- double itemWidth,
- IndexedWidgetBuilder itemBuilder,
- int index,
- bool loop,
- int itemCount,
- Axis scrollDirection,
+ Key? key,
+ Curve? curve,
+ int? duration,
+ SwiperController? controller,
+ ValueChanged? onIndexChanged,
+ double? itemHeight,
+ double? itemWidth,
+ IndexedWidgetBuilder? itemBuilder,
+ int? index,
+ bool? loop,
+ int? itemCount,
+ Axis? scrollDirection,
}) : assert(itemWidth != null && itemHeight != null),
super(
loop: loop,
@@ -719,24 +719,24 @@ class _TinderSwiper extends _SubSwiper {
@override
State createState() {
- return new _TinderState();
+ return _TinderState();
}
}
class _StackSwiper extends _SubSwiper {
_StackSwiper({
- Key key,
- Curve curve,
- int duration,
- SwiperController controller,
- ValueChanged onIndexChanged,
- double itemHeight,
- double itemWidth,
- IndexedWidgetBuilder itemBuilder,
- int index,
- bool loop,
- int itemCount,
- Axis scrollDirection,
+ Key? key,
+ Curve? curve,
+ int? duration,
+ SwiperController? controller,
+ ValueChanged? onIndexChanged,
+ double? itemHeight,
+ double? itemWidth,
+ IndexedWidgetBuilder? itemBuilder,
+ int? index,
+ bool? loop,
+ int? itemCount,
+ Axis? scrollDirection,
}) : super(
loop: loop,
key: key,
@@ -753,19 +753,19 @@ class _StackSwiper extends _SubSwiper {
@override
State createState() {
- return new _StackViewState();
+ return _StackViewState();
}
}
class _TinderState extends _CustomLayoutStateBase<_TinderSwiper> {
- List scales;
- List offsetsX;
- List offsetsY;
- List opacity;
- List rotates;
+ late List scales;
+ late List offsetsX;
+ late List offsetsY;
+ late List opacity;
+ late List rotates;
double getOffsetY(double scale) {
- return widget.itemHeight - widget.itemHeight * scale;
+ return widget.itemHeight! - widget.itemHeight! * scale;
}
@override
@@ -818,30 +818,30 @@ class _TinderState extends _CustomLayoutStateBase<_TinderSwiper> {
@override
Widget _buildItem(int i, int realIndex, double animationValue) {
- double s = _getValue(scales, animationValue, i);
- double f = _getValue(offsetsX, animationValue, i);
- double fy = _getValue(offsetsY, animationValue, i);
- double o = _getValue(opacity, animationValue, i);
- double a = _getValue(rotates, animationValue, i);
+ final s = _getValue(scales, animationValue, i)!;
+ final f = _getValue(offsetsX, animationValue, i)!;
+ final fy = _getValue(offsetsY, animationValue, i)!;
+ final o = _getValue(opacity, animationValue, i)!;
+ final a = _getValue(rotates, animationValue, i)!;
- Alignment alignment = widget.scrollDirection == Axis.horizontal
+ final alignment = widget.scrollDirection == Axis.horizontal
? Alignment.bottomCenter
: Alignment.centerLeft;
- return new Opacity(
+ return Opacity(
opacity: o,
- child: new Transform.rotate(
+ child: Transform.rotate(
angle: a / 180.0,
- child: new Transform.translate(
- key: new ValueKey(_currentIndex + i),
- offset: new Offset(f, fy),
- child: new Transform.scale(
+ child: Transform.translate(
+ key: ValueKey(_currentIndex + i),
+ offset: Offset(f, fy),
+ child: Transform.scale(
scale: s,
alignment: alignment,
- child: new SizedBox(
+ child: SizedBox(
width: widget.itemWidth ?? double.infinity,
height: widget.itemHeight ?? double.infinity,
- child: widget.itemBuilder(context, realIndex),
+ child: widget.itemBuilder!(context, realIndex),
),
),
),
@@ -851,9 +851,10 @@ class _TinderState extends _CustomLayoutStateBase<_TinderSwiper> {
}
class _StackViewState extends _CustomLayoutStateBase<_StackSwiper> {
- List scales;
- List offsets;
- List opacity;
+ late List scales;
+ late List offsets;
+ late List opacity;
+
@override
void didChangeDependencies() {
super.didChangeDependencies();
@@ -861,10 +862,10 @@ class _StackViewState extends _CustomLayoutStateBase<_StackSwiper> {
void _updateValues() {
if (widget.scrollDirection == Axis.horizontal) {
- double space = (_swiperWidth - widget.itemWidth) / 2;
+ final space = (_swiperWidth! - widget.itemWidth!) / 2;
offsets = [-space, -space / 3 * 2, -space / 3, 0.0, _swiperWidth];
} else {
- double space = (_swiperHeight - widget.itemHeight) / 2;
+ final space = (_swiperHeight! - widget.itemHeight!) / 2;
offsets = [-space, -space / 3 * 2, -space / 3, 0.0, _swiperHeight];
}
}
@@ -892,30 +893,30 @@ class _StackViewState extends _CustomLayoutStateBase<_StackSwiper> {
@override
Widget _buildItem(int i, int realIndex, double animationValue) {
- double s = _getValue(scales, animationValue, i);
- double f = _getValue(offsets, animationValue, i);
- double o = _getValue(opacity, animationValue, i);
+ final s = _getValue(scales, animationValue, i)!;
+ final f = _getValue(offsets, animationValue, i);
+ final o = _getValue(opacity, animationValue, i)!;
- Offset offset = widget.scrollDirection == Axis.horizontal
- ? new Offset(f, 0.0)
- : new Offset(0.0, f);
+ final offset = widget.scrollDirection == Axis.horizontal
+ ? Offset(f!, 0.0)
+ : Offset(0.0, f!);
- Alignment alignment = widget.scrollDirection == Axis.horizontal
+ final alignment = widget.scrollDirection == Axis.horizontal
? Alignment.centerLeft
: Alignment.topCenter;
- return new Opacity(
+ return Opacity(
opacity: o,
- child: new Transform.translate(
- key: new ValueKey(_currentIndex + i),
+ child: Transform.translate(
+ key: ValueKey(_currentIndex + i),
offset: offset,
- child: new Transform.scale(
+ child: Transform.scale(
scale: s,
alignment: alignment,
- child: new SizedBox(
+ child: SizedBox(
width: widget.itemWidth ?? double.infinity,
height: widget.itemHeight ?? double.infinity,
- child: widget.itemBuilder(context, realIndex),
+ child: widget.itemBuilder!(context, realIndex),
),
),
),
@@ -924,31 +925,31 @@ class _StackViewState extends _CustomLayoutStateBase<_StackSwiper> {
}
class ScaleAndFadeTransformer extends PageTransformer {
- final double _scale;
- final double _fade;
+ final double? _scale;
+ final double? _fade;
- ScaleAndFadeTransformer({double fade: 0.3, double scale: 0.8})
+ ScaleAndFadeTransformer({double? fade = 0.3, double? scale = 0.8})
: _fade = fade,
_scale = scale;
@override
Widget transform(Widget item, TransformInfo info) {
- double position = info.position;
- Widget child = item;
+ final position = info.position;
+ var child = item;
if (_scale != null) {
- double scaleFactor = (1 - position.abs()) * (1 - _scale);
- double scale = _scale + scaleFactor;
+ final scaleFactor = (1 - position!.abs()) * (1 - _scale!);
+ final scale = _scale! + scaleFactor;
- child = new Transform.scale(
+ child = Transform.scale(
scale: scale,
child: item,
);
}
if (_fade != null) {
- double fadeFactor = (1 - position.abs()) * (1 - _fade);
- double opacity = _fade + fadeFactor;
- child = new Opacity(
+ final fadeFactor = (1 - position!.abs()) * (1 - _fade!);
+ final opacity = _fade! + fadeFactor;
+ child = Opacity(
opacity: opacity,
child: child,
);
diff --git a/lib/src/swiper_control.dart b/lib/src/swiper_control.dart
index 158b460..f437926 100644
--- a/lib/src/swiper_control.dart
+++ b/lib/src/swiper_control.dart
@@ -12,34 +12,35 @@ class SwiperControl extends SwiperPlugin {
final double size;
///Icon normal color, The theme's [ThemeData.primaryColor] by default.
- final Color color;
+ final Color? color;
///if set loop=false on Swiper, this color will be used when swiper goto the last slide.
///The theme's [ThemeData.disabledColor] by default.
- final Color disableColor;
+ final Color? disableColor;
final EdgeInsetsGeometry padding;
- final Key key;
+ final Key? key;
- const SwiperControl(
- {this.iconPrevious: Icons.arrow_back_ios,
- this.iconNext: Icons.arrow_forward_ios,
- this.color,
- this.disableColor,
- this.key,
- this.size: 30.0,
- this.padding: const EdgeInsets.all(5.0)});
+ const SwiperControl({
+ this.iconPrevious = Icons.arrow_back_ios,
+ this.iconNext = Icons.arrow_forward_ios,
+ this.color,
+ this.disableColor,
+ this.key,
+ this.size = 30.0,
+ this.padding = const EdgeInsets.all(5.0),
+ });
- Widget buildButton(SwiperPluginConfig config, Color color, IconData iconDaga,
+ Widget buildButton(SwiperPluginConfig? config, Color color, IconData iconDaga,
int quarterTurns, bool previous) {
- return new GestureDetector(
+ return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
if (previous) {
- config.controller.previous(animation: true);
+ config!.controller.previous(animation: true);
} else {
- config.controller.next(animation: true);
+ config!.controller.next(animation: true);
}
},
child: Padding(
@@ -48,7 +49,7 @@ class SwiperControl extends SwiperPlugin {
quarterTurns: quarterTurns,
child: Icon(
iconDaga,
- semanticLabel: previous ? "Previous" : "Next",
+ semanticLabel: previous ? 'Previous' : 'Next',
size: size,
color: color,
))),
@@ -56,19 +57,19 @@ class SwiperControl extends SwiperPlugin {
}
@override
- Widget build(BuildContext context, SwiperPluginConfig config) {
- ThemeData themeData = Theme.of(context);
+ Widget build(BuildContext context, SwiperPluginConfig? config) {
+ final themeData = Theme.of(context);
- Color color = this.color ?? themeData.primaryColor;
- Color disableColor = this.disableColor ?? themeData.disabledColor;
- Color prevColor;
- Color nextColor;
+ final color = this.color ?? themeData.primaryColor;
+ final disableColor = this.disableColor ?? themeData.disabledColor;
+ var prevColor;
+ var nextColor;
- if (config.loop) {
+ if (config!.loop!) {
prevColor = nextColor = color;
} else {
- bool next = config.activeIndex < config.itemCount - 1;
- bool prev = config.activeIndex > 0;
+ final next = config.activeIndex! < config.itemCount! - 1;
+ final prev = config.activeIndex! > 0;
prevColor = prev ? color : disableColor;
nextColor = next ? color : disableColor;
}
@@ -94,10 +95,10 @@ class SwiperControl extends SwiperPlugin {
);
}
- return new Container(
+ return Container(
height: double.infinity,
- child: child,
width: double.infinity,
+ child: child,
);
}
}
diff --git a/lib/src/swiper_controller.dart b/lib/src/swiper_controller.dart
index a659500..29b3147 100644
--- a/lib/src/swiper_controller.dart
+++ b/lib/src/swiper_controller.dart
@@ -1,5 +1,5 @@
import 'package:flutter_swiper/src/swiper_plugin.dart';
-import 'package:transformer_page_view/transformer_page_view.dart';
+import 'package:flutter_swiper/src/transformer_page_view/index_controller.dart';
class SwiperController extends IndexController {
// Autoplay is started
@@ -16,27 +16,31 @@ class SwiperController extends IndexController {
static const int BUILD = 5;
// available when `event` == SwiperController.BUILD
- SwiperPluginConfig config;
+ SwiperPluginConfig? config;
// available when `event` == SwiperController.SWIPE
// this value is PageViewController.pos
- double pos;
+ double? pos;
- int index;
- bool animation;
- bool autoplay;
+ @override
+ int? index;
+
+ @override
+ bool? animation;
+
+ bool? autoplay;
SwiperController();
void startAutoplay() {
event = SwiperController.START_AUTOPLAY;
- this.autoplay = true;
+ autoplay = true;
notifyListeners();
}
void stopAutoplay() {
event = SwiperController.STOP_AUTOPLAY;
- this.autoplay = false;
+ autoplay = false;
notifyListeners();
}
}
diff --git a/lib/src/swiper_pagination.dart b/lib/src/swiper_pagination.dart
index a866de2..e6a4ba7 100644
--- a/lib/src/swiper_pagination.dart
+++ b/lib/src/swiper_pagination.dart
@@ -1,15 +1,14 @@
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
-
-import 'package:flutter_page_indicator/flutter_page_indicator.dart';
+import 'package:flutter_swiper/src/flutter_page_indicator/flutter_page_indicator.dart';
class FractionPaginationBuilder extends SwiperPlugin {
///color ,if set null , will be Theme.of(context).scaffoldBackgroundColor
- final Color color;
+ final Color? color;
///color when active,if set null , will be Theme.of(context).primaryColor
- final Color activeColor;
+ final Color? activeColor;
////font size
final double fontSize;
@@ -17,51 +16,52 @@ class FractionPaginationBuilder extends SwiperPlugin {
///font size when active
final double activeFontSize;
- final Key key;
+ final Key? key;
- const FractionPaginationBuilder(
- {this.color,
- this.fontSize: 20.0,
- this.key,
- this.activeColor,
- this.activeFontSize: 35.0});
+ const FractionPaginationBuilder({
+ this.color,
+ this.fontSize = 20.0,
+ this.key,
+ this.activeColor,
+ this.activeFontSize = 35.0,
+ });
@override
- Widget build(BuildContext context, SwiperPluginConfig config) {
- ThemeData themeData = Theme.of(context);
- Color activeColor = this.activeColor ?? themeData.primaryColor;
- Color color = this.color ?? themeData.scaffoldBackgroundColor;
+ Widget build(BuildContext context, SwiperPluginConfig? config) {
+ final themeData = Theme.of(context);
+ final activeColor = this.activeColor ?? themeData.primaryColor;
+ final color = this.color ?? themeData.scaffoldBackgroundColor;
- if (Axis.vertical == config.scrollDirection) {
- return new Column(
+ if (Axis.vertical == config!.scrollDirection) {
+ return Column(
key: key,
mainAxisSize: MainAxisSize.min,
children: [
- new Text(
- "${config.activeIndex + 1}",
+ Text(
+ '${config.activeIndex! + 1}',
style: TextStyle(color: activeColor, fontSize: activeFontSize),
),
- new Text(
- "/",
+ Text(
+ '/',
style: TextStyle(color: color, fontSize: fontSize),
),
- new Text(
- "${config.itemCount}",
+ Text(
+ '${config.itemCount}',
style: TextStyle(color: color, fontSize: fontSize),
)
],
);
} else {
- return new Row(
+ return Row(
key: key,
mainAxisSize: MainAxisSize.min,
children: [
- new Text(
- "${config.activeIndex + 1}",
+ Text(
+ '${config.activeIndex! + 1}',
style: TextStyle(color: activeColor, fontSize: activeFontSize),
),
- new Text(
- " / ${config.itemCount}",
+ Text(
+ ' / ${config.itemCount}',
style: TextStyle(color: color, fontSize: fontSize),
)
],
@@ -72,10 +72,10 @@ class FractionPaginationBuilder extends SwiperPlugin {
class RectSwiperPaginationBuilder extends SwiperPlugin {
///color when current index,if set null , will be Theme.of(context).primaryColor
- final Color activeColor;
+ final Color? activeColor;
///,if set null , will be Theme.of(context).scaffoldBackgroundColor
- final Color color;
+ final Color? color;
///Size of the rect when activate
final Size activeSize;
@@ -86,54 +86,57 @@ class RectSwiperPaginationBuilder extends SwiperPlugin {
/// Space between rects
final double space;
- final Key key;
+ final Key? key;
- const RectSwiperPaginationBuilder(
- {this.activeColor,
- this.color,
- this.key,
- this.size: const Size(10.0, 2.0),
- this.activeSize: const Size(10.0, 2.0),
- this.space: 3.0});
+ const RectSwiperPaginationBuilder({
+ this.activeColor,
+ this.color,
+ this.key,
+ this.size = const Size(10.0, 2.0),
+ this.activeSize = const Size(10.0, 2.0),
+ this.space = 3.0,
+ });
@override
- Widget build(BuildContext context, SwiperPluginConfig config) {
- ThemeData themeData = Theme.of(context);
- Color activeColor = this.activeColor ?? themeData.primaryColor;
- Color color = this.color ?? themeData.scaffoldBackgroundColor;
+ Widget build(BuildContext context, SwiperPluginConfig? config) {
+ final themeData = Theme.of(context);
+ final activeColor = this.activeColor ?? themeData.primaryColor;
+ final color = this.color ?? themeData.scaffoldBackgroundColor;
- List list = [];
+ var list = [];
- if (config.itemCount > 20) {
+ if (config!.itemCount! > 20) {
print(
- "The itemCount is too big, we suggest use FractionPaginationBuilder instead of DotSwiperPaginationBuilder in this sitituation");
+ 'The itemCount is too big, we suggest use FractionPaginationBuilder '
+ 'instead of DotSwiperPaginationBuilder in this situation',
+ );
}
- int itemCount = config.itemCount;
- int activeIndex = config.activeIndex;
+ var itemCount = config.itemCount!;
+ var activeIndex = config.activeIndex;
- for (int i = 0; i < itemCount; ++i) {
- bool active = i == activeIndex;
- Size size = active ? this.activeSize : this.size;
+ for (var i = 0; i < itemCount; ++i) {
+ var active = i == activeIndex;
+ var size = active ? activeSize : this.size;
list.add(SizedBox(
width: size.width,
height: size.height,
child: Container(
color: active ? activeColor : color,
- key: Key("pagination_$i"),
+ key: Key('pagination_$i'),
margin: EdgeInsets.all(space),
),
));
}
if (config.scrollDirection == Axis.vertical) {
- return new Column(
+ return Column(
key: key,
mainAxisSize: MainAxisSize.min,
children: list,
);
} else {
- return new Row(
+ return Row(
key: key,
mainAxisSize: MainAxisSize.min,
children: list,
@@ -144,10 +147,10 @@ class RectSwiperPaginationBuilder extends SwiperPlugin {
class DotSwiperPaginationBuilder extends SwiperPlugin {
///color when current index,if set null , will be Theme.of(context).primaryColor
- final Color activeColor;
+ final Color? activeColor;
///,if set null , will be Theme.of(context).scaffoldBackgroundColor
- final Color color;
+ final Color? color;
///Size of the dot when activate
final double activeSize;
@@ -158,36 +161,39 @@ class DotSwiperPaginationBuilder extends SwiperPlugin {
/// Space between dots
final double space;
- final Key key;
+ final Key? key;
- const DotSwiperPaginationBuilder(
- {this.activeColor,
- this.color,
- this.key,
- this.size: 10.0,
- this.activeSize: 10.0,
- this.space: 3.0});
+ const DotSwiperPaginationBuilder({
+ this.activeColor,
+ this.color,
+ this.key,
+ this.size = 10.0,
+ this.activeSize = 10.0,
+ this.space = 3.0,
+ });
@override
- Widget build(BuildContext context, SwiperPluginConfig config) {
- if (config.itemCount > 20) {
+ Widget build(BuildContext context, SwiperPluginConfig? config) {
+ if (config!.itemCount! > 20) {
print(
- "The itemCount is too big, we suggest use FractionPaginationBuilder instead of DotSwiperPaginationBuilder in this sitituation");
+ 'The itemCount is too big, we suggest use FractionPaginationBuilder '
+ 'instead of DotSwiperPaginationBuilder in this situation',
+ );
}
- Color activeColor = this.activeColor;
- Color color = this.color;
+ var activeColor = this.activeColor;
+ var color = this.color;
if (activeColor == null || color == null) {
- ThemeData themeData = Theme.of(context);
+ final themeData = Theme.of(context);
activeColor = this.activeColor ?? themeData.primaryColor;
color = this.color ?? themeData.scaffoldBackgroundColor;
}
if (config.indicatorLayout != PageIndicatorLayout.NONE &&
config.layout == SwiperLayout.DEFAULT) {
- return new PageIndicator(
- count: config.itemCount,
- controller: config.pageController,
+ return PageIndicator(
+ count: config.itemCount!,
+ controller: config.pageController!,
layout: config.indicatorLayout,
size: size,
activeColor: activeColor,
@@ -196,15 +202,15 @@ class DotSwiperPaginationBuilder extends SwiperPlugin {
);
}
- List list = [];
+ var list = [];
- int itemCount = config.itemCount;
- int activeIndex = config.activeIndex;
+ var itemCount = config.itemCount!;
+ var activeIndex = config.activeIndex;
- for (int i = 0; i < itemCount; ++i) {
- bool active = i == activeIndex;
+ for (var i = 0; i < itemCount; ++i) {
+ var active = i == activeIndex;
list.add(Container(
- key: Key("pagination_$i"),
+ key: Key('pagination_$i'),
margin: EdgeInsets.all(space),
child: ClipOval(
child: Container(
@@ -217,13 +223,13 @@ class DotSwiperPaginationBuilder extends SwiperPlugin {
}
if (config.scrollDirection == Axis.vertical) {
- return new Column(
+ return Column(
key: key,
mainAxisSize: MainAxisSize.min,
children: list,
);
} else {
- return new Row(
+ return Row(
key: key,
mainAxisSize: MainAxisSize.min,
children: list,
@@ -232,58 +238,61 @@ class DotSwiperPaginationBuilder extends SwiperPlugin {
}
}
-typedef Widget SwiperPaginationBuilder(
- BuildContext context, SwiperPluginConfig config);
+typedef SwiperPaginationBuilder = Function(
+ BuildContext context,
+ SwiperPluginConfig? config,
+);
class SwiperCustomPagination extends SwiperPlugin {
final SwiperPaginationBuilder builder;
- SwiperCustomPagination({@required this.builder}) : assert(builder != null);
+ const SwiperCustomPagination({required this.builder});
@override
- Widget build(BuildContext context, SwiperPluginConfig config) {
+ Widget build(BuildContext context, SwiperPluginConfig? config) {
return builder(context, config);
}
}
class SwiperPagination extends SwiperPlugin {
/// dot style pagination
- static const SwiperPlugin dots = const DotSwiperPaginationBuilder();
+ static const SwiperPlugin dots = DotSwiperPaginationBuilder();
/// fraction style pagination
- static const SwiperPlugin fraction = const FractionPaginationBuilder();
+ static const SwiperPlugin fraction = FractionPaginationBuilder();
- static const SwiperPlugin rect = const RectSwiperPaginationBuilder();
+ static const SwiperPlugin rect = RectSwiperPaginationBuilder();
/// Alignment.bottomCenter by default when scrollDirection== Axis.horizontal
/// Alignment.centerRight by default when scrollDirection== Axis.vertical
- final Alignment alignment;
+ final Alignment? alignment;
/// Distance between pagination and the container
final EdgeInsetsGeometry margin;
- /// Build the widet
+ /// Build the widget
final SwiperPlugin builder;
- final Key key;
+ final Key? key;
- const SwiperPagination(
- {this.alignment,
- this.key,
- this.margin: const EdgeInsets.all(10.0),
- this.builder: SwiperPagination.dots});
+ const SwiperPagination({
+ this.alignment = Alignment.bottomCenter,
+ this.key,
+ this.margin = const EdgeInsets.all(10.0),
+ this.builder = SwiperPagination.dots,
+ });
- Widget build(BuildContext context, SwiperPluginConfig config) {
- Alignment alignment = this.alignment ??
- (config.scrollDirection == Axis.horizontal
- ? Alignment.bottomCenter
- : Alignment.centerRight);
+ @override
+ Widget build(BuildContext context, SwiperPluginConfig? config) {
+ final alignment = config!.scrollDirection == Axis.horizontal
+ ? Alignment.bottomCenter
+ : Alignment.centerRight;
Widget child = Container(
margin: margin,
- child: this.builder.build(context, config),
+ child: builder.build(context, config),
);
- if (!config.outer) {
- child = new Align(
+ if (!config.outer!) {
+ child = Align(
key: key,
alignment: alignment,
child: child,
diff --git a/lib/src/swiper_plugin.dart b/lib/src/swiper_plugin.dart
index 5c9fb9a..cd6ba10 100644
--- a/lib/src/swiper_plugin.dart
+++ b/lib/src/swiper_plugin.dart
@@ -1,6 +1,6 @@
import 'package:flutter/widgets.dart';
-import 'package:flutter_page_indicator/flutter_page_indicator.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
+import 'package:flutter_swiper/src/flutter_page_indicator/flutter_page_indicator.dart';
/// plugin to display swiper components
///
@@ -11,28 +11,27 @@ abstract class SwiperPlugin {
}
class SwiperPluginConfig {
- final int activeIndex;
- final int itemCount;
- final PageIndicatorLayout indicatorLayout;
final Axis scrollDirection;
- final bool loop;
- final bool outer;
- final PageController pageController;
final SwiperController controller;
- final SwiperLayout layout;
+ final int? activeIndex;
+ final int? itemCount;
+ final PageIndicatorLayout? indicatorLayout;
+ final bool? loop;
+ final bool? outer;
+ final PageController? pageController;
+ final SwiperLayout? layout;
- const SwiperPluginConfig(
- {this.activeIndex,
- this.itemCount,
- this.indicatorLayout,
- this.outer,
- this.scrollDirection,
- this.controller,
- this.pageController,
- this.layout,
- this.loop})
- : assert(scrollDirection != null),
- assert(controller != null);
+ const SwiperPluginConfig({
+ required this.scrollDirection,
+ required this.controller,
+ this.activeIndex,
+ this.itemCount,
+ this.indicatorLayout,
+ this.outer,
+ this.pageController,
+ this.layout,
+ this.loop,
+ });
}
class SwiperPluginView extends StatelessWidget {
diff --git a/lib/src/transformer_page_view/index_controller.dart b/lib/src/transformer_page_view/index_controller.dart
new file mode 100644
index 0000000..654898b
--- /dev/null
+++ b/lib/src/transformer_page_view/index_controller.dart
@@ -0,0 +1,47 @@
+import 'dart:async';
+
+import 'package:flutter/foundation.dart';
+import 'package:flutter/widgets.dart';
+
+class IndexController extends ChangeNotifier {
+ static const int NEXT = 1;
+ static const int PREVIOUS = -1;
+ static const int MOVE = 0;
+
+ late Completer _completer;
+
+ int? index;
+ bool? animation;
+ int? event;
+
+ Future move(int index, {bool animation = true}) {
+ this.animation = animation;
+ this.index = index;
+ event = MOVE;
+ _completer = Completer();
+ notifyListeners();
+ return _completer.future;
+ }
+
+ Future next({bool animation = true}) {
+ event = NEXT;
+ this.animation = animation;
+ _completer = Completer();
+ notifyListeners();
+ return _completer.future;
+ }
+
+ Future previous({bool animation = true}) {
+ event = PREVIOUS;
+ this.animation = animation;
+ _completer = Completer();
+ notifyListeners();
+ return _completer.future;
+ }
+
+ void complete() {
+ if (!_completer.isCompleted) {
+ _completer.complete();
+ }
+ }
+}
diff --git a/lib/src/transformer_page_view/parallax.dart b/lib/src/transformer_page_view/parallax.dart
new file mode 100644
index 0000000..5c6800e
--- /dev/null
+++ b/lib/src/transformer_page_view/parallax.dart
@@ -0,0 +1,143 @@
+import 'package:flutter/widgets.dart';
+import 'package:flutter_swiper/src/transformer_page_view/transformer_page_view.dart';
+
+typedef PaintCallback = Function(Canvas canvas, Size size);
+
+class ColorPainter extends CustomPainter {
+ final Paint _paint;
+ final TransformInfo info;
+ final List colors;
+
+ ColorPainter(this._paint, this.info, this.colors);
+
+ @override
+ void paint(Canvas canvas, Size size) {
+ var index = info.fromIndex!;
+ _paint.color = colors[index];
+ canvas.drawRect(Rect.fromLTWH(0.0, 0.0, size.width, size.height), _paint);
+ if (info.done!) {
+ return;
+ }
+ int alpha;
+ int color;
+ double opacity;
+ final position = info.position;
+ if (info.forward!) {
+ if (index < colors.length - 1) {
+ color = colors[index + 1].value & 0x00ffffff;
+ opacity = (position! <= 0
+ ? (-position / info.viewportFraction!)
+ : 1 - position / info.viewportFraction!);
+ if (opacity > 1) {
+ opacity -= 1.0;
+ }
+ if (opacity < 0) {
+ opacity += 1.0;
+ }
+ alpha = (0xff * opacity).toInt();
+
+ _paint.color = Color((alpha << 24) | color);
+ canvas.drawRect(
+ Rect.fromLTWH(0.0, 0.0, size.width, size.height), _paint);
+ }
+ } else {
+ if (index > 0) {
+ color = colors[index - 1].value & 0x00ffffff;
+ opacity = (position! > 0
+ ? position / info.viewportFraction!
+ : (1 + position / info.viewportFraction!));
+ if (opacity > 1) {
+ opacity -= 1.0;
+ }
+ if (opacity < 0) {
+ opacity += 1.0;
+ }
+ alpha = (0xff * opacity).toInt();
+
+ _paint.color = Color((alpha << 24) | color);
+ canvas.drawRect(
+ Rect.fromLTWH(0.0, 0.0, size.width, size.height), _paint);
+ }
+ }
+ }
+
+ @override
+ bool shouldRepaint(ColorPainter oldDelegate) {
+ return oldDelegate.info != info;
+ }
+}
+
+class _ParallaxColorState extends State {
+ Paint paint = Paint();
+
+ @override
+ Widget build(BuildContext context) {
+ return CustomPaint(
+ painter: ColorPainter(paint, widget.info, widget.colors),
+ child: widget.child,
+ );
+ }
+}
+
+class ParallaxColor extends StatefulWidget {
+ final Widget child;
+
+ final List colors;
+
+ final TransformInfo info;
+
+ ParallaxColor({
+ required this.colors,
+ required this.info,
+ required this.child,
+ });
+
+ @override
+ State createState() {
+ return _ParallaxColorState();
+ }
+}
+
+class ParallaxContainer extends StatelessWidget {
+ final Widget child;
+ final double position;
+ final double translationFactor;
+ final double opacityFactor;
+
+ const ParallaxContainer({
+ required this.child,
+ required this.position,
+ this.translationFactor = 100.0,
+ this.opacityFactor = 1.0,
+ });
+
+ @override
+ Widget build(BuildContext context) {
+ return Opacity(
+ opacity: (1 - position.abs()).clamp(0.0, 1.0) * opacityFactor,
+ child: Transform.translate(
+ offset: Offset(position * translationFactor, 0.0),
+ child: child,
+ ),
+ );
+ }
+}
+
+class ParallaxImage extends StatelessWidget {
+ final Image image;
+ final double imageFactor;
+
+ ParallaxImage.asset(String name,
+ {required double position, this.imageFactor = 0.3})
+ : image = Image.asset(name,
+ fit: BoxFit.cover,
+ alignment: FractionalOffset(
+ 0.5 + position * imageFactor,
+ 0.5,
+ ));
+
+ @override
+ Widget build(BuildContext context) {
+ return image;
+ }
+}
diff --git a/lib/src/transformer_page_view/transformer_page_view.dart b/lib/src/transformer_page_view/transformer_page_view.dart
new file mode 100644
index 0000000..cc71fcd
--- /dev/null
+++ b/lib/src/transformer_page_view/transformer_page_view.dart
@@ -0,0 +1,617 @@
+library transformer_page_view;
+
+import 'package:flutter/widgets.dart';
+import 'package:flutter_swiper/src/transformer_page_view/index_controller.dart';
+
+///
+/// NOTICE::
+///
+/// In order to make package smaller,currently we're not supporting any build-in page transformers
+/// You can find build in transforms here:
+///
+///
+///
+
+const int kMaxValue = 2000000000;
+const int kMiddleValue = 1000000000;
+
+/// Default auto play transition duration (in millisecond)
+const int kDefaultTransactionDuration = 300;
+
+class TransformInfo {
+ /// The `width` of the `TransformerPageView`
+ final double? width;
+
+ /// The `height` of the `TransformerPageView`
+ final double? height;
+
+ /// The `position` of the widget pass to [PageTransformer.transform]
+ /// A `position` describes how visible the widget is.
+ /// The widget in the center of the screen' which is full visible, position is 0.0.
+ /// The widge in the left ,may be hidden, of the screen's position is less than 0.0, -1.0 when out of the screen.
+ /// The widge in the right ,may be hidden, of the screen's position is greater than 0.0, 1.0 when out of the screen
+ ///
+ ///
+ final double? position;
+
+ /// The `index` of the widget pass to [PageTransformer.transform]
+ final int? index;
+
+ /// The `activeIndex` of the PageView
+ final int? activeIndex;
+
+ /// The `activeIndex` of the PageView, from user start to swipe
+ /// It will change when user end drag
+ final int? fromIndex;
+
+ /// Next `index` is greater than this `index`
+ final bool? forward;
+
+ /// User drag is done.
+ final bool? done;
+
+ /// Same as [TransformerPageView.viewportFraction]
+ final double? viewportFraction;
+
+ /// Copy from [TransformerPageView.scrollDirection]
+ final Axis? scrollDirection;
+
+ TransformInfo({
+ this.index,
+ this.position,
+ this.width,
+ this.height,
+ this.activeIndex,
+ this.fromIndex,
+ this.forward,
+ this.done,
+ this.viewportFraction,
+ this.scrollDirection,
+ });
+}
+
+abstract class PageTransformer {
+ ///
+ final bool reverse;
+
+ PageTransformer({this.reverse = false});
+
+ /// Return a transformed widget, based on child and TransformInfo
+ Widget transform(Widget child, TransformInfo info);
+}
+
+typedef PageTransformerBuilderCallback = Function(
+ Widget child, TransformInfo info);
+
+class PageTransformerBuilder extends PageTransformer {
+ final PageTransformerBuilderCallback builder;
+
+ PageTransformerBuilder({bool reverse = false, required this.builder})
+ : super(reverse: reverse);
+
+ @override
+ Widget transform(Widget child, TransformInfo info) {
+ return builder(child, info);
+ }
+}
+
+class TransformerPageController extends PageController {
+ final bool loop;
+ final int itemCount;
+ final bool reverse;
+
+ TransformerPageController({
+ int initialPage = 0,
+ bool keepPage = true,
+ double viewportFraction = 1.0,
+ this.loop = false,
+ this.itemCount = 0,
+ this.reverse = false,
+ }) : super(
+ initialPage: TransformerPageController._getRealIndexFromRenderIndex(
+ initialPage, loop, itemCount, reverse),
+ keepPage: keepPage,
+ viewportFraction: viewportFraction);
+
+ int? getRenderIndexFromRealIndex(num index) {
+ return _getRenderIndexFromRealIndex(index, loop, itemCount, reverse);
+ }
+
+ int? getRealItemCount() {
+ if (itemCount == 0) return 0;
+ return loop ? itemCount + kMaxValue : itemCount;
+ }
+
+ static int? _getRenderIndexFromRealIndex(
+ num? index, bool loop, int? itemCount, bool reverse) {
+ if (itemCount == 0) return 0;
+ int? renderIndex;
+ if (loop) {
+ renderIndex = index! - kMiddleValue as int?;
+ renderIndex = renderIndex! % itemCount!;
+ if (renderIndex < 0) {
+ renderIndex += itemCount;
+ }
+ } else {
+ renderIndex = index as int?;
+ }
+ if (reverse) {
+ renderIndex = itemCount! - renderIndex! - 1;
+ }
+
+ return renderIndex;
+ }
+
+ double get realPage => super.page ?? 0.0;
+
+ static double? _getRenderPageFromRealPage(
+ double? page, bool loop, int? itemCount, bool reverse) {
+ double? renderPage;
+ if (loop) {
+ renderPage = page! - kMiddleValue;
+ renderPage = renderPage % itemCount!;
+ if (renderPage < 0) {
+ renderPage += itemCount;
+ }
+ } else {
+ renderPage = page;
+ }
+ if (reverse) {
+ renderPage = itemCount! - renderPage! - 1;
+ }
+
+ return renderPage;
+ }
+
+ @override
+ double? get page {
+ return loop
+ ? _getRenderPageFromRealPage(realPage, loop, itemCount, reverse)
+ : realPage;
+ }
+
+ int? getRealIndexFromRenderIndex(num index) {
+ return _getRealIndexFromRenderIndex(index, loop, itemCount, reverse);
+ }
+
+ static int _getRealIndexFromRenderIndex(
+ num index, bool loop, int itemCount, bool reverse) {
+ var result = reverse ? itemCount - index - 1 as int : index as int;
+ if (loop) {
+ result += kMiddleValue;
+ }
+ return result;
+ }
+}
+
+class TransformerPageView extends StatefulWidget {
+ /// Create a `transformed` widget base on the widget that has been passed to the [PageTransformer.transform].
+ /// See [TransformInfo]
+ ///
+ final PageTransformer? transformer;
+
+ /// Same as [PageView.scrollDirection]
+ ///
+ /// Defaults to [Axis.horizontal].
+ final Axis scrollDirection;
+
+ /// Same as [PageView.physics]
+ final ScrollPhysics? physics;
+
+ /// Set to false to disable page snapping, useful for custom scroll behavior.
+ /// Same as [PageView.pageSnapping]
+ final bool pageSnapping;
+
+ /// Called whenever the page in the center of the viewport changes.
+ /// Same as [PageView.onPageChanged]
+ final ValueChanged? onPageChanged;
+
+ final IndexedWidgetBuilder? itemBuilder;
+
+ // See [IndexController.mode],[IndexController.next],[IndexController.previous]
+ final IndexController? controller;
+
+ /// Animation duration
+ final Duration duration;
+
+ /// Animation curve
+ final Curve curve;
+
+ final TransformerPageController? pageController;
+
+ /// Set true to open infinity loop mode.
+ final bool loop;
+
+ /// This value is only valid when `pageController` is not set,
+ final int itemCount;
+
+ /// This value is only valid when `pageController` is not set,
+ final double viewportFraction;
+
+ /// If not set, it is controlled by this widget.
+ final int? index;
+
+ /// Creates a scrollable list that works page by page using widgets that are
+ /// created on demand.
+ ///
+ /// This constructor is appropriate for page views with a large (or infinite)
+ /// number of children because the builder is called only for those children
+ /// that are actually visible.
+ ///
+ /// Providing a non-null [itemCount] lets the [PageView] compute the maximum
+ /// scroll extent.
+ ///
+ /// [itemBuilder] will be called only with indices greater than or equal to
+ /// zero and less than [itemCount].
+ TransformerPageView({
+ Key? key,
+ this.index,
+ Duration? duration,
+ this.curve = Curves.ease,
+ this.viewportFraction = 1.0,
+ this.loop = false,
+ this.scrollDirection = Axis.horizontal,
+ this.physics,
+ this.pageSnapping = true,
+ this.onPageChanged,
+ this.controller,
+ this.transformer,
+ this.itemBuilder,
+ this.pageController,
+ required this.itemCount,
+ }) : assert(itemCount == 0 || itemBuilder != null || transformer != null),
+ duration =
+ duration ?? Duration(milliseconds: kDefaultTransactionDuration),
+ super(key: key);
+
+ factory TransformerPageView.children(
+ {Key? key,
+ int? index,
+ Duration? duration,
+ Curve curve = Curves.ease,
+ double viewportFraction = 1.0,
+ bool loop = false,
+ Axis scrollDirection = Axis.horizontal,
+ ScrollPhysics? physics,
+ bool pageSnapping = true,
+ ValueChanged? onPageChanged,
+ IndexController? controller,
+ PageTransformer? transformer,
+ required List children,
+ TransformerPageController? pageController}) {
+ return TransformerPageView(
+ itemCount: children.length,
+ itemBuilder: (BuildContext context, int index) {
+ return children[index];
+ },
+ pageController: pageController,
+ transformer: transformer,
+ pageSnapping: pageSnapping,
+ key: key,
+ index: index,
+ duration: duration,
+ curve: curve,
+ viewportFraction: viewportFraction,
+ scrollDirection: scrollDirection,
+ physics: physics,
+ onPageChanged: onPageChanged,
+ controller: controller,
+ );
+ }
+
+ @override
+ State createState() {
+ return _TransformerPageViewState();
+ }
+
+ static int? getRealIndexFromRenderIndex({
+ required bool reverse,
+ int index = 0,
+ int itemCount = 0,
+ required bool loop,
+ }) {
+ var initPage = reverse ? (itemCount - index - 1) : index;
+ if (loop) {
+ initPage += kMiddleValue;
+ }
+ return initPage;
+ }
+
+ static PageController createPageController(
+ {required bool reverse,
+ int index = 0,
+ int itemCount = 0,
+ required bool loop,
+ required double viewportFraction}) {
+ return PageController(
+ initialPage: getRealIndexFromRenderIndex(
+ reverse: reverse, index: index, itemCount: itemCount, loop: loop)!,
+ viewportFraction: viewportFraction);
+ }
+}
+
+class _TransformerPageViewState extends State {
+ Size? _size;
+ int _activeIndex = 0;
+ double? _currentPixels;
+ bool _done = false;
+
+ ///This value will not change until user end drag.
+ int? _fromIndex;
+
+ PageTransformer? _transformer;
+
+ TransformerPageController? _pageController;
+
+ Widget _buildItemNormal(BuildContext context, int index) {
+ final renderIndex = _pageController!.getRenderIndexFromRealIndex(index)!;
+ return widget.itemBuilder!(context, renderIndex);
+ }
+
+ Widget _buildItem(BuildContext context, int index) {
+ return AnimatedBuilder(
+ animation: _pageController!,
+ builder: (BuildContext c, Widget? w) {
+ var renderIndex = _pageController!.getRenderIndexFromRealIndex(index);
+ Widget? child;
+ if (widget.itemBuilder != null) {
+ child = widget.itemBuilder!(context, renderIndex!);
+ }
+
+ child ??= Container();
+
+ if (_size == null) {
+ return child;
+ }
+
+ double position;
+
+ double? page = _pageController!.realPage;
+
+ if (_transformer!.reverse) {
+ position = page - index;
+ } else {
+ position = index - page;
+ }
+ position *= widget.viewportFraction;
+
+ final info = TransformInfo(
+ index: renderIndex,
+ width: _size!.width,
+ height: _size!.height,
+ position: position.clamp(-1.0, 1.0),
+ activeIndex:
+ _pageController!.getRenderIndexFromRealIndex(_activeIndex),
+ fromIndex: _fromIndex,
+ forward: _pageController!.position.pixels - _currentPixels! >= 0,
+ done: _done,
+ scrollDirection: widget.scrollDirection,
+ viewportFraction: widget.viewportFraction,
+ );
+
+ return _transformer!.transform(child, info);
+ });
+ }
+
+ double? _calcCurrentPixels() {
+ _currentPixels =
+ _pageController!.getRenderIndexFromRealIndex(_activeIndex)! *
+ _pageController!.position.viewportDimension *
+ widget.viewportFraction;
+
+ // print("activeIndex:$_activeIndex , pix:$_currentPixels");
+
+ return _currentPixels;
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final builder = _transformer == null ? _buildItemNormal : _buildItem;
+ var child = PageView.builder(
+ itemBuilder: builder,
+ itemCount: _pageController!.getRealItemCount(),
+ onPageChanged: _onIndexChanged,
+ controller: _pageController,
+ scrollDirection: widget.scrollDirection,
+ physics: widget.physics,
+ pageSnapping: widget.pageSnapping,
+ reverse: _pageController!.reverse,
+ );
+ if (_transformer == null) {
+ return child;
+ }
+ return NotificationListener(
+ onNotification: (ScrollNotification notification) {
+ if (notification is ScrollStartNotification) {
+ _calcCurrentPixels();
+ _done = false;
+ _fromIndex = _activeIndex;
+ } else if (notification is ScrollEndNotification) {
+ _calcCurrentPixels();
+ _fromIndex = _activeIndex;
+ _done = true;
+ }
+
+ return false;
+ },
+ child: child,
+ );
+ }
+
+ void _onIndexChanged(int index) {
+ _activeIndex = index;
+ if (widget.onPageChanged != null) {
+ widget
+ .onPageChanged!(_pageController!.getRenderIndexFromRealIndex(index));
+ }
+ }
+
+ void _onGetSize(_) {
+ Size? size;
+
+ // if (context == null) {
+ // onGetSize(size);
+ // return;
+ // }
+ final renderObject = context.findRenderObject();
+ if (renderObject != null) {
+ final bounds = renderObject.paintBounds;
+ size = bounds.size;
+ }
+ _calcCurrentPixels();
+ onGetSize(size);
+ }
+
+ void onGetSize(Size? size) {
+ if (mounted) {
+ setState(() {
+ _size = size;
+ });
+ }
+ }
+
+ @override
+ void initState() {
+ _transformer = widget.transformer;
+ // int index = widget.index ?? 0;
+ _pageController = widget.pageController;
+ _pageController ??= TransformerPageController(
+ initialPage: widget.index ?? 0,
+ itemCount: widget.itemCount,
+ loop: widget.loop,
+ reverse:
+ widget.transformer == null ? false : widget.transformer!.reverse);
+ // int initPage = _getRealIndexFromRenderIndex(index);
+ // _pageController = PageController(initialPage: initPage,viewportFraction: widget.viewportFraction);
+ _fromIndex = _activeIndex = _pageController!.initialPage;
+
+ _controller = getNotifier();
+ if (_controller != null) {
+ _controller!.addListener(onChangeNotifier);
+ }
+ super.initState();
+ }
+
+ @override
+ void didUpdateWidget(TransformerPageView oldWidget) {
+ _transformer = widget.transformer;
+ final index = widget.index ?? 0;
+ var created = false;
+ if (_pageController != widget.pageController) {
+ if (widget.pageController != null) {
+ _pageController = widget.pageController;
+ } else {
+ created = true;
+ _pageController = TransformerPageController(
+ initialPage: widget.index ?? 0,
+ itemCount: widget.itemCount,
+ loop: widget.loop,
+ reverse: widget.transformer == null
+ ? false
+ : widget.transformer!.reverse);
+ }
+ }
+
+ if (_pageController!.getRenderIndexFromRealIndex(_activeIndex) != index) {
+ _fromIndex = _activeIndex = _pageController!.initialPage;
+ if (!created) {
+ final initPage = _pageController!.getRealIndexFromRenderIndex(index)!;
+ _pageController!.animateToPage(initPage,
+ duration: widget.duration, curve: widget.curve);
+ }
+ }
+ if (_transformer != null) {
+ WidgetsBinding.instance!.addPostFrameCallback(_onGetSize);
+ }
+
+ if (_controller != getNotifier()) {
+ if (_controller != null) {
+ _controller!.removeListener(onChangeNotifier);
+ }
+ _controller = getNotifier();
+ if (_controller != null) {
+ _controller!.addListener(onChangeNotifier);
+ }
+ }
+ super.didUpdateWidget(oldWidget);
+ }
+
+ @override
+ void didChangeDependencies() {
+ if (_transformer != null) {
+ WidgetsBinding.instance!.addPostFrameCallback(_onGetSize);
+ }
+ super.didChangeDependencies();
+ }
+
+ ChangeNotifier? getNotifier() {
+ return widget.controller;
+ }
+
+ int _calcNextIndex(bool next) {
+ var currentIndex = _activeIndex;
+ if (_pageController!.reverse) {
+ if (next) {
+ currentIndex--;
+ } else {
+ currentIndex++;
+ }
+ } else {
+ if (next) {
+ currentIndex++;
+ } else {
+ currentIndex--;
+ }
+ }
+
+ if (!_pageController!.loop) {
+ if (currentIndex >= _pageController!.itemCount) {
+ currentIndex = 0;
+ } else if (currentIndex < 0) {
+ currentIndex = _pageController!.itemCount - 1;
+ }
+ }
+
+ return currentIndex;
+ }
+
+ void onChangeNotifier() {
+ final event = widget.controller!.event;
+ var index;
+ switch (event) {
+ case IndexController.MOVE:
+ {
+ index = _pageController!
+ .getRealIndexFromRenderIndex(widget.controller!.index!);
+ }
+ break;
+ case IndexController.PREVIOUS:
+ case IndexController.NEXT:
+ {
+ index = _calcNextIndex(event == IndexController.NEXT);
+ }
+ break;
+ default:
+ //ignore this event
+ return;
+ }
+ if (widget.controller!.animation!) {
+ _pageController!
+ .animateToPage(index!, duration: widget.duration, curve: widget.curve)
+ .whenComplete(widget.controller!.complete);
+ } else {
+ _pageController!.jumpToPage(index!);
+ widget.controller!.complete();
+ }
+ }
+
+ ChangeNotifier? _controller;
+
+ @override
+ void dispose() {
+ if (_controller != null) {
+ _controller!.removeListener(onChangeNotifier);
+ }
+ super.dispose();
+ }
+}
diff --git a/pubspec.lock b/pubspec.lock
index 86f253d..1888d43 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -1,46 +1,60 @@
# Generated by pub
-# See https://www.dartlang.org/tools/pub/glossary#lockfile
+# See https://dart.dev/tools/pub/glossary#lockfile
packages:
async:
dependency: transitive
description:
name: async
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.8"
+ version: "2.5.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.0.4"
+ version: "2.1.0"
+ characters:
+ dependency: transitive
+ description:
+ name: characters
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.1.0"
charcode:
dependency: transitive
description:
name: charcode
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.2"
+ version: "1.2.0"
+ clock:
+ dependency: transitive
+ description:
+ name: clock
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.1.0"
collection:
dependency: transitive
description:
name: collection
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.15.0"
+ fake_async:
+ dependency: transitive
+ description:
+ name: fake_async
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.14.11"
+ version: "1.2.0"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
- flutter_page_indicator:
- dependency: "direct main"
- description:
- name: flutter_page_indicator
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "0.0.3"
flutter_test:
dependency: "direct dev"
description: flutter
@@ -50,30 +64,30 @@ packages:
dependency: transitive
description:
name: matcher
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "0.12.3+1"
+ version: "0.12.10"
meta:
dependency: transitive
description:
name: meta
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.6"
+ version: "1.3.0"
path:
dependency: transitive
description:
name: path
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.6.2"
- quiver:
- dependency: transitive
+ version: "1.8.0"
+ pedantic:
+ dependency: "direct dev"
description:
- name: quiver
- url: "https://pub.flutter-io.cn"
+ name: pedantic
+ url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.1"
+ version: "1.11.0"
sky_engine:
dependency: transitive
description: flutter
@@ -83,65 +97,58 @@ packages:
dependency: transitive
description:
name: source_span
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.4.1"
+ version: "1.8.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.9.3"
+ version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.6.8"
+ version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.0.4"
+ version: "1.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.0.1"
+ version: "1.2.0"
test_api:
dependency: transitive
description:
name: test_api
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "0.2.1"
- transformer_page_view:
- dependency: "direct main"
- description:
- name: transformer_page_view
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "0.1.5"
+ version: "0.2.19"
typed_data:
dependency: transitive
description:
name: typed_data
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.6"
+ version: "1.3.0"
vector_math:
dependency: transitive
description:
name: vector_math
- url: "https://pub.flutter-io.cn"
+ url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.8"
+ version: "2.1.0"
sdks:
- dart: ">=2.0.0 <3.0.0"
- flutter: ">=0.1.4 <3.0.0"
+ dart: ">=2.12.0 <3.0.0"
+ flutter: ">=0.1.4"
diff --git a/pubspec.yaml b/pubspec.yaml
index 17ed711..0f5e80b 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
name: flutter_swiper
description: The best swiper(carousel) for flutter, with multiple layouts, infinite loop. Compatible with Android & iOS.
-version: 1.1.6
+version: 2.0.0
author: JZoom
homepage: https://github.com/jzoom/flutter_swiper
@@ -8,15 +8,13 @@ dependencies:
flutter:
sdk: flutter
- transformer_page_view: ^0.1.6
- flutter_page_indicator: ^0.0.3
-
environment:
- sdk: ">=2.0.0-dev.48.0 <3.0.0"
+ sdk: ">=2.12.0 <3.0.0"
flutter: ">=0.1.4 <3.0.0"
dev_dependencies:
flutter_test:
sdk: flutter
+ pedantic: '^1.11.0'
flutter:
diff --git a/test/control_test.dart b/test/control_test.dart
index 9f9f2f1..7705606 100644
--- a/test/control_test.dart
+++ b/test/control_test.dart
@@ -4,25 +4,25 @@ import 'package:flutter_swiper/flutter_swiper.dart';
void main() {
testWidgets('Control horizontal', (WidgetTester tester) async {
- SwiperController controller = new SwiperController();
+ final controller = SwiperController();
- SwiperPluginConfig config = new SwiperPluginConfig(
+ final config = SwiperPluginConfig(
activeIndex: 0,
controller: controller,
itemCount: 10,
loop: true,
scrollDirection: Axis.horizontal);
- Key key = new UniqueKey();
- await tester.pumpWidget(new MaterialApp(
- home: new Scaffold(body: new Builder(builder: (BuildContext context) {
- return new SwiperControl(key: key).build(context, config);
+ Key key = UniqueKey();
+ await tester.pumpWidget(MaterialApp(
+ home: Scaffold(body: Builder(builder: (BuildContext context) {
+ return SwiperControl(key: key).build(context, config);
})),
));
expect(find.byKey(key), findsOneWidget);
- bool first = true;
+ var first = true;
await tester.tap(find.byWidgetPredicate((Widget widget) {
if (widget is GestureDetector && first) {
@@ -35,19 +35,19 @@ void main() {
});
testWidgets('Control vertical', (WidgetTester tester) async {
- SwiperController controller = new SwiperController();
+ final controller = SwiperController();
- SwiperPluginConfig config = new SwiperPluginConfig(
+ final config = SwiperPluginConfig(
activeIndex: 0,
controller: controller,
itemCount: 10,
loop: true,
scrollDirection: Axis.vertical);
- Key key = new UniqueKey();
- await tester.pumpWidget(new MaterialApp(
- home: new Scaffold(body: new Builder(builder: (BuildContext context) {
- return new SwiperControl(
+ Key key = UniqueKey();
+ await tester.pumpWidget(MaterialApp(
+ home: Scaffold(body: Builder(builder: (BuildContext context) {
+ return SwiperControl(
key: key, color: Colors.white, disableColor: Colors.black87)
.build(context, config);
})),
@@ -55,7 +55,7 @@ void main() {
expect(find.byKey(key), findsOneWidget);
- bool first = true;
+ var first = true;
await tester.tap(find.byWidgetPredicate((Widget widget) {
if (widget is GestureDetector && first) {
diff --git a/test/flutter_swiper_test.dart b/test/flutter_swiper_test.dart
index c73c576..42ab30a 100644
--- a/test/flutter_swiper_test.dart
+++ b/test/flutter_swiper_test.dart
@@ -5,14 +5,18 @@ import 'package:flutter_swiper/flutter_swiper.dart';
void main() {
testWidgets('Default Swiper', (WidgetTester tester) async {
// Build our app and trigger a frame.
- await tester.pumpWidget(MaterialApp(
+ await tester.pumpWidget(
+ MaterialApp(
home: Swiper(
- itemBuilder: (context, index) {
- return Text("0");
- },
- itemCount: 10)));
-
- expect(find.text("0", skipOffstage: false), findsOneWidget);
+ itemBuilder: (context, index) {
+ return Text('0');
+ },
+ itemCount: 10,
+ ),
+ ),
+ );
+
+ expect(find.text('0', skipOffstage: false), findsOneWidget);
});
testWidgets('Default Swiper loop:false', (WidgetTester tester) async {
@@ -21,98 +25,99 @@ void main() {
home: Swiper(
onTap: (int inde) {},
itemBuilder: (context, index) {
- return Text("0");
+ return Text('0');
},
itemCount: 10,
loop: false,
)));
- expect(find.text("0", skipOffstage: true), findsOneWidget);
+ expect(find.text('0', skipOffstage: true), findsOneWidget);
});
testWidgets('Create Swiper with children', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MaterialApp(
home: Swiper.children(
- children: [Text("0"), Text("1")],
+ children: [Text('0'), Text('1')],
)));
- expect(find.text("0", skipOffstage: false), findsOneWidget);
+ expect(find.text('0', skipOffstage: false), findsOneWidget);
});
testWidgets('Create Swiper with list', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MaterialApp(
home: Swiper.list(
- list: ["0", "1"],
+ list: ['0', '1'],
builder: (BuildContext context, dynamic data, int index) {
return Text(data);
},
)));
- expect(find.text("0", skipOffstage: false), findsOneWidget);
+ expect(find.text('0', skipOffstage: false), findsOneWidget);
});
testWidgets('Swiper with default plugins', (WidgetTester tester) async {
// Build our app and trigger a frame.
- SwiperController controller = SwiperController();
+ final controller = SwiperController();
await tester.pumpWidget(MaterialApp(
home: Swiper(
controller: controller,
itemBuilder: (context, index) {
- return Text("0");
+ return Text('0');
},
itemCount: 10,
pagination: SwiperPagination(),
control: SwiperControl(),
)));
- expect(find.text("0", skipOffstage: false), findsOneWidget);
+ expect(find.text('0', skipOffstage: false), findsOneWidget);
});
- const List titles = [
- "Flutter Swiper is awosome",
- "Really nice",
- "Yeap"
- ];
+ const titles = ['Flutter Swiper is awesome', 'Really nice', 'Yeah'];
testWidgets('Customize pagination', (WidgetTester tester) async {
// Build our app and trigger a frame.
- SwiperController controller = SwiperController();
- await tester.pumpWidget(MaterialApp(
+ final controller = SwiperController();
+ await tester.pumpWidget(
+ MaterialApp(
home: Swiper(
- controller: controller,
- itemBuilder: (context, index) {
- return Text("0");
- },
- itemCount: 10,
- pagination: SwiperCustomPagination(
- builder: (BuildContext context, SwiperPluginConfig config) {
- return ConstrainedBox(
- child: Row(
- children: [
- Text(
- "${titles[config.activeIndex]} ${config.activeIndex + 1}/${config.itemCount}",
- style: TextStyle(fontSize: 20.0),
- ),
- Expanded(
- child: Align(
- alignment: Alignment.centerRight,
- child: DotSwiperPaginationBuilder(
- color: Colors.black12,
- activeColor: Colors.black,
- size: 10.0,
- activeSize: 20.0)
- .build(context, config),
+ controller: controller,
+ itemBuilder: (context, index) {
+ return Text('0');
+ },
+ itemCount: 10,
+ pagination: SwiperCustomPagination(
+ builder: (BuildContext context, SwiperPluginConfig? config) {
+ return ConstrainedBox(
+ constraints: BoxConstraints.expand(height: 50.0),
+ child: Row(
+ children: [
+ if (config != null)
+ Text(
+ '${titles[config.activeIndex!]} ${config.activeIndex! + 1}/${config.itemCount}',
+ style: TextStyle(fontSize: 20.0),
+ ),
+ Expanded(
+ child: Align(
+ alignment: Alignment.centerRight,
+ child: DotSwiperPaginationBuilder(
+ color: Colors.black12,
+ activeColor: Colors.black,
+ size: 10.0,
+ activeSize: 20.0)
+ .build(context, config),
+ ),
+ )
+ ],
),
- )
- ],
+ );
+ },
),
- constraints: BoxConstraints.expand(height: 50.0),
- );
- }),
- control: SwiperControl(),
- )));
+ control: SwiperControl(),
+ ),
+ ),
+ );
controller.startAutoplay();
@@ -124,40 +129,40 @@ void main() {
await controller.next(animation: false);
await controller.previous(animation: false);
- expect(find.text("0", skipOffstage: false), findsOneWidget);
+ expect(find.text('0', skipOffstage: false), findsOneWidget);
});
testWidgets('Swiper fraction', (WidgetTester tester) async {
// Build our app and trigger a frame.
- SwiperController controller = SwiperController();
+ final controller = SwiperController();
await tester.pumpWidget(MaterialApp(
home: Swiper(
controller: controller,
itemBuilder: (context, index) {
- return Text("0");
+ return Text('0');
},
itemCount: 10,
pagination: SwiperPagination(builder: SwiperPagination.fraction),
control: SwiperControl(),
)));
- expect(find.text("0", skipOffstage: false), findsOneWidget);
+ expect(find.text('0', skipOffstage: false), findsOneWidget);
});
testWidgets('Zero itemCount', (WidgetTester tester) async {
// Build our app and trigger a frame.
- SwiperController controller = SwiperController();
+ final controller = SwiperController();
await tester.pumpWidget(MaterialApp(
home: Swiper(
controller: controller,
itemBuilder: (context, index) {
- return Text("0");
+ return Text('0');
},
itemCount: 0,
pagination: SwiperPagination(builder: SwiperPagination.fraction),
control: SwiperControl(),
)));
- expect(find.text("0", skipOffstage: false), findsNothing);
+ expect(find.text('0', skipOffstage: false), findsNothing);
});
}
diff --git a/test/layout_test.dart b/test/layout_test.dart
index 233acfd..4422193 100644
--- a/test/layout_test.dart
+++ b/test/layout_test.dart
@@ -4,78 +4,91 @@ import 'package:flutter_swiper/flutter_swiper.dart';
void main() {
testWidgets('STACK', (WidgetTester tester) async {
- await tester.pumpWidget(MaterialApp(
+ await tester.pumpWidget(
+ MaterialApp(
home: Swiper(
- layout: SwiperLayout.STACK,
- itemWidth: 300.0,
- itemHeight: 200.0,
- itemBuilder: (context, index) {
- return new Container(
- color: Colors.grey,
- child: new Center(
- child: new Text("$index"),
- ),
- );
- },
- itemCount: 10)));
+ layout: SwiperLayout.STACK,
+ itemWidth: 300.0,
+ itemHeight: 200.0,
+ itemBuilder: (context, index) {
+ return Container(
+ color: Colors.grey,
+ child: Center(
+ child: Text('$index'),
+ ),
+ );
+ },
+ itemCount: 10,
+ ),
+ ),
+ );
});
testWidgets('TINDER', (WidgetTester tester) async {
- await tester.pumpWidget(MaterialApp(
+ await tester.pumpWidget(
+ MaterialApp(
home: Swiper(
- layout: SwiperLayout.TINDER,
- itemWidth: 300.0,
- itemHeight: 200.0,
- itemBuilder: (context, index) {
- return new Container(
- color: Colors.grey,
- child: new Center(
- child: new Text("$index"),
- ),
- );
- },
- itemCount: 10)));
+ layout: SwiperLayout.TINDER,
+ itemWidth: 300.0,
+ itemHeight: 200.0,
+ itemBuilder: (context, index) {
+ return Container(
+ color: Colors.grey,
+ child: Center(
+ child: Text('$index'),
+ ),
+ );
+ },
+ itemCount: 10,
+ ),
+ ),
+ );
});
testWidgets('DEFAULT', (WidgetTester tester) async {
- await tester.pumpWidget(MaterialApp(
+ await tester.pumpWidget(
+ MaterialApp(
home: Swiper(
- layout: SwiperLayout.DEFAULT,
- viewportFraction: 0.8,
- scale: 0.9,
- itemBuilder: (context, index) {
- return new Container(
- color: Colors.grey,
- child: new Center(
- child: new Text("$index"),
- ),
- );
- },
- itemCount: 10)));
+ layout: SwiperLayout.DEFAULT,
+ viewportFraction: 0.8,
+ scale: 0.9,
+ itemBuilder: (context, index) {
+ return Container(
+ color: Colors.grey,
+ child: Center(
+ child: Text('$index'),
+ ),
+ );
+ },
+ itemCount: 10,
+ ),
+ ),
+ );
});
testWidgets('CUSTOM', (WidgetTester tester) async {
CustomLayoutOption customLayoutOption;
- customLayoutOption = new CustomLayoutOption(startIndex: -1, stateCount: 3)
- .addRotate([-45.0 / 180, 0.0, 45.0 / 180]).addTranslate([
- new Offset(-370.0, -40.0),
- new Offset(0.0, 0.0),
- new Offset(370.0, -40.0)
- ]);
- await tester.pumpWidget(MaterialApp(
+ customLayoutOption = CustomLayoutOption(startIndex: -1, stateCount: 3)
+ .addRotate([-45.0 / 180, 0.0, 45.0 / 180]).addTranslate(
+ [Offset(-370.0, -40.0), Offset(0.0, 0.0), Offset(370.0, -40.0)]);
+ await tester.pumpWidget(
+ MaterialApp(
home: Swiper(
- layout: SwiperLayout.CUSTOM,
- itemWidth: 300.0,
- itemHeight: 200.0,
- customLayoutOption: customLayoutOption,
- itemBuilder: (context, index) {
- return new Container(
- color: Colors.grey,
- child: new Center(
- child: new Text("$index"),
- ),
- );
- },
- itemCount: 10)));
+ layout: SwiperLayout.CUSTOM,
+ itemWidth: 300.0,
+ itemHeight: 200.0,
+ customLayoutOption: customLayoutOption,
+ itemBuilder: (context, index) {
+ return Container(
+ color: Colors.grey,
+ child: Center(
+ child: Text('$index'),
+ ),
+ );
+ },
+ itemCount: 10,
+ ),
+ ),
+ );
});
}
diff --git a/test/pagination_test.dart b/test/pagination_test.dart
index 04101be..2a644a8 100644
--- a/test/pagination_test.dart
+++ b/test/pagination_test.dart
@@ -4,21 +4,22 @@ import 'package:flutter_swiper/flutter_swiper.dart';
void main() {
testWidgets('Pagination', (WidgetTester tester) async {
- SwiperController controller = new SwiperController();
-
- SwiperPluginConfig config = new SwiperPluginConfig(
- activeIndex: 0,
- controller: controller,
- itemCount: 10,
- scrollDirection: Axis.horizontal);
-
- Key key = new UniqueKey();
- await tester.pumpWidget(new MaterialApp(
- home: new Scaffold(body: new Builder(builder: (BuildContext context) {
- return new DotSwiperPaginationBuilder(
+ final controller = SwiperController();
+
+ final config = SwiperPluginConfig(
+ activeIndex: 0,
+ controller: controller,
+ itemCount: 10,
+ scrollDirection: Axis.horizontal,
+ );
+
+ Key key = UniqueKey();
+ await tester.pumpWidget(MaterialApp(
+ home: Scaffold(body: Builder(builder: (BuildContext context) {
+ return DotSwiperPaginationBuilder(
key: key,
- activeColor: new Color(0xff000000),
- color: new Color(0xffffffff),
+ activeColor: Color(0xff000000),
+ color: Color(0xffffffff),
space: 10.0,
size: 10.0,
activeSize: 20.0)
@@ -26,7 +27,7 @@ void main() {
})),
));
- for (int i = 0; i < 10; ++i) {
+ for (var i = 0; i < 10; ++i) {
expect(find.byWidgetPredicate((Widget widget) {
if (widget.key != null &&
widget.key is ValueKey &&
@@ -40,21 +41,21 @@ void main() {
});
testWidgets('Pagination vertical', (WidgetTester tester) async {
- SwiperController controller = new SwiperController();
+ final controller = SwiperController();
- SwiperPluginConfig config = new SwiperPluginConfig(
+ final config = SwiperPluginConfig(
activeIndex: 0,
controller: controller,
itemCount: 10,
- scrollDirection: Axis.vertical);
+ scrollDirection: Axis.vertical,);
- Key key = new UniqueKey();
- await tester.pumpWidget(new MaterialApp(
- home: new Scaffold(body: new Builder(builder: (BuildContext context) {
- return new DotSwiperPaginationBuilder(
+ Key key = UniqueKey();
+ await tester.pumpWidget(MaterialApp(
+ home: Scaffold(body: Builder(builder: (BuildContext context) {
+ return DotSwiperPaginationBuilder(
key: key,
- activeColor: new Color(0xff000000),
- color: new Color(0xffffffff),
+ activeColor: Color(0xff000000),
+ color: Color(0xffffffff),
space: 10.0,
size: 10.0,
activeSize: 20.0)
@@ -62,7 +63,7 @@ void main() {
})),
));
- for (int i = 0; i < 10; ++i) {
+ for (var i = 0; i < 10; ++i) {
expect(find.byWidgetPredicate((Widget widget) {
if (widget.key != null &&
widget.key is ValueKey &&
@@ -76,53 +77,53 @@ void main() {
});
testWidgets('Pagination fraction', (WidgetTester tester) async {
- SwiperController controller = new SwiperController();
+ final controller = SwiperController();
- SwiperPluginConfig config = new SwiperPluginConfig(
+ final config = SwiperPluginConfig(
activeIndex: 0,
controller: controller,
itemCount: 10,
scrollDirection: Axis.horizontal);
- Key key = new UniqueKey();
- await tester.pumpWidget(new MaterialApp(
- home: new Scaffold(body: new Builder(builder: (BuildContext context) {
- return new FractionPaginationBuilder(
+ Key key = UniqueKey();
+ await tester.pumpWidget(MaterialApp(
+ home: Scaffold(body: Builder(builder: (BuildContext context) {
+ return FractionPaginationBuilder(
key: key,
- activeColor: new Color(0xff000000),
- color: new Color(0xffffffff),
+ activeColor: Color(0xff000000),
+ color: Color(0xffffffff),
).build(context, config);
})),
));
- expect(find.text("1"), findsOneWidget);
- expect(find.text(" / 10"), findsOneWidget);
+ expect(find.text('1'), findsOneWidget);
+ expect(find.text(' / 10'), findsOneWidget);
expect(find.byKey(key), findsOneWidget);
});
testWidgets('Pagination fraction vertical', (WidgetTester tester) async {
- SwiperController controller = new SwiperController();
+ final controller = SwiperController();
- SwiperPluginConfig config = new SwiperPluginConfig(
+ final config = SwiperPluginConfig(
activeIndex: 0,
controller: controller,
itemCount: 10,
- scrollDirection: Axis.vertical);
+ scrollDirection: Axis.vertical,);
- Key key = new UniqueKey();
- await tester.pumpWidget(new MaterialApp(
- home: new Scaffold(body: new Builder(builder: (BuildContext context) {
- return new FractionPaginationBuilder(
+ Key key = UniqueKey();
+ await tester.pumpWidget(MaterialApp(
+ home: Scaffold(body: Builder(builder: (BuildContext context) {
+ return FractionPaginationBuilder(
key: key,
- activeColor: new Color(0xff000000),
- color: new Color(0xffffffff),
+ activeColor: Color(0xff000000),
+ color: Color(0xffffffff),
).build(context, config);
})),
));
- expect(find.text("1"), findsOneWidget);
- expect(find.text("10"), findsOneWidget);
+ expect(find.text('1'), findsOneWidget);
+ expect(find.text('10'), findsOneWidget);
expect(find.byKey(key), findsOneWidget);
});