├── .gitignore
├── .metadata
├── CHANGELOG.md
├── LICENSE
├── README.md
├── example
├── app
│ ├── .gitignore
│ ├── .metadata
│ ├── README.md
│ ├── android
│ │ ├── .gitignore
│ │ ├── app
│ │ │ ├── build.gradle
│ │ │ └── src
│ │ │ │ ├── debug
│ │ │ │ └── AndroidManifest.xml
│ │ │ │ ├── main
│ │ │ │ ├── AndroidManifest.xml
│ │ │ │ ├── kotlin
│ │ │ │ │ └── com
│ │ │ │ │ │ └── example
│ │ │ │ │ │ └── app
│ │ │ │ │ │ └── MainActivity.kt
│ │ │ │ └── res
│ │ │ │ │ ├── drawable
│ │ │ │ │ └── launch_background.xml
│ │ │ │ │ ├── mipmap-hdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── mipmap-mdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── mipmap-xhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ └── values
│ │ │ │ │ └── styles.xml
│ │ │ │ └── profile
│ │ │ │ └── AndroidManifest.xml
│ │ ├── build.gradle
│ │ ├── gradle.properties
│ │ ├── gradle
│ │ │ └── wrapper
│ │ │ │ └── gradle-wrapper.properties
│ │ └── settings.gradle
│ ├── ios
│ │ ├── .gitignore
│ │ ├── Flutter
│ │ │ ├── AppFrameworkInfo.plist
│ │ │ ├── Debug.xcconfig
│ │ │ └── Release.xcconfig
│ │ ├── Runner.xcodeproj
│ │ │ ├── project.pbxproj
│ │ │ ├── project.xcworkspace
│ │ │ │ └── contents.xcworkspacedata
│ │ │ └── xcshareddata
│ │ │ │ └── xcschemes
│ │ │ │ └── Runner.xcscheme
│ │ ├── Runner.xcworkspace
│ │ │ └── contents.xcworkspacedata
│ │ └── Runner
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Assets.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ ├── Contents.json
│ │ │ │ ├── Icon-App-1024x1024@1x.png
│ │ │ │ ├── Icon-App-20x20@1x.png
│ │ │ │ ├── Icon-App-20x20@2x.png
│ │ │ │ ├── Icon-App-20x20@3x.png
│ │ │ │ ├── Icon-App-29x29@1x.png
│ │ │ │ ├── Icon-App-29x29@2x.png
│ │ │ │ ├── Icon-App-29x29@3x.png
│ │ │ │ ├── Icon-App-40x40@1x.png
│ │ │ │ ├── Icon-App-40x40@2x.png
│ │ │ │ ├── Icon-App-40x40@3x.png
│ │ │ │ ├── Icon-App-60x60@2x.png
│ │ │ │ ├── Icon-App-60x60@3x.png
│ │ │ │ ├── Icon-App-76x76@1x.png
│ │ │ │ ├── Icon-App-76x76@2x.png
│ │ │ │ └── Icon-App-83.5x83.5@2x.png
│ │ │ └── LaunchImage.imageset
│ │ │ │ ├── Contents.json
│ │ │ │ ├── LaunchImage.png
│ │ │ │ ├── LaunchImage@2x.png
│ │ │ │ ├── LaunchImage@3x.png
│ │ │ │ └── README.md
│ │ │ ├── Base.lproj
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ │ ├── Info.plist
│ │ │ └── Runner-Bridging-Header.h
│ ├── lib
│ │ └── main.dart
│ ├── pubspec.lock
│ ├── pubspec.yaml
│ └── test
│ │ └── widget_test.dart
├── isolated.dart
└── main.dart
├── lib
├── calculate.dart
├── isolated.dart
├── list_diff.dart
├── operation.dart
└── trim.dart
├── pubspec.lock
├── pubspec.yaml
└── test
└── list_diff_test.dart
/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 |
12 | # IntelliJ related
13 | *.iml
14 | *.ipr
15 | *.iws
16 | .idea/
17 |
18 | # The .vscode folder contains launch configuration and tasks you configure in
19 | # VS Code which you may wish to be included in version control, so this line
20 | # is commented out by default.
21 | .vscode/
22 |
23 | # Flutter/Dart/Pub related
24 | **/doc/api/
25 | .dart_tool/
26 | .flutter-plugins
27 | .packages
28 | .pub-cache/
29 | .pub/
30 | build/
31 |
32 | # Android related
33 | **/android/**/gradle-wrapper.jar
34 | **/android/.gradle
35 | **/android/captures/
36 | **/android/gradlew
37 | **/android/gradlew.bat
38 | **/android/local.properties
39 | **/android/**/GeneratedPluginRegistrant.java
40 |
41 | # iOS/XCode related
42 | **/ios/**/*.mode1v3
43 | **/ios/**/*.mode2v3
44 | **/ios/**/*.moved-aside
45 | **/ios/**/*.pbxuser
46 | **/ios/**/*.perspectivev3
47 | **/ios/**/*sync/
48 | **/ios/**/.sconsign.dblite
49 | **/ios/**/.tags*
50 | **/ios/**/.vagrant/
51 | **/ios/**/DerivedData/
52 | **/ios/**/Icon?
53 | **/ios/**/Pods/
54 | **/ios/**/.symlinks/
55 | **/ios/**/profile
56 | **/ios/**/xcuserdata
57 | **/ios/.generated/
58 | **/ios/Flutter/App.framework
59 | **/ios/Flutter/Flutter.framework
60 | **/ios/Flutter/Generated.xcconfig
61 | **/ios/Flutter/app.flx
62 | **/ios/Flutter/app.zip
63 | **/ios/Flutter/flutter_assets/
64 | **/ios/Flutter/flutter_export_environment.sh
65 | **/ios/ServiceDefinitions.json
66 | **/ios/Runner/GeneratedPluginRegistrant.*
67 |
68 | # Exceptions to above rules.
69 | !**/ios/**/default.mode1v3
70 | !**/ios/**/default.mode2v3
71 | !**/ios/**/default.pbxuser
72 | !**/ios/**/default.perspectivev3
73 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
74 |
--------------------------------------------------------------------------------
/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: f4b4616f872ed683ffde7740b90778ca415adfe1
8 | channel: master
9 |
10 | project_type: package
11 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 2.0.1
2 |
3 | * Fix bug that caused a crash when the lists overlap in a certain way.
4 | * Thanks to @ductranit for reporting the issue!
5 |
6 | ## 2.0.0
7 |
8 | * Migrate to null-safety.
9 |
10 | ## 1.3.2
11 |
12 | * Relax dependency on async.
13 |
14 | ## 1.3.1
15 |
16 | * Fix the assert message.
17 |
18 | ## 1.3.0
19 |
20 | * Add `diffSync` method.
21 |
22 | ## 1.2.1
23 |
24 | * Add extension method for more intuitive `list.apply(operation)` instead of `operation.applyTo(list)`.
25 | * Revised readme.
26 |
27 | ## 1.2.0
28 |
29 | * Add option to provide `areEqual` and `getHashCode` functions.
30 |
31 | ## 1.1.3
32 |
33 | * Important fix: Fixed error in the algorithm that made it crash when the two lists are the same.
34 |
35 | ## 1.1.2
36 |
37 | * Important fix: Fixed error in the algorithm that produced wrong results that you can't apply.
38 |
39 | ## 1.1.1
40 |
41 | * BREAKING CHANGE: `runOnSeparateIsolate` renamed to `spawnIsolate`.
42 | * By default, the `diff` function intelligently tries to choose whether or not to spawn an isolate based on the lengths on the lists.
43 | * Revised readme.
44 |
45 | ## 1.1.0
46 |
47 | * BREAKING CHANGE: `diff` is now asynchronous.
48 | * Add support for running `diff` on another isolate by setting `runOnSeparateIsolate` to `true`.
49 | * Add `isolated.dart` example.
50 | * Better error messages.
51 | * Revised doc comments.
52 | * Add readme.
53 |
54 | ## 1.0.1
55 |
56 | * Remove unused dependency `dart:isolate`.
57 |
58 | ## 1.0.0
59 |
60 | * This Initial release features the `diff` function that takes two lists and returns a list of `Operation`s that turn the first into the second list if applied in order.
61 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2019 Marcel Garus
2 |
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions are met:
5 |
6 | 1. Redistributions of source code must retain the above copyright notice, this
7 | list of conditions and the following disclaimer.
8 |
9 | 2. Redistributions in binary form must reproduce the above copyright notice,
10 | this list of conditions and the following disclaimer in the documentation
11 | and/or other materials provided with the distribution.
12 |
13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
17 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
21 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Offers a `diff` method that accepts two `List`s and returns a list of
2 | `Operation`s for turning the first list into the second one:
3 |
4 | ```dart
5 | var operations = await diff(
6 | ['coconut', 'nut', 'peanut'],
7 | ['kiwi', 'coconut', 'maracuja', 'nut', 'banana'],
8 | );
9 | operations.forEach(print);
10 |
11 | // Operations:
12 | // Insertion of kiwi at 0.
13 | // Insertion of maracuja at 2.
14 | // Insertion of banana at 4.
15 | // Deletion of peanut at 5.
16 | ```
17 |
18 | `Operation`s are either an insertion or deletion of an item at an index. You
19 | can also directly apply them to a list:
20 |
21 | ```dart
22 | // Let's try it out!
23 | var fruitBowl = ['coconut', 'nut', 'peanut'];
24 |
25 | for (var operation in operations) {
26 | fruitBowl.apply(operation);
27 | }
28 |
29 | // Transforming:
30 | // [coconut, nut, peanut]
31 | // [kiwi, coconut, nut, peanut]
32 | // [kiwi, coconut, maracuja, nut, peanut]
33 | // [kiwi, coconut, maracuja, nut, banana, peanut]
34 | // [kiwi, coconut, maracuja, nut, banana]
35 | ```
36 |
37 | The lists' items are compared using their `==` operator and `hashCode` by default.
38 | But you can specify a custom comparison method and hash code:
39 |
40 | ```dart
41 | var operations = await diff(
42 | first,
43 | second,
44 | areEqual: (a, b) => ...,
45 | getHashCode: (a) => ...,
46 | );
47 | ```
48 |
49 | ### A word about performance and threading
50 |
51 | I'm not sure the current version is as performant as it could be.
52 | The runtime is currently O(N*M), where N and M are the lengths of the lists.
53 | If you know a better algorithm, feel welcome to open an issue or file a pull request.
54 |
55 | If the data sets are large, the `diff` function automatically spawns an
56 | isolate. If you want more control on whether an isolate should be
57 | spawned, you can also explicitly set the `spawnIsolate` parameter:
58 |
59 | ```dart
60 | var operations = await diff(first, second, spawnIsolate: true);
61 | ```
62 |
63 | ### For Flutter users
64 |
65 | `diff` can be used to calculate updates for an `AnimatedList`.
66 | The [implicitly_animated_list](https://pub.dev/packages/implicitly_animated_list) package does that for you.
67 |
--------------------------------------------------------------------------------
/example/app/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 |
12 | # IntelliJ related
13 | *.iml
14 | *.ipr
15 | *.iws
16 | .idea/
17 |
18 | # The .vscode folder contains launch configuration and tasks you configure in
19 | # VS Code which you may wish to be included in version control, so this line
20 | # is commented out by default.
21 | #.vscode/
22 |
23 | # Flutter/Dart/Pub related
24 | **/doc/api/
25 | .dart_tool/
26 | .flutter-plugins
27 | .packages
28 | .pub-cache/
29 | .pub/
30 | /build/
31 |
32 | # Web related
33 | lib/generated_plugin_registrant.dart
34 |
35 | # Exceptions to above rules.
36 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
37 |
--------------------------------------------------------------------------------
/example/app/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: f4b4616f872ed683ffde7740b90778ca415adfe1
8 | channel: master
9 |
10 | project_type: app
11 |
--------------------------------------------------------------------------------
/example/app/README.md:
--------------------------------------------------------------------------------
1 | # app
2 |
3 | A new Flutter project.
4 |
5 | ## Getting Started
6 |
7 | This project is a starting point for a Flutter application.
8 |
9 | A few resources to get you started if this is your first Flutter project:
10 |
11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
13 |
14 | For help getting started with Flutter, view our
15 | [online documentation](https://flutter.dev/docs), which offers tutorials,
16 | samples, guidance on mobile development, and a full API reference.
17 |
--------------------------------------------------------------------------------
/example/app/android/.gitignore:
--------------------------------------------------------------------------------
1 | gradle-wrapper.jar
2 | /.gradle
3 | /captures/
4 | /gradlew
5 | /gradlew.bat
6 | /local.properties
7 | GeneratedPluginRegistrant.java
8 |
--------------------------------------------------------------------------------
/example/app/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | def localProperties = new Properties()
2 | def localPropertiesFile = rootProject.file('local.properties')
3 | if (localPropertiesFile.exists()) {
4 | localPropertiesFile.withReader('UTF-8') { reader ->
5 | localProperties.load(reader)
6 | }
7 | }
8 |
9 | def flutterRoot = localProperties.getProperty('flutter.sdk')
10 | if (flutterRoot == null) {
11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12 | }
13 |
14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15 | if (flutterVersionCode == null) {
16 | flutterVersionCode = '1'
17 | }
18 |
19 | def flutterVersionName = localProperties.getProperty('flutter.versionName')
20 | if (flutterVersionName == null) {
21 | flutterVersionName = '1.0'
22 | }
23 |
24 | apply plugin: 'com.android.application'
25 | apply plugin: 'kotlin-android'
26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27 |
28 | android {
29 | compileSdkVersion 28
30 |
31 | sourceSets {
32 | main.java.srcDirs += 'src/main/kotlin'
33 | }
34 |
35 | lintOptions {
36 | disable 'InvalidPackage'
37 | }
38 |
39 | defaultConfig {
40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
41 | applicationId "com.example.app"
42 | minSdkVersion 16
43 | targetSdkVersion 28
44 | versionCode flutterVersionCode.toInteger()
45 | versionName flutterVersionName
46 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
47 | }
48 |
49 | buildTypes {
50 | release {
51 | // TODO: Add your own signing config for the release build.
52 | // Signing with the debug keys for now, so `flutter run --release` works.
53 | signingConfig signingConfigs.debug
54 | }
55 | }
56 | }
57 |
58 | flutter {
59 | source '../..'
60 | }
61 |
62 | dependencies {
63 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
64 | testImplementation 'junit:junit:4.12'
65 | androidTestImplementation 'androidx.test:runner:1.1.1'
66 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
67 | }
68 |
--------------------------------------------------------------------------------
/example/app/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/app/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
8 |
12 |
19 |
23 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/example/app/android/app/src/main/kotlin/com/example/app/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.example.app
2 |
3 | import android.os.Bundle
4 | import io.flutter.app.FlutterActivity
5 | import io.flutter.plugins.GeneratedPluginRegistrant
6 |
7 | class MainActivity: FlutterActivity() {
8 | override fun onCreate(savedInstanceState: Bundle?) {
9 | super.onCreate(savedInstanceState)
10 | GeneratedPluginRegistrant.registerWith(this)
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/example/app/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/example/app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MarcelGarus/list_diff/e09754b46ab43aeb66527cf1e41af84327c9c6ef/example/app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MarcelGarus/list_diff/e09754b46ab43aeb66527cf1e41af84327c9c6ef/example/app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MarcelGarus/list_diff/e09754b46ab43aeb66527cf1e41af84327c9c6ef/example/app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MarcelGarus/list_diff/e09754b46ab43aeb66527cf1e41af84327c9c6ef/example/app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MarcelGarus/list_diff/e09754b46ab43aeb66527cf1e41af84327c9c6ef/example/app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/app/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
--------------------------------------------------------------------------------
/example/app/android/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/app/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext.kotlin_version = '1.3.50'
3 | repositories {
4 | google()
5 | jcenter()
6 | }
7 |
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.5.0'
10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | google()
17 | jcenter()
18 | }
19 | }
20 |
21 | rootProject.buildDir = '../build'
22 | subprojects {
23 | project.buildDir = "${rootProject.buildDir}/${project.name}"
24 | }
25 | subprojects {
26 | project.evaluationDependsOn(':app')
27 | }
28 |
29 | task clean(type: Delete) {
30 | delete rootProject.buildDir
31 | }
32 |
--------------------------------------------------------------------------------
/example/app/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.enableR8=true
3 | android.useAndroidX=true
4 | android.enableJetifier=true
5 |
--------------------------------------------------------------------------------
/example/app/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jun 23 08:50:38 CEST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
7 |
--------------------------------------------------------------------------------
/example/app/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
4 |
5 | def plugins = new Properties()
6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
7 | if (pluginsFile.exists()) {
8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
9 | }
10 |
11 | plugins.each { name, path ->
12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
13 | include ":$name"
14 | project(":$name").projectDir = pluginDirectory
15 | }
16 |
--------------------------------------------------------------------------------
/example/app/ios/.gitignore:
--------------------------------------------------------------------------------
1 | *.mode1v3
2 | *.mode2v3
3 | *.moved-aside
4 | *.pbxuser
5 | *.perspectivev3
6 | **/*sync/
7 | .sconsign.dblite
8 | .tags*
9 | **/.vagrant/
10 | **/DerivedData/
11 | Icon?
12 | **/Pods/
13 | **/.symlinks/
14 | profile
15 | xcuserdata
16 | **/.generated/
17 | Flutter/App.framework
18 | Flutter/Flutter.framework
19 | Flutter/Generated.xcconfig
20 | Flutter/app.flx
21 | Flutter/app.zip
22 | Flutter/flutter_assets/
23 | Flutter/flutter_export_environment.sh
24 | ServiceDefinitions.json
25 | Runner/GeneratedPluginRegistrant.*
26 |
27 | # Exceptions to above rules.
28 | !default.mode1v3
29 | !default.mode2v3
30 | !default.pbxuser
31 | !default.perspectivev3
32 |
--------------------------------------------------------------------------------
/example/app/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | App
9 | CFBundleIdentifier
10 | io.flutter.flutter.app
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | App
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | MinimumOSVersion
24 | 8.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/app/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/example/app/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/example/app/ios/Runner.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
11 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
12 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
13 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
14 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
15 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
16 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
17 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
18 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
19 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
20 | /* End PBXBuildFile section */
21 |
22 | /* Begin PBXCopyFilesBuildPhase section */
23 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = {
24 | isa = PBXCopyFilesBuildPhase;
25 | buildActionMask = 2147483647;
26 | dstPath = "";
27 | dstSubfolderSpec = 10;
28 | files = (
29 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
30 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
31 | );
32 | name = "Embed Frameworks";
33 | runOnlyForDeploymentPostprocessing = 0;
34 | };
35 | /* End PBXCopyFilesBuildPhase section */
36 |
37 | /* Begin PBXFileReference section */
38 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; };
39 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; };
40 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; };
41 | 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; };
42 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; };
43 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
44 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; };
45 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; };
46 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; };
47 | 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; };
48 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
49 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
50 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
51 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
52 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
53 | /* End PBXFileReference section */
54 |
55 | /* Begin PBXFrameworksBuildPhase section */
56 | 97C146EB1CF9000F007C117D /* Frameworks */ = {
57 | isa = PBXFrameworksBuildPhase;
58 | buildActionMask = 2147483647;
59 | files = (
60 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
61 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
62 | );
63 | runOnlyForDeploymentPostprocessing = 0;
64 | };
65 | /* End PBXFrameworksBuildPhase section */
66 |
67 | /* Begin PBXGroup section */
68 | 9740EEB11CF90186004384FC /* Flutter */ = {
69 | isa = PBXGroup;
70 | children = (
71 | 3B80C3931E831B6300D905FE /* App.framework */,
72 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
73 | 9740EEBA1CF902C7004384FC /* Flutter.framework */,
74 | 9740EEB21CF90195004384FC /* Debug.xcconfig */,
75 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
76 | 9740EEB31CF90195004384FC /* Generated.xcconfig */,
77 | );
78 | name = Flutter;
79 | sourceTree = "";
80 | };
81 | 97C146E51CF9000F007C117D = {
82 | isa = PBXGroup;
83 | children = (
84 | 9740EEB11CF90186004384FC /* Flutter */,
85 | 97C146F01CF9000F007C117D /* Runner */,
86 | 97C146EF1CF9000F007C117D /* Products */,
87 | );
88 | sourceTree = "";
89 | };
90 | 97C146EF1CF9000F007C117D /* Products */ = {
91 | isa = PBXGroup;
92 | children = (
93 | 97C146EE1CF9000F007C117D /* Runner.app */,
94 | );
95 | name = Products;
96 | sourceTree = "";
97 | };
98 | 97C146F01CF9000F007C117D /* Runner */ = {
99 | isa = PBXGroup;
100 | children = (
101 | 97C146FA1CF9000F007C117D /* Main.storyboard */,
102 | 97C146FD1CF9000F007C117D /* Assets.xcassets */,
103 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
104 | 97C147021CF9000F007C117D /* Info.plist */,
105 | 97C146F11CF9000F007C117D /* Supporting Files */,
106 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
107 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
108 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
109 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
110 | );
111 | path = Runner;
112 | sourceTree = "";
113 | };
114 | 97C146F11CF9000F007C117D /* Supporting Files */ = {
115 | isa = PBXGroup;
116 | children = (
117 | );
118 | name = "Supporting Files";
119 | sourceTree = "";
120 | };
121 | /* End PBXGroup section */
122 |
123 | /* Begin PBXNativeTarget section */
124 | 97C146ED1CF9000F007C117D /* Runner */ = {
125 | isa = PBXNativeTarget;
126 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
127 | buildPhases = (
128 | 9740EEB61CF901F6004384FC /* Run Script */,
129 | 97C146EA1CF9000F007C117D /* Sources */,
130 | 97C146EB1CF9000F007C117D /* Frameworks */,
131 | 97C146EC1CF9000F007C117D /* Resources */,
132 | 9705A1C41CF9048500538489 /* Embed Frameworks */,
133 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */,
134 | );
135 | buildRules = (
136 | );
137 | dependencies = (
138 | );
139 | name = Runner;
140 | productName = Runner;
141 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
142 | productType = "com.apple.product-type.application";
143 | };
144 | /* End PBXNativeTarget section */
145 |
146 | /* Begin PBXProject section */
147 | 97C146E61CF9000F007C117D /* Project object */ = {
148 | isa = PBXProject;
149 | attributes = {
150 | LastUpgradeCheck = 1020;
151 | ORGANIZATIONNAME = "The Chromium Authors";
152 | TargetAttributes = {
153 | 97C146ED1CF9000F007C117D = {
154 | CreatedOnToolsVersion = 7.3.1;
155 | LastSwiftMigration = 0910;
156 | };
157 | };
158 | };
159 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
160 | compatibilityVersion = "Xcode 3.2";
161 | developmentRegion = en;
162 | hasScannedForEncodings = 0;
163 | knownRegions = (
164 | en,
165 | Base,
166 | );
167 | mainGroup = 97C146E51CF9000F007C117D;
168 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
169 | projectDirPath = "";
170 | projectRoot = "";
171 | targets = (
172 | 97C146ED1CF9000F007C117D /* Runner */,
173 | );
174 | };
175 | /* End PBXProject section */
176 |
177 | /* Begin PBXResourcesBuildPhase section */
178 | 97C146EC1CF9000F007C117D /* Resources */ = {
179 | isa = PBXResourcesBuildPhase;
180 | buildActionMask = 2147483647;
181 | files = (
182 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
183 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
184 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
185 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
186 | );
187 | runOnlyForDeploymentPostprocessing = 0;
188 | };
189 | /* End PBXResourcesBuildPhase section */
190 |
191 | /* Begin PBXShellScriptBuildPhase section */
192 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
193 | isa = PBXShellScriptBuildPhase;
194 | buildActionMask = 2147483647;
195 | files = (
196 | );
197 | inputPaths = (
198 | );
199 | name = "Thin Binary";
200 | outputPaths = (
201 | );
202 | runOnlyForDeploymentPostprocessing = 0;
203 | shellPath = /bin/sh;
204 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
205 | };
206 | 9740EEB61CF901F6004384FC /* Run Script */ = {
207 | isa = PBXShellScriptBuildPhase;
208 | buildActionMask = 2147483647;
209 | files = (
210 | );
211 | inputPaths = (
212 | );
213 | name = "Run Script";
214 | outputPaths = (
215 | );
216 | runOnlyForDeploymentPostprocessing = 0;
217 | shellPath = /bin/sh;
218 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
219 | };
220 | /* End PBXShellScriptBuildPhase section */
221 |
222 | /* Begin PBXSourcesBuildPhase section */
223 | 97C146EA1CF9000F007C117D /* Sources */ = {
224 | isa = PBXSourcesBuildPhase;
225 | buildActionMask = 2147483647;
226 | files = (
227 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
228 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
229 | );
230 | runOnlyForDeploymentPostprocessing = 0;
231 | };
232 | /* End PBXSourcesBuildPhase section */
233 |
234 | /* Begin PBXVariantGroup section */
235 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = {
236 | isa = PBXVariantGroup;
237 | children = (
238 | 97C146FB1CF9000F007C117D /* Base */,
239 | );
240 | name = Main.storyboard;
241 | sourceTree = "";
242 | };
243 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = {
244 | isa = PBXVariantGroup;
245 | children = (
246 | 97C147001CF9000F007C117D /* Base */,
247 | );
248 | name = LaunchScreen.storyboard;
249 | sourceTree = "";
250 | };
251 | /* End PBXVariantGroup section */
252 |
253 | /* Begin XCBuildConfiguration section */
254 | 249021D3217E4FDB00AE95B9 /* Profile */ = {
255 | isa = XCBuildConfiguration;
256 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
257 | buildSettings = {
258 | ALWAYS_SEARCH_USER_PATHS = NO;
259 | CLANG_ANALYZER_NONNULL = YES;
260 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
261 | CLANG_CXX_LIBRARY = "libc++";
262 | CLANG_ENABLE_MODULES = YES;
263 | CLANG_ENABLE_OBJC_ARC = YES;
264 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
265 | CLANG_WARN_BOOL_CONVERSION = YES;
266 | CLANG_WARN_COMMA = YES;
267 | CLANG_WARN_CONSTANT_CONVERSION = YES;
268 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
269 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
270 | CLANG_WARN_EMPTY_BODY = YES;
271 | CLANG_WARN_ENUM_CONVERSION = YES;
272 | CLANG_WARN_INFINITE_RECURSION = YES;
273 | CLANG_WARN_INT_CONVERSION = YES;
274 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
275 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
276 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
277 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
278 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
279 | CLANG_WARN_STRICT_PROTOTYPES = YES;
280 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
281 | CLANG_WARN_UNREACHABLE_CODE = YES;
282 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
283 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
284 | COPY_PHASE_STRIP = NO;
285 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
286 | ENABLE_NS_ASSERTIONS = NO;
287 | ENABLE_STRICT_OBJC_MSGSEND = YES;
288 | GCC_C_LANGUAGE_STANDARD = gnu99;
289 | GCC_NO_COMMON_BLOCKS = YES;
290 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
291 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
292 | GCC_WARN_UNDECLARED_SELECTOR = YES;
293 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
294 | GCC_WARN_UNUSED_FUNCTION = YES;
295 | GCC_WARN_UNUSED_VARIABLE = YES;
296 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
297 | MTL_ENABLE_DEBUG_INFO = NO;
298 | SDKROOT = iphoneos;
299 | SUPPORTED_PLATFORMS = iphoneos;
300 | TARGETED_DEVICE_FAMILY = "1,2";
301 | VALIDATE_PRODUCT = YES;
302 | };
303 | name = Profile;
304 | };
305 | 249021D4217E4FDB00AE95B9 /* Profile */ = {
306 | isa = XCBuildConfiguration;
307 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
308 | buildSettings = {
309 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
310 | CLANG_ENABLE_MODULES = YES;
311 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
312 | ENABLE_BITCODE = NO;
313 | FRAMEWORK_SEARCH_PATHS = (
314 | "$(inherited)",
315 | "$(PROJECT_DIR)/Flutter",
316 | );
317 | INFOPLIST_FILE = Runner/Info.plist;
318 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
319 | LIBRARY_SEARCH_PATHS = (
320 | "$(inherited)",
321 | "$(PROJECT_DIR)/Flutter",
322 | );
323 | PRODUCT_BUNDLE_IDENTIFIER = com.example.app;
324 | PRODUCT_NAME = "$(TARGET_NAME)";
325 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
326 | SWIFT_VERSION = 4.0;
327 | VERSIONING_SYSTEM = "apple-generic";
328 | };
329 | name = Profile;
330 | };
331 | 97C147031CF9000F007C117D /* Debug */ = {
332 | isa = XCBuildConfiguration;
333 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
334 | buildSettings = {
335 | ALWAYS_SEARCH_USER_PATHS = NO;
336 | CLANG_ANALYZER_NONNULL = YES;
337 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
338 | CLANG_CXX_LIBRARY = "libc++";
339 | CLANG_ENABLE_MODULES = YES;
340 | CLANG_ENABLE_OBJC_ARC = YES;
341 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
342 | CLANG_WARN_BOOL_CONVERSION = YES;
343 | CLANG_WARN_COMMA = YES;
344 | CLANG_WARN_CONSTANT_CONVERSION = YES;
345 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
346 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
347 | CLANG_WARN_EMPTY_BODY = YES;
348 | CLANG_WARN_ENUM_CONVERSION = YES;
349 | CLANG_WARN_INFINITE_RECURSION = YES;
350 | CLANG_WARN_INT_CONVERSION = YES;
351 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
352 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
353 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
354 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
355 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
356 | CLANG_WARN_STRICT_PROTOTYPES = YES;
357 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
358 | CLANG_WARN_UNREACHABLE_CODE = YES;
359 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
360 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
361 | COPY_PHASE_STRIP = NO;
362 | DEBUG_INFORMATION_FORMAT = dwarf;
363 | ENABLE_STRICT_OBJC_MSGSEND = YES;
364 | ENABLE_TESTABILITY = YES;
365 | GCC_C_LANGUAGE_STANDARD = gnu99;
366 | GCC_DYNAMIC_NO_PIC = NO;
367 | GCC_NO_COMMON_BLOCKS = YES;
368 | GCC_OPTIMIZATION_LEVEL = 0;
369 | GCC_PREPROCESSOR_DEFINITIONS = (
370 | "DEBUG=1",
371 | "$(inherited)",
372 | );
373 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
374 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
375 | GCC_WARN_UNDECLARED_SELECTOR = YES;
376 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
377 | GCC_WARN_UNUSED_FUNCTION = YES;
378 | GCC_WARN_UNUSED_VARIABLE = YES;
379 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
380 | MTL_ENABLE_DEBUG_INFO = YES;
381 | ONLY_ACTIVE_ARCH = YES;
382 | SDKROOT = iphoneos;
383 | TARGETED_DEVICE_FAMILY = "1,2";
384 | };
385 | name = Debug;
386 | };
387 | 97C147041CF9000F007C117D /* Release */ = {
388 | isa = XCBuildConfiguration;
389 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
390 | buildSettings = {
391 | ALWAYS_SEARCH_USER_PATHS = NO;
392 | CLANG_ANALYZER_NONNULL = YES;
393 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
394 | CLANG_CXX_LIBRARY = "libc++";
395 | CLANG_ENABLE_MODULES = YES;
396 | CLANG_ENABLE_OBJC_ARC = YES;
397 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
398 | CLANG_WARN_BOOL_CONVERSION = YES;
399 | CLANG_WARN_COMMA = YES;
400 | CLANG_WARN_CONSTANT_CONVERSION = YES;
401 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
402 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
403 | CLANG_WARN_EMPTY_BODY = YES;
404 | CLANG_WARN_ENUM_CONVERSION = YES;
405 | CLANG_WARN_INFINITE_RECURSION = YES;
406 | CLANG_WARN_INT_CONVERSION = YES;
407 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
408 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
409 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
410 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
411 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
412 | CLANG_WARN_STRICT_PROTOTYPES = YES;
413 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
414 | CLANG_WARN_UNREACHABLE_CODE = YES;
415 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
416 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
417 | COPY_PHASE_STRIP = NO;
418 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
419 | ENABLE_NS_ASSERTIONS = NO;
420 | ENABLE_STRICT_OBJC_MSGSEND = YES;
421 | GCC_C_LANGUAGE_STANDARD = gnu99;
422 | GCC_NO_COMMON_BLOCKS = YES;
423 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
424 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
425 | GCC_WARN_UNDECLARED_SELECTOR = YES;
426 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
427 | GCC_WARN_UNUSED_FUNCTION = YES;
428 | GCC_WARN_UNUSED_VARIABLE = YES;
429 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
430 | MTL_ENABLE_DEBUG_INFO = NO;
431 | SDKROOT = iphoneos;
432 | SUPPORTED_PLATFORMS = iphoneos;
433 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
434 | TARGETED_DEVICE_FAMILY = "1,2";
435 | VALIDATE_PRODUCT = YES;
436 | };
437 | name = Release;
438 | };
439 | 97C147061CF9000F007C117D /* Debug */ = {
440 | isa = XCBuildConfiguration;
441 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
442 | buildSettings = {
443 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
444 | CLANG_ENABLE_MODULES = YES;
445 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
446 | ENABLE_BITCODE = NO;
447 | FRAMEWORK_SEARCH_PATHS = (
448 | "$(inherited)",
449 | "$(PROJECT_DIR)/Flutter",
450 | );
451 | INFOPLIST_FILE = Runner/Info.plist;
452 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
453 | LIBRARY_SEARCH_PATHS = (
454 | "$(inherited)",
455 | "$(PROJECT_DIR)/Flutter",
456 | );
457 | PRODUCT_BUNDLE_IDENTIFIER = com.example.app;
458 | PRODUCT_NAME = "$(TARGET_NAME)";
459 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
460 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
461 | SWIFT_VERSION = 4.0;
462 | VERSIONING_SYSTEM = "apple-generic";
463 | };
464 | name = Debug;
465 | };
466 | 97C147071CF9000F007C117D /* Release */ = {
467 | isa = XCBuildConfiguration;
468 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
469 | buildSettings = {
470 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
471 | CLANG_ENABLE_MODULES = YES;
472 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
473 | ENABLE_BITCODE = NO;
474 | FRAMEWORK_SEARCH_PATHS = (
475 | "$(inherited)",
476 | "$(PROJECT_DIR)/Flutter",
477 | );
478 | INFOPLIST_FILE = Runner/Info.plist;
479 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
480 | LIBRARY_SEARCH_PATHS = (
481 | "$(inherited)",
482 | "$(PROJECT_DIR)/Flutter",
483 | );
484 | PRODUCT_BUNDLE_IDENTIFIER = com.example.app;
485 | PRODUCT_NAME = "$(TARGET_NAME)";
486 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
487 | SWIFT_VERSION = 4.0;
488 | VERSIONING_SYSTEM = "apple-generic";
489 | };
490 | name = Release;
491 | };
492 | /* End XCBuildConfiguration section */
493 |
494 | /* Begin XCConfigurationList section */
495 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = {
496 | isa = XCConfigurationList;
497 | buildConfigurations = (
498 | 97C147031CF9000F007C117D /* Debug */,
499 | 97C147041CF9000F007C117D /* Release */,
500 | 249021D3217E4FDB00AE95B9 /* Profile */,
501 | );
502 | defaultConfigurationIsVisible = 0;
503 | defaultConfigurationName = Release;
504 | };
505 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = {
506 | isa = XCConfigurationList;
507 | buildConfigurations = (
508 | 97C147061CF9000F007C117D /* Debug */,
509 | 97C147071CF9000F007C117D /* Release */,
510 | 249021D4217E4FDB00AE95B9 /* Profile */,
511 | );
512 | defaultConfigurationIsVisible = 0;
513 | defaultConfigurationName = Release;
514 | };
515 | /* End XCConfigurationList section */
516 |
517 | };
518 | rootObject = 97C146E61CF9000F007C117D /* Project object */;
519 | }
520 |
--------------------------------------------------------------------------------
/example/app/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/app/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/example/app/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/app/ios/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 | import Flutter
3 |
4 | @UIApplicationMain
5 | @objc class AppDelegate: FlutterAppDelegate {
6 | override func application(
7 | _ application: UIApplication,
8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
9 | ) -> Bool {
10 | GeneratedPluginRegistrant.register(with: self)
11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "20x20",
5 | "idiom" : "iphone",
6 | "filename" : "Icon-App-20x20@2x.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "20x20",
11 | "idiom" : "iphone",
12 | "filename" : "Icon-App-20x20@3x.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "Icon-App-29x29@1x.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "29x29",
23 | "idiom" : "iphone",
24 | "filename" : "Icon-App-29x29@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "29x29",
29 | "idiom" : "iphone",
30 | "filename" : "Icon-App-29x29@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "40x40",
35 | "idiom" : "iphone",
36 | "filename" : "Icon-App-40x40@2x.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "40x40",
41 | "idiom" : "iphone",
42 | "filename" : "Icon-App-40x40@3x.png",
43 | "scale" : "3x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "Icon-App-60x60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "Icon-App-60x60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "20x20",
59 | "idiom" : "ipad",
60 | "filename" : "Icon-App-20x20@1x.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "20x20",
65 | "idiom" : "ipad",
66 | "filename" : "Icon-App-20x20@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "29x29",
71 | "idiom" : "ipad",
72 | "filename" : "Icon-App-29x29@1x.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "29x29",
77 | "idiom" : "ipad",
78 | "filename" : "Icon-App-29x29@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "40x40",
83 | "idiom" : "ipad",
84 | "filename" : "Icon-App-40x40@1x.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "40x40",
89 | "idiom" : "ipad",
90 | "filename" : "Icon-App-40x40@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "76x76",
95 | "idiom" : "ipad",
96 | "filename" : "Icon-App-76x76@1x.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "76x76",
101 | "idiom" : "ipad",
102 | "filename" : "Icon-App-76x76@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "83.5x83.5",
107 | "idiom" : "ipad",
108 | "filename" : "Icon-App-83.5x83.5@2x.png",
109 | "scale" : "2x"
110 | },
111 | {
112 | "size" : "1024x1024",
113 | "idiom" : "ios-marketing",
114 | "filename" : "Icon-App-1024x1024@1x.png",
115 | "scale" : "1x"
116 | }
117 | ],
118 | "info" : {
119 | "version" : 1,
120 | "author" : "xcode"
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MarcelGarus/list_diff/e09754b46ab43aeb66527cf1e41af84327c9c6ef/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
--------------------------------------------------------------------------------
/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MarcelGarus/list_diff/e09754b46ab43aeb66527cf1e41af84327c9c6ef/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MarcelGarus/list_diff/e09754b46ab43aeb66527cf1e41af84327c9c6ef/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MarcelGarus/list_diff/e09754b46ab43aeb66527cf1e41af84327c9c6ef/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MarcelGarus/list_diff/e09754b46ab43aeb66527cf1e41af84327c9c6ef/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MarcelGarus/list_diff/e09754b46ab43aeb66527cf1e41af84327c9c6ef/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MarcelGarus/list_diff/e09754b46ab43aeb66527cf1e41af84327c9c6ef/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MarcelGarus/list_diff/e09754b46ab43aeb66527cf1e41af84327c9c6ef/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MarcelGarus/list_diff/e09754b46ab43aeb66527cf1e41af84327c9c6ef/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MarcelGarus/list_diff/e09754b46ab43aeb66527cf1e41af84327c9c6ef/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MarcelGarus/list_diff/e09754b46ab43aeb66527cf1e41af84327c9c6ef/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MarcelGarus/list_diff/e09754b46ab43aeb66527cf1e41af84327c9c6ef/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MarcelGarus/list_diff/e09754b46ab43aeb66527cf1e41af84327c9c6ef/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MarcelGarus/list_diff/e09754b46ab43aeb66527cf1e41af84327c9c6ef/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MarcelGarus/list_diff/e09754b46ab43aeb66527cf1e41af84327c9c6ef/example/app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/example/app/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchImage.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchImage@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "LaunchImage@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/example/app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MarcelGarus/list_diff/e09754b46ab43aeb66527cf1e41af84327c9c6ef/example/app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/example/app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MarcelGarus/list_diff/e09754b46ab43aeb66527cf1e41af84327c9c6ef/example/app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/example/app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MarcelGarus/list_diff/e09754b46ab43aeb66527cf1e41af84327c9c6ef/example/app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/example/app/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md:
--------------------------------------------------------------------------------
1 | # Launch Screen Assets
2 |
3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory.
4 |
5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
--------------------------------------------------------------------------------
/example/app/ios/Runner/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/example/app/ios/Runner/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/app/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | app
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | $(FLUTTER_BUILD_NAME)
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(FLUTTER_BUILD_NUMBER)
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UISupportedInterfaceOrientations
30 |
31 | UIInterfaceOrientationPortrait
32 | UIInterfaceOrientationLandscapeLeft
33 | UIInterfaceOrientationLandscapeRight
34 |
35 | UISupportedInterfaceOrientations~ipad
36 |
37 | UIInterfaceOrientationPortrait
38 | UIInterfaceOrientationPortraitUpsideDown
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 | UIViewControllerBasedStatusBarAppearance
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/example/app/ios/Runner/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | #import "GeneratedPluginRegistrant.h"
--------------------------------------------------------------------------------
/example/app/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'dart:math';
2 |
3 | import 'package:flutter/material.dart';
4 | import 'package:list_diff/list_diff.dart';
5 |
6 | void main() => runApp(MyApp());
7 |
8 | class MyApp extends StatelessWidget {
9 | @override
10 | Widget build(BuildContext context) {
11 | return MaterialApp(
12 | title: 'Flutter Demo',
13 | theme: ThemeData(primarySwatch: Colors.red),
14 | home: MyHomePage(title: 'Flutter Demo Home Page'),
15 | );
16 | }
17 | }
18 |
19 | class MyHomePage extends StatefulWidget {
20 | MyHomePage({Key key, this.title}) : super(key: key);
21 |
22 | final String title;
23 |
24 | @override
25 | _MyHomePageState createState() => _MyHomePageState();
26 | }
27 |
28 | class _MyHomePageState extends State {
29 | int get numSamples => spawnTimes.length;
30 |
31 | String message;
32 |
33 | final spawnTimes = [];
34 | double get spawnTimesAverage => spawnTimes.isEmpty
35 | ? null
36 | : spawnTimes.reduce((a, b) => a + b) / spawnTimes.length;
37 |
38 | final timesPerCell = [];
39 | double get timesPerCellAverage => timesPerCell.isEmpty
40 | ? null
41 | : timesPerCell.reduce((a, b) => a + b) / timesPerCell.length;
42 |
43 | void _profileTick() async {
44 | var r = Random();
45 | var stopwatch = Stopwatch();
46 | var a = List.generate(r.nextInt(900) + 100, (_) => r.nextInt(100));
47 | var b = List.generate(r.nextInt(900) + 100, (_) => r.nextInt(100));
48 |
49 | stopwatch.start();
50 | await diff(a, b, spawnIsolate: false);
51 | var withoutIsolate = stopwatch.elapsedMicroseconds;
52 | stopwatch
53 | ..reset()
54 | ..start();
55 | await diff(a, b, spawnIsolate: true);
56 | var withIsolate = stopwatch.elapsedMicroseconds;
57 | var spawnTime = (withIsolate - withoutIsolate).clamp(0, 10000000000);
58 | var timePerCell = withoutIsolate / (a.length + 1) / (b.length + 1);
59 | setState(() {
60 | message =
61 | 'Diffed ${a.length}x${b.length} lists. Without isolate: $withoutIsolate ys';
62 | spawnTimes.add(spawnTime.toDouble());
63 | timesPerCell.add(timePerCell);
64 | });
65 | }
66 |
67 | @override
68 | void initState() {
69 | super.initState();
70 | _profile();
71 | }
72 |
73 | void _profile() async {
74 | while (true) {
75 | await Future.delayed(Duration(milliseconds: 500));
76 | _profileTick();
77 | }
78 | }
79 |
80 | @override
81 | Widget build(BuildContext context) {
82 | return Scaffold(
83 | appBar: AppBar(title: Text(widget.title)),
84 | body: Center(
85 | child: Column(
86 | mainAxisAlignment: MainAxisAlignment.center,
87 | children: [
88 | Text('Samples: $numSamples'),
89 | Text('Spawn time: $spawnTimesAverage'),
90 | Text('Times per cell: $timesPerCellAverage'),
91 | ],
92 | ),
93 | ),
94 | );
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/example/app/pubspec.lock:
--------------------------------------------------------------------------------
1 | # Generated by pub
2 | # See https://dart.dev/tools/pub/glossary#lockfile
3 | packages:
4 | async:
5 | dependency: transitive
6 | description:
7 | name: async
8 | url: "https://pub.dartlang.org"
9 | source: hosted
10 | version: "2.8.2"
11 | boolean_selector:
12 | dependency: transitive
13 | description:
14 | name: boolean_selector
15 | url: "https://pub.dartlang.org"
16 | source: hosted
17 | version: "2.1.0"
18 | characters:
19 | dependency: transitive
20 | description:
21 | name: characters
22 | url: "https://pub.dartlang.org"
23 | source: hosted
24 | version: "1.2.0"
25 | charcode:
26 | dependency: transitive
27 | description:
28 | name: charcode
29 | url: "https://pub.dartlang.org"
30 | source: hosted
31 | version: "1.3.1"
32 | clock:
33 | dependency: transitive
34 | description:
35 | name: clock
36 | url: "https://pub.dartlang.org"
37 | source: hosted
38 | version: "1.1.0"
39 | collection:
40 | dependency: transitive
41 | description:
42 | name: collection
43 | url: "https://pub.dartlang.org"
44 | source: hosted
45 | version: "1.15.0"
46 | cupertino_icons:
47 | dependency: "direct main"
48 | description:
49 | name: cupertino_icons
50 | url: "https://pub.dartlang.org"
51 | source: hosted
52 | version: "0.1.2"
53 | fake_async:
54 | dependency: transitive
55 | description:
56 | name: fake_async
57 | url: "https://pub.dartlang.org"
58 | source: hosted
59 | version: "1.2.0"
60 | flutter:
61 | dependency: "direct main"
62 | description: flutter
63 | source: sdk
64 | version: "0.0.0"
65 | flutter_test:
66 | dependency: "direct dev"
67 | description: flutter
68 | source: sdk
69 | version: "0.0.0"
70 | list_diff:
71 | dependency: "direct main"
72 | description:
73 | path: "../.."
74 | relative: true
75 | source: path
76 | version: "2.0.0"
77 | matcher:
78 | dependency: transitive
79 | description:
80 | name: matcher
81 | url: "https://pub.dartlang.org"
82 | source: hosted
83 | version: "0.12.11"
84 | meta:
85 | dependency: transitive
86 | description:
87 | name: meta
88 | url: "https://pub.dartlang.org"
89 | source: hosted
90 | version: "1.7.0"
91 | path:
92 | dependency: transitive
93 | description:
94 | name: path
95 | url: "https://pub.dartlang.org"
96 | source: hosted
97 | version: "1.8.0"
98 | sky_engine:
99 | dependency: transitive
100 | description: flutter
101 | source: sdk
102 | version: "0.0.99"
103 | source_span:
104 | dependency: transitive
105 | description:
106 | name: source_span
107 | url: "https://pub.dartlang.org"
108 | source: hosted
109 | version: "1.8.1"
110 | stack_trace:
111 | dependency: transitive
112 | description:
113 | name: stack_trace
114 | url: "https://pub.dartlang.org"
115 | source: hosted
116 | version: "1.10.0"
117 | stream_channel:
118 | dependency: transitive
119 | description:
120 | name: stream_channel
121 | url: "https://pub.dartlang.org"
122 | source: hosted
123 | version: "2.1.0"
124 | string_scanner:
125 | dependency: transitive
126 | description:
127 | name: string_scanner
128 | url: "https://pub.dartlang.org"
129 | source: hosted
130 | version: "1.1.0"
131 | term_glyph:
132 | dependency: transitive
133 | description:
134 | name: term_glyph
135 | url: "https://pub.dartlang.org"
136 | source: hosted
137 | version: "1.2.0"
138 | test_api:
139 | dependency: transitive
140 | description:
141 | name: test_api
142 | url: "https://pub.dartlang.org"
143 | source: hosted
144 | version: "0.4.3"
145 | typed_data:
146 | dependency: transitive
147 | description:
148 | name: typed_data
149 | url: "https://pub.dartlang.org"
150 | source: hosted
151 | version: "1.3.0"
152 | vector_math:
153 | dependency: transitive
154 | description:
155 | name: vector_math
156 | url: "https://pub.dartlang.org"
157 | source: hosted
158 | version: "2.1.1"
159 | sdks:
160 | dart: ">=2.14.0 <3.0.0"
161 |
--------------------------------------------------------------------------------
/example/app/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: app
2 | description: A new Flutter project.
3 |
4 | # The following defines the version and build number for your application.
5 | # A version number is three numbers separated by dots, like 1.2.43
6 | # followed by an optional build number separated by a +.
7 | # Both the version and the builder number may be overridden in flutter
8 | # build by specifying --build-name and --build-number, respectively.
9 | # In Android, build-name is used as versionName while build-number used as versionCode.
10 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning
11 | # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
12 | # Read more about iOS versioning at
13 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
14 | version: 1.0.0+1
15 |
16 | environment:
17 | sdk: ">=2.1.0 <3.0.0"
18 |
19 | dependencies:
20 | flutter:
21 | sdk: flutter
22 |
23 | list_diff:
24 | path: ../..
25 |
26 | # The following adds the Cupertino Icons font to your application.
27 | # Use with the CupertinoIcons class for iOS style icons.
28 | cupertino_icons: ^0.1.2
29 |
30 | dev_dependencies:
31 | flutter_test:
32 | sdk: flutter
33 |
34 | # For information on the generic Dart part of this file, see the
35 | # following page: https://dart.dev/tools/pub/pubspec
36 |
37 | # The following section is specific to Flutter.
38 | flutter:
39 | # The following line ensures that the Material Icons font is
40 | # included with your application, so that you can use the icons in
41 | # the material Icons class.
42 | uses-material-design: true
43 | # To add assets to your application, add an assets section, like this:
44 | # assets:
45 | # - images/a_dot_burr.jpeg
46 | # - images/a_dot_ham.jpeg
47 | # An image asset can refer to one or more resolution-specific "variants", see
48 | # https://flutter.dev/assets-and-images/#resolution-aware.
49 | # For details regarding adding assets from package dependencies, see
50 | # https://flutter.dev/assets-and-images/#from-packages
51 | # To add custom fonts to your application, add a fonts section here,
52 | # in this "flutter" section. Each entry in this list should have a
53 | # "family" key with the font family name, and a "fonts" key with a
54 | # list giving the asset and other descriptors for the font. For
55 | # example:
56 | # fonts:
57 | # - family: Schyler
58 | # fonts:
59 | # - asset: fonts/Schyler-Regular.ttf
60 | # - asset: fonts/Schyler-Italic.ttf
61 | # style: italic
62 | # - family: Trajan Pro
63 | # fonts:
64 | # - asset: fonts/TrajanPro.ttf
65 | # - asset: fonts/TrajanPro_Bold.ttf
66 | # weight: 700
67 | #
68 | # For details regarding fonts from package dependencies,
69 | # see https://flutter.dev/custom-fonts/#from-packages
70 |
--------------------------------------------------------------------------------
/example/app/test/widget_test.dart:
--------------------------------------------------------------------------------
1 | // This is a basic Flutter widget test.
2 | //
3 | // To perform an interaction with a widget in your test, use the WidgetTester
4 | // utility that Flutter provides. For example, you can send tap and scroll
5 | // gestures. You can also use WidgetTester to find child widgets in the widget
6 | // tree, read text, and verify that the values of widget properties are correct.
7 |
8 | import 'package:flutter/material.dart';
9 | import 'package:flutter_test/flutter_test.dart';
10 |
11 | import 'package:app/main.dart';
12 |
13 | void main() {
14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async {
15 | // Build our app and trigger a frame.
16 | await tester.pumpWidget(MyApp());
17 |
18 | // Verify that our counter starts at 0.
19 | expect(find.text('0'), findsOneWidget);
20 | expect(find.text('1'), findsNothing);
21 |
22 | // Tap the '+' icon and trigger a frame.
23 | await tester.tap(find.byIcon(Icons.add));
24 | await tester.pump();
25 |
26 | // Verify that our counter has incremented.
27 | expect(find.text('0'), findsNothing);
28 | expect(find.text('1'), findsOneWidget);
29 | });
30 | }
31 |
--------------------------------------------------------------------------------
/example/isolated.dart:
--------------------------------------------------------------------------------
1 | import 'dart:math';
2 |
3 | import 'package:list_diff/list_diff.dart';
4 |
5 | Future main() async {
6 | var random = Random();
7 | var first = List.generate(1000, (_) => random.nextInt(100));
8 | var second = List.generate(1000, (_) => random.nextInt(100));
9 |
10 | print('Calculating operations on other isolate.');
11 | var operations = await diff(first, second, spawnIsolate: true);
12 | print('${operations.length} operations needed.');
13 | }
14 |
--------------------------------------------------------------------------------
/example/main.dart:
--------------------------------------------------------------------------------
1 | import 'package:list_diff/list_diff.dart';
2 |
3 | void main() async {
4 | var nutMix = ['coconut', 'nut', 'peanut'];
5 | var tropic = ['kiwi', 'coconut', 'maracuja', 'nut', 'banana'];
6 |
7 | // Now, let's turn the nut mix into the tropical mix.
8 | var recipe = await diff(nutMix, tropic);
9 |
10 | // Let's try it out!
11 | var bowl = List.from(nutMix);
12 | print(bowl);
13 |
14 | for (var operation in recipe) {
15 | operation.applyTo(bowl);
16 | print('$operation\n$bowl');
17 | }
18 |
19 | // Output:
20 | // [coconut, nut, peanut]
21 | // Insertion of kiwi at 0.
22 | // [kiwi, coconut, nut, peanut]
23 | // Insertion of maracuja at 2.
24 | // [kiwi, coconut, maracuja, nut, peanut]
25 | // Insertion of banana at 4.
26 | // [kiwi, coconut, maracuja, nut, banana, peanut]
27 | // Deletion of peanut at 5.
28 | // [kiwi, coconut, maracuja, nut, banana]
29 | }
30 |
--------------------------------------------------------------------------------
/lib/calculate.dart:
--------------------------------------------------------------------------------
1 | import 'operation.dart';
2 | import 'isolated.dart';
3 |
4 | /// A sequence of operations applied onto the old list. In contrast to raw
5 | /// [Operation]s, a [Sequence] is not index-aware and also supports a [type] of
6 | /// [null], indicating that nothing changed.
7 | ///
8 | /// The index is derived from how many [_Sequence]s were applied before. This
9 | /// model works quite well: An insertion sequence and an advance the cursor by
10 | /// 1, a deletion sequence doesn't change the cursor.
11 | /// For example, the sequence
12 | /// `_Sequence.delete(_Sequence.unchanged(_Sequence.insert(null, a)), c)`
13 | /// means that given the original list, insert `a` at the beginning (cursor 0).
14 | /// Then the cursor advances to index 1. Leave that unchanged. The cursor
15 | /// advances. Remove the item at index 2.
16 | class _Sequence- {
17 | final _Sequence
- ? parent;
18 | final OperationType? type;
19 | final Item? item;
20 | final int length;
21 |
22 | const _Sequence.insert(this.parent, this.item)
23 | : type = OperationType.insertion,
24 | length = (parent?.length ?? 0) + 1;
25 | const _Sequence.delete(this.parent, this.item)
26 | : type = OperationType.deletion,
27 | length = (parent?.length ?? 0) + 1;
28 | const _Sequence.unchanged(this.parent)
29 | : type = null,
30 | item = null,
31 | length = parent?.length ?? 0;
32 |
33 | bool isShorterThan(_Sequence other) => length < other.length;
34 |
35 | /// Turns this [_Sequence] and its [parent]s into a list of [Operation]s.
36 | /// Includes [null], for [_Sequence.unchanged].
37 | List?> _toOperationsOrNull() {
38 | var ops = parent?._toOperationsOrNull() ?? [];
39 | return [
40 | ...ops,
41 | if (type != null)
42 | Operation(
43 | type: type!,
44 | index: ops.where((op) => op == null || op.isInsertion).length - 1,
45 | item: item!,
46 | )
47 | else
48 | null,
49 | ];
50 | }
51 |
52 | /// Turns this [_Sequene] and its [parent]s into a list of [Operation]s.
53 | List> toOperations() => _toOperationsOrNull()
54 | .where((op) => op != null)
55 | .cast>()
56 | .toList();
57 | }
58 |
59 | /// Calculates the difference between two lists.
60 | ///
61 | /// This algorithm works by filling out a table with the two lists at the axes,
62 | /// where a cell at position (x,y) represents the number of operations needed to
63 | /// get from the first x items of the first list to the first y items of the
64 | /// second one.
65 | ///
66 | /// For example, let's say, the old list is `[a, b]` and the new one is
67 | /// `[a, c]`. The following table is created:
68 | ///
69 | /// | a b
70 | /// --+------
71 | /// | 0 1 2
72 | /// a | 1 0 1
73 | /// c | 2 1 2
74 | ///
75 | /// As you see, the first row and column are just a sequence of numbers. That's
76 | /// because for each new character, it takes one more deletion to get to the
77 | /// empty list and one more insertion to get from the empty list to the new one.
78 | ///
79 | /// All the other cells are filled out using these rules:
80 | ///
81 | /// * If the item at index x in the old list and the item at index y in the new
82 | /// list are equal, no operation is needed.
83 | /// That means, the value of the cell left above the current one can just be
84 | /// copied. (If it takes N operations to get from `oldList` to `newList`, it
85 | /// takes the same N operations to get from `[...oldList, item]` to
86 | /// `[...newList, item]`).
87 | /// * Otherwise, we can either _insert_ an item coming from the cell above or
88 | /// _delete_ an item coming from the cell on the left. That translates in
89 | /// aking either the cell above or on the left and adding one operation.
90 | /// The smaller one of those both should be chosen for the shortest possible
91 | /// sequence of operations.
92 | ///
93 | /// Implementation details:
94 | /// * For storage efficiency, only the active row of the table is actually
95 | /// saved. Then, the new row is calculated and the original row is replaced
96 | /// with the new one.
97 | /// * Instead of storing just the number of moves, we store the [_Sequence] of
98 | /// operations so that we can later retrace the path we took.
99 | Future
>> calculateDiff- (
100 | List
- oldList,
101 | List
- newList,
102 | bool Function(Item a, Item b) areEqual,
103 | ) async {
104 | var row = _getInitialRow(oldList);
105 |
106 | for (var y = 0; y < newList.length; y++) {
107 | final nextRow = <_Sequence
- >[];
108 |
109 | for (var x = 0; x <= oldList.length; x++) {
110 | if (x == 0) {
111 | nextRow.add(_Sequence.insert(row[0], newList[y]));
112 | } else if (await _doItemsMatch(newList[y], oldList[x - 1], areEqual)) {
113 | nextRow.add(_Sequence.unchanged(row[x - 1]));
114 | } else if (row[x].isShorterThan(nextRow[x - 1])) {
115 | nextRow.add(_Sequence.insert(row[x], newList[y]));
116 | } else {
117 | nextRow.add(_Sequence.delete(nextRow[x - 1], oldList[x - 1]));
118 | }
119 | }
120 |
121 | row = nextRow;
122 | }
123 |
124 | return row.last.toOperations();
125 | }
126 |
127 | Future _doItemsMatch
- (
128 | Item first,
129 | Item second,
130 | bool Function(Item a, Item b) areEqual,
131 | ) async {
132 | if (Item == ReferenceToItemOnOtherIsolate) {
133 | final firstRef = first as ReferenceToItemOnOtherIsolate;
134 | final secondRef = second as ReferenceToItemOnOtherIsolate;
135 | return await firstRef.equals(secondRef);
136 | } else {
137 | return areEqual(first, second);
138 | }
139 | }
140 |
141 | /// A synchronous variant of [_calculateDiff].
142 | List> calculateDiffSync
- (
143 | List
- oldList,
144 | List
- newList,
145 | bool Function(Item a, Item b) areEqual,
146 | ) {
147 | assert(Item is! ReferenceToItemOnOtherIsolate);
148 |
149 | var row = _getInitialRow(oldList);
150 |
151 | for (var y = 0; y < newList.length; y++) {
152 | final nextRow = <_Sequence
- >[];
153 |
154 | for (var x = 0; x <= oldList.length; x++) {
155 | if (x == 0) {
156 | nextRow.add(_Sequence.insert(row[0], newList[y]));
157 | } else if (areEqual(newList[y], oldList[x - 1])) {
158 | nextRow.add(_Sequence.unchanged(row[x - 1]));
159 | } else if (row[x].isShorterThan(nextRow[x - 1])) {
160 | nextRow.add(_Sequence.insert(row[x], newList[y]));
161 | } else {
162 | nextRow.add(_Sequence.delete(nextRow[x - 1], oldList[x - 1]));
163 | }
164 | }
165 |
166 | row = nextRow;
167 | }
168 |
169 | return row.last.toOperations();
170 | }
171 |
172 | List<_Sequence
- > _getInitialRow
- (List
- oldList) {
173 | final row = <_Sequence
- >[];
174 |
175 | for (var x = 0; x <= oldList.length; x++) {
176 | if (x == 0) {
177 | row.add(_Sequence.unchanged(null));
178 | } else {
179 | row.add(_Sequence.delete(row.last, oldList[x - 1]));
180 | }
181 | }
182 | ;
183 | return row;
184 | }
185 |
--------------------------------------------------------------------------------
/lib/isolated.dart:
--------------------------------------------------------------------------------
1 | import 'dart:isolate';
2 |
3 | import 'package:async/async.dart';
4 |
5 | import 'list_diff.dart';
6 | import 'operation.dart';
7 |
8 | bool shouldSpawnIsolate
- (List
- oldList, List
- newList) {
9 | // If no [spawnIsolate] is given, we try to automatically choose a value that
10 | // aligns with our performance goals.
11 | // The algorithm fills an N times M table of cells, where N and M are the
12 | // lengths of both lists. Because most Dart code is eventually used in
13 | // Flutter as AOT-compiled code, I did some performance testing on a
14 | // OnePlus 6T. Turns out, spawning an isolate and transmitting the necessary
15 | // data takes about 13 ms and filling one cell about 4 µs.
16 | // Let's say an app wants to achieve 90 fps (that may seem like a stretch,
17 | // but keep in mind that there are lots of less-performant devices, so the
18 | // benchmark speeds are taken with an upper-bound-ish kind of view).
19 | // That leaves us with about 11 ms per frame. Because there's probably a lot
20 | // of other stuff happening apart from calculating the differences (like,
21 | // actually animating stuff and building widgets), let's say we want the diff
22 | // to at most take up half of the time, so at most 6 ms.
23 | // Whether we should spawn an isolate only depends on if we can fit the
24 | // calculation of the N*M cells into the timeframe of 6 ms. With a cell
25 | // calculation time of 4 µs, we can calculate the value of
26 | // 6 ms / 4 µs = 1.500 cells to still be able to hit our deadline.
27 | return oldList.length * newList.length > 1500;
28 | }
29 |
30 | // Isolates do not share memory and only communicate using ports which can only
31 | // send some primitive types. That means, the items can't be copied to the
32 | // other isolate.
33 | // Rather, we create the hashCode of each item and send those to the other
34 | // isolate. When two items' hashCodes match, the second isolate asks the first
35 | // isolate if the items at the indexes are equal to avoid false positives.
36 | // Here's how the communication between the isolates looks:
37 | // * The main isolate spawns the worker isolate with a SendPort.
38 | // * The worker isolate sends another SendPort back to the main isolate.
39 | // Now, the two isolates can communicate.
40 | // * For both the old and the new list, the main isolate sends:
41 | // * The size of the list.
42 | // * The hashCodes of the items.
43 | // * The worker isolate starts calculating the diff and when encountering a
44 | // possible item match, asks the main isolate if the items really match by
45 | // * sending false to indicate it's not done calculating the diff,
46 | // * sending the index of the item in the first list,
47 | // * sending the index of the item in the second list.
48 | // * Then, the main isolate responds with a bool, indicating whether the
49 | // items really match.
50 | // * Once the worker isolate is done, it sends true to indicate so. Then, for
51 | // each operation, it sends
52 | // * whether it's an insertion (true for insertion, false for deletion)
53 | // * the index operation
54 | // * the index of the item in the old list if this is a deletion or the index
55 | // in the new list if this is an insertion.
56 | // * The main isolate can then reconstruct the operations by looking up the
57 | // original items.
58 | Future
>> calculateDiffInSeparateIsolate- (
59 | List
- oldList,
60 | List
- newList,
61 | bool Function(Item a, Item b) areEqual,
62 | int Function(Item item) getHashCode,
63 | ) async {
64 | final receivePort = ReceivePort();
65 | await Isolate.spawn(_calculationInIsolate, receivePort.sendPort);
66 | final port = StreamQueue(receivePort);
67 | final SendPort sendPort = await port.next;
68 |
69 | _sendItemList(sendPort, oldList, getHashCode);
70 | _sendItemList(sendPort, newList, getHashCode);
71 |
72 | while (!await port.next) {
73 | // Two items' hashCodes match. Let's find out if they're really the same.
74 | final first = oldList[await port.next];
75 | final second = newList[await port.next];
76 | sendPort.send(areEqual(first, second));
77 | }
78 |
79 | final operations = await _receiveOperationsList(port, oldList, newList);
80 | receivePort.close();
81 | return operations;
82 | }
83 |
84 | Future _calculationInIsolate(dynamic message) async {
85 | final sendPort = message as SendPort;
86 | final receivePort = ReceivePort();
87 | sendPort.send(receivePort.sendPort);
88 | final port = StreamQueue(receivePort);
89 |
90 | final oldList = await _receiveItemList(port, sendPort, isOldList: true);
91 | final newList = await _receiveItemList(port, sendPort, isOldList: false);
92 |
93 | var operations = await diff(oldList, newList);
94 |
95 | _sendOperationsList(sendPort, operations);
96 | receivePort.close();
97 | }
98 |
99 | // Used in the worker isolate to refer to an item in the main isolate.
100 | class ReferenceToItemOnOtherIsolate {
101 | final StreamQueue port;
102 | final SendPort sendPort;
103 |
104 | final bool isFromOldList;
105 | final int index;
106 | final int hashCode;
107 |
108 | ReferenceToItemOnOtherIsolate({
109 | required this.port,
110 | required this.sendPort,
111 | required this.isFromOldList,
112 | required this.index,
113 | required this.hashCode,
114 | });
115 |
116 | Future equals(ReferenceToItemOnOtherIsolate other) async {
117 | assert(isFromOldList != other.isFromOldList,
118 | "We shouldn't need to compare items of the same list.");
119 | if (hashCode != other.hashCode) {
120 | return false;
121 | }
122 | final itemFromOldList = isFromOldList ? this : other;
123 | final itemFromNewList = isFromOldList ? other : this;
124 | sendPort
125 | ..send(false)
126 | ..send(itemFromOldList.index)
127 | ..send(itemFromNewList.index);
128 | return await port.next;
129 | }
130 | }
131 |
132 | void _sendItemList
- (
133 | SendPort sendPort,
134 | List list,
135 | int Function(Item item) getHashCode,
136 | ) {
137 | sendPort.send(list.length);
138 | for (var item in list) {
139 | sendPort.send(getHashCode(item));
140 | }
141 | }
142 |
143 | Future
> _receiveItemList(
144 | StreamQueue port, SendPort sendPort,
145 | {required bool isOldList}) async {
146 | final length = await port.next;
147 | final list = [];
148 |
149 | for (var i = 0; i < length; i++) {
150 | list.add(ReferenceToItemOnOtherIsolate(
151 | port: port,
152 | sendPort: sendPort,
153 | isFromOldList: isOldList,
154 | index: i,
155 | hashCode: await port.next,
156 | ));
157 | }
158 | return list;
159 | }
160 |
161 | void _sendOperationsList(SendPort sendPort,
162 | List> operations) {
163 | sendPort..send(true)..send(operations.length);
164 | for (final op in operations) {
165 | sendPort..send(op.isInsertion)..send(op.index)..send(op.item.index);
166 | }
167 | }
168 |
169 | Future>> _receiveOperationsList- (
170 | StreamQueue port,
171 | List
- oldList,
172 | List
- newList,
173 | ) async {
174 | Future> _receiveOperation() async {
175 | final bool isInsertion = await port.next;
176 | return Operation
- (
177 | type: isInsertion ? OperationType.insertion : OperationType.deletion,
178 | index: await port.next,
179 | item: isInsertion ? newList[await port.next] : oldList[await port.next],
180 | );
181 | }
182 |
183 | return [
184 | for (var i = await port.next; i > 0; i--) await _receiveOperation(),
185 | ];
186 | }
187 |
--------------------------------------------------------------------------------
/lib/list_diff.dart:
--------------------------------------------------------------------------------
1 | import 'calculate.dart';
2 | import 'isolated.dart';
3 | import 'operation.dart';
4 | import 'trim.dart';
5 |
6 | export 'operation.dart';
7 |
8 | typedef EqualityChecker
- = bool Function(Item a, Item b);
9 | typedef HashCodeGetter
- = int Function(Item a);
10 |
11 | /// Calculates a minimal list of [Operation]s that convert the [oldList] into
12 | /// the [newList].
13 | ///
14 | /// ```
15 | /// var operations = await diff(
16 | /// ['coconut', 'nut', 'peanut'],
17 | /// ['kiwi', 'coconut', 'maracuja', 'nut', 'banana'],
18 | /// );
19 | ///
20 | /// // Operations:
21 | /// // Insertion of kiwi at 0.
22 | /// // Insertion of maracuja at 2.
23 | /// // Insertion of banana at 4.
24 | /// // Deletion of peanut at 5.
25 | /// ```
26 | ///
27 | /// [Items] are compared using [areEqual] and [getHashCode] functions or the
28 | /// [Item]'s [==] operator if parameters aren't specified.
29 | ///
30 | /// This function uses a variant of the Levenshtein algorithm to find the
31 | /// minimum number of operations. This is a simple solution. If you need a more
32 | /// performant solution, such as Myers' algorith, your're welcome to contribute
33 | /// to this library at https://github.com/marcelgarus/list_diff.
34 | ///
35 | /// If the lists are large, this operation may take some time so if you're
36 | /// handling large data sets, better run this on a background isolate by
37 | /// setting [spawnIsolate] to [true]:
38 | ///
39 | /// ```
40 | /// var operations = await diff(first, second, useSeparateIsolate: true);
41 | /// ```
42 | ///
43 | /// **For Flutter users**: [diff] can be used to calculate updates for an
44 | /// [AnimatedList]:
45 | ///
46 | /// ```
47 | /// final _listKey = GlobalKey();
48 | /// List _lastFruits;
49 | /// ...
50 | ///
51 | /// StreamBuilder(
52 | /// stream: fruitStream,
53 | /// initialData: [],
54 | /// builder: (context, snapshot) {
55 | /// for (var operation in await diff(_lastFruits, snapshot.data)) {
56 | /// if (operation.isInsertion) {
57 | /// _listKey.insertItem(operation.index);
58 | /// } else {
59 | /// _listKey.removeItem(operation.index, (context, animation) => ...);
60 | /// }
61 | /// }
62 | ///
63 | /// return AnimatedList(
64 | /// key: _listKey,
65 | /// itemBuilder: (context, index, animation) => ...,
66 | /// );
67 | /// },
68 | /// ),
69 | /// ```
70 | ///
71 | /// See also:
72 | /// - [diffSync], if your lists are very small.
73 | Future
>> diff- (
74 | List
- oldList,
75 | List
- newList, {
76 | bool? spawnIsolate,
77 | EqualityChecker
- ? areEqual,
78 | HashCodeGetter
- ? getHashCode,
79 | }) async {
80 | assert(
81 | (areEqual == null) == (getHashCode == null),
82 | 'You have to either provide both an areEqual and a getHashCode function or '
83 | 'none at all. For more information, see the documentation of hashCode: '
84 | 'https://api.dart.dev/stable/2.9.2/dart-core/Object/hashCode.html',
85 | );
86 |
87 | // Use == operator and item hash code as default comparison functions
88 | final areEqualCheck = areEqual ?? (a, b) => a == b;
89 | final getHashCodeCheck = getHashCode ?? (item) => item.hashCode;
90 |
91 | final trimResult = trim(oldList, newList, areEqualCheck);
92 |
93 | final spawnIsolate_ = spawnIsolate ??
94 | shouldSpawnIsolate(
95 | trimResult.shortenedOldList,
96 | trimResult.shortenedNewList,
97 | );
98 |
99 | // Those are sublists that reduce the problem to a smaller problem domain.
100 | List> operations = spawnIsolate_
101 | ? await calculateDiffInSeparateIsolate(
102 | trimResult.shortenedOldList,
103 | trimResult.shortenedNewList,
104 | areEqualCheck,
105 | getHashCodeCheck,
106 | )
107 | : diffSync(
108 | trimResult.shortenedOldList,
109 | trimResult.shortenedNewList,
110 | areEqual: areEqualCheck,
111 | );
112 |
113 | // Shift operations back.
114 | return operations.map((op) => op.shift(trimResult.start)).toList();
115 | }
116 |
117 | /// Calculates a minimal list of [Operation]s that convert the [oldList] into
118 | /// the [newList].
119 | ///
120 | /// Unlike [diff], this function works synchronously (i.e., without using
121 | /// [Future]s).
122 | ///
123 | /// See also:
124 | /// - [diff], for a detailed explanation or if you have very long lists.
125 | List> diffSync
- (
126 | List
- oldList,
127 | List
- newList, {
128 | EqualityChecker
- ? areEqual,
129 | }) {
130 | // Use == operator and item hash code as default comparison functions
131 | final areEqualCheck = areEqual ?? (a, b) => a == b;
132 |
133 | final trimResult = trim(oldList, newList, areEqualCheck);
134 |
135 | // Those are sublists that reduce the problem to a smaller problem domain.
136 | List> operations = calculateDiffSync(
137 | trimResult.shortenedOldList,
138 | trimResult.shortenedNewList,
139 | areEqualCheck,
140 | );
141 |
142 | // Shift operations back.
143 | return operations.map((op) => op.shift(trimResult.start)).toList();
144 | }
145 |
--------------------------------------------------------------------------------
/lib/operation.dart:
--------------------------------------------------------------------------------
1 | enum OperationType { insertion, deletion }
2 |
3 | /// A single operation on a list – either an insertion or deletion of an [item]
4 | /// at an [index].
5 | ///
6 | /// Can be applied to a [List] by calling [applyTo].
7 | class Operation
- {
8 | final OperationType type;
9 | bool get isInsertion => type == OperationType.insertion;
10 | bool get isDeletion => type == OperationType.deletion;
11 |
12 | final int index;
13 | final Item item;
14 |
15 | Operation({required this.type, required this.index, required this.item});
16 |
17 | Operation
- shift(int shiftAmount) => Operation(
18 | type: type,
19 | index: index + shiftAmount,
20 | item: item,
21 | );
22 |
23 | /// Actually applies this operation on the [list] by mutating it.
24 | void applyTo(List
- list) {
25 | if (isInsertion) {
26 | list.insert(index, item);
27 | } else {
28 | assert(
29 | list[index] == item,
30 | "Tried to remove item $item at index $index, but there's a different "
31 | 'item at that position: ${list[index]}.',
32 | );
33 | list.removeAt(index);
34 | }
35 | }
36 |
37 | String toString() => '<${isInsertion ? 'Insert' : 'Delete'} $item at $index>';
38 | }
39 |
40 | extension ApplyOperation on List {
41 | void apply(Operation operation) => operation.applyTo(this);
42 | }
43 |
--------------------------------------------------------------------------------
/lib/trim.dart:
--------------------------------------------------------------------------------
1 | /// Check if the lists start or end with the same items to trim the problem down
2 | /// as much as possible.
3 | _TrimResult
- trim
- (
4 | List
- oldList,
5 | List
- newList,
6 | bool Function(Item a, Item b) areEqual,
7 | ) {
8 | var oldLen = oldList.length;
9 | var newLen = newList.length;
10 |
11 | var end = 0;
12 | while (end < oldLen &&
13 | end < newLen &&
14 | areEqual(oldList[oldLen - 1 - end], newList[newLen - 1 - end])) {
15 | end++;
16 | }
17 | oldList = oldList.sublist(0, oldLen - end);
18 | newList = newList.sublist(0, newLen - end);
19 | oldLen -= end;
20 | newLen -= end;
21 |
22 | var start = 0;
23 | while (start < oldLen &&
24 | start < newLen &&
25 | areEqual(oldList[start], newList[start])) {
26 | start++;
27 | }
28 |
29 | // We can now reduce the problem to two possibly smaller sublists.
30 | return _TrimResult(
31 | shortenedOldList: oldList.sublist(start),
32 | shortenedNewList: newList.sublist(start),
33 | start: start,
34 | );
35 | }
36 |
37 | class _TrimResult
- {
38 | const _TrimResult({
39 | required this.shortenedOldList,
40 | required this.shortenedNewList,
41 | required this.start,
42 | });
43 |
44 | final List
- shortenedOldList;
45 | final List
- shortenedNewList;
46 | final int start;
47 | }
48 |
--------------------------------------------------------------------------------
/pubspec.lock:
--------------------------------------------------------------------------------
1 | # Generated by pub
2 | # See https://dart.dev/tools/pub/glossary#lockfile
3 | packages:
4 | _fe_analyzer_shared:
5 | dependency: transitive
6 | description:
7 | name: _fe_analyzer_shared
8 | url: "https://pub.dartlang.org"
9 | source: hosted
10 | version: "17.0.0"
11 | analyzer:
12 | dependency: transitive
13 | description:
14 | name: analyzer
15 | url: "https://pub.dartlang.org"
16 | source: hosted
17 | version: "1.1.0"
18 | args:
19 | dependency: transitive
20 | description:
21 | name: args
22 | url: "https://pub.dartlang.org"
23 | source: hosted
24 | version: "2.0.0"
25 | async:
26 | dependency: "direct main"
27 | description:
28 | name: async
29 | url: "https://pub.dartlang.org"
30 | source: hosted
31 | version: "2.5.0"
32 | boolean_selector:
33 | dependency: transitive
34 | description:
35 | name: boolean_selector
36 | url: "https://pub.dartlang.org"
37 | source: hosted
38 | version: "2.1.0"
39 | charcode:
40 | dependency: transitive
41 | description:
42 | name: charcode
43 | url: "https://pub.dartlang.org"
44 | source: hosted
45 | version: "1.2.0"
46 | cli_util:
47 | dependency: transitive
48 | description:
49 | name: cli_util
50 | url: "https://pub.dartlang.org"
51 | source: hosted
52 | version: "0.3.0"
53 | collection:
54 | dependency: transitive
55 | description:
56 | name: collection
57 | url: "https://pub.dartlang.org"
58 | source: hosted
59 | version: "1.15.0"
60 | convert:
61 | dependency: transitive
62 | description:
63 | name: convert
64 | url: "https://pub.dartlang.org"
65 | source: hosted
66 | version: "3.0.0"
67 | coverage:
68 | dependency: transitive
69 | description:
70 | name: coverage
71 | url: "https://pub.dartlang.org"
72 | source: hosted
73 | version: "1.0.1"
74 | crypto:
75 | dependency: transitive
76 | description:
77 | name: crypto
78 | url: "https://pub.dartlang.org"
79 | source: hosted
80 | version: "3.0.0"
81 | file:
82 | dependency: transitive
83 | description:
84 | name: file
85 | url: "https://pub.dartlang.org"
86 | source: hosted
87 | version: "6.1.0"
88 | glob:
89 | dependency: transitive
90 | description:
91 | name: glob
92 | url: "https://pub.dartlang.org"
93 | source: hosted
94 | version: "2.0.0"
95 | http_multi_server:
96 | dependency: transitive
97 | description:
98 | name: http_multi_server
99 | url: "https://pub.dartlang.org"
100 | source: hosted
101 | version: "3.0.0"
102 | http_parser:
103 | dependency: transitive
104 | description:
105 | name: http_parser
106 | url: "https://pub.dartlang.org"
107 | source: hosted
108 | version: "4.0.0"
109 | io:
110 | dependency: transitive
111 | description:
112 | name: io
113 | url: "https://pub.dartlang.org"
114 | source: hosted
115 | version: "1.0.0"
116 | js:
117 | dependency: transitive
118 | description:
119 | name: js
120 | url: "https://pub.dartlang.org"
121 | source: hosted
122 | version: "0.6.3"
123 | logging:
124 | dependency: transitive
125 | description:
126 | name: logging
127 | url: "https://pub.dartlang.org"
128 | source: hosted
129 | version: "1.0.0"
130 | matcher:
131 | dependency: transitive
132 | description:
133 | name: matcher
134 | url: "https://pub.dartlang.org"
135 | source: hosted
136 | version: "0.12.10"
137 | meta:
138 | dependency: transitive
139 | description:
140 | name: meta
141 | url: "https://pub.dartlang.org"
142 | source: hosted
143 | version: "1.3.0"
144 | mime:
145 | dependency: transitive
146 | description:
147 | name: mime
148 | url: "https://pub.dartlang.org"
149 | source: hosted
150 | version: "1.0.0"
151 | node_preamble:
152 | dependency: transitive
153 | description:
154 | name: node_preamble
155 | url: "https://pub.dartlang.org"
156 | source: hosted
157 | version: "1.4.13"
158 | package_config:
159 | dependency: transitive
160 | description:
161 | name: package_config
162 | url: "https://pub.dartlang.org"
163 | source: hosted
164 | version: "2.0.0"
165 | path:
166 | dependency: transitive
167 | description:
168 | name: path
169 | url: "https://pub.dartlang.org"
170 | source: hosted
171 | version: "1.8.0"
172 | pedantic:
173 | dependency: transitive
174 | description:
175 | name: pedantic
176 | url: "https://pub.dartlang.org"
177 | source: hosted
178 | version: "1.11.0"
179 | pool:
180 | dependency: transitive
181 | description:
182 | name: pool
183 | url: "https://pub.dartlang.org"
184 | source: hosted
185 | version: "1.5.0"
186 | pub_semver:
187 | dependency: transitive
188 | description:
189 | name: pub_semver
190 | url: "https://pub.dartlang.org"
191 | source: hosted
192 | version: "2.0.0"
193 | shelf:
194 | dependency: transitive
195 | description:
196 | name: shelf
197 | url: "https://pub.dartlang.org"
198 | source: hosted
199 | version: "1.0.0"
200 | shelf_packages_handler:
201 | dependency: transitive
202 | description:
203 | name: shelf_packages_handler
204 | url: "https://pub.dartlang.org"
205 | source: hosted
206 | version: "3.0.0"
207 | shelf_static:
208 | dependency: transitive
209 | description:
210 | name: shelf_static
211 | url: "https://pub.dartlang.org"
212 | source: hosted
213 | version: "1.0.0"
214 | shelf_web_socket:
215 | dependency: transitive
216 | description:
217 | name: shelf_web_socket
218 | url: "https://pub.dartlang.org"
219 | source: hosted
220 | version: "1.0.0"
221 | source_map_stack_trace:
222 | dependency: transitive
223 | description:
224 | name: source_map_stack_trace
225 | url: "https://pub.dartlang.org"
226 | source: hosted
227 | version: "2.1.0"
228 | source_maps:
229 | dependency: transitive
230 | description:
231 | name: source_maps
232 | url: "https://pub.dartlang.org"
233 | source: hosted
234 | version: "0.10.10"
235 | source_span:
236 | dependency: transitive
237 | description:
238 | name: source_span
239 | url: "https://pub.dartlang.org"
240 | source: hosted
241 | version: "1.8.1"
242 | stack_trace:
243 | dependency: transitive
244 | description:
245 | name: stack_trace
246 | url: "https://pub.dartlang.org"
247 | source: hosted
248 | version: "1.10.0"
249 | stream_channel:
250 | dependency: transitive
251 | description:
252 | name: stream_channel
253 | url: "https://pub.dartlang.org"
254 | source: hosted
255 | version: "2.1.0"
256 | string_scanner:
257 | dependency: transitive
258 | description:
259 | name: string_scanner
260 | url: "https://pub.dartlang.org"
261 | source: hosted
262 | version: "1.1.0"
263 | term_glyph:
264 | dependency: transitive
265 | description:
266 | name: term_glyph
267 | url: "https://pub.dartlang.org"
268 | source: hosted
269 | version: "1.2.0"
270 | test:
271 | dependency: "direct dev"
272 | description:
273 | name: test
274 | url: "https://pub.dartlang.org"
275 | source: hosted
276 | version: "1.16.5"
277 | test_api:
278 | dependency: transitive
279 | description:
280 | name: test_api
281 | url: "https://pub.dartlang.org"
282 | source: hosted
283 | version: "0.2.19"
284 | test_core:
285 | dependency: transitive
286 | description:
287 | name: test_core
288 | url: "https://pub.dartlang.org"
289 | source: hosted
290 | version: "0.3.15"
291 | typed_data:
292 | dependency: transitive
293 | description:
294 | name: typed_data
295 | url: "https://pub.dartlang.org"
296 | source: hosted
297 | version: "1.3.0"
298 | vm_service:
299 | dependency: transitive
300 | description:
301 | name: vm_service
302 | url: "https://pub.dartlang.org"
303 | source: hosted
304 | version: "6.1.0+1"
305 | watcher:
306 | dependency: transitive
307 | description:
308 | name: watcher
309 | url: "https://pub.dartlang.org"
310 | source: hosted
311 | version: "1.0.0"
312 | web_socket_channel:
313 | dependency: transitive
314 | description:
315 | name: web_socket_channel
316 | url: "https://pub.dartlang.org"
317 | source: hosted
318 | version: "2.0.0"
319 | webkit_inspection_protocol:
320 | dependency: transitive
321 | description:
322 | name: webkit_inspection_protocol
323 | url: "https://pub.dartlang.org"
324 | source: hosted
325 | version: "1.0.0"
326 | yaml:
327 | dependency: transitive
328 | description:
329 | name: yaml
330 | url: "https://pub.dartlang.org"
331 | source: hosted
332 | version: "3.1.0"
333 | sdks:
334 | dart: ">=2.12.0 <3.0.0"
335 |
--------------------------------------------------------------------------------
/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: list_diff
2 | description: '📃 Calculates a minimal list of operations that convert one list into another if applied in order.'
3 | version: 2.0.1
4 | homepage: https://github.com/marcelgarus/list_diff
5 |
6 | environment:
7 | sdk: '>=2.12.0 <3.0.0'
8 |
9 | dependencies:
10 | async: ^2.5.0
11 |
12 | dev_dependencies:
13 | test: ^1.16.5
14 |
--------------------------------------------------------------------------------
/test/list_diff_test.dart:
--------------------------------------------------------------------------------
1 | import 'package:list_diff/list_diff.dart';
2 | import 'package:test/test.dart';
3 |
4 | late List
- list, newList;
5 |
6 | class Item {
7 | Item(this.id, this.value);
8 |
9 | int id;
10 | int value;
11 |
12 | @override
13 | bool operator ==(Object other) =>
14 | identical(this, other) ||
15 | other is Item && runtimeType == other.runtimeType && id == other.id;
16 |
17 | @override
18 | int get hashCode => id.hashCode;
19 | }
20 |
21 | void main() {
22 | group('Diff tests', () {
23 | setUp(() {
24 | list = [
25 | Item(0, 0),
26 | Item(1, 1),
27 | Item(2, 2),
28 | Item(3, 3),
29 | ];
30 | newList = List.from(list);
31 | });
32 |
33 | group('Default equals function tests', () {
34 | test('Identical list diff returns empty list', () async {
35 | final operations = await diff(list, newList);
36 |
37 | expect(operations, isEmpty);
38 | });
39 |
40 | test('List with one removed element returns one deletion', () async {
41 | newList.removeAt(1);
42 |
43 | final operations = await diff(list, newList);
44 |
45 | expect(operations, hasLength(1));
46 | expect(operations.first.type, OperationType.deletion);
47 | expect(operations.first.item, list[1]);
48 | expect(operations.first.index, 1);
49 | });
50 |
51 | test('List with one added element returns one insertion', () async {
52 | newList.add(Item(4, 4));
53 |
54 | final operations = await diff(list, newList);
55 |
56 | expect(operations, hasLength(1));
57 | expect(operations.first.type, OperationType.insertion);
58 | expect(operations.first.item, newList[4]);
59 | expect(operations.first.index, 4);
60 | });
61 |
62 | test(
63 | 'List with two neighboring switched elements returns insertion and deletion',
64 | () async {
65 | final temp = newList.first;
66 | newList.first = newList[1];
67 | newList[1] = temp;
68 |
69 | final operations = await diff(list, newList);
70 |
71 | expect(operations, hasLength(2));
72 |
73 | expect(operations.first.type, OperationType.insertion);
74 | expect(operations.first.item, newList[0]);
75 | expect(operations.first.index, 0);
76 |
77 | expect(operations[1].type, OperationType.deletion);
78 | expect(operations[1].item, list[1]);
79 | expect(operations[1].index, 2);
80 | });
81 |
82 | test(
83 | 'List with two not neighboring switched elements returns correct operations',
84 | () async {
85 | final temp = newList.first;
86 | newList.first = newList[2];
87 | newList[2] = temp;
88 |
89 | final operations = await diff(list, newList);
90 |
91 | expect(operations, hasLength(4));
92 |
93 | expect(operations.first.type, OperationType.insertion);
94 | expect(operations.first.item, newList.first);
95 | expect(operations.first.index, 0);
96 |
97 | expect(operations[1].type, OperationType.insertion);
98 | expect(operations[1].item, newList[1]);
99 | expect(operations[1].index, 1);
100 |
101 | expect(operations[2].type, OperationType.deletion);
102 | expect(operations[2].item, list[1]);
103 | expect(operations[2].index, 3);
104 |
105 | expect(operations[3].type, OperationType.deletion);
106 | expect(operations[3].item, list[2]);
107 | expect(operations[3].index, 3);
108 | });
109 | });
110 |
111 | group('Custom equals function tests', () {
112 | final areEqual = (a, b) => a.value == b.value;
113 | final getHashCode = (item) => item.hashCode;
114 |
115 | test('Identical list diff returns empty list', () async {
116 | final operations = await diff(
117 | list,
118 | newList,
119 | areEqual: areEqual,
120 | getHashCode: getHashCode,
121 | );
122 |
123 | expect(operations, isEmpty);
124 | });
125 |
126 | test('List with one removed element returns one deletion', () async {
127 | newList.removeAt(1);
128 |
129 | final operations = await diff(
130 | list,
131 | newList,
132 | areEqual: areEqual,
133 | getHashCode: getHashCode,
134 | );
135 |
136 | expect(operations, hasLength(1));
137 | expect(operations.first.type, OperationType.deletion);
138 | expect(operations.first.item, list[1]);
139 | expect(operations.first.index, 1);
140 | });
141 |
142 | test('List with one added element returns one insertion', () async {
143 | newList.add(Item(4, 4));
144 |
145 | final operations = await diff(
146 | list,
147 | newList,
148 | areEqual: areEqual,
149 | getHashCode: getHashCode,
150 | );
151 |
152 | expect(operations, hasLength(1));
153 | expect(operations.first.type, OperationType.insertion);
154 | expect(operations.first.item, newList[4]);
155 | expect(operations.first.index, 4);
156 | });
157 |
158 | test(
159 | 'List with two neighboring switched elements returns insertion and deletion',
160 | () async {
161 | final temp = newList.first;
162 | newList.first = newList[1];
163 | newList[1] = temp;
164 |
165 | final operations = await diff(
166 | list,
167 | newList,
168 | areEqual: areEqual,
169 | getHashCode: getHashCode,
170 | );
171 |
172 | expect(operations, hasLength(2));
173 |
174 | expect(operations.first.type, OperationType.insertion);
175 | expect(operations.first.item, newList[0]);
176 | expect(operations.first.index, 0);
177 |
178 | expect(operations[1].type, OperationType.deletion);
179 | expect(operations[1].item, list[1]);
180 | expect(operations[1].index, 2);
181 | });
182 |
183 | test(
184 | 'List with two not neighboring switched elements returns correct operations',
185 | () async {
186 | final temp = newList.first;
187 | newList.first = newList[2];
188 | newList[2] = temp;
189 |
190 | final operations = await diff(
191 | list,
192 | newList,
193 | areEqual: areEqual,
194 | getHashCode: getHashCode,
195 | );
196 |
197 | expect(operations, hasLength(4));
198 |
199 | expect(operations.first.type, OperationType.insertion);
200 | expect(operations.first.item, newList.first);
201 | expect(operations.first.index, 0);
202 |
203 | expect(operations[1].type, OperationType.insertion);
204 | expect(operations[1].item, newList[1]);
205 | expect(operations[1].index, 1);
206 |
207 | expect(operations[2].type, OperationType.deletion);
208 | expect(operations[2].item, list[1]);
209 | expect(operations[2].index, 3);
210 |
211 | expect(operations[3].type, OperationType.deletion);
212 | expect(operations[3].item, list[2]);
213 | expect(operations[3].index, 3);
214 | });
215 |
216 | test('List with item replaced with equal one return empty list',
217 | () async {
218 | newList.first = Item(4, 0);
219 |
220 | final operations = await diff(
221 | list,
222 | newList,
223 | areEqual: areEqual,
224 | getHashCode: getHashCode,
225 | );
226 |
227 | expect(operations, isEmpty);
228 | });
229 | });
230 | });
231 | }
232 |
--------------------------------------------------------------------------------