├── .gitignore
├── .idea
├── .gitignore
├── codeStyles
│ └── Project.xml
├── libraries
│ └── Dart_SDK.xml
├── misc.xml
├── modules.xml
├── vcs.xml
└── workspace.xml
├── .vscode
└── launch.json
├── CHANGELOG.md
├── LICENSE
├── README.md
├── android
├── app
│ └── src
│ │ └── main
│ │ └── java
│ │ └── io
│ │ └── flutter
│ │ └── plugins
│ │ └── GeneratedPluginRegistrant.java
└── local.properties
├── example
├── .gitignore
├── .metadata
├── README.md
├── android
│ ├── app
│ │ ├── build.gradle
│ │ └── src
│ │ │ └── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── example
│ │ │ │ └── MainActivity.java
│ │ │ └── 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
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ └── gradle-wrapper.properties
│ └── settings.gradle
├── ios
│ ├── Flutter
│ │ ├── AppFrameworkInfo.plist
│ │ ├── Debug.xcconfig
│ │ ├── Release.xcconfig
│ │ └── flutter_export_environment.sh
│ ├── Runner.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ └── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── Runner.xcscheme
│ ├── Runner.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── Runner
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── 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
│ │ └── main.m
├── lib
│ ├── horizontal_explicit.dart
│ ├── horziontal.dart
│ ├── main.dart
│ └── vertical.dart
└── pubspec.yaml
├── lib
├── size_providers.dart
├── snaplist.dart
├── snaplist_bloc.dart
├── snaplist_controller.dart
├── snaplist_events.dart
└── snaplist_view.dart
├── pubspec.lock
├── pubspec.yaml
├── snaplist.iml
└── test
├── event_matchers.dart
├── snaplist_controller_test.dart
└── snaplist_test.dart
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .dart_tool/
3 |
4 | .packages
5 | .pub/
6 |
7 | build/
8 | ios/.generated/
9 | ios/Flutter/Generated.xcconfig
10 | ios/Runner/GeneratedPluginRegistrant.*
11 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Project exclude paths
3 | /.
4 | # Project exclude paths
5 | /.
6 | # Project exclude paths
7 | /.
8 | # Project exclude paths
9 | /.
10 | # Project exclude paths
11 | /.
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/.idea/libraries/Dart_SDK.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 | 1589303960013
111 |
112 |
113 | 1589303960013
114 |
115 |
116 |
117 |
118 |
119 |
128 |
129 |
130 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Flutter",
9 | "request": "launch",
10 | "type": "dart",
11 | "program": "example/lib/main.dart"
12 | }
13 | ]
14 | }
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## [0.1.8] - 16.03.2019
4 |
5 | * Introducing `SnaplistController` to allow initial item position and setting position programatically.
6 |
7 | ## [0.1.7] - 01.02.2019
8 |
9 | * Hot reload did nothing to snaplist. Now it is fixed. A big thanks to [@raacker](https://github.com/raacker).
10 |
11 | ## [0.1.6] - 31.10.2018
12 |
13 | * Hot reload did nothing to snaplist. Now it is fixed. A big thanks to [@raacker](https://github.com/raacker).
14 |
15 | ## [0.1.5] - 28.10.2018
16 |
17 | * Implements vertical axis scroll and snip. A big thanks to [@raacker](https://github.com/raacker).
18 |
19 | ## [0.1.4] - 27.10.2018
20 |
21 | * Adds a simple example to the package
22 |
23 | ## [0.1.3] - 26.10.2018
24 |
25 | * Readme and organizational updates.
26 |
27 | ## [0.1.2] - 25.10.2018
28 |
29 | * Implements snapping back to original item if not enough velocity or progress
30 |
31 | ## [0.1.1] - 24.10.2018
32 |
33 | * Explicitly provides current item position, does not hide it in builder data
34 | * Removes unnessesary `setState` calls from snip animation
35 |
36 | ## [0.1.0] - 21.10.2018
37 |
38 | * It's alive!
39 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2018 David Leibovych
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://stackoverflow.com/questions/tagged/flutter?sort=votes)
2 | [](https://pub.dartlang.org/packages/snaplist)
3 |
4 | # snaplist
5 |
6 | A small cozy library that allows you to make snappable list views.
7 |
8 | **Issues and Pull Requests are really appreciated!**
9 |
10 | Snaplist supports different and even dynamically sized children to be listed and correctly snapped.
11 |
12 | ## Showcase
13 |
14 | 
15 |
16 | ## Include to your project
17 |
18 | In your `pubspec.yaml` root add:
19 |
20 | ```yaml
21 | dependencies:
22 | snaplist: ^0.1.8
23 | ```
24 |
25 | ## Include
26 |
27 | The library does provide `StatefulWidget` which is called `SnapList`.
28 |
29 | Include the widget like this:
30 | `import 'package:snaplist/snaplist.dart';`
31 |
32 | ## Usage
33 |
34 | Use it as you'd use any widget:
35 |
36 | ```dart
37 | Widget build(BuildContext context) {
38 | return SnapList(
39 | sizeProvider: (index, data) => Size(100.0, 100.0),
40 | separatorProvider: (index, data) => Size(10.0, 10.0),
41 | builder: (context, index, data) => SizedBox(),
42 | count: 1,
43 | );
44 | }
45 | ```
46 |
47 | Snaplist uses gesture detection for swiping the list, so, please, be sure that the gestures you apply to the widgets inside are not overlapping for best user experience.
48 |
49 | ## Properties
50 |
51 | There are 4 required fields:
52 |
53 | - `sizeProvider` is a provider of each widget size. The library will wrap each built widget to a sized box of specified size. This is required so snapping calculations will work correctly.
54 | - `separatorProvider` is similar to `sizeProvider`, but this size will be used to build the list separators.
55 | - `builder` works like a regular `Flutter` builder all of us are familiar with. It will pass you the context, current item index and some additional data.
56 | - `count` - Children count as in a `ListView`.
57 |
58 | The `data` which is provided to each provider and the builder is a combination of three fields:
59 |
60 | - `center` - is the position which is now displayed and referenced as the center widget.
61 | - `next` - is the position which the user is scrolling to. It is `-1` if idle.
62 | - `progress` - is the scroll and snip progress. The values are from `0` to `100`.
63 |
64 | Snaplist defaults to horizontal scrolling. You can set `axis` to Axis.vertical for vertical scrolling.
65 |
--------------------------------------------------------------------------------
/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java:
--------------------------------------------------------------------------------
1 | package io.flutter.plugins;
2 |
3 | import io.flutter.plugin.common.PluginRegistry;
4 |
5 | /**
6 | * Generated file. Do not edit.
7 | */
8 | public final class GeneratedPluginRegistrant {
9 | public static void registerWith(PluginRegistry registry) {
10 | if (alreadyRegisteredWith(registry)) {
11 | return;
12 | }
13 | }
14 |
15 | private static boolean alreadyRegisteredWith(PluginRegistry registry) {
16 | final String key = GeneratedPluginRegistrant.class.getCanonicalName();
17 | if (registry.hasPlugin(key)) {
18 | return true;
19 | }
20 | registry.registrarFor(key);
21 | return false;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/android/local.properties:
--------------------------------------------------------------------------------
1 | sdk.dir=/Users/david/Library/Android/sdk
2 | flutter.sdk=/Users/david/Tools/flutter
3 | flutter.versionName=0.1.3
--------------------------------------------------------------------------------
/example/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.lock
4 | *.log
5 | *.pyc
6 | *.swp
7 | .DS_Store
8 | .atom/
9 | .buildlog/
10 | .history
11 | .svn/
12 |
13 | # IntelliJ related
14 | *.iml
15 | *.ipr
16 | *.iws
17 | .idea/
18 |
19 | # Visual Studio Code related
20 | .vscode/
21 |
22 | # Flutter/Dart/Pub related
23 | **/doc/api/
24 | .dart_tool/
25 | .flutter-plugins
26 | .packages
27 | .pub-cache/
28 | .pub/
29 | build/
30 |
31 | # Android related
32 | **/android/**/gradle-wrapper.jar
33 | **/android/.gradle
34 | **/android/captures/
35 | **/android/gradlew
36 | **/android/gradlew.bat
37 | **/android/local.properties
38 | **/android/**/GeneratedPluginRegistrant.java
39 |
40 | # iOS/XCode related
41 | **/ios/**/*.mode1v3
42 | **/ios/**/*.mode2v3
43 | **/ios/**/*.moved-aside
44 | **/ios/**/*.pbxuser
45 | **/ios/**/*.perspectivev3
46 | **/ios/**/*sync/
47 | **/ios/**/.sconsign.dblite
48 | **/ios/**/.tags*
49 | **/ios/**/.vagrant/
50 | **/ios/**/DerivedData/
51 | **/ios/**/Icon?
52 | **/ios/**/Pods/
53 | **/ios/**/.symlinks/
54 | **/ios/**/profile
55 | **/ios/**/xcuserdata
56 | **/ios/.generated/
57 | **/ios/Flutter/App.framework
58 | **/ios/Flutter/Flutter.framework
59 | **/ios/Flutter/Generated.xcconfig
60 | **/ios/Flutter/app.flx
61 | **/ios/Flutter/app.zip
62 | **/ios/Flutter/flutter_assets/
63 | **/ios/ServiceDefinitions.json
64 | **/ios/Runner/GeneratedPluginRegistrant.*
65 |
66 | # Exceptions to above rules.
67 | !**/ios/**/default.mode1v3
68 | !**/ios/**/default.mode2v3
69 | !**/ios/**/default.pbxuser
70 | !**/ios/**/default.perspectivev3
71 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
72 |
--------------------------------------------------------------------------------
/example/.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: f37c235c32fc15babe6dc7b7bc2ee4387e5ecf92
8 | channel: beta
9 |
--------------------------------------------------------------------------------
/example/README.md:
--------------------------------------------------------------------------------
1 | # example
2 |
3 | Sample app for the Snaplist library.
4 |
5 | .
6 |
7 | This application shows two uses case of using snaplist - vertical and horizontal snapping.
8 |
9 | The only actual difference between those two is the `axis` value. But I still believe it is important considering both options, especially if you are providing some additional gestures to the displayed item.
10 |
11 | Please, be sure that your gesture does not conflict with the gesture which is used for the list scroll and snaps.
--------------------------------------------------------------------------------
/example/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 from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
26 |
27 | android {
28 | compileSdkVersion 29
29 |
30 | lintOptions {
31 | disable 'InvalidPackage'
32 | }
33 |
34 | defaultConfig {
35 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
36 | applicationId "com.example.example"
37 | minSdkVersion 16
38 | targetSdkVersion 29
39 | versionCode flutterVersionCode.toInteger()
40 | versionName flutterVersionName
41 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
42 | }
43 |
44 | buildTypes {
45 | release {
46 | // TODO: Add your own signing config for the release build.
47 | // Signing with the debug keys for now, so `flutter run --release` works.
48 | signingConfig signingConfigs.debug
49 | }
50 | }
51 | }
52 |
53 | flutter {
54 | source '../..'
55 | }
56 |
57 | dependencies {
58 | testImplementation 'junit:junit:4.12'
59 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
60 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
61 | }
62 |
--------------------------------------------------------------------------------
/example/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
15 |
19 |
26 |
30 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/com/example/example/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.example;
2 |
3 | import android.os.Bundle;
4 | import io.flutter.app.FlutterActivity;
5 | import io.flutter.plugins.GeneratedPluginRegistrant;
6 |
7 | public class MainActivity extends FlutterActivity {
8 | @Override
9 | protected void onCreate(Bundle savedInstanceState) {
10 | super.onCreate(savedInstanceState);
11 | GeneratedPluginRegistrant.registerWith(this);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ariedov/flutter_snaplist/ae735207d8dc93658843cc801bf3965b2320359b/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ariedov/flutter_snaplist/ae735207d8dc93658843cc801bf3965b2320359b/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ariedov/flutter_snaplist/ae735207d8dc93658843cc801bf3965b2320359b/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ariedov/flutter_snaplist/ae735207d8dc93658843cc801bf3965b2320359b/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ariedov/flutter_snaplist/ae735207d8dc93658843cc801bf3965b2320359b/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
--------------------------------------------------------------------------------
/example/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | google()
4 | jcenter()
5 | }
6 |
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:3.6.3'
9 | }
10 | }
11 |
12 | allprojects {
13 | repositories {
14 | google()
15 | jcenter()
16 | }
17 | }
18 |
19 | rootProject.buildDir = '../build'
20 | subprojects {
21 | project.buildDir = "${rootProject.buildDir}/${project.name}"
22 | }
23 | subprojects {
24 | project.evaluationDependsOn(':app')
25 | }
26 |
27 | task clean(type: Delete) {
28 | delete rootProject.buildDir
29 | }
30 |
--------------------------------------------------------------------------------
/example/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.enableR8=true
3 | android.useAndroidX=true
4 |
--------------------------------------------------------------------------------
/example/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.4-all.zip
7 |
--------------------------------------------------------------------------------
/example/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/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
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/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/example/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/example/ios/Flutter/flutter_export_environment.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # This is a generated file; do not edit or check into version control.
3 | export "FLUTTER_ROOT=C:\Users\aried\Tools\flutter"
4 | export "FLUTTER_APPLICATION_PATH=C:\Users\aried\Projects\flutter_snaplist\example"
5 | export "FLUTTER_TARGET=lib\main.dart"
6 | export "FLUTTER_BUILD_DIR=build"
7 | export "SYMROOT=${SOURCE_ROOT}/../build\ios"
8 | export "OTHER_LDFLAGS=$(inherited) -framework Flutter"
9 | export "FLUTTER_FRAMEWORK_DIR=C:\Users\aried\Tools\flutter\bin\cache\artifacts\engine\ios"
10 | export "FLUTTER_BUILD_NAME=1.0.0"
11 | export "FLUTTER_BUILD_NUMBER=1"
12 |
--------------------------------------------------------------------------------
/example/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 | 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
12 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
13 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
14 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
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 | 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; };
18 | 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
19 | 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
20 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
21 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
22 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
23 | /* End PBXBuildFile section */
24 |
25 | /* Begin PBXCopyFilesBuildPhase section */
26 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = {
27 | isa = PBXCopyFilesBuildPhase;
28 | buildActionMask = 2147483647;
29 | dstPath = "";
30 | dstSubfolderSpec = 10;
31 | files = (
32 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
33 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
34 | );
35 | name = "Embed Frameworks";
36 | runOnlyForDeploymentPostprocessing = 0;
37 | };
38 | /* End PBXCopyFilesBuildPhase section */
39 |
40 | /* Begin PBXFileReference section */
41 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; };
42 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; };
43 | 2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
44 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; };
45 | 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; };
46 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; };
47 | 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
48 | 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
49 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; };
50 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; };
51 | 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; };
52 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
53 | 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
54 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
55 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
56 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
57 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
58 | /* End PBXFileReference section */
59 |
60 | /* Begin PBXFrameworksBuildPhase section */
61 | 97C146EB1CF9000F007C117D /* Frameworks */ = {
62 | isa = PBXFrameworksBuildPhase;
63 | buildActionMask = 2147483647;
64 | files = (
65 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
66 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
67 | );
68 | runOnlyForDeploymentPostprocessing = 0;
69 | };
70 | /* End PBXFrameworksBuildPhase section */
71 |
72 | /* Begin PBXGroup section */
73 | 9740EEB11CF90186004384FC /* Flutter */ = {
74 | isa = PBXGroup;
75 | children = (
76 | 2D5378251FAA1A9400D5DBA9 /* flutter_assets */,
77 | 3B80C3931E831B6300D905FE /* App.framework */,
78 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
79 | 9740EEBA1CF902C7004384FC /* Flutter.framework */,
80 | 9740EEB21CF90195004384FC /* Debug.xcconfig */,
81 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
82 | 9740EEB31CF90195004384FC /* Generated.xcconfig */,
83 | );
84 | name = Flutter;
85 | sourceTree = "";
86 | };
87 | 97C146E51CF9000F007C117D = {
88 | isa = PBXGroup;
89 | children = (
90 | 9740EEB11CF90186004384FC /* Flutter */,
91 | 97C146F01CF9000F007C117D /* Runner */,
92 | 97C146EF1CF9000F007C117D /* Products */,
93 | CF3B75C9A7D2FA2A4C99F110 /* Frameworks */,
94 | );
95 | sourceTree = "";
96 | };
97 | 97C146EF1CF9000F007C117D /* Products */ = {
98 | isa = PBXGroup;
99 | children = (
100 | 97C146EE1CF9000F007C117D /* Runner.app */,
101 | );
102 | name = Products;
103 | sourceTree = "";
104 | };
105 | 97C146F01CF9000F007C117D /* Runner */ = {
106 | isa = PBXGroup;
107 | children = (
108 | 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */,
109 | 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */,
110 | 97C146FA1CF9000F007C117D /* Main.storyboard */,
111 | 97C146FD1CF9000F007C117D /* Assets.xcassets */,
112 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
113 | 97C147021CF9000F007C117D /* Info.plist */,
114 | 97C146F11CF9000F007C117D /* Supporting Files */,
115 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
116 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
117 | );
118 | path = Runner;
119 | sourceTree = "";
120 | };
121 | 97C146F11CF9000F007C117D /* Supporting Files */ = {
122 | isa = PBXGroup;
123 | children = (
124 | 97C146F21CF9000F007C117D /* main.m */,
125 | );
126 | name = "Supporting Files";
127 | sourceTree = "";
128 | };
129 | /* End PBXGroup section */
130 |
131 | /* Begin PBXNativeTarget section */
132 | 97C146ED1CF9000F007C117D /* Runner */ = {
133 | isa = PBXNativeTarget;
134 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
135 | buildPhases = (
136 | 9740EEB61CF901F6004384FC /* Run Script */,
137 | 97C146EA1CF9000F007C117D /* Sources */,
138 | 97C146EB1CF9000F007C117D /* Frameworks */,
139 | 97C146EC1CF9000F007C117D /* Resources */,
140 | 9705A1C41CF9048500538489 /* Embed Frameworks */,
141 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */,
142 | );
143 | buildRules = (
144 | );
145 | dependencies = (
146 | );
147 | name = Runner;
148 | productName = Runner;
149 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
150 | productType = "com.apple.product-type.application";
151 | };
152 | /* End PBXNativeTarget section */
153 |
154 | /* Begin PBXProject section */
155 | 97C146E61CF9000F007C117D /* Project object */ = {
156 | isa = PBXProject;
157 | attributes = {
158 | LastUpgradeCheck = 0910;
159 | ORGANIZATIONNAME = "The Chromium Authors";
160 | TargetAttributes = {
161 | 97C146ED1CF9000F007C117D = {
162 | CreatedOnToolsVersion = 7.3.1;
163 | };
164 | };
165 | };
166 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
167 | compatibilityVersion = "Xcode 3.2";
168 | developmentRegion = English;
169 | hasScannedForEncodings = 0;
170 | knownRegions = (
171 | en,
172 | Base,
173 | );
174 | mainGroup = 97C146E51CF9000F007C117D;
175 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
176 | projectDirPath = "";
177 | projectRoot = "";
178 | targets = (
179 | 97C146ED1CF9000F007C117D /* Runner */,
180 | );
181 | };
182 | /* End PBXProject section */
183 |
184 | /* Begin PBXResourcesBuildPhase section */
185 | 97C146EC1CF9000F007C117D /* Resources */ = {
186 | isa = PBXResourcesBuildPhase;
187 | buildActionMask = 2147483647;
188 | files = (
189 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
190 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
191 | 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
192 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
193 | 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */,
194 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
195 | );
196 | runOnlyForDeploymentPostprocessing = 0;
197 | };
198 | /* End PBXResourcesBuildPhase section */
199 |
200 | /* Begin PBXShellScriptBuildPhase section */
201 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
202 | isa = PBXShellScriptBuildPhase;
203 | buildActionMask = 2147483647;
204 | files = (
205 | );
206 | inputPaths = (
207 | );
208 | name = "Thin Binary";
209 | outputPaths = (
210 | );
211 | runOnlyForDeploymentPostprocessing = 0;
212 | shellPath = /bin/sh;
213 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
214 | };
215 | 9740EEB61CF901F6004384FC /* Run Script */ = {
216 | isa = PBXShellScriptBuildPhase;
217 | buildActionMask = 2147483647;
218 | files = (
219 | );
220 | inputPaths = (
221 | );
222 | name = "Run Script";
223 | outputPaths = (
224 | );
225 | runOnlyForDeploymentPostprocessing = 0;
226 | shellPath = /bin/sh;
227 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
228 | };
229 | /* End PBXShellScriptBuildPhase section */
230 |
231 | /* Begin PBXSourcesBuildPhase section */
232 | 97C146EA1CF9000F007C117D /* Sources */ = {
233 | isa = PBXSourcesBuildPhase;
234 | buildActionMask = 2147483647;
235 | files = (
236 | 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */,
237 | 97C146F31CF9000F007C117D /* main.m in Sources */,
238 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
239 | );
240 | runOnlyForDeploymentPostprocessing = 0;
241 | };
242 | /* End PBXSourcesBuildPhase section */
243 |
244 | /* Begin PBXVariantGroup section */
245 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = {
246 | isa = PBXVariantGroup;
247 | children = (
248 | 97C146FB1CF9000F007C117D /* Base */,
249 | );
250 | name = Main.storyboard;
251 | sourceTree = "";
252 | };
253 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = {
254 | isa = PBXVariantGroup;
255 | children = (
256 | 97C147001CF9000F007C117D /* Base */,
257 | );
258 | name = LaunchScreen.storyboard;
259 | sourceTree = "";
260 | };
261 | /* End PBXVariantGroup section */
262 |
263 | /* Begin XCBuildConfiguration section */
264 | 97C147031CF9000F007C117D /* Debug */ = {
265 | isa = XCBuildConfiguration;
266 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
267 | buildSettings = {
268 | ALWAYS_SEARCH_USER_PATHS = NO;
269 | CLANG_ANALYZER_NONNULL = YES;
270 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
271 | CLANG_CXX_LIBRARY = "libc++";
272 | CLANG_ENABLE_MODULES = YES;
273 | CLANG_ENABLE_OBJC_ARC = YES;
274 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
275 | CLANG_WARN_BOOL_CONVERSION = YES;
276 | CLANG_WARN_COMMA = YES;
277 | CLANG_WARN_CONSTANT_CONVERSION = YES;
278 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
279 | CLANG_WARN_EMPTY_BODY = YES;
280 | CLANG_WARN_ENUM_CONVERSION = YES;
281 | CLANG_WARN_INFINITE_RECURSION = YES;
282 | CLANG_WARN_INT_CONVERSION = YES;
283 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
284 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
285 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
286 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
287 | CLANG_WARN_STRICT_PROTOTYPES = YES;
288 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
289 | CLANG_WARN_UNREACHABLE_CODE = YES;
290 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
291 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
292 | COPY_PHASE_STRIP = NO;
293 | DEBUG_INFORMATION_FORMAT = dwarf;
294 | ENABLE_STRICT_OBJC_MSGSEND = YES;
295 | ENABLE_TESTABILITY = YES;
296 | GCC_C_LANGUAGE_STANDARD = gnu99;
297 | GCC_DYNAMIC_NO_PIC = NO;
298 | GCC_NO_COMMON_BLOCKS = YES;
299 | GCC_OPTIMIZATION_LEVEL = 0;
300 | GCC_PREPROCESSOR_DEFINITIONS = (
301 | "DEBUG=1",
302 | "$(inherited)",
303 | );
304 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
305 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
306 | GCC_WARN_UNDECLARED_SELECTOR = YES;
307 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
308 | GCC_WARN_UNUSED_FUNCTION = YES;
309 | GCC_WARN_UNUSED_VARIABLE = YES;
310 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
311 | MTL_ENABLE_DEBUG_INFO = YES;
312 | ONLY_ACTIVE_ARCH = YES;
313 | SDKROOT = iphoneos;
314 | TARGETED_DEVICE_FAMILY = "1,2";
315 | };
316 | name = Debug;
317 | };
318 | 97C147041CF9000F007C117D /* Release */ = {
319 | isa = XCBuildConfiguration;
320 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
321 | buildSettings = {
322 | ALWAYS_SEARCH_USER_PATHS = NO;
323 | CLANG_ANALYZER_NONNULL = YES;
324 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
325 | CLANG_CXX_LIBRARY = "libc++";
326 | CLANG_ENABLE_MODULES = YES;
327 | CLANG_ENABLE_OBJC_ARC = YES;
328 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
329 | CLANG_WARN_BOOL_CONVERSION = YES;
330 | CLANG_WARN_COMMA = YES;
331 | CLANG_WARN_CONSTANT_CONVERSION = YES;
332 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
333 | CLANG_WARN_EMPTY_BODY = YES;
334 | CLANG_WARN_ENUM_CONVERSION = YES;
335 | CLANG_WARN_INFINITE_RECURSION = YES;
336 | CLANG_WARN_INT_CONVERSION = YES;
337 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
338 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
339 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
340 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
341 | CLANG_WARN_STRICT_PROTOTYPES = YES;
342 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
343 | CLANG_WARN_UNREACHABLE_CODE = YES;
344 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
345 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
346 | COPY_PHASE_STRIP = NO;
347 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
348 | ENABLE_NS_ASSERTIONS = NO;
349 | ENABLE_STRICT_OBJC_MSGSEND = YES;
350 | GCC_C_LANGUAGE_STANDARD = gnu99;
351 | GCC_NO_COMMON_BLOCKS = YES;
352 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
353 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
354 | GCC_WARN_UNDECLARED_SELECTOR = YES;
355 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
356 | GCC_WARN_UNUSED_FUNCTION = YES;
357 | GCC_WARN_UNUSED_VARIABLE = YES;
358 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
359 | MTL_ENABLE_DEBUG_INFO = NO;
360 | SDKROOT = iphoneos;
361 | TARGETED_DEVICE_FAMILY = "1,2";
362 | VALIDATE_PRODUCT = YES;
363 | };
364 | name = Release;
365 | };
366 | 97C147061CF9000F007C117D /* Debug */ = {
367 | isa = XCBuildConfiguration;
368 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
369 | buildSettings = {
370 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
371 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
372 | ENABLE_BITCODE = NO;
373 | FRAMEWORK_SEARCH_PATHS = (
374 | "$(inherited)",
375 | "$(PROJECT_DIR)/Flutter",
376 | );
377 | INFOPLIST_FILE = Runner/Info.plist;
378 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
379 | LIBRARY_SEARCH_PATHS = (
380 | "$(inherited)",
381 | "$(PROJECT_DIR)/Flutter",
382 | );
383 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example;
384 | PRODUCT_NAME = "$(TARGET_NAME)";
385 | VERSIONING_SYSTEM = "apple-generic";
386 | };
387 | name = Debug;
388 | };
389 | 97C147071CF9000F007C117D /* Release */ = {
390 | isa = XCBuildConfiguration;
391 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
392 | buildSettings = {
393 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
394 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
395 | ENABLE_BITCODE = NO;
396 | FRAMEWORK_SEARCH_PATHS = (
397 | "$(inherited)",
398 | "$(PROJECT_DIR)/Flutter",
399 | );
400 | INFOPLIST_FILE = Runner/Info.plist;
401 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
402 | LIBRARY_SEARCH_PATHS = (
403 | "$(inherited)",
404 | "$(PROJECT_DIR)/Flutter",
405 | );
406 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example;
407 | PRODUCT_NAME = "$(TARGET_NAME)";
408 | VERSIONING_SYSTEM = "apple-generic";
409 | };
410 | name = Release;
411 | };
412 | /* End XCBuildConfiguration section */
413 |
414 | /* Begin XCConfigurationList section */
415 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = {
416 | isa = XCConfigurationList;
417 | buildConfigurations = (
418 | 97C147031CF9000F007C117D /* Debug */,
419 | 97C147041CF9000F007C117D /* Release */,
420 | );
421 | defaultConfigurationIsVisible = 0;
422 | defaultConfigurationName = Release;
423 | };
424 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = {
425 | isa = XCConfigurationList;
426 | buildConfigurations = (
427 | 97C147061CF9000F007C117D /* Debug */,
428 | 97C147071CF9000F007C117D /* Release */,
429 | );
430 | defaultConfigurationIsVisible = 0;
431 | defaultConfigurationName = Release;
432 | };
433 | /* End XCConfigurationList section */
434 | };
435 | rootObject = 97C146E61CF9000F007C117D /* Project object */;
436 | }
437 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
31 |
32 |
33 |
34 |
40 |
41 |
42 |
43 |
44 |
45 |
56 |
58 |
64 |
65 |
66 |
67 |
68 |
69 |
75 |
77 |
83 |
84 |
85 |
86 |
88 |
89 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/ios/Runner/AppDelegate.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | @interface AppDelegate : FlutterAppDelegate
5 |
6 | @end
7 |
--------------------------------------------------------------------------------
/example/ios/Runner/AppDelegate.m:
--------------------------------------------------------------------------------
1 | #include "AppDelegate.h"
2 | #include "GeneratedPluginRegistrant.h"
3 |
4 | @implementation AppDelegate
5 |
6 | - (BOOL)application:(UIApplication *)application
7 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
8 | [GeneratedPluginRegistrant registerWithRegistry:self];
9 | // Override point for customization after application launch.
10 | return [super application:application didFinishLaunchingWithOptions:launchOptions];
11 | }
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/example/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/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ariedov/flutter_snaplist/ae735207d8dc93658843cc801bf3965b2320359b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ariedov/flutter_snaplist/ae735207d8dc93658843cc801bf3965b2320359b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ariedov/flutter_snaplist/ae735207d8dc93658843cc801bf3965b2320359b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ariedov/flutter_snaplist/ae735207d8dc93658843cc801bf3965b2320359b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ariedov/flutter_snaplist/ae735207d8dc93658843cc801bf3965b2320359b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ariedov/flutter_snaplist/ae735207d8dc93658843cc801bf3965b2320359b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ariedov/flutter_snaplist/ae735207d8dc93658843cc801bf3965b2320359b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ariedov/flutter_snaplist/ae735207d8dc93658843cc801bf3965b2320359b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ariedov/flutter_snaplist/ae735207d8dc93658843cc801bf3965b2320359b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ariedov/flutter_snaplist/ae735207d8dc93658843cc801bf3965b2320359b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ariedov/flutter_snaplist/ae735207d8dc93658843cc801bf3965b2320359b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ariedov/flutter_snaplist/ae735207d8dc93658843cc801bf3965b2320359b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ariedov/flutter_snaplist/ae735207d8dc93658843cc801bf3965b2320359b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ariedov/flutter_snaplist/ae735207d8dc93658843cc801bf3965b2320359b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ariedov/flutter_snaplist/ae735207d8dc93658843cc801bf3965b2320359b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/example/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/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ariedov/flutter_snaplist/ae735207d8dc93658843cc801bf3965b2320359b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ariedov/flutter_snaplist/ae735207d8dc93658843cc801bf3965b2320359b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ariedov/flutter_snaplist/ae735207d8dc93658843cc801bf3965b2320359b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/example/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/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/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/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | example
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/ios/Runner/main.m:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 | #import "AppDelegate.h"
4 |
5 | int main(int argc, char* argv[]) {
6 | @autoreleasepool {
7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/example/lib/horizontal_explicit.dart:
--------------------------------------------------------------------------------
1 | import 'dart:math';
2 |
3 | import 'package:flutter/material.dart';
4 | import 'package:snaplist/snaplist.dart';
5 |
6 | class HorizontalExplicitTab extends StatelessWidget {
7 | final List images;
8 | final VoidCallback loadMore;
9 |
10 | const HorizontalExplicitTab({Key key, this.images, this.loadMore})
11 | : super(key: key);
12 |
13 | @override
14 | Widget build(BuildContext context) {
15 | final Size cardSize = Size(300.0, 460.0);
16 |
17 | final random = new Random();
18 | final controller = SnaplistController(initialPosition: 2);
19 | return Stack(
20 | children: [
21 | SnapList(
22 | padding: EdgeInsets.only(
23 | left: (MediaQuery.of(context).size.width - cardSize.width) / 2),
24 | sizeProvider: (index, data) => cardSize,
25 | separatorProvider: (index, data) => Size(10.0, 10.0),
26 | positionUpdate: (int index) {
27 | if (index == images.length - 1) {
28 | loadMore();
29 | }
30 | },
31 | builder: (context, index, data) {
32 | return ClipRRect(
33 | borderRadius: new BorderRadius.circular(16.0),
34 | child: Image.network(
35 | images[index],
36 | fit: BoxFit.fill,
37 | ),
38 | );
39 | },
40 | count: images.length,
41 | snaplistController: controller,
42 | ),
43 | Positioned(
44 | child: FloatingActionButton(
45 | onPressed: () =>
46 | controller.setPosition(random.nextInt(images.length)),
47 | ),
48 | bottom: 10,
49 | right: 10,
50 | )
51 | ],
52 | );
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/example/lib/horziontal.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:snaplist/snaplist.dart';
3 |
4 | class HorizontalTab extends StatelessWidget {
5 | final List images;
6 | final VoidCallback loadMore;
7 |
8 | const HorizontalTab({Key key, this.images, this.loadMore}) : super(key: key);
9 |
10 | @override
11 | Widget build(BuildContext context) {
12 | final Size cardSize = Size(300.0, 460.0);
13 | return SnapList(
14 | padding: EdgeInsets.only(
15 | left: (MediaQuery.of(context).size.width - cardSize.width) / 2),
16 | sizeProvider: (index, data) => cardSize,
17 | separatorProvider: (index, data) => Size(10.0, 10.0),
18 | positionUpdate: (int index) {
19 | if (index == images.length - 1) {
20 | loadMore();
21 | }
22 | },
23 | builder: (context, index, data) {
24 | return ClipRRect(
25 | borderRadius: new BorderRadius.circular(16.0),
26 | child: Image.network(
27 | images[index],
28 | fit: BoxFit.fill,
29 | ),
30 | );
31 | },
32 | count: images.length,
33 | );
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/example/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'package:example/horizontal_explicit.dart';
2 | import 'package:example/horziontal.dart';
3 | import 'package:example/vertical.dart';
4 | import 'package:flutter/material.dart';
5 |
6 | void main() => runApp(new MyApp());
7 |
8 | class MyApp extends StatelessWidget {
9 | @override
10 | Widget build(BuildContext context) {
11 | return new MaterialApp(
12 | title: 'Snaplist Demo',
13 | theme: new ThemeData(
14 | primarySwatch: Colors.blue,
15 | ),
16 | home: new MyHomePage(),
17 | );
18 | }
19 | }
20 |
21 | class MyHomePage extends StatefulWidget {
22 | @override
23 | _MyHomePageState createState() => new _MyHomePageState();
24 | }
25 |
26 | class _MyHomePageState extends State {
27 | List urls = [
28 | "https://image.tmdb.org/t/p/w370_and_h556_bestv2/2uNW4WbgBXL25BAbXGLnLqX71Sw.jpg",
29 | "https://image.tmdb.org/t/p/w370_and_h556_bestv2/lNkDYKmrVem1J0aAfCnQlJOCKnT.jpg",
30 | "https://image.tmdb.org/t/p/w370_and_h556_bestv2/wrFpXMNBRj2PBiN4Z5kix51XaIZ.jpg",
31 | "https://image.tmdb.org/t/p/w370_and_h556_bestv2/r6pPUVUKU5eIpYj4oEzidk5ZibB.jpg",
32 | "https://image.tmdb.org/t/p/w370_and_h556_bestv2/x1txcDXkcM65gl7w20PwYSxAYah.jpg",
33 | "https://image.tmdb.org/t/p/w370_and_h556_bestv2/ptSrT1JwZFWGhjSpYUtJaasQrh.jpg",
34 | "https://image.tmdb.org/t/p/w370_and_h556_bestv2/wMq9kQXTeQCHUZOG4fAe5cAxyUA.jpg",
35 | "https://image.tmdb.org/t/p/w370_and_h556_bestv2/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg",
36 | ];
37 |
38 | @override
39 | Widget build(BuildContext context) {
40 | return DefaultTabController(
41 | child: Scaffold(
42 | appBar: AppBar(
43 | title: Text("Snaplist demo"),
44 | bottom: TabBar(tabs: [
45 | Tab(
46 | text: "Horizontal",
47 | ),
48 | Tab(
49 | text: "Explicit",
50 | ),
51 | Tab(text: "Vertical")
52 | ])),
53 | body: TabBarView(
54 | physics: NeverScrollableScrollPhysics(),
55 | children: [ HorizontalTab(
56 | images: urls, loadMore: _loadMoreItems,
57 | ),
58 | HorizontalExplicitTab(
59 | images: urls, loadMore: _loadMoreItems,
60 | ),
61 | VerticalTab(images: urls, loadMore: _loadMoreItems)
62 | ],
63 | ),
64 | ),
65 | length: 3
66 | );
67 | }
68 |
69 | void _loadMoreItems() {
70 | setState(() {
71 | urls = new List.from(urls)..addAll(urls);
72 | });
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/example/lib/vertical.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:snaplist/snaplist.dart';
3 |
4 | class VerticalTab extends StatelessWidget {
5 | final List images;
6 | final VoidCallback loadMore;
7 |
8 | const VerticalTab({Key key, this.images, this.loadMore}) : super(key: key);
9 |
10 | @override
11 | Widget build(BuildContext context) {
12 | final Size cardSize = Size(250.0, 250.0);
13 | return SnapList(
14 | padding: EdgeInsets.only(
15 | top: (MediaQuery.of(context).size.height - 180 - cardSize.height) / 2),
16 | sizeProvider: (index, data) => cardSize,
17 | separatorProvider: (index, data) => Size(50.0, 50.0),
18 | positionUpdate: (int index){
19 | if(index==images.length-1){
20 | loadMore();
21 | }
22 | },
23 | builder: (context, index, data) {
24 | return ClipOval(
25 | child: Image.network(
26 | images[index],
27 | fit: BoxFit.cover,
28 | ),
29 | );
30 | },
31 | count: images.length,
32 | axis: Axis.vertical,
33 | );
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/example/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: example
2 | description: A demo showcase of snaplist library.
3 |
4 | version: 1.0.0+1
5 |
6 | environment:
7 | sdk: ">=2.0.0-dev.68.0 <3.0.0"
8 |
9 | dependencies:
10 | flutter:
11 | sdk: flutter
12 | snaplist:
13 | path: ../
14 |
15 | dev_dependencies:
16 | flutter_test:
17 | sdk: flutter
18 |
19 | flutter:
20 | uses-material-design: true
21 |
--------------------------------------------------------------------------------
/lib/size_providers.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/widgets.dart';
2 |
3 | typedef Size CardSizeProvider(int position, BuilderData data);
4 | typedef Size SeparatorSizeProvider(int position, BuilderData data);
5 |
6 | class BuilderData {
7 | final int center;
8 | final int next;
9 | final double progress;
10 |
11 | BuilderData(this.center, this.next, this.progress);
12 | }
13 |
--------------------------------------------------------------------------------
/lib/snaplist.dart:
--------------------------------------------------------------------------------
1 | library snaplist;
2 |
3 | export 'snaplist_view.dart';
4 | export 'snaplist_controller.dart';
--------------------------------------------------------------------------------
/lib/snaplist_bloc.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 |
3 | import 'package:flutter/widgets.dart';
4 | import 'package:snaplist/size_providers.dart';
5 | import 'package:snaplist/snaplist_events.dart';
6 |
7 | class SnapListBloc {
8 | int _itemsCount;
9 | CardSizeProvider _sizeProvider;
10 | SeparatorSizeProvider _separatorProvider;
11 | double _swipeVelocity;
12 | Axis _axis;
13 |
14 | int _centerItemPosition = 0;
15 | int _nextItemPosition = -1;
16 |
17 | double _scrollOffset;
18 | double _startPosition;
19 |
20 | double _scrollProgress;
21 |
22 | ScrollDirection _direction = ScrollDirection.NONE;
23 | bool get _isVertical => _axis == Axis.vertical;
24 |
25 | StreamController _swipeStartController = StreamController();
26 | Sink get swipeStartSink => _swipeStartController.sink;
27 |
28 | StreamController _swipeUpdateController = StreamController();
29 | Sink get swipeUpdateSink => _swipeUpdateController.sink;
30 |
31 | StreamController _swipeEndController = StreamController();
32 | Sink get swipeEndSink => _swipeEndController.sink;
33 |
34 | StreamController _snipStartController = StreamController();
35 | Stream get snipStartStream => _snipStartController.stream;
36 |
37 | StreamController _snipUpdateController = StreamController();
38 | Sink get snipUpdateSink => _snipUpdateController.sink;
39 |
40 | StreamController _snipFinishController = StreamController();
41 | Sink get snipFinishSink => _snipFinishController.sink;
42 |
43 | StreamController _positionChangeController =
44 | StreamController();
45 | Stream get positionStream =>
46 | _positionChangeController.stream;
47 |
48 | StreamController _explicitPositionChangeController = StreamController();
49 | Sink get explicitPositionChangeSink =>
50 | _explicitPositionChangeController.sink;
51 |
52 | StreamController _explicitPositionChangeStream = StreamController();
53 | Stream get explicitPositionChangeStream =>
54 | _explicitPositionChangeStream.stream;
55 |
56 | StreamController _offsetController = StreamController();
57 | Stream get offsetStream => _offsetController.stream;
58 |
59 | StreamController _itemCountController = StreamController();
60 | Sink get itemCountSink => _itemCountController.sink;
61 |
62 | StreamController _uiController = StreamController();
63 | Stream get uiStream => _uiController.stream;
64 |
65 | SnapListBloc(
66 | {int itemsCount, sizeProvider, separatorProvider, axis, swipeVelocity}) {
67 | initializeField(
68 | itemsCount: itemsCount,
69 | sizeProvider: sizeProvider,
70 | axis: axis,
71 | separatorProvider: separatorProvider,
72 | swipeVelocity: swipeVelocity,
73 | );
74 |
75 | _swipeStartController.stream.listen((event) {
76 | _direction = ScrollDirection.NONE;
77 |
78 | _scrollOffset = event.offset;
79 | _startPosition = event.position;
80 |
81 | _scrollProgress = 0.0;
82 | });
83 |
84 | _swipeUpdateController.stream.listen((event) {
85 | if (event.position < _startPosition) {
86 | _direction = _isVertical ? ScrollDirection.DOWN : ScrollDirection.RIGHT;
87 | _nextItemPosition = _centerItemPosition + 1;
88 | } else {
89 | _direction = _isVertical ? ScrollDirection.UP : ScrollDirection.LEFT;
90 | _nextItemPosition = _centerItemPosition - 1;
91 | }
92 |
93 | if (_nextItemPosition < 0 || _nextItemPosition >= _itemsCount) {
94 | return;
95 | }
96 |
97 | _scrollOffset = _scrollOffset - event.delta;
98 | _scrollProgress = _calculateScrollProgress(event.position);
99 | _offsetController.add(OffsetEvent(_scrollOffset, _scrollProgress,
100 | _centerItemPosition, _nextItemPosition));
101 |
102 | _uiController.add(
103 | UiEvent(_centerItemPosition, _nextItemPosition, _scrollProgress));
104 | });
105 |
106 | _swipeEndController.stream.listen((event) {
107 | if (_swipeVelocity != 0.0 &&
108 | _swipeVelocity >=
109 | (_isVertical ? event.vector.dy.abs() : event.vector.dx.abs()) &&
110 | _scrollProgress < 50) {
111 | _scrollProgress = 100 - _scrollProgress;
112 | _swipeNextAndCenter();
113 | _direction = ScrollDirection.NONE;
114 | }
115 |
116 | if (_direction != null &&
117 | _nextItemPosition >= 0 &&
118 | _nextItemPosition < _itemsCount) {
119 | _snipStartController.add(SnipStartEvent(
120 | _scrollOffset, _calculateTargetOffset(), _scrollProgress));
121 | }
122 | });
123 |
124 | _snipUpdateController.stream.listen((event) {
125 | _scrollProgress = event.progress;
126 | _scrollOffset = event.snip;
127 |
128 | _offsetController.add(OffsetEvent(_scrollOffset, _scrollProgress,
129 | _centerItemPosition, _nextItemPosition));
130 | _uiController.add(
131 | UiEvent(_centerItemPosition, _nextItemPosition, _scrollProgress));
132 | });
133 |
134 | _snipFinishController.stream.listen((event) {
135 | _centerItemPosition = _nextItemPosition.clamp(0, _itemsCount - 1);
136 | _nextItemPosition = -1;
137 | _scrollProgress = 0.0;
138 |
139 | _positionChangeController.add(PositionChangeEvent(_centerItemPosition));
140 | });
141 |
142 | _explicitPositionChangeController.stream.listen((position) {
143 | _nextItemPosition = position.clamp(0, _itemsCount - 1);
144 | _scrollProgress = 0.0;
145 |
146 | _explicitPositionChangeStream.add(_calculateTargetOffset());
147 |
148 | _centerItemPosition = _nextItemPosition;
149 | _nextItemPosition = -1;
150 | });
151 |
152 | _itemCountController.stream.listen((itemCount) {
153 | _itemsCount = itemCount;
154 |
155 | if (_centerItemPosition >= _itemsCount - 1) {
156 | _centerItemPosition = _itemsCount - 1;
157 | _positionChangeController.add(PositionChangeEvent(_centerItemPosition));
158 | }
159 | });
160 | }
161 |
162 | initializeField(
163 | {itemsCount, sizeProvider, separatorProvider, axis, swipeVelocity}) {
164 | _itemsCount = itemsCount ?? 0;
165 | _sizeProvider = sizeProvider;
166 | _separatorProvider = separatorProvider;
167 | _axis = axis;
168 | _swipeVelocity = swipeVelocity;
169 | }
170 |
171 | _swipeNextAndCenter() {
172 | final tmp = _centerItemPosition;
173 | _centerItemPosition = _nextItemPosition;
174 | _nextItemPosition = tmp;
175 | }
176 |
177 | _calculateScrollProgress(double currentPosition) {
178 | final distance = (_startPosition - currentPosition).abs();
179 | Size cardSize = _sizeProvider(_centerItemPosition, _createBuilderData());
180 | return ((distance * 100) / (_isVertical ? cardSize.height : cardSize.width))
181 | .clamp(0.0, 100.0);
182 | }
183 |
184 | double _calculateTargetOffset() {
185 | return calculateTargetOffset(
186 | _centerItemPosition, _nextItemPosition, _isVertical, _sizeProvider, _separatorProvider, _createBuilderData());
187 | }
188 |
189 | _createBuilderData() {
190 | return BuilderData(_centerItemPosition, _nextItemPosition, _scrollProgress);
191 | }
192 |
193 | void onSwipingFinished() {
194 | _centerItemPosition = _nextItemPosition;
195 | _nextItemPosition = -1;
196 | }
197 |
198 | void dispose() {
199 | _itemCountController.close();
200 |
201 | _swipeStartController.close();
202 | _swipeUpdateController.close();
203 | _swipeEndController.close();
204 |
205 | _snipStartController.close();
206 | _snipUpdateController.close();
207 | _snipFinishController.close();
208 |
209 | _positionChangeController.close();
210 | _offsetController.close();
211 |
212 | _explicitPositionChangeController.close();
213 | _explicitPositionChangeStream.close();
214 |
215 | _uiController.close();
216 | }
217 | }
218 |
219 | double calculateTargetOffset(
220 | int currentItem,
221 | int calculateTo,
222 | bool isVertical,
223 | CardSizeProvider sizeProvider,
224 | SeparatorSizeProvider separatorSizeProvider,
225 | BuilderData builderData) {
226 | double result = 0.0;
227 |
228 | for (var i = 1; i <= calculateTo; ++i) {
229 | Size cardSize = sizeProvider(
230 | i - 1,
231 | BuilderData(
232 | currentItem,
233 | calculateTo,
234 | 100.0,
235 | ));
236 | Size separatorSize = separatorSizeProvider(i - 1, builderData);
237 |
238 | if (isVertical) {
239 | result += cardSize.height;
240 | result += separatorSize.height;
241 | } else {
242 | result += cardSize.width;
243 | result += separatorSize.width;
244 | }
245 | }
246 | return result;
247 | }
248 |
249 | enum ScrollDirection { RIGHT, NONE, LEFT, UP, DOWN }
250 |
--------------------------------------------------------------------------------
/lib/snaplist_controller.dart:
--------------------------------------------------------------------------------
1 | class SnaplistController {
2 |
3 | final int initialPosition;
4 |
5 | PositionChanged positionChanged;
6 |
7 | SnaplistController({
8 | this.initialPosition
9 | });
10 |
11 | setPosition(int position) {
12 | if (positionChanged != null) {
13 | positionChanged(position);
14 | }
15 | }
16 | }
17 |
18 | typedef PositionChanged(int position);
--------------------------------------------------------------------------------
/lib/snaplist_events.dart:
--------------------------------------------------------------------------------
1 |
2 | import 'dart:ui';
3 |
4 | class StartEvent {
5 | final double offset;
6 | final double position;
7 |
8 | StartEvent(this.offset, this.position);
9 | }
10 | class UpdateEvent {
11 | final double position;
12 | final double delta;
13 |
14 | UpdateEvent(this.position, this.delta);
15 | }
16 | class EndEvent {
17 | final Offset vector;
18 |
19 | EndEvent(this.vector);
20 | }
21 |
22 | class SnipStartEvent {
23 | final double offset;
24 | final double targetOffset;
25 | final double progress;
26 |
27 | SnipStartEvent(this.offset, this.targetOffset, this.progress);
28 | }
29 | class SnipUpdateEvent {
30 | final double snip;
31 | final double progress;
32 |
33 | SnipUpdateEvent(this.snip, this.progress);
34 | }
35 | class SnipFinishEvent {}
36 |
37 | class PositionChangeEvent {
38 | final newPosition;
39 |
40 | PositionChangeEvent(this.newPosition);
41 | }
42 |
43 | class OffsetEvent {
44 | final double offset;
45 | final double progress;
46 | final int centerPosition;
47 | final int nextPosition;
48 |
49 | OffsetEvent(
50 | this.offset, this.progress, this.centerPosition, this.nextPosition);
51 | }
52 |
53 | class UiEvent {
54 | final int center;
55 | final int next;
56 | final double progress;
57 |
58 | UiEvent(this.center, this.next, this.progress);
59 | }
--------------------------------------------------------------------------------
/lib/snaplist_view.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/widgets.dart';
2 | import 'package:snaplist/size_providers.dart';
3 | import 'package:snaplist/snaplist_bloc.dart';
4 | import 'package:snaplist/snaplist_controller.dart';
5 | import 'package:snaplist/snaplist_events.dart';
6 |
7 | class SnapList extends StatefulWidget {
8 | final SeparatorSizeProvider separatorProvider;
9 | final CardSizeProvider sizeProvider;
10 | final CardBuilder builder;
11 | final int count;
12 |
13 | final ScrollProgressUpdate progressUpdate;
14 | final PositionUpdate positionUpdate;
15 | final ScrollStart scrollStart;
16 | final Axis axis;
17 |
18 | final Duration snipDuration;
19 | final Curve snipCurve;
20 |
21 | final EdgeInsets padding;
22 | final Alignment alignment;
23 | final double swipeVelocity;
24 |
25 | final SnaplistController snaplistController;
26 |
27 | SnapList({
28 | Key key,
29 | @required this.sizeProvider,
30 | @required this.builder,
31 | @required this.separatorProvider,
32 | @required this.count,
33 | this.padding,
34 | this.progressUpdate,
35 | this.positionUpdate,
36 | this.scrollStart,
37 | this.axis = Axis.horizontal,
38 | this.snipDuration,
39 | this.snipCurve,
40 | this.alignment = Alignment.center,
41 | this.swipeVelocity = 0.0,
42 | this.snaplistController,
43 | }) : super(key: key) {
44 | assert(this.sizeProvider != null);
45 | assert(this.builder != null);
46 | assert(this.separatorProvider != null);
47 | assert(this.count != null);
48 | }
49 |
50 | @override
51 | State createState() => _SnapListState();
52 | }
53 |
54 | class _SnapListState extends State with TickerProviderStateMixin {
55 | GlobalKey _listKey = GlobalKey();
56 | ScrollController _controller = ScrollController();
57 |
58 | SnapListBloc bloc;
59 |
60 | AnimationController _snipController;
61 | Tween _progressTween = Tween();
62 | Tween _snipTween = Tween();
63 |
64 | @override
65 | void initState() {
66 | bloc = SnapListBloc(
67 | itemsCount: widget.count,
68 | sizeProvider: widget.sizeProvider,
69 | axis: widget.axis,
70 | separatorProvider: widget.separatorProvider,
71 | swipeVelocity: widget.swipeVelocity
72 | );
73 |
74 | bloc.offsetStream.listen((event) {
75 | _controller.jumpTo(event.offset);
76 | _updateProgress(event.progress, event.centerPosition, event.nextPosition);
77 | });
78 |
79 | bloc.positionStream.listen((event) {
80 | _updatePosition(event.newPosition);
81 | });
82 |
83 | bloc.snipStartStream.listen((event) {
84 | _snipTween = Tween(begin: event.offset, end: event.targetOffset);
85 | _progressTween = Tween(begin: event.progress, end: 100.0);
86 |
87 | _snipController.forward(from: 0.0);
88 | });
89 |
90 | bloc.explicitPositionChangeStream.listen((offset) {
91 | print("new offset: $offset");
92 | _controller.jumpTo(offset);
93 | });
94 |
95 | _snipController = AnimationController(
96 | vsync: this,
97 | duration: widget.snipDuration ?? Duration(milliseconds: 300))
98 | ..addListener(() {
99 | Animation resultAnimation = _snipController;
100 | if (widget.snipCurve != null) {
101 | resultAnimation = CurvedAnimation(parent: _snipController, curve: widget.snipCurve);
102 | }
103 | final scrollProgress = _progressTween.evaluate(resultAnimation);
104 | final snip = _snipTween.evaluate(resultAnimation);
105 | bloc.snipUpdateSink.add(SnipUpdateEvent(snip, scrollProgress));
106 | })
107 | ..addStatusListener((status) {
108 | if (status == AnimationStatus.completed) {
109 | bloc.snipFinishSink.add(SnipFinishEvent());
110 | }
111 | });
112 |
113 | widget.snaplistController?.positionChanged = (position) {
114 | bloc.explicitPositionChangeSink.add(position);
115 | };
116 |
117 | if (widget.snaplistController?.initialPosition != null) {
118 | bloc.explicitPositionChangeSink.add(widget.snaplistController.initialPosition);
119 | }
120 |
121 | super.initState();
122 | }
123 |
124 | _updateProgress(
125 | double progress, int centerItemPosition, int nextItemPosition) {
126 | if (widget.progressUpdate != null) {
127 | widget.progressUpdate(progress, centerItemPosition, nextItemPosition);
128 | }
129 | }
130 |
131 | _updatePosition(int newPosition) {
132 | if (widget.positionUpdate != null) {
133 | widget.positionUpdate(newPosition);
134 | }
135 | }
136 |
137 | @override
138 | void didUpdateWidget(SnapList oldWidget) {
139 | bloc.itemCountSink.add(widget.count);
140 |
141 | super.didUpdateWidget(oldWidget);
142 | bloc.initializeField(
143 | itemsCount: widget.count,
144 | sizeProvider: widget.sizeProvider,
145 | axis: widget.axis,
146 | separatorProvider: widget.separatorProvider,
147 | swipeVelocity: widget.swipeVelocity,
148 | );
149 |
150 | widget.snaplistController?.positionChanged = (position) {
151 | bloc.explicitPositionChangeSink.add(position);
152 | };
153 | }
154 |
155 | @override
156 | Widget build(BuildContext context) {
157 | return StreamBuilder(
158 | initialData: UiEvent(0, -1, 0.0),
159 | stream: bloc.uiStream,
160 | builder: (context, snapshot) {
161 | UiEvent event = snapshot.data;
162 |
163 | if (isAnimating) {
164 | return _buildList(event.center, event.next, event.progress);
165 | }
166 | if (widget.axis == Axis.vertical) {
167 | return GestureDetector(
168 | onVerticalDragStart: _onVerticalStart,
169 | onVerticalDragUpdate: _onVerticalUpdate,
170 | onVerticalDragEnd: _onVerticalEnd,
171 | child: _buildList(event.center, event.next, event.progress),
172 | );
173 | } else {
174 | return GestureDetector(
175 | onHorizontalDragStart: _onHorizontalStart,
176 | onHorizontalDragUpdate: _onHorizontalUpdate,
177 | onHorizontalDragEnd: _onHorizontalEnd,
178 | child: _buildList(event.center, event.next, event.progress),
179 | );
180 | }
181 | },
182 | );
183 | }
184 |
185 | _buildList(int center, int next, double progress) {
186 | return ListView.separated(
187 | key: _listKey,
188 | padding: widget.padding,
189 | scrollDirection: widget.axis,
190 | physics: NeverScrollableScrollPhysics(),
191 | controller: _controller,
192 | separatorBuilder: (context, index) {
193 | if (widget.axis == Axis.vertical) {
194 | return SizedBox(
195 | height: widget
196 | .separatorProvider(index, BuilderData(center, next, progress))
197 | .height,
198 | );
199 | } else {
200 | return SizedBox(
201 | width: widget
202 | .separatorProvider(index, BuilderData(center, next, progress))
203 | .width,
204 | );
205 | }
206 | },
207 | itemBuilder: (context, index) {
208 | final builderData = BuilderData(center, next, progress);
209 | final size = widget.sizeProvider(index, builderData);
210 | return Align(
211 | alignment: widget.alignment,
212 | child: SizedBox.fromSize(
213 | size: size,
214 | child: widget.builder(
215 | context,
216 | index,
217 | builderData,
218 | ),
219 | ),
220 | );
221 | },
222 | itemCount: widget.count);
223 | }
224 |
225 | @override
226 | void dispose() {
227 | bloc.dispose();
228 | _controller.dispose();
229 | _snipController.dispose();
230 | super.dispose();
231 | }
232 |
233 | void _onHorizontalStart(DragStartDetails details) {
234 | bloc.swipeStartSink
235 | .add(StartEvent(_controller.offset, details.globalPosition.dx));
236 |
237 | if (widget.scrollStart != null) {
238 | widget.scrollStart();
239 | }
240 | }
241 |
242 | void _onHorizontalUpdate(DragUpdateDetails details) {
243 | bloc.swipeUpdateSink
244 | .add(UpdateEvent(details.globalPosition.dx, details.delta.dx));
245 | }
246 |
247 | void _onHorizontalEnd(DragEndDetails details) {
248 | bloc.swipeEndSink.add(EndEvent(details.velocity.pixelsPerSecond));
249 | }
250 |
251 | void _onVerticalStart(DragStartDetails details) {
252 | bloc.swipeStartSink
253 | .add(StartEvent(_controller.offset, details.globalPosition.dy));
254 |
255 | if (widget.scrollStart != null) {
256 | widget.scrollStart();
257 | }
258 | }
259 |
260 | void _onVerticalUpdate(DragUpdateDetails details) {
261 | bloc.swipeUpdateSink
262 | .add(UpdateEvent(details.globalPosition.dy, details.delta.dy));
263 | }
264 |
265 | void _onVerticalEnd(DragEndDetails details) {
266 | bloc.swipeEndSink.add(EndEvent(details.velocity.pixelsPerSecond));
267 | }
268 |
269 | bool get isAnimating => _snipController.isAnimating;
270 | }
271 |
272 | typedef Widget CardBuilder(
273 | BuildContext context,
274 | int position,
275 | BuilderData data,
276 | );
277 |
278 | typedef ScrollStart();
279 | typedef void ScrollProgressUpdate(double progress, int center, int next);
280 | typedef void PositionUpdate(int center);
281 |
--------------------------------------------------------------------------------
/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.3.0"
11 | boolean_selector:
12 | dependency: transitive
13 | description:
14 | name: boolean_selector
15 | url: "https://pub.dartlang.org"
16 | source: hosted
17 | version: "1.0.5"
18 | charcode:
19 | dependency: transitive
20 | description:
21 | name: charcode
22 | url: "https://pub.dartlang.org"
23 | source: hosted
24 | version: "1.1.2"
25 | collection:
26 | dependency: transitive
27 | description:
28 | name: collection
29 | url: "https://pub.dartlang.org"
30 | source: hosted
31 | version: "1.14.11"
32 | flutter:
33 | dependency: "direct main"
34 | description: flutter
35 | source: sdk
36 | version: "0.0.0"
37 | flutter_test:
38 | dependency: "direct dev"
39 | description: flutter
40 | source: sdk
41 | version: "0.0.0"
42 | matcher:
43 | dependency: transitive
44 | description:
45 | name: matcher
46 | url: "https://pub.dartlang.org"
47 | source: hosted
48 | version: "0.12.5"
49 | meta:
50 | dependency: transitive
51 | description:
52 | name: meta
53 | url: "https://pub.dartlang.org"
54 | source: hosted
55 | version: "1.1.7"
56 | path:
57 | dependency: transitive
58 | description:
59 | name: path
60 | url: "https://pub.dartlang.org"
61 | source: hosted
62 | version: "1.6.4"
63 | pedantic:
64 | dependency: transitive
65 | description:
66 | name: pedantic
67 | url: "https://pub.dartlang.org"
68 | source: hosted
69 | version: "1.8.0+1"
70 | quiver:
71 | dependency: transitive
72 | description:
73 | name: quiver
74 | url: "https://pub.dartlang.org"
75 | source: hosted
76 | version: "2.0.5"
77 | sky_engine:
78 | dependency: transitive
79 | description: flutter
80 | source: sdk
81 | version: "0.0.99"
82 | source_span:
83 | dependency: transitive
84 | description:
85 | name: source_span
86 | url: "https://pub.dartlang.org"
87 | source: hosted
88 | version: "1.5.5"
89 | stack_trace:
90 | dependency: transitive
91 | description:
92 | name: stack_trace
93 | url: "https://pub.dartlang.org"
94 | source: hosted
95 | version: "1.9.3"
96 | stream_channel:
97 | dependency: transitive
98 | description:
99 | name: stream_channel
100 | url: "https://pub.dartlang.org"
101 | source: hosted
102 | version: "2.0.0"
103 | string_scanner:
104 | dependency: transitive
105 | description:
106 | name: string_scanner
107 | url: "https://pub.dartlang.org"
108 | source: hosted
109 | version: "1.0.5"
110 | term_glyph:
111 | dependency: transitive
112 | description:
113 | name: term_glyph
114 | url: "https://pub.dartlang.org"
115 | source: hosted
116 | version: "1.1.0"
117 | test_api:
118 | dependency: transitive
119 | description:
120 | name: test_api
121 | url: "https://pub.dartlang.org"
122 | source: hosted
123 | version: "0.2.5"
124 | typed_data:
125 | dependency: transitive
126 | description:
127 | name: typed_data
128 | url: "https://pub.dartlang.org"
129 | source: hosted
130 | version: "1.1.6"
131 | vector_math:
132 | dependency: transitive
133 | description:
134 | name: vector_math
135 | url: "https://pub.dartlang.org"
136 | source: hosted
137 | version: "2.0.8"
138 | sdks:
139 | dart: ">=2.2.2 <3.0.0"
140 |
--------------------------------------------------------------------------------
/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: snaplist
2 | description: A small library that allows to create lists with snapping to item.
3 | version: 0.1.8
4 | author: David Leibovych
5 | homepage: https://github.com/ariedov/flutter_snaplist
6 |
7 | environment:
8 | sdk: ">=2.2.0 <3.0.0"
9 |
10 | dependencies:
11 | flutter:
12 | sdk: flutter
13 |
14 | dev_dependencies:
15 | flutter_test:
16 | sdk: flutter
17 |
18 | flutter:
19 |
20 |
--------------------------------------------------------------------------------
/snaplist.iml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/test/event_matchers.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_test/flutter_test.dart';
2 | import 'package:snaplist/snaplist_events.dart';
3 |
4 | class OffsetMatcher extends Matcher {
5 | final OffsetEvent expected;
6 | OffsetMatcher(this.expected);
7 |
8 | @override
9 | Description describe(Description description) =>
10 | description.add("did not match");
11 |
12 | @override
13 | bool matches(item, Map matchState) {
14 | OffsetEvent event = item;
15 | return expected.offset == event.offset &&
16 | expected.progress == event.progress &&
17 | expected.centerPosition == event.centerPosition &&
18 | expected.nextPosition == event.nextPosition;
19 | }
20 | }
21 |
22 | class SnipStartMatcher extends Matcher {
23 | final SnipStartEvent expected;
24 | SnipStartMatcher(this.expected);
25 |
26 | @override
27 | Description describe(Description description) =>
28 | description.add("did not match");
29 |
30 | @override
31 | bool matches(item, Map matchState) {
32 | SnipStartEvent event = item;
33 | return expected.offset == event.offset &&
34 | expected.progress == event.progress &&
35 | expected.targetOffset == event.targetOffset;
36 | }
37 | }
38 |
39 | class PositionChangeMatcher extends Matcher {
40 | final PositionChangeEvent expected;
41 | PositionChangeMatcher(this.expected);
42 |
43 | @override
44 | Description describe(Description description) => description.add("did not match");
45 |
46 | @override
47 | bool matches(item, Map matchState) {
48 | PositionChangeEvent event = item;
49 | return event.newPosition == expected.newPosition;
50 | }
51 | }
--------------------------------------------------------------------------------
/test/snaplist_controller_test.dart:
--------------------------------------------------------------------------------
1 | import 'package:snaplist/snaplist_controller.dart';
2 | import 'package:test_api/test_api.dart';
3 |
4 | void main() {
5 | test("position change test", () {
6 | var position;
7 |
8 | final controller = SnaplistController();
9 | controller.positionChanged = (newPosition) => {
10 | position = newPosition
11 | };
12 |
13 | controller.setPosition(1);
14 |
15 | expect(position, 1);
16 | });
17 |
18 | test("position change test multiple times", () {
19 | var position = [];
20 |
21 | final controller = SnaplistController();
22 | controller.positionChanged = (newPosition) => {
23 | position.add(newPosition)
24 | };
25 |
26 | controller.setPosition(1);
27 | controller.setPosition(2);
28 |
29 | expect(position.length, 2);
30 | expect(position[0], 1);
31 | expect(position[1], 2);
32 | });
33 | }
34 |
--------------------------------------------------------------------------------
/test/snaplist_test.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ui';
2 |
3 | import 'package:flutter_test/flutter_test.dart';
4 | import 'package:snaplist/snaplist_bloc.dart';
5 | import 'package:snaplist/snaplist_events.dart';
6 |
7 | import 'event_matchers.dart';
8 |
9 | void main() {
10 | test("full scroll test", () {
11 | final bloc = SnapListBloc(
12 | itemsCount: 10,
13 | separatorProvider: (index, data) => Size(10.0, 10.0),
14 | sizeProvider: (index, data) => Size(50.0, 50.0),
15 | swipeVelocity: 0.0);
16 |
17 | expect(bloc.offsetStream,
18 | emits(OffsetMatcher(OffsetEvent(-10.0, 40.0, 0, 1))));
19 |
20 | expect(bloc.snipStartStream,
21 | emits(SnipStartMatcher(SnipStartEvent(-10.0, 60.0, 40.0))));
22 |
23 | expect(bloc.positionStream,
24 | emits(PositionChangeMatcher(PositionChangeEvent(1))));
25 |
26 | bloc.swipeStartSink.add(StartEvent(0.0, 50.0));
27 | bloc.swipeUpdateSink.add(UpdateEvent(30.0, 10.0));
28 | bloc.swipeEndSink.add(EndEvent(Offset(1000.0, 1000.0)));
29 |
30 | bloc.snipFinishSink.add(SnipFinishEvent());
31 | });
32 |
33 | test("explicit item set test", () {
34 | final bloc = SnapListBloc(
35 | itemsCount: 10,
36 | separatorProvider: (index, data) => Size(10.0, 10.0),
37 | sizeProvider: (index, data) => Size(50.0, 50.0),
38 | swipeVelocity: 0.0);
39 |
40 | expect(bloc.explicitPositionChangeStream, emits(180));
41 |
42 | bloc.explicitPositionChangeSink.add(3);
43 | });
44 | }
45 |
--------------------------------------------------------------------------------