├── android ├── gradle.properties ├── app │ ├── src │ │ ├── main │ │ │ ├── res │ │ │ │ ├── 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 │ │ │ │ └── drawable │ │ │ │ │ └── launch_background.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── wilin │ │ │ │ │ └── union_tabs │ │ │ │ │ └── MainActivity.kt │ │ │ └── AndroidManifest.xml │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ └── profile │ │ │ └── AndroidManifest.xml │ └── build.gradle ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── settings.gradle └── build.gradle ├── ios ├── Flutter │ ├── Debug.xcconfig │ ├── Release.xcconfig │ └── AppFrameworkInfo.plist ├── Runner │ ├── AppDelegate.h │ ├── Assets.xcassets │ │ ├── LaunchImage.imageset │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ ├── README.md │ │ │ └── Contents.json │ │ └── AppIcon.appiconset │ │ │ ├── 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-1024x1024@1x.png │ │ │ ├── Icon-App-83.5x83.5@2x.png │ │ │ └── Contents.json │ ├── main.m │ ├── AppDelegate.m │ ├── Base.lproj │ │ ├── Main.storyboard │ │ └── LaunchScreen.storyboard │ └── Info.plist ├── Runner.xcworkspace │ └── contents.xcworkspacedata └── Runner.xcodeproj │ ├── project.xcworkspace │ └── contents.xcworkspacedata │ └── xcshareddata │ └── xcschemes │ └── Runner.xcscheme ├── example ├── ios │ ├── Flutter │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ └── AppFrameworkInfo.plist │ ├── Runner │ │ ├── AppDelegate.h │ │ ├── Assets.xcassets │ │ │ ├── LaunchImage.imageset │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ ├── README.md │ │ │ │ └── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ ├── 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-1024x1024@1x.png │ │ │ │ ├── Icon-App-83.5x83.5@2x.png │ │ │ │ └── Contents.json │ │ ├── main.m │ │ ├── AppDelegate.m │ │ ├── Base.lproj │ │ │ ├── Main.storyboard │ │ │ └── LaunchScreen.storyboard │ │ └── Info.plist │ ├── Runner.xcworkspace │ │ └── contents.xcworkspacedata │ └── Runner.xcodeproj │ │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ │ ├── xcshareddata │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ │ └── project.pbxproj ├── android │ ├── gradle.properties │ ├── app │ │ ├── src │ │ │ ├── main │ │ │ │ ├── res │ │ │ │ │ ├── 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 │ │ │ │ │ └── drawable │ │ │ │ │ │ └── launch_background.xml │ │ │ │ ├── kotlin │ │ │ │ │ └── com │ │ │ │ │ │ └── wilin │ │ │ │ │ │ └── example │ │ │ │ │ │ └── MainActivity.kt │ │ │ │ └── AndroidManifest.xml │ │ │ ├── debug │ │ │ │ └── AndroidManifest.xml │ │ │ └── profile │ │ │ │ └── AndroidManifest.xml │ │ └── build.gradle │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ ├── settings.gradle │ └── build.gradle ├── .metadata ├── README.md ├── test │ └── widget_test.dart ├── .gitignore ├── lib │ └── main.dart ├── pubspec.yaml └── pubspec.lock ├── screenshot └── screenshot.gif ├── lib ├── union_tabs.dart └── src │ ├── outer │ ├── union_outer_scroll_position.dart │ ├── union_outer_gesture_delegate.dart │ ├── union_outer_sliver.dart │ ├── union_outer_tab_view.dart │ └── union_outer_page_view.dart │ ├── inner │ ├── union_tabs_provider.dart │ ├── union_inner_tab_view.dart │ └── union_inner_page_view.dart │ └── notification │ ├── page_scroll_physics.dart │ ├── scroll_position.dart │ ├── page_controller.dart │ └── union_scroll_notification.dart ├── .metadata ├── test └── widget_test.dart ├── CHANGELOG.md ├── LICENSE ├── .gitignore ├── README.md ├── pubspec.yaml └── pubspec.lock /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | 3 | -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | 3 | android.enableR8=true 4 | -------------------------------------------------------------------------------- /screenshot/screenshot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/screenshot/screenshot.gif -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : FlutterAppDelegate 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /lib/union_tabs.dart: -------------------------------------------------------------------------------- 1 | export 'package:union_tabs/src/inner/union_inner_tab_view.dart'; 2 | export 'package:union_tabs/src/outer/union_outer_tab_view.dart'; 3 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : FlutterAppDelegate 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/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/wilin52/union_tabs/HEAD/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/wilin52/union_tabs/HEAD/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/wilin52/union_tabs/HEAD/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/wilin52/union_tabs/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/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/wilin52/union_tabs/HEAD/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/wilin52/union_tabs/HEAD/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/wilin52/union_tabs/HEAD/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/wilin52/union_tabs/HEAD/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/wilin52/union_tabs/HEAD/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/wilin52/union_tabs/HEAD/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/wilin52/union_tabs/HEAD/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/wilin52/union_tabs/HEAD/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/wilin52/union_tabs/HEAD/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/wilin52/union_tabs/HEAD/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/wilin52/union_tabs/HEAD/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/wilin52/union_tabs/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilin52/union_tabs/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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-4.10.2-all.zip 7 | -------------------------------------------------------------------------------- /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-4.10.2-all.zip 7 | -------------------------------------------------------------------------------- /.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: 2d2a1ffec95cc70a3218872a2cd3f8de4933c42f 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /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: 2d2a1ffec95cc70a3218872a2cd3f8de4933c42f 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /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/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. -------------------------------------------------------------------------------- /test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility that Flutter provides. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | void main() {} 9 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/wilin/union_tabs/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.wilin.union_tabs 2 | 3 | import android.os.Bundle 4 | 5 | import io.flutter.app.FlutterActivity 6 | import io.flutter.plugins.GeneratedPluginRegistrant 7 | 8 | class MainActivity: FlutterActivity() { 9 | override fun onCreate(savedInstanceState: Bundle?) { 10 | super.onCreate(savedInstanceState) 11 | GeneratedPluginRegistrant.registerWith(this) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/wilin/example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.wilin.example 2 | 3 | import android.os.Bundle 4 | 5 | import io.flutter.app.FlutterActivity 6 | import io.flutter.plugins.GeneratedPluginRegistrant 7 | 8 | class MainActivity: FlutterActivity() { 9 | override fun onCreate(savedInstanceState: Bundle?) { 10 | super.onCreate(savedInstanceState) 11 | GeneratedPluginRegistrant.registerWith(this) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.0.0+7 2 | 3 | * fix fast overscroll then back to the previous one. 4 | 5 | ## 1.0.0+5 6 | 7 | * support flutter 1.12, remove duplicate code. 8 | 9 | ## 1.0.0+4 10 | 11 | * fix nested TabBarView overscrolling then scroll reversely, the UI stuck. 12 | 13 | ## 1.0.0+3 14 | 15 | * add Demo Comments. 16 | 17 | ## 1.0.0+2 18 | 19 | * Clear flutter warnings. 20 | 21 | ## 1.0.0+1 22 | 23 | * A nested TabBarView overscroll event unites outer TabBarView scroll event. -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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/README.md: -------------------------------------------------------------------------------- 1 | # example 2 | 3 | A new Flutter application. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) 13 | 14 | For help getting started with Flutter, view our 15 | [online documentation](https://flutter.dev/docs), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.2.71' 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.2.1' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | jcenter() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.2.71' 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.2.1' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | jcenter() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019, Wilin 2 | All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | this software and associated documentation files (the "Software"), to deal in 6 | the Software without restriction, including without limitation the rights to 7 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | of the Software, and to permit persons to whom the Software is furnished to do 9 | so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR -------------------------------------------------------------------------------- /example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility that Flutter provides. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:example/main.dart'; 9 | import 'package:flutter/material.dart'; 10 | import 'package:flutter_test/flutter_test.dart'; 11 | 12 | void main() { 13 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 14 | // Build our app and trigger a frame. 15 | await tester.pumpWidget(MyApp()); 16 | 17 | // Verify that our counter starts at 0. 18 | expect(find.text('0'), findsOneWidget); 19 | expect(find.text('1'), findsNothing); 20 | 21 | // Tap the '+' icon and trigger a frame. 22 | await tester.tap(find.byIcon(Icons.add)); 23 | await tester.pump(); 24 | 25 | // Verify that our counter has incremented. 26 | expect(find.text('0'), findsNothing); 27 | expect(find.text('1'), findsOneWidget); 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /lib/src/outer/union_outer_scroll_position.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | import 'package:flutter/widgets.dart'; 3 | import 'package:union_tabs/src/notification/scroll_position.dart'; 4 | 5 | class UnionOuterScrollPosition extends PagePosition implements PageMetrics { 6 | UnionOuterScrollPosition({ 7 | ScrollPhysics physics, 8 | ScrollContext context, 9 | int initialPage = 0, 10 | bool keepPage = true, 11 | double viewportFraction = 1.0, 12 | ScrollPosition oldPosition, 13 | }) : super( 14 | physics: physics, 15 | context: context, 16 | initialPage: initialPage, 17 | keepPage: keepPage, 18 | viewportFraction: viewportFraction, 19 | oldPosition: oldPosition, 20 | ); 21 | 22 | double _overscrollOffset = -1; 23 | bool _overscroll = false; 24 | 25 | bool get overscroll => _overscroll; 26 | 27 | @mustCallSuper 28 | void onGestureDone() { 29 | _overscrollOffset = -1; 30 | _overscroll = false; 31 | } 32 | 33 | @override 34 | double setPixels(double newPixels) { 35 | if (!_overscroll) { 36 | return super.setPixels(newPixels); 37 | } else { 38 | double overscroll = newPixels + _overscrollOffset; 39 | if (overscroll != 0.0) { 40 | _overscroll = true; 41 | _overscrollOffset = overscroll; 42 | didOverscrollBy(overscroll); 43 | return overscroll; 44 | } 45 | } 46 | return super.setPixels(newPixels); 47 | } 48 | 49 | @override 50 | void dispose() { 51 | _overscroll = false; 52 | _overscrollOffset = -1; 53 | super.dispose(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | union_tabs 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/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 | $(DEVELOPMENT_LANGUAGE) 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 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .packages 28 | .pub-cache/ 29 | .pub/ 30 | /build/ 31 | 32 | # Android related 33 | **/android/**/gradle-wrapper.jar 34 | **/android/.gradle 35 | **/android/captures/ 36 | **/android/gradlew 37 | **/android/gradlew.bat 38 | **/android/local.properties 39 | **/android/**/GeneratedPluginRegistrant.java 40 | 41 | # iOS/XCode related 42 | **/ios/**/*.mode1v3 43 | **/ios/**/*.mode2v3 44 | **/ios/**/*.moved-aside 45 | **/ios/**/*.pbxuser 46 | **/ios/**/*.perspectivev3 47 | **/ios/**/*sync/ 48 | **/ios/**/.sconsign.dblite 49 | **/ios/**/.tags* 50 | **/ios/**/.vagrant/ 51 | **/ios/**/DerivedData/ 52 | **/ios/**/Icon? 53 | **/ios/**/Pods/ 54 | **/ios/**/.symlinks/ 55 | **/ios/**/profile 56 | **/ios/**/xcuserdata 57 | **/ios/.generated/ 58 | **/ios/Flutter/App.framework 59 | **/ios/Flutter/Flutter.framework 60 | **/ios/Flutter/Generated.xcconfig 61 | **/ios/Flutter/app.flx 62 | **/ios/Flutter/app.zip 63 | **/ios/Flutter/flutter_assets/ 64 | **/ios/Flutter/flutter_export_environment.sh 65 | **/ios/ServiceDefinitions.json 66 | **/ios/Runner/GeneratedPluginRegistrant.* 67 | 68 | # Exceptions to above rules. 69 | !**/ios/**/default.mode1v3 70 | !**/ios/**/default.mode2v3 71 | !**/ios/**/default.pbxuser 72 | !**/ios/**/default.perspectivev3 73 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 74 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # union_tabs 2 | 3 | Screenshot 4 | 5 | A nested TabBarView overscroll event unites outer TabBarView scroll event 6 | 7 | ## Getting Started 8 | 9 | **1.Install** 10 | ```yaml 11 | dependencies: 12 | union_tabs: ^1.0.0+7 13 | ``` 14 | 15 | **2.Import** 16 | 17 | ```dart 18 | import 'package:union_tabs/union_tabs.dart'; 19 | ``` 20 | 21 | **3.Usage** 22 | ``` 23 | @override 24 | Widget build(BuildContext context) { 25 | return Scaffold( 26 | appBar: AppBar( 27 | title: Text(widget.title), 28 | bottom: TabBar( 29 | controller: _controller, 30 | tabs: tabsText.map((it) => Tab(text: it)).toList()), 31 | ), 32 | body: UnionOuterTabBarView( /// outerTabBarView 33 | controller: _controller, 34 | children: _createTabContent(), 35 | )); 36 | } 37 | 38 | List _createTabContent() { 39 | List tabContent = List(); 40 | tabContent.add(Center(child: Text(tabsText[0]))); 41 | final child = Column( 42 | children: [ 43 | TabBar( 44 | labelColor: Colors.black, 45 | unselectedLabelColor: Colors.black45, 46 | controller: _childController, 47 | tabs: secondTabsText.map((it) => Tab(text: it)).toList()), 48 | Expanded( 49 | child: UnionInnerTabBarView( /// innerTabBarView 50 | controller: _childController, 51 | children: 52 | secondTabsText.map((it) => Center(child: Text(it))).toList()), 53 | ) 54 | ], 55 | ); 56 | tabContent.add(child); 57 | tabContent.add(Center(child: Text(tabsText[2]))); 58 | return tabContent; 59 | } 60 | ``` 61 | 62 | More detail see example: main.dart -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .packages 28 | .pub-cache/ 29 | .pub/ 30 | /build/ 31 | 32 | # Android related 33 | **/android/**/gradle-wrapper.jar 34 | **/android/.gradle 35 | **/android/captures/ 36 | **/android/gradlew 37 | **/android/gradlew.bat 38 | **/android/local.properties 39 | **/android/**/GeneratedPluginRegistrant.java 40 | 41 | # iOS/XCode related 42 | **/ios/**/*.mode1v3 43 | **/ios/**/*.mode2v3 44 | **/ios/**/*.moved-aside 45 | **/ios/**/*.pbxuser 46 | **/ios/**/*.perspectivev3 47 | **/ios/**/*sync/ 48 | **/ios/**/.sconsign.dblite 49 | **/ios/**/.tags* 50 | **/ios/**/.vagrant/ 51 | **/ios/**/DerivedData/ 52 | **/ios/**/Icon? 53 | **/ios/**/Pods/ 54 | **/ios/**/.symlinks/ 55 | **/ios/**/profile 56 | **/ios/**/xcuserdata 57 | **/ios/.generated/ 58 | **/ios/Flutter/App.framework 59 | **/ios/Flutter/Flutter.framework 60 | **/ios/Flutter/Generated.xcconfig 61 | **/ios/Flutter/app.flx 62 | **/ios/Flutter/app.zip 63 | **/ios/Flutter/flutter_assets/ 64 | **/ios/Flutter/flutter_export_environment.sh 65 | **/ios/ServiceDefinitions.json 66 | **/ios/Runner/GeneratedPluginRegistrant.* 67 | 68 | # Exceptions to above rules. 69 | !**/ios/**/default.mode1v3 70 | !**/ios/**/default.mode2v3 71 | !**/ios/**/default.pbxuser 72 | !**/ios/**/default.perspectivev3 73 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 74 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 9 | 13 | 20 | 24 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 9 | 13 | 20 | 24 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /lib/src/inner/union_tabs_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | 3 | enum ScrollDirection { left, right, none } 4 | 5 | class TabBarOverScroll with ChangeNotifier { 6 | bool overScroll = false; 7 | ScrollDirection direction = ScrollDirection.none; 8 | 9 | void setScrollDirection(ScrollDirection direction) { 10 | this.direction = direction; 11 | } 12 | 13 | void setOverScroll(bool overScroll) { 14 | this.overScroll = overScroll; 15 | notifyListeners(); 16 | } 17 | } 18 | 19 | class TabBarOverScrollStateProvider extends StatefulWidget { 20 | final WidgetBuilder builder; 21 | 22 | TabBarOverScrollStateProvider({Key key, this.builder}) : super(key: key); 23 | 24 | @override 25 | _TabBarOverScrollStateProviderState createState() => 26 | _TabBarOverScrollStateProviderState(); 27 | 28 | static TabBarOverScroll of(BuildContext context) { 29 | final scope = context 30 | .getElementForInheritedWidgetOfExactType<_OverScrollStateScope>() 31 | ?.widget as _OverScrollStateScope; 32 | return scope?.overScroll; 33 | } 34 | } 35 | 36 | class _TabBarOverScrollStateProviderState 37 | extends State { 38 | TabBarOverScroll _overScroll = TabBarOverScroll(); 39 | 40 | @override 41 | Widget build(BuildContext context) { 42 | return _OverScrollStateScope( 43 | overScroll: _overScroll, 44 | child: widget.builder(context), 45 | ); 46 | } 47 | 48 | @override 49 | void dispose() { 50 | _overScroll.dispose(); 51 | super.dispose(); 52 | } 53 | } 54 | 55 | class _OverScrollStateScope extends InheritedWidget { 56 | final TabBarOverScroll overScroll; 57 | 58 | const _OverScrollStateScope({Key key, this.overScroll, Widget child}) 59 | : super(key: key, child: child); 60 | 61 | @override 62 | bool updateShouldNotify(InheritedWidget oldWidget) { 63 | return false; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /lib/src/notification/page_scroll_physics.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | 3 | import 'scroll_position.dart'; 4 | 5 | class UnionPageScrollPhysics extends ScrollPhysics { 6 | /// Creates physics for a [UnionInnerPageView]. 7 | const UnionPageScrollPhysics({ScrollPhysics parent}) : super(parent: parent); 8 | 9 | @override 10 | UnionPageScrollPhysics applyTo(ScrollPhysics ancestor) { 11 | return UnionPageScrollPhysics(parent: buildParent(ancestor)); 12 | } 13 | 14 | double _getPage(ScrollMetrics position) { 15 | if (position is PagePosition) return position.page; 16 | return position.pixels / position.viewportDimension; 17 | } 18 | 19 | double _getPixels(ScrollMetrics position, double page) { 20 | if (position is PagePosition) return position.getPixelsFromPage(page); 21 | return page * position.viewportDimension; 22 | } 23 | 24 | double _getTargetPixels( 25 | ScrollMetrics position, Tolerance tolerance, double velocity) { 26 | double page = _getPage(position); 27 | if (velocity < -tolerance.velocity) 28 | page -= 0.5; 29 | else if (velocity > tolerance.velocity) page += 0.5; 30 | return _getPixels(position, page.roundToDouble()); 31 | } 32 | 33 | @override 34 | Simulation createBallisticSimulation( 35 | ScrollMetrics position, double velocity) { 36 | // If we're out of range and not headed back in range, defer to the parent 37 | // ballistics, which should put us back in range at a page boundary. 38 | if ((velocity <= 0.0 && position.pixels <= position.minScrollExtent) || 39 | (velocity >= 0.0 && position.pixels >= position.maxScrollExtent)) 40 | return super.createBallisticSimulation(position, velocity); 41 | final Tolerance tolerance = this.tolerance; 42 | final double target = _getTargetPixels(position, tolerance, velocity); 43 | if (target != position.pixels) 44 | return ScrollSpringSimulation(spring, position.pixels, target, velocity, 45 | tolerance: tolerance); 46 | return null; 47 | } 48 | 49 | @override 50 | bool get allowImplicitScrolling => false; 51 | } 52 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion 28 30 | 31 | sourceSets { 32 | main.java.srcDirs += 'src/main/kotlin' 33 | } 34 | 35 | lintOptions { 36 | disable 'InvalidPackage' 37 | } 38 | 39 | defaultConfig { 40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 41 | applicationId "com.wilin.union_tabs" 42 | minSdkVersion 16 43 | targetSdkVersion 28 44 | versionCode flutterVersionCode.toInteger() 45 | versionName flutterVersionName 46 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 47 | } 48 | 49 | buildTypes { 50 | release { 51 | // TODO: Add your own signing config for the release build. 52 | // Signing with the debug keys for now, so `flutter run --release` works. 53 | signingConfig signingConfigs.debug 54 | } 55 | } 56 | } 57 | 58 | flutter { 59 | source '../..' 60 | } 61 | 62 | dependencies { 63 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 64 | testImplementation 'junit:junit:4.12' 65 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 66 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 67 | } 68 | -------------------------------------------------------------------------------- /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 plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion 28 30 | 31 | sourceSets { 32 | main.java.srcDirs += 'src/main/kotlin' 33 | } 34 | 35 | lintOptions { 36 | disable 'InvalidPackage' 37 | } 38 | 39 | defaultConfig { 40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 41 | applicationId "com.wilin.example" 42 | minSdkVersion 16 43 | targetSdkVersion 28 44 | versionCode flutterVersionCode.toInteger() 45 | versionName flutterVersionName 46 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 47 | } 48 | 49 | buildTypes { 50 | release { 51 | // TODO: Add your own signing config for the release build. 52 | // Signing with the debug keys for now, so `flutter run --release` works. 53 | signingConfig signingConfigs.debug 54 | } 55 | } 56 | } 57 | 58 | flutter { 59 | source '../..' 60 | } 61 | 62 | dependencies { 63 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 64 | testImplementation 'junit:junit:4.12' 65 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 66 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 67 | } 68 | -------------------------------------------------------------------------------- /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/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/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:union_tabs/union_tabs.dart'; 3 | 4 | void main() => runApp(MyApp()); 5 | 6 | class MyApp extends StatelessWidget { 7 | @override 8 | Widget build(BuildContext context) { 9 | return MaterialApp( 10 | title: 'Flutter Demo', 11 | theme: ThemeData( 12 | primarySwatch: Colors.blue, 13 | ), 14 | home: MyHomePage(title: 'Flutter Demo Home Page'), 15 | ); 16 | } 17 | } 18 | 19 | class MyHomePage extends StatefulWidget { 20 | MyHomePage({Key key, this.title}) : super(key: key); 21 | final String title; 22 | 23 | @override 24 | _MyHomePageState createState() => _MyHomePageState(); 25 | } 26 | 27 | class _MyHomePageState extends State with TickerProviderStateMixin { 28 | List tabsText = ["一", "二", "三"]; 29 | List secondTabsText = ["one", "two", "three"]; 30 | TabController _controller; 31 | TabController _childController; 32 | 33 | @override 34 | void initState() { 35 | _controller = TabController(length: tabsText.length, vsync: this); 36 | _childController = 37 | TabController(length: secondTabsText.length, vsync: this); 38 | super.initState(); 39 | } 40 | 41 | @override 42 | Widget build(BuildContext context) { 43 | return Scaffold( 44 | appBar: AppBar( 45 | title: Text(widget.title), 46 | bottom: TabBar( 47 | controller: _controller, 48 | tabs: tabsText.map((it) => Tab(text: it)).toList()), 49 | ), 50 | 51 | /// outer tabTarView which receives OverscrollNotification of inner tabBarView. 52 | body: UnionOuterTabBarView( 53 | controller: _controller, 54 | children: _createTabContent(), 55 | )); 56 | } 57 | 58 | List _createTabContent() { 59 | List tabContent = List(); 60 | tabContent.add(Center(child: Text(tabsText[0]))); 61 | final child = Column( 62 | children: [ 63 | TabBar( 64 | labelColor: Colors.black, 65 | unselectedLabelColor: Colors.black45, 66 | controller: _childController, 67 | tabs: secondTabsText.map((it) => Tab(text: it)).toList()), 68 | Expanded( 69 | /// convert inner tabBarView OverscrollNotification to UnionOverscrollNotification to notify outer tabBarView. 70 | child: UnionInnerTabBarView( 71 | controller: _childController, 72 | children: 73 | secondTabsText.map((it) => Center(child: Text(it))).toList()), 74 | ) 75 | ], 76 | ); 77 | tabContent.add(child); 78 | tabContent.add(Center(child: Text(tabsText[2]))); 79 | return tabContent; 80 | } 81 | 82 | @override 83 | void dispose() { 84 | _controller.dispose(); 85 | _childController.dispose(); 86 | super.dispose(); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /lib/src/outer/union_outer_gesture_delegate.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/gestures.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter/widgets.dart'; 4 | import 'package:union_tabs/src/notification/union_scroll_notification.dart'; 5 | 6 | import 'union_outer_page_view.dart'; 7 | 8 | class UnionOuterGestureDelegate { 9 | UnionOuterPageController pageController; 10 | TabController tabController; 11 | 12 | UnionOuterGestureDelegate( 13 | {@required this.pageController, @required this.tabController}); 14 | 15 | /// 用于手势下发。 16 | /// record the gesture. 17 | Drag _drag; 18 | 19 | /// 将处理UnionScrollNotification. 20 | bool handleUnionScrollNotification( 21 | BuildContext context, UnionScrollNotification notification) { 22 | if (tabController.index != notification.index) { 23 | return false; 24 | } 25 | 26 | if (notification is UnionScrollStartNotification) { 27 | _drag = pageController.position.drag(notification.dragDetails, () { 28 | _drag = null; 29 | }); 30 | } else if (notification is UnionOverscrollNotification) { 31 | if (_drag == null) { 32 | return true; 33 | } 34 | 35 | /// 计算用户滑动 36 | /// update the offset, to update the indicator's position 37 | MediaQueryData data = MediaQuery.of(context); 38 | tabController.offset = 39 | (tabController.offset + notification.overscroll / data.size.width) 40 | .clamp(-1.0, 1.0); 41 | 42 | if (notification.dragDetails != null) { 43 | /// update the viewpager's position 44 | _drag.update(notification.dragDetails); 45 | } 46 | } else if (notification is UnionScrollEndNotification) { 47 | _drag?.cancel(); 48 | _drag = null; 49 | double dx = notification.dragDetails?.velocity?.pixelsPerSecond?.dx ?? 0; 50 | if (dx != 0) { 51 | int offset = dx > 0 ? -1 : 1; 52 | int index = tabController.index + offset; 53 | if (index < 0) index = 0; 54 | if (index >= tabController.length) index = tabController.length - 1; 55 | 56 | tabController.animateTo(index, duration: Duration(milliseconds: 500)); 57 | } 58 | } else if (notification is UnionScrollUpdateNotification) { 59 | if (_drag != null && notification.dragDetails != null) { 60 | /// update the viewpager's position 61 | _drag.update(notification.dragDetails); 62 | 63 | /// 计算用户滑动 64 | /// update the offset, to update the indicator's position 65 | MediaQueryData data = MediaQuery.of(context); 66 | tabController.offset = (tabController.offset + 67 | notification.dragDetails.delta.dx / data.size.width) 68 | .clamp(-1.0, 1.0); 69 | } 70 | } 71 | return true; 72 | } 73 | 74 | void dispose() { 75 | pageController = null; 76 | tabController = null; 77 | _drag?.cancel(); 78 | _drag = null; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: example 2 | description: A new Flutter application. 3 | 4 | # The following defines the version and build number for your application. 5 | # A version number is three numbers separated by dots, like 1.2.43 6 | # followed by an optional build number separated by a +. 7 | # Both the version and the builder number may be overridden in flutter 8 | # build by specifying --build-name and --build-number, respectively. 9 | # In Android, build-name is used as versionName while build-number used as versionCode. 10 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 11 | # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. 12 | # Read more about iOS versioning at 13 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 14 | version: 1.0.0+1 15 | 16 | environment: 17 | sdk: '>=2.10.0 <3.0.0' 18 | 19 | dependencies: 20 | flutter: 21 | sdk: flutter 22 | union_tabs: 23 | path: ../../union_tabs 24 | # The following adds the Cupertino Icons font to your application. 25 | # Use with the CupertinoIcons class for iOS style icons. 26 | cupertino_icons: ^1.0.0 27 | 28 | dev_dependencies: 29 | flutter_test: 30 | sdk: flutter 31 | 32 | 33 | # For information on the generic Dart part of this file, see the 34 | # following page: https://dart.dev/tools/pub/pubspec 35 | 36 | # The following section is specific to Flutter. 37 | flutter: 38 | 39 | # The following line ensures that the Material Icons font is 40 | # included with your application, so that you can use the icons in 41 | # the material Icons class. 42 | uses-material-design: true 43 | 44 | # To add assets to your application, add an assets section, like this: 45 | # assets: 46 | # - images/a_dot_burr.jpeg 47 | # - images/a_dot_ham.jpeg 48 | 49 | # An image asset can refer to one or more resolution-specific "variants", see 50 | # https://flutter.dev/assets-and-images/#resolution-aware. 51 | 52 | # For details regarding adding assets from package dependencies, see 53 | # https://flutter.dev/assets-and-images/#from-packages 54 | 55 | # To add custom fonts to your application, add a fonts section here, 56 | # in this "flutter" section. Each entry in this list should have a 57 | # "family" key with the font family name, and a "fonts" key with a 58 | # list giving the asset and other descriptors for the font. For 59 | # example: 60 | # fonts: 61 | # - family: Schyler 62 | # fonts: 63 | # - asset: fonts/Schyler-Regular.ttf 64 | # - asset: fonts/Schyler-Italic.ttf 65 | # style: italic 66 | # - family: Trajan Pro 67 | # fonts: 68 | # - asset: fonts/TrajanPro.ttf 69 | # - asset: fonts/TrajanPro_Bold.ttf 70 | # weight: 700 71 | # 72 | # For details regarding fonts from package dependencies, 73 | # see https://flutter.dev/custom-fonts/#from-packages 74 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: union_tabs 2 | description: A nested TabBarView overscroll event unites outer TabBarView scroll event. 3 | 4 | 5 | # The following defines the version and build number for your application. 6 | # A version number is three numbers separated by dots, like 1.2.43 7 | # followed by an optional build number separated by a +. 8 | # Both the version and the builder number may be overridden in flutter 9 | # build by specifying --build-name and --build-number, respectively. 10 | # In Android, build-name is used as versionName while build-number used as versionCode. 11 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 12 | # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. 13 | # Read more about iOS versioning at 14 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 15 | version: 1.0.0+7 16 | author: wilin 17 | homepage: https://github.com/wilin52/union_tabs 18 | 19 | environment: 20 | sdk: '>=2.10.0 <3.0.0' 21 | 22 | dependencies: 23 | flutter: 24 | sdk: flutter 25 | 26 | # The following adds the Cupertino Icons font to your application. 27 | # Use with the CupertinoIcons class for iOS style icons. 28 | cupertino_icons: ^1.0.0 29 | 30 | 31 | dev_dependencies: 32 | flutter_test: 33 | sdk: flutter 34 | 35 | 36 | # For information on the generic Dart part of this file, see the 37 | # following page: https://dart.dev/tools/pub/pubspec 38 | 39 | # The following section is specific to Flutter. 40 | flutter: 41 | 42 | # The following line ensures that the Material Icons font is 43 | # included with your application, so that you can use the icons in 44 | # the material Icons class. 45 | uses-material-design: true 46 | 47 | # To add assets to your application, add an assets section, like this: 48 | # assets: 49 | # - images/a_dot_burr.jpeg 50 | # - images/a_dot_ham.jpeg 51 | 52 | # An image asset can refer to one or more resolution-specific "variants", see 53 | # https://flutter.dev/assets-and-images/#resolution-aware. 54 | 55 | # For details regarding adding assets from package dependencies, see 56 | # https://flutter.dev/assets-and-images/#from-packages 57 | 58 | # To add custom fonts to your application, add a fonts section here, 59 | # in this "flutter" section. Each entry in this list should have a 60 | # "family" key with the font family name, and a "fonts" key with a 61 | # list giving the asset and other descriptors for the font. For 62 | # example: 63 | # fonts: 64 | # - family: Schyler 65 | # fonts: 66 | # - asset: fonts/Schyler-Regular.ttf 67 | # - asset: fonts/Schyler-Italic.ttf 68 | # style: italic 69 | # - family: Trajan Pro 70 | # fonts: 71 | # - asset: fonts/TrajanPro.ttf 72 | # - asset: fonts/TrajanPro_Bold.ttf 73 | # weight: 700 74 | # 75 | # For details regarding fonts from package dependencies, 76 | # see https://flutter.dev/custom-fonts/#from-packages 77 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /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.5.0-nullsafety.1" 11 | boolean_selector: 12 | dependency: transitive 13 | description: 14 | name: boolean_selector 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "2.1.0-nullsafety.1" 18 | characters: 19 | dependency: transitive 20 | description: 21 | name: characters 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "1.1.0-nullsafety.3" 25 | charcode: 26 | dependency: transitive 27 | description: 28 | name: charcode 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "1.2.0-nullsafety.1" 32 | clock: 33 | dependency: transitive 34 | description: 35 | name: clock 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "1.1.0-nullsafety.1" 39 | collection: 40 | dependency: transitive 41 | description: 42 | name: collection 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "1.15.0-nullsafety.3" 46 | cupertino_icons: 47 | dependency: "direct main" 48 | description: 49 | name: cupertino_icons 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "1.0.0" 53 | fake_async: 54 | dependency: transitive 55 | description: 56 | name: fake_async 57 | url: "https://pub.dartlang.org" 58 | source: hosted 59 | version: "1.2.0-nullsafety.1" 60 | flutter: 61 | dependency: "direct main" 62 | description: flutter 63 | source: sdk 64 | version: "0.0.0" 65 | flutter_test: 66 | dependency: "direct dev" 67 | description: flutter 68 | source: sdk 69 | version: "0.0.0" 70 | matcher: 71 | dependency: transitive 72 | description: 73 | name: matcher 74 | url: "https://pub.dartlang.org" 75 | source: hosted 76 | version: "0.12.10-nullsafety.1" 77 | meta: 78 | dependency: transitive 79 | description: 80 | name: meta 81 | url: "https://pub.dartlang.org" 82 | source: hosted 83 | version: "1.3.0-nullsafety.3" 84 | path: 85 | dependency: transitive 86 | description: 87 | name: path 88 | url: "https://pub.dartlang.org" 89 | source: hosted 90 | version: "1.8.0-nullsafety.1" 91 | sky_engine: 92 | dependency: transitive 93 | description: flutter 94 | source: sdk 95 | version: "0.0.99" 96 | source_span: 97 | dependency: transitive 98 | description: 99 | name: source_span 100 | url: "https://pub.dartlang.org" 101 | source: hosted 102 | version: "1.8.0-nullsafety.2" 103 | stack_trace: 104 | dependency: transitive 105 | description: 106 | name: stack_trace 107 | url: "https://pub.dartlang.org" 108 | source: hosted 109 | version: "1.10.0-nullsafety.1" 110 | stream_channel: 111 | dependency: transitive 112 | description: 113 | name: stream_channel 114 | url: "https://pub.dartlang.org" 115 | source: hosted 116 | version: "2.1.0-nullsafety.1" 117 | string_scanner: 118 | dependency: transitive 119 | description: 120 | name: string_scanner 121 | url: "https://pub.dartlang.org" 122 | source: hosted 123 | version: "1.1.0-nullsafety.1" 124 | term_glyph: 125 | dependency: transitive 126 | description: 127 | name: term_glyph 128 | url: "https://pub.dartlang.org" 129 | source: hosted 130 | version: "1.2.0-nullsafety.1" 131 | test_api: 132 | dependency: transitive 133 | description: 134 | name: test_api 135 | url: "https://pub.dartlang.org" 136 | source: hosted 137 | version: "0.2.19-nullsafety.2" 138 | typed_data: 139 | dependency: transitive 140 | description: 141 | name: typed_data 142 | url: "https://pub.dartlang.org" 143 | source: hosted 144 | version: "1.3.0-nullsafety.3" 145 | vector_math: 146 | dependency: transitive 147 | description: 148 | name: vector_math 149 | url: "https://pub.dartlang.org" 150 | source: hosted 151 | version: "2.1.0-nullsafety.3" 152 | sdks: 153 | dart: ">=2.10.0 <2.11.0" 154 | -------------------------------------------------------------------------------- /example/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.5.0-nullsafety.1" 11 | boolean_selector: 12 | dependency: transitive 13 | description: 14 | name: boolean_selector 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "2.1.0-nullsafety.1" 18 | characters: 19 | dependency: transitive 20 | description: 21 | name: characters 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "1.1.0-nullsafety.3" 25 | charcode: 26 | dependency: transitive 27 | description: 28 | name: charcode 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "1.2.0-nullsafety.1" 32 | clock: 33 | dependency: transitive 34 | description: 35 | name: clock 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "1.1.0-nullsafety.1" 39 | collection: 40 | dependency: transitive 41 | description: 42 | name: collection 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "1.15.0-nullsafety.3" 46 | cupertino_icons: 47 | dependency: "direct main" 48 | description: 49 | name: cupertino_icons 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "1.0.0" 53 | fake_async: 54 | dependency: transitive 55 | description: 56 | name: fake_async 57 | url: "https://pub.dartlang.org" 58 | source: hosted 59 | version: "1.2.0-nullsafety.1" 60 | flutter: 61 | dependency: "direct main" 62 | description: flutter 63 | source: sdk 64 | version: "0.0.0" 65 | flutter_test: 66 | dependency: "direct dev" 67 | description: flutter 68 | source: sdk 69 | version: "0.0.0" 70 | matcher: 71 | dependency: transitive 72 | description: 73 | name: matcher 74 | url: "https://pub.dartlang.org" 75 | source: hosted 76 | version: "0.12.10-nullsafety.1" 77 | meta: 78 | dependency: transitive 79 | description: 80 | name: meta 81 | url: "https://pub.dartlang.org" 82 | source: hosted 83 | version: "1.3.0-nullsafety.3" 84 | path: 85 | dependency: transitive 86 | description: 87 | name: path 88 | url: "https://pub.dartlang.org" 89 | source: hosted 90 | version: "1.8.0-nullsafety.1" 91 | sky_engine: 92 | dependency: transitive 93 | description: flutter 94 | source: sdk 95 | version: "0.0.99" 96 | source_span: 97 | dependency: transitive 98 | description: 99 | name: source_span 100 | url: "https://pub.dartlang.org" 101 | source: hosted 102 | version: "1.8.0-nullsafety.2" 103 | stack_trace: 104 | dependency: transitive 105 | description: 106 | name: stack_trace 107 | url: "https://pub.dartlang.org" 108 | source: hosted 109 | version: "1.10.0-nullsafety.1" 110 | stream_channel: 111 | dependency: transitive 112 | description: 113 | name: stream_channel 114 | url: "https://pub.dartlang.org" 115 | source: hosted 116 | version: "2.1.0-nullsafety.1" 117 | string_scanner: 118 | dependency: transitive 119 | description: 120 | name: string_scanner 121 | url: "https://pub.dartlang.org" 122 | source: hosted 123 | version: "1.1.0-nullsafety.1" 124 | term_glyph: 125 | dependency: transitive 126 | description: 127 | name: term_glyph 128 | url: "https://pub.dartlang.org" 129 | source: hosted 130 | version: "1.2.0-nullsafety.1" 131 | test_api: 132 | dependency: transitive 133 | description: 134 | name: test_api 135 | url: "https://pub.dartlang.org" 136 | source: hosted 137 | version: "0.2.19-nullsafety.2" 138 | typed_data: 139 | dependency: transitive 140 | description: 141 | name: typed_data 142 | url: "https://pub.dartlang.org" 143 | source: hosted 144 | version: "1.3.0-nullsafety.3" 145 | union_tabs: 146 | dependency: "direct main" 147 | description: 148 | path: ".." 149 | relative: true 150 | source: path 151 | version: "1.0.0+5" 152 | vector_math: 153 | dependency: transitive 154 | description: 155 | name: vector_math 156 | url: "https://pub.dartlang.org" 157 | source: hosted 158 | version: "2.1.0-nullsafety.3" 159 | sdks: 160 | dart: ">=2.10.0 <2.11.0" 161 | -------------------------------------------------------------------------------- /lib/src/outer/union_outer_sliver.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | import 'package:union_tabs/src/notification/union_scroll_notification.dart'; 3 | 4 | /// A delegate that supplies children for slivers using a builder callback. 5 | /// [SliverChildListDelegate] override build, intend to send [UnionOverscrollNotification]. 6 | class UnionSliverChildListDelegate extends SliverChildListDelegate { 7 | UnionSliverChildListDelegate( 8 | List children, { 9 | bool addAutomaticKeepAlives = true, 10 | bool addRepaintBoundaries = true, 11 | bool addSemanticIndexes = true, 12 | int semanticIndexOffset = 0, 13 | }) : super(children, 14 | addAutomaticKeepAlives: addAutomaticKeepAlives, 15 | addRepaintBoundaries: addRepaintBoundaries, 16 | addSemanticIndexes: addSemanticIndexes, 17 | semanticIndexOffset: semanticIndexOffset); 18 | 19 | @override 20 | Widget build(BuildContext context, int index) { 21 | /// convert scrollNotification into UnionScrollNotification 22 | /// convert scrollNotification into UnionScrollNotification 23 | return UnionScrollChild( 24 | index: index, 25 | child: super.build(context, index), 26 | ); 27 | } 28 | } 29 | 30 | /// A delegate that supplies children for slivers using a builder callback. 31 | /// [SliverChildBuilderDelegate] override build, intend to send [UnionOverscrollNotification]. 32 | class UnionSliverChildBuilderDelegate extends SliverChildBuilderDelegate { 33 | UnionSliverChildBuilderDelegate( 34 | IndexedWidgetBuilder builder, { 35 | ChildIndexGetter findChildIndexCallback, 36 | int childCount, 37 | bool addAutomaticKeepAlives = true, 38 | bool addRepaintBoundaries = true, 39 | bool addSemanticIndexes = true, 40 | int semanticIndexOffset = 0, 41 | }) : super(builder, 42 | findChildIndexCallback: findChildIndexCallback, 43 | addAutomaticKeepAlives: addAutomaticKeepAlives, 44 | addRepaintBoundaries: addRepaintBoundaries, 45 | addSemanticIndexes: addSemanticIndexes, 46 | semanticIndexOffset: semanticIndexOffset); 47 | 48 | @override 49 | Widget build(BuildContext context, int index) { 50 | /// convert scrollNotification into UnionScrollNotification 51 | return UnionScrollChild( 52 | child: super.build(context, index), 53 | index: index, 54 | ); 55 | } 56 | } 57 | 58 | class UnionScrollChild extends StatefulWidget { 59 | final Widget child; 60 | final int index; 61 | 62 | UnionScrollChild({Key key, @required this.child, @required this.index}) 63 | : super(key: key); 64 | 65 | @override 66 | _UnionScrollChildState createState() => _UnionScrollChildState(); 67 | } 68 | 69 | class _UnionScrollChildState extends State { 70 | @override 71 | Widget build(BuildContext context) { 72 | return NotificationListener( 73 | onNotification: (ScrollNotification notification) { 74 | return handleScrollNotification( 75 | context: context, 76 | notification: notification, 77 | index: widget.index); 78 | }, 79 | child: widget.child ?? Container()); 80 | } 81 | 82 | /// 缓存startNotification, 当开始滑动的时候发送到上层[UnionTabBarView]; 83 | /// when overscroll begins, firstly send a startNotification. 84 | UnionScrollStartNotification _scrollStartNotification; 85 | 86 | /// 标记是否是边界滑动,如果是,处理ScrollEnd, 否则,不将滑动结束通知到上层[UnionTabBarView]. 87 | /// if true, when scroll ends, send a endNotification. 88 | bool _overscroll = false; 89 | 90 | bool handleScrollNotification( 91 | {@required BuildContext context, 92 | @required ScrollNotification notification, 93 | @required int index}) { 94 | if (!defaultScrollNotificationPredicate(notification)) { 95 | return false; 96 | } 97 | 98 | if (notification is OverscrollNotification) { 99 | /// 发送startNotification 100 | /// dispatch a startNotification. 101 | if (_scrollStartNotification != null) { 102 | _scrollStartNotification.dispatch(context); 103 | } 104 | 105 | bool overscroll = true; 106 | if (!_overscroll) { 107 | setState(() { 108 | _overscroll = overscroll; 109 | }); 110 | } 111 | 112 | _scrollStartNotification = null; 113 | 114 | UnionOverscrollNotification.merge( 115 | notification: notification, index: index) 116 | .dispatch(context); 117 | } else if (notification is ScrollEndNotification) { 118 | /// 发送endNotification 119 | /// dispatch a endNotification. 120 | if (_overscroll) { 121 | UnionScrollEndNotification.merge( 122 | notification: notification, index: index) 123 | .dispatch(context); 124 | } 125 | 126 | bool overscroll = false; 127 | if (_overscroll) { 128 | setState(() { 129 | _overscroll = overscroll; 130 | }); 131 | } 132 | _scrollStartNotification = null; 133 | } else if (notification is ScrollStartNotification) { 134 | _scrollStartNotification = UnionScrollStartNotification.merge( 135 | notification: notification, index: index); 136 | } else if (notification is ScrollUpdateNotification) { 137 | if (_overscroll) { 138 | UnionScrollUpdateNotification.merge( 139 | notification: notification, index: index) 140 | .dispatch(context); 141 | } 142 | } 143 | 144 | return false; 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /lib/src/notification/scroll_position.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | import 'dart:math' as math; 6 | 7 | import 'package:flutter/foundation.dart' show precisionErrorTolerance; 8 | import 'package:flutter/rendering.dart'; 9 | import 'package:flutter/widgets.dart'; 10 | 11 | class PagePosition extends ScrollPositionWithSingleContext 12 | implements PageMetrics { 13 | PagePosition({ 14 | ScrollPhysics physics, 15 | ScrollContext context, 16 | this.initialPage = 0, 17 | bool keepPage = true, 18 | double viewportFraction = 1.0, 19 | ScrollPosition oldPosition, 20 | }) : assert(initialPage != null), 21 | assert(keepPage != null), 22 | assert(viewportFraction != null), 23 | assert(viewportFraction > 0.0), 24 | _viewportFraction = viewportFraction, 25 | _pageToUseOnStartup = initialPage.toDouble(), 26 | super( 27 | physics: physics, 28 | context: context, 29 | initialPixels: null, 30 | keepScrollOffset: keepPage, 31 | oldPosition: oldPosition, 32 | ); 33 | 34 | final int initialPage; 35 | double _pageToUseOnStartup; 36 | 37 | @override 38 | double get viewportFraction => _viewportFraction; 39 | double _viewportFraction; 40 | 41 | set viewportFraction(double value) { 42 | if (_viewportFraction == value) return; 43 | final double oldPage = page; 44 | _viewportFraction = value; 45 | if (oldPage != null) forcePixels(getPixelsFromPage(oldPage)); 46 | } 47 | 48 | // The amount of offset that will be added to [minScrollExtent] and subtracted 49 | // from [maxScrollExtent], such that every page will properly snap to the center 50 | // of the viewport when viewportFraction is greater than 1. 51 | // 52 | // The value is 0 if viewportFraction is less than or equal to 1, larger than 0 53 | // otherwise. 54 | double get _initialPageOffset => 55 | math.max(0, viewportDimension * (viewportFraction - 1) / 2); 56 | 57 | double getPageFromPixels(double pixels, double viewportDimension) { 58 | final double actual = math.max(0.0, pixels - _initialPageOffset) / 59 | math.max(1.0, viewportDimension * viewportFraction); 60 | final double round = actual.roundToDouble(); 61 | if ((actual - round).abs() < precisionErrorTolerance) { 62 | return round; 63 | } 64 | return actual; 65 | } 66 | 67 | double getPixelsFromPage(double page) { 68 | return page * viewportDimension * viewportFraction + _initialPageOffset; 69 | } 70 | 71 | @override 72 | double get page { 73 | assert( 74 | pixels == null || (minScrollExtent != null && maxScrollExtent != null), 75 | 'Page value is only available after content dimensions are established.', 76 | ); 77 | return pixels == null 78 | ? null 79 | : getPageFromPixels( 80 | pixels.clamp(minScrollExtent, maxScrollExtent) as double, 81 | viewportDimension); 82 | } 83 | 84 | @override 85 | void saveScrollOffset() { 86 | PageStorage.of(context.storageContext)?.writeState( 87 | context.storageContext, getPageFromPixels(pixels, viewportDimension)); 88 | } 89 | 90 | @override 91 | void restoreScrollOffset() { 92 | if (pixels == null) { 93 | final double value = PageStorage.of(context.storageContext) 94 | ?.readState(context.storageContext) as double; 95 | if (value != null) _pageToUseOnStartup = value; 96 | } 97 | } 98 | 99 | @override 100 | void saveOffset() { 101 | context.saveOffset(getPageFromPixels(pixels, viewportDimension)); 102 | } 103 | 104 | @override 105 | void restoreOffset(double offset, {bool initialRestore = false}) { 106 | assert(initialRestore != null); 107 | assert(offset != null); 108 | if (initialRestore) { 109 | _pageToUseOnStartup = offset; 110 | } else { 111 | jumpTo(getPixelsFromPage(offset)); 112 | } 113 | } 114 | 115 | @override 116 | bool applyViewportDimension(double viewportDimension) { 117 | final double oldViewportDimensions = this.viewportDimension; 118 | if (viewportDimension == oldViewportDimensions) { 119 | return true; 120 | } 121 | final bool result = super.applyViewportDimension(viewportDimension); 122 | final double oldPixels = pixels; 123 | final double page = (oldPixels == null || oldViewportDimensions == 0.0) 124 | ? _pageToUseOnStartup 125 | : getPageFromPixels(oldPixels, oldViewportDimensions); 126 | final double newPixels = getPixelsFromPage(page); 127 | 128 | if (newPixels != oldPixels) { 129 | correctPixels(newPixels); 130 | return false; 131 | } 132 | return result; 133 | } 134 | 135 | @override 136 | bool applyContentDimensions(double minScrollExtent, double maxScrollExtent) { 137 | final double newMinScrollExtent = minScrollExtent + _initialPageOffset; 138 | return super.applyContentDimensions( 139 | newMinScrollExtent, 140 | math.max(newMinScrollExtent, maxScrollExtent - _initialPageOffset), 141 | ); 142 | } 143 | 144 | @override 145 | PageMetrics copyWith({ 146 | double minScrollExtent, 147 | double maxScrollExtent, 148 | double pixels, 149 | double viewportDimension, 150 | AxisDirection axisDirection, 151 | double viewportFraction, 152 | }) { 153 | return PageMetrics( 154 | minScrollExtent: minScrollExtent ?? this.minScrollExtent, 155 | maxScrollExtent: maxScrollExtent ?? this.maxScrollExtent, 156 | pixels: pixels ?? this.pixels, 157 | viewportDimension: viewportDimension ?? this.viewportDimension, 158 | axisDirection: axisDirection ?? this.axisDirection, 159 | viewportFraction: viewportFraction ?? this.viewportFraction, 160 | ); 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /lib/src/notification/page_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | 3 | import 'scroll_position.dart'; 4 | 5 | class UnionPageController extends ScrollController { 6 | /// Creates a page controller. 7 | /// 8 | /// The [initialPage], [keepPage], and [viewportFraction] arguments must not be null. 9 | UnionPageController({ 10 | this.initialPage = 0, 11 | this.keepPage = true, 12 | this.viewportFraction = 1.0, 13 | }) : assert(initialPage != null), 14 | assert(keepPage != null), 15 | assert(viewportFraction != null), 16 | assert(viewportFraction > 0.0); 17 | 18 | /// The page to show when first creating the [UnionInnerPageView]. 19 | final int initialPage; 20 | 21 | /// Save the current [page] with [PageStorage] and restore it if 22 | /// this controller's scrollable is recreated. 23 | /// 24 | /// If this property is set to false, the current [page] is never saved 25 | /// and [initialPage] is always used to initialize the scroll offset. 26 | /// If true (the default), the initial page is used the first time the 27 | /// controller's scrollable is created, since there's isn't a page to 28 | /// restore yet. Subsequently the saved page is restored and 29 | /// [initialPage] is ignored. 30 | /// 31 | /// See also: 32 | /// 33 | /// * [PageStorageKey], which should be used when more than one 34 | /// scrollable appears in the same route, to distinguish the [PageStorage] 35 | /// locations used to save scroll offsets. 36 | final bool keepPage; 37 | 38 | /// The fraction of the viewport that each page should occupy. 39 | /// 40 | /// Defaults to 1.0, which means each page fills the viewport in the scrolling 41 | /// direction. 42 | final double viewportFraction; 43 | 44 | /// The current page displayed in the controlled [UnionInnerPageView]. 45 | /// 46 | /// There are circumstances that this [UnionPageController] can't know the current 47 | /// page. Reading [page] will throw an [AssertionError] in the following cases: 48 | /// 49 | /// 1. No [UnionInnerPageView] is currently using this [UnionPageController]. Once a 50 | /// [UnionInnerPageView] starts using this [UnionPageController], the new [page] 51 | /// position will be derived: 52 | /// 53 | /// * First, based on the attached [UnionInnerPageView]'s [BuildContext] and the 54 | /// position saved at that context's [PageStorage] if [keepPage] is true. 55 | /// * Second, from the [UnionPageController]'s [initialPage]. 56 | /// 57 | /// 2. More than one [UnionInnerPageView] using the same [UnionPageController]. 58 | /// 59 | /// The [hasClients] property can be used to check if a [UnionInnerPageView] is attached 60 | /// prior to accessing [page]. 61 | double get page { 62 | assert( 63 | positions.isNotEmpty, 64 | 'UnionPageController.page cannot be accessed before a UnionPageView is built with it.', 65 | ); 66 | assert( 67 | positions.length == 1, 68 | 'The page property cannot be read when multiple PageViews are attached to ' 69 | 'the same UnionPageController.', 70 | ); 71 | final PagePosition position = this.position as PagePosition; 72 | return position.page; 73 | } 74 | 75 | /// Animates the controlled [UnionInnerPageView] from the current page to the given page. 76 | /// 77 | /// The animation lasts for the given duration and follows the given curve. 78 | /// The returned [Future] resolves when the animation completes. 79 | /// 80 | /// The `duration` and `curve` arguments must not be null. 81 | Future animateToPage( 82 | int page, { 83 | @required Duration duration, 84 | @required Curve curve, 85 | }) { 86 | final PagePosition position = this.position as PagePosition; 87 | return position.animateTo( 88 | position.getPixelsFromPage(page.toDouble()), 89 | duration: duration, 90 | curve: curve, 91 | ); 92 | } 93 | 94 | /// Changes which page is displayed in the controlled [UnionInnerPageView]. 95 | /// 96 | /// Jumps the page position from its current value to the given value, 97 | /// without animation, and without checking if the new value is in range. 98 | void jumpToPage(int page) { 99 | final PagePosition position = this.position as PagePosition; 100 | position.jumpTo(position.getPixelsFromPage(page.toDouble())); 101 | } 102 | 103 | /// Animates the controlled [UnionInnerPageView] to the next page. 104 | /// 105 | /// The animation lasts for the given duration and follows the given curve. 106 | /// The returned [Future] resolves when the animation completes. 107 | /// 108 | /// The `duration` and `curve` arguments must not be null. 109 | Future nextPage({@required Duration duration, @required Curve curve}) { 110 | return animateToPage(page.round() + 1, duration: duration, curve: curve); 111 | } 112 | 113 | /// Animates the controlled [UnionInnerPageView] to the previous page. 114 | /// 115 | /// The animation lasts for the given duration and follows the given curve. 116 | /// The returned [Future] resolves when the animation completes. 117 | /// 118 | /// The `duration` and `curve` arguments must not be null. 119 | Future previousPage( 120 | {@required Duration duration, @required Curve curve}) { 121 | return animateToPage(page.round() - 1, duration: duration, curve: curve); 122 | } 123 | 124 | @override 125 | ScrollPosition createScrollPosition(ScrollPhysics physics, 126 | ScrollContext context, ScrollPosition oldPosition) { 127 | return PagePosition( 128 | physics: physics, 129 | context: context, 130 | initialPage: initialPage, 131 | keepPage: keepPage, 132 | viewportFraction: viewportFraction, 133 | oldPosition: oldPosition, 134 | ); 135 | } 136 | 137 | @override 138 | void attach(ScrollPosition position) { 139 | super.attach(position); 140 | final PagePosition pagePosition = position as PagePosition; 141 | pagePosition.viewportFraction = viewportFraction; 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /lib/src/inner/union_inner_tab_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/gestures.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter/widgets.dart'; 4 | import 'package:union_tabs/src/inner/union_inner_page_view.dart'; 5 | import 'package:union_tabs/src/notification/page_controller.dart'; 6 | 7 | /// A page view that displays the widget which corresponds to the currently 8 | /// selected tab. 9 | /// 10 | /// This widget is typically used in conjunction with a [TabBar]. 11 | /// 12 | /// If a [TabController] is not provided, then there must be a [DefaultTabController] 13 | /// ancestor. 14 | /// 15 | /// The tab controller's [TabController.length] must equal the length of the 16 | /// [children] list and the length of the [TabBar.tabs] list. 17 | /// 18 | /// To see a sample implementation, visit the [TabController] documentation. 19 | class UnionInnerTabBarView extends StatefulWidget { 20 | /// Creates a page view with one child per tab. 21 | /// 22 | /// The length of [children] must be the same as the [controller]'s length. 23 | const UnionInnerTabBarView({ 24 | Key key, 25 | @required this.children, 26 | this.controller, 27 | this.physics, 28 | this.dragStartBehavior = DragStartBehavior.start, 29 | }) : assert(children != null), 30 | assert(dragStartBehavior != null), 31 | super(key: key); 32 | 33 | /// This widget's selection and animation state. 34 | /// 35 | /// If [TabController] is not provided, then the value of [DefaultTabController.of] 36 | /// will be used. 37 | final TabController controller; 38 | 39 | /// One widget per tab. 40 | /// 41 | /// Its length must match the length of the [TabBar.tabs] 42 | /// list, as well as the [controller]'s [TabController.length]. 43 | final List children; 44 | 45 | /// How the page view should respond to user input. 46 | /// 47 | /// For example, determines how the page view continues to animate after the 48 | /// user stops dragging the page view. 49 | /// 50 | /// The physics are modified to snap to page boundaries using 51 | /// [PageScrollPhysics] prior to being used. 52 | /// 53 | /// Defaults to matching platform conventions. 54 | final ScrollPhysics physics; 55 | 56 | /// {@macro flutter.widgets.scrollable.dragStartBehavior} 57 | final DragStartBehavior dragStartBehavior; 58 | 59 | @override 60 | _UnionInnerTabBarViewState createState() => _UnionInnerTabBarViewState(); 61 | } 62 | 63 | class _UnionInnerTabBarViewState extends State { 64 | TabController _controller; 65 | UnionPageController _pageController; 66 | List _children; 67 | List _childrenWithKey; 68 | int _currentIndex; 69 | int _warpUnderwayCount = 0; 70 | 71 | // If the TabBarView is rebuilt with a new tab controller, the caller should 72 | // dispose the old one. In that case the old controller's animation will be 73 | // null and should not be accessed. 74 | bool get _controllerIsValid => _controller?.animation != null; 75 | 76 | void _updateTabController() { 77 | final TabController newController = 78 | widget.controller ?? DefaultTabController.of(context); 79 | assert(() { 80 | if (newController == null) { 81 | throw FlutterError('No TabController for ${widget.runtimeType}.\n' 82 | 'When creating a ${widget.runtimeType}, you must either provide an explicit ' 83 | 'TabController using the "controller" property, or you must ensure that there ' 84 | 'is a DefaultTabController above the ${widget.runtimeType}.\n' 85 | 'In this case, there was neither an explicit controller nor a default controller.'); 86 | } 87 | return true; 88 | }()); 89 | 90 | if (newController == _controller) return; 91 | 92 | if (_controllerIsValid) 93 | _controller.animation.removeListener(_handleTabControllerAnimationTick); 94 | _controller = newController; 95 | if (_controller != null) 96 | _controller.animation.addListener(_handleTabControllerAnimationTick); 97 | } 98 | 99 | @override 100 | void initState() { 101 | super.initState(); 102 | _updateChildren(); 103 | } 104 | 105 | @override 106 | void didChangeDependencies() { 107 | super.didChangeDependencies(); 108 | _updateTabController(); 109 | _currentIndex = _controller?.index; 110 | _pageController = UnionPageController(initialPage: _currentIndex ?? 0); 111 | } 112 | 113 | @override 114 | void didUpdateWidget(UnionInnerTabBarView oldWidget) { 115 | super.didUpdateWidget(oldWidget); 116 | if (widget.controller != oldWidget.controller) _updateTabController(); 117 | if (widget.children != oldWidget.children && _warpUnderwayCount == 0) 118 | _updateChildren(); 119 | } 120 | 121 | @override 122 | void dispose() { 123 | if (_controllerIsValid) 124 | _controller.animation.removeListener(_handleTabControllerAnimationTick); 125 | _controller = null; 126 | // We don't own the _controller Animation, so it's not disposed here. 127 | super.dispose(); 128 | } 129 | 130 | void _updateChildren() { 131 | _children = widget.children; 132 | _childrenWithKey = KeyedSubtree.ensureUniqueKeysForList(widget.children); 133 | } 134 | 135 | void _handleTabControllerAnimationTick() { 136 | if (_warpUnderwayCount > 0 || !_controller.indexIsChanging) 137 | return; // This widget is driving the controller's animation. 138 | 139 | if (_controller.index != _currentIndex) { 140 | _currentIndex = _controller.index; 141 | _warpToCurrentIndex(); 142 | } 143 | } 144 | 145 | Future _warpToCurrentIndex() async { 146 | if (!mounted) return Future.value(); 147 | 148 | if (_pageController.page == _currentIndex.toDouble()) 149 | return Future.value(); 150 | 151 | final int previousIndex = _controller.previousIndex; 152 | if ((_currentIndex - previousIndex).abs() == 1) { 153 | _warpUnderwayCount += 1; 154 | await _pageController.animateToPage(_currentIndex, 155 | duration: kTabScrollDuration, curve: Curves.ease); 156 | _warpUnderwayCount -= 1; 157 | return Future.value(); 158 | } 159 | 160 | assert((_currentIndex - previousIndex).abs() > 1); 161 | final int initialPage = 162 | _currentIndex > previousIndex ? _currentIndex - 1 : _currentIndex + 1; 163 | final List originalChildren = _childrenWithKey; 164 | setState(() { 165 | _warpUnderwayCount += 1; 166 | 167 | _childrenWithKey = List.from(_childrenWithKey, growable: false); 168 | final Widget temp = _childrenWithKey[initialPage]; 169 | _childrenWithKey[initialPage] = _childrenWithKey[previousIndex]; 170 | _childrenWithKey[previousIndex] = temp; 171 | }); 172 | _pageController.jumpToPage(initialPage); 173 | 174 | await _pageController.animateToPage(_currentIndex, 175 | duration: kTabScrollDuration, curve: Curves.ease); 176 | if (!mounted) return Future.value(); 177 | setState(() { 178 | _warpUnderwayCount -= 1; 179 | if (widget.children != _children) { 180 | _updateChildren(); 181 | } else { 182 | _childrenWithKey = originalChildren; 183 | } 184 | }); 185 | } 186 | 187 | // Called when the PageView scrolls 188 | bool _handleScrollNotification(ScrollNotification notification) { 189 | if (_warpUnderwayCount > 0) return false; 190 | 191 | if (notification.depth != 0) return false; 192 | 193 | _warpUnderwayCount += 1; 194 | if (notification is ScrollUpdateNotification && 195 | !_controller.indexIsChanging) { 196 | if ((_pageController.page - _controller.index).abs() > 1.0) { 197 | _controller.index = _pageController.page.floor(); 198 | _currentIndex = _controller.index; 199 | } 200 | _controller.offset = 201 | (_pageController.page - _controller.index).clamp(-1.0, 1.0) as double; 202 | } else if (notification is ScrollEndNotification) { 203 | _controller.index = _pageController.page.round(); 204 | _currentIndex = _controller.index; 205 | if (!_controller.indexIsChanging) 206 | _controller.offset = (_pageController.page - _controller.index) 207 | .clamp(-1.0, 1.0) as double; 208 | } 209 | _warpUnderwayCount -= 1; 210 | 211 | return false; 212 | } 213 | 214 | @override 215 | Widget build(BuildContext context) { 216 | assert(() { 217 | if (_controller.length != widget.children.length) { 218 | throw FlutterError( 219 | "Controller's length property (${_controller.length}) does not match the " 220 | "number of tabs (${widget.children.length}) present in TabBar's tabs property."); 221 | } 222 | return true; 223 | }()); 224 | return NotificationListener( 225 | onNotification: _handleScrollNotification, 226 | child: UnionInnerPageView( 227 | dragStartBehavior: widget.dragStartBehavior, 228 | controller: _pageController, 229 | physics: widget.physics == null 230 | ? const PageScrollPhysics().applyTo(const ClampingScrollPhysics()) 231 | : const PageScrollPhysics().applyTo(widget.physics), 232 | children: _childrenWithKey, 233 | ), 234 | ); 235 | } 236 | } 237 | -------------------------------------------------------------------------------- /lib/src/outer/union_outer_tab_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/gestures.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter/widgets.dart'; 4 | import 'package:union_tabs/src/notification/union_scroll_notification.dart'; 5 | 6 | import 'union_outer_gesture_delegate.dart'; 7 | import 'union_outer_page_view.dart'; 8 | 9 | /// A page view that displays the widget which corresponds to the currently 10 | /// selected tab. 11 | /// 12 | /// This widget is typically used in conjunction with a [TabBar]. 13 | /// 14 | /// If a [TabController] is not provided, then there must be a [DefaultTabController] 15 | /// ancestor. 16 | /// 17 | /// The tab controller's [TabController.length] must equal the length of the 18 | /// [children] list and the length of the [TabBar.tabs] list. 19 | /// 20 | /// To see a sample implementation, visit the [TabController] documentation. 21 | class UnionOuterTabBarView extends StatefulWidget { 22 | /// Creates a page view with one child per tab. 23 | /// 24 | /// The length of [children] must be the same as the [controller]'s length. 25 | const UnionOuterTabBarView({ 26 | Key key, 27 | @required this.children, 28 | this.controller, 29 | this.physics, 30 | this.dragStartBehavior = DragStartBehavior.start, 31 | }) : assert(children != null), 32 | assert(dragStartBehavior != null), 33 | super(key: key); 34 | 35 | /// This widget's selection and animation state. 36 | /// 37 | /// If [TabController] is not provided, then the value of [DefaultTabController.of] 38 | /// will be used. 39 | final TabController controller; 40 | 41 | /// One widget per tab. 42 | /// 43 | /// Its length must match the length of the [TabBar.tabs] 44 | /// list, as well as the [controller]'s [TabController.length]. 45 | final List children; 46 | 47 | /// How the page view should respond to user input. 48 | /// 49 | /// For example, determines how the page view continues to animate after the 50 | /// user stops dragging the page view. 51 | /// 52 | /// The physics are modified to snap to page boundaries using 53 | /// [PageScrollPhysics] prior to being used. 54 | /// 55 | /// Defaults to matching platform conventions. 56 | final ScrollPhysics physics; 57 | 58 | /// {@macro flutter.widgets.scrollable.dragStartBehavior} 59 | final DragStartBehavior dragStartBehavior; 60 | 61 | @override 62 | _UnionOuterTabBarViewState createState() => _UnionOuterTabBarViewState(); 63 | } 64 | 65 | class _UnionOuterTabBarViewState extends State { 66 | TabController _controller; 67 | UnionOuterPageController _pageController; 68 | List _children; 69 | List _childrenWithKey; 70 | int _currentIndex; 71 | int _warpUnderwayCount = 0; 72 | 73 | // If the TabBarView is rebuilt with a new tab controller, the caller should 74 | // dispose the old one. In that case the old controller's animation will be 75 | // null and should not be accessed. 76 | bool get _controllerIsValid => _controller?.animation != null; 77 | 78 | UnionOuterGestureDelegate _gestureDelegate; 79 | 80 | void _updateTabController() { 81 | final TabController newController = 82 | widget.controller ?? DefaultTabController.of(context); 83 | assert(() { 84 | if (newController == null) { 85 | throw FlutterError('No TabController for ${widget.runtimeType}.\n' 86 | 'When creating a ${widget.runtimeType}, you must either provide an explicit ' 87 | 'TabController using the "controller" property, or you must ensure that there ' 88 | 'is a DefaultTabController above the ${widget.runtimeType}.\n' 89 | 'In this case, there was neither an explicit controller nor a default controller.'); 90 | } 91 | return true; 92 | }()); 93 | 94 | if (newController == _controller) return; 95 | 96 | if (_controllerIsValid) 97 | _controller.animation.removeListener(_handleTabControllerAnimationTick); 98 | _controller = newController; 99 | if (_controller != null) 100 | _controller.animation.addListener(_handleTabControllerAnimationTick); 101 | } 102 | 103 | void _updateGestureDelegate() { 104 | _gestureDelegate = UnionOuterGestureDelegate( 105 | pageController: _pageController, tabController: _controller); 106 | } 107 | 108 | @override 109 | void initState() { 110 | super.initState(); 111 | _updateChildren(); 112 | } 113 | 114 | @override 115 | void didChangeDependencies() { 116 | super.didChangeDependencies(); 117 | _updateTabController(); 118 | _currentIndex = _controller?.index; 119 | _pageController = UnionOuterPageController(initialPage: _currentIndex ?? 0); 120 | _updateGestureDelegate(); 121 | } 122 | 123 | @override 124 | void didUpdateWidget(UnionOuterTabBarView oldWidget) { 125 | super.didUpdateWidget(oldWidget); 126 | if (widget.controller != oldWidget.controller) { 127 | _updateTabController(); 128 | _updateGestureDelegate(); 129 | } 130 | 131 | if (widget.children != oldWidget.children && _warpUnderwayCount == 0) 132 | _updateChildren(); 133 | } 134 | 135 | @override 136 | void dispose() { 137 | if (_controllerIsValid) 138 | _controller.animation.removeListener(_handleTabControllerAnimationTick); 139 | _controller = null; 140 | // We don't own the _controller Animation, so it's not disposed here. 141 | 142 | _gestureDelegate?.dispose(); 143 | super.dispose(); 144 | } 145 | 146 | void _updateChildren() { 147 | _children = widget.children; 148 | _childrenWithKey = KeyedSubtree.ensureUniqueKeysForList(widget.children); 149 | } 150 | 151 | void _handleTabControllerAnimationTick() { 152 | if (_warpUnderwayCount > 0 || !_controller.indexIsChanging) 153 | return; // This widget is driving the controller's animation. 154 | 155 | if (_controller.index != _currentIndex) { 156 | _currentIndex = _controller.index; 157 | _warpToCurrentIndex(); 158 | } 159 | } 160 | 161 | Future _warpToCurrentIndex() async { 162 | if (!mounted) return Future.value(); 163 | 164 | if (_pageController.page == _currentIndex.toDouble()) 165 | return Future.value(); 166 | 167 | final int previousIndex = _controller.previousIndex; 168 | if ((_currentIndex - previousIndex).abs() == 1) { 169 | _warpUnderwayCount += 1; 170 | await _pageController.animateToPage(_currentIndex, 171 | duration: kTabScrollDuration, curve: Curves.ease); 172 | _warpUnderwayCount -= 1; 173 | return Future.value(); 174 | } 175 | 176 | assert((_currentIndex - previousIndex).abs() > 1); 177 | final int initialPage = 178 | _currentIndex > previousIndex ? _currentIndex - 1 : _currentIndex + 1; 179 | final List originalChildren = _childrenWithKey; 180 | setState(() { 181 | _warpUnderwayCount += 1; 182 | 183 | _childrenWithKey = List.from(_childrenWithKey, growable: false); 184 | final Widget temp = _childrenWithKey[initialPage]; 185 | _childrenWithKey[initialPage] = _childrenWithKey[previousIndex]; 186 | _childrenWithKey[previousIndex] = temp; 187 | }); 188 | _pageController.jumpToPage(initialPage); 189 | 190 | await _pageController.animateToPage(_currentIndex, 191 | duration: kTabScrollDuration, curve: Curves.ease); 192 | if (!mounted) return Future.value(); 193 | setState(() { 194 | _warpUnderwayCount -= 1; 195 | if (widget.children != _children) { 196 | _updateChildren(); 197 | } else { 198 | _childrenWithKey = originalChildren; 199 | } 200 | }); 201 | } 202 | 203 | // Called when the PageView scrolls 204 | bool _handleScrollNotification(ScrollNotification notification) { 205 | if (_warpUnderwayCount > 0) return false; 206 | 207 | if (notification.depth != 0) return false; 208 | 209 | _warpUnderwayCount += 1; 210 | if (notification is ScrollUpdateNotification && 211 | !_controller.indexIsChanging) { 212 | if ((_pageController.page - _controller.index).abs() > 1.0) { 213 | _controller.index = _pageController.page.floor(); 214 | _currentIndex = _controller.index; 215 | } 216 | _controller.offset = 217 | (_pageController.page - _controller.index).clamp(-1.0, 1.0) as double; 218 | } else if (notification is ScrollEndNotification) { 219 | _controller.index = _pageController.page.round(); 220 | _currentIndex = _controller.index; 221 | if (!_controller.indexIsChanging) 222 | _controller.offset = (_pageController.page - _controller.index) 223 | .clamp(-1.0, 1.0) as double; 224 | } 225 | _warpUnderwayCount -= 1; 226 | 227 | return false; 228 | } 229 | 230 | @override 231 | Widget build(BuildContext context) { 232 | assert(() { 233 | if (_controller.length != widget.children.length) { 234 | throw FlutterError( 235 | "Controller's length property (${_controller.length}) does not match the " 236 | "number of tabs (${widget.children.length}) present in TabBar's tabs property."); 237 | } 238 | return true; 239 | }()); 240 | return NotificationListener( 241 | onNotification: (UnionScrollNotification notification) { 242 | return _gestureDelegate?.handleUnionScrollNotification( 243 | context, notification); 244 | }, 245 | child: NotificationListener( 246 | onNotification: _handleScrollNotification, 247 | child: UnionOuterPageView( 248 | dragStartBehavior: widget.dragStartBehavior, 249 | controller: _pageController, 250 | physics: widget.physics == null 251 | ? const PageScrollPhysics().applyTo(const ClampingScrollPhysics()) 252 | : const PageScrollPhysics().applyTo(widget.physics), 253 | children: _childrenWithKey, 254 | ), 255 | ), 256 | ); 257 | } 258 | } 259 | -------------------------------------------------------------------------------- /lib/src/outer/union_outer_page_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/gestures.dart'; 2 | import 'package:flutter/rendering.dart'; 3 | import 'package:flutter/widgets.dart'; 4 | import 'package:union_tabs/src/notification/page_controller.dart'; 5 | import 'package:union_tabs/src/notification/page_scroll_physics.dart'; 6 | 7 | import 'union_outer_scroll_position.dart'; 8 | import 'union_outer_sliver.dart'; 9 | 10 | final UnionOuterPageController _defaultPageController = 11 | UnionOuterPageController(); 12 | const UnionPageScrollPhysics _kPagePhysics = UnionPageScrollPhysics(); 13 | 14 | /// usage like [PageView] 15 | /// 16 | /// See also: 17 | /// 18 | /// * [PageController], which controls which page is visible in the view. 19 | /// * [SingleChildScrollView], when you need to make a single child scrollable. 20 | /// * [ListView], for a scrollable list of boxes. 21 | /// * [GridView], for a scrollable grid of boxes. 22 | /// * [ScrollNotification] and [NotificationListener], which can be used to watch 23 | /// the scroll position without using a [ScrollController]. 24 | class UnionOuterPageView extends StatefulWidget { 25 | /// usage like [PageView], but childrenDelegate must be a [UnionSliverChildListDelegate] 26 | UnionOuterPageView({ 27 | Key key, 28 | this.scrollDirection = Axis.horizontal, 29 | this.reverse = false, 30 | UnionOuterPageController controller, 31 | this.physics, 32 | this.pageSnapping = true, 33 | this.onPageChanged, 34 | List children = const [], 35 | this.dragStartBehavior = DragStartBehavior.start, 36 | this.allowImplicitScrolling = false, 37 | this.restorationId, 38 | this.clipBehavior = Clip.hardEdge, 39 | }) : assert(allowImplicitScrolling != null), 40 | assert(clipBehavior != null), 41 | controller = controller ?? _defaultPageController, 42 | childrenDelegate = UnionSliverChildListDelegate(children), 43 | super(key: key); 44 | 45 | /// usage like [PageView], but childrenDelegate must be a [UnionSliverChildBuilderDelegate] 46 | UnionOuterPageView.builder({ 47 | Key key, 48 | this.scrollDirection = Axis.horizontal, 49 | this.reverse = false, 50 | PageController controller, 51 | this.physics, 52 | this.pageSnapping = true, 53 | this.onPageChanged, 54 | @required IndexedWidgetBuilder itemBuilder, 55 | int itemCount, 56 | this.dragStartBehavior = DragStartBehavior.start, 57 | this.allowImplicitScrolling = false, 58 | this.restorationId, 59 | this.clipBehavior = Clip.hardEdge, 60 | }) : assert(allowImplicitScrolling != null), 61 | assert(clipBehavior != null), 62 | controller = controller ?? _defaultPageController, 63 | childrenDelegate = 64 | UnionSliverChildBuilderDelegate(itemBuilder, childCount: itemCount), 65 | super(key: key); 66 | 67 | /// Controls whether the widget's pages will respond to 68 | /// [RenderObject.showOnScreen], which will allow for implicit accessibility 69 | /// scrolling. 70 | /// 71 | /// With this flag set to false, when accessibility focus reaches the end of 72 | /// the current page and the user attempts to move it to the next element, the 73 | /// focus will traverse to the next widget outside of the page view. 74 | /// 75 | /// With this flag set to true, when accessibility focus reaches the end of 76 | /// the current page and user attempts to move it to the next element, focus 77 | /// will traverse to the next page in the page view. 78 | final bool allowImplicitScrolling; 79 | 80 | /// {@macro flutter.widgets.scrollable.restorationId} 81 | final String restorationId; 82 | 83 | /// The axis along which the page view scrolls. 84 | /// 85 | /// Defaults to [Axis.horizontal]. 86 | final Axis scrollDirection; 87 | 88 | /// Whether the page view scrolls in the reading direction. 89 | /// 90 | /// For example, if the reading direction is left-to-right and 91 | /// [scrollDirection] is [Axis.horizontal], then the page view scrolls from 92 | /// left to right when [reverse] is false and from right to left when 93 | /// [reverse] is true. 94 | /// 95 | /// Similarly, if [scrollDirection] is [Axis.vertical], then the page view 96 | /// scrolls from top to bottom when [reverse] is false and from bottom to top 97 | /// when [reverse] is true. 98 | /// 99 | /// Defaults to false. 100 | final bool reverse; 101 | 102 | /// An object that can be used to control the position to which this page 103 | /// view is scrolled. 104 | final UnionOuterPageController controller; 105 | 106 | /// How the page view should respond to user input. 107 | /// 108 | /// For example, determines how the page view continues to animate after the 109 | /// user stops dragging the page view. 110 | /// 111 | /// The physics are modified to snap to page boundaries using 112 | /// [PageScrollPhysics] prior to being used. 113 | /// 114 | /// Defaults to matching platform conventions. 115 | final ScrollPhysics physics; 116 | 117 | /// Set to false to disable page snapping, useful for custom scroll behavior. 118 | final bool pageSnapping; 119 | 120 | /// Called whenever the page in the center of the viewport changes. 121 | final ValueChanged onPageChanged; 122 | 123 | /// A delegate that provides the children for the [UnionOuterPageView]. 124 | /// 125 | /// The [UnionOuterPageView.custom] constructor lets you specify this delegate 126 | /// explicitly. The [UnionOuterPageView] and [UnionOuterPageView.builder] constructors create a 127 | /// [childrenDelegate] that wraps the given [List] and [IndexedWidgetBuilder], 128 | /// respectively. 129 | final SliverChildDelegate childrenDelegate; 130 | 131 | /// {@macro flutter.widgets.scrollable.dragStartBehavior} 132 | final DragStartBehavior dragStartBehavior; 133 | 134 | /// {@macro flutter.widgets.Clip} 135 | /// 136 | /// Defaults to [Clip.hardEdge]. 137 | final Clip clipBehavior; 138 | 139 | @override 140 | _UnionOuterPageViewState createState() => _UnionOuterPageViewState(); 141 | } 142 | 143 | class _UnionOuterPageViewState extends State { 144 | int _lastReportedPage = 0; 145 | 146 | @override 147 | void initState() { 148 | super.initState(); 149 | _lastReportedPage = widget.controller.initialPage; 150 | } 151 | 152 | AxisDirection _getDirection(BuildContext context) { 153 | switch (widget.scrollDirection) { 154 | case Axis.horizontal: 155 | assert(debugCheckHasDirectionality(context)); 156 | final TextDirection textDirection = Directionality.of(context); 157 | final AxisDirection axisDirection = 158 | textDirectionToAxisDirection(textDirection); 159 | return widget.reverse 160 | ? flipAxisDirection(axisDirection) 161 | : axisDirection; 162 | case Axis.vertical: 163 | return widget.reverse ? AxisDirection.up : AxisDirection.down; 164 | } 165 | return null; 166 | } 167 | 168 | @override 169 | Widget build(BuildContext context) { 170 | final AxisDirection axisDirection = _getDirection(context); 171 | final ScrollPhysics physics = _ForceImplicitScrollPhysics( 172 | allowImplicitScrolling: widget.allowImplicitScrolling, 173 | ).applyTo(widget.pageSnapping 174 | ? _kPagePhysics.applyTo(widget.physics) 175 | : widget.physics); 176 | 177 | return NotificationListener( 178 | onNotification: (ScrollNotification notification) { 179 | if (notification.depth == 0 && 180 | widget.onPageChanged != null && 181 | notification is ScrollUpdateNotification) { 182 | final PageMetrics metrics = notification.metrics as PageMetrics; 183 | final int currentPage = metrics.page.round(); 184 | if (currentPage != _lastReportedPage) { 185 | _lastReportedPage = currentPage; 186 | widget.onPageChanged(currentPage); 187 | } 188 | } 189 | return false; 190 | }, 191 | child: Scrollable( 192 | dragStartBehavior: widget.dragStartBehavior, 193 | axisDirection: axisDirection, 194 | controller: widget.controller, 195 | physics: physics, 196 | restorationId: widget.restorationId, 197 | viewportBuilder: (BuildContext context, ViewportOffset position) { 198 | return Viewport( 199 | // TODO(dnfield): we should provide a way to set cacheExtent 200 | // independent of implicit scrolling: 201 | // https://github.com/flutter/flutter/issues/45632 202 | cacheExtent: widget.allowImplicitScrolling ? 1.0 : 0.0, 203 | cacheExtentStyle: CacheExtentStyle.viewport, 204 | axisDirection: axisDirection, 205 | offset: position, 206 | clipBehavior: widget.clipBehavior, 207 | slivers: [ 208 | SliverFillViewport( 209 | viewportFraction: widget.controller.viewportFraction, 210 | delegate: widget.childrenDelegate, 211 | ), 212 | ], 213 | ); 214 | }, 215 | ), 216 | ); 217 | } 218 | 219 | @override 220 | void debugFillProperties(DiagnosticPropertiesBuilder description) { 221 | super.debugFillProperties(description); 222 | description 223 | .add(EnumProperty('scrollDirection', widget.scrollDirection)); 224 | description.add( 225 | FlagProperty('reverse', value: widget.reverse, ifTrue: 'reversed')); 226 | description.add(DiagnosticsProperty( 227 | 'controller', widget.controller, 228 | showName: false)); 229 | description.add(DiagnosticsProperty( 230 | 'physics', widget.physics, 231 | showName: false)); 232 | description.add(FlagProperty('pageSnapping', 233 | value: widget.pageSnapping, ifFalse: 'snapping disabled')); 234 | description.add(FlagProperty('allowImplicitScrolling', 235 | value: widget.allowImplicitScrolling, 236 | ifTrue: 'allow implicit scrolling')); 237 | } 238 | } 239 | 240 | class UnionOuterPageController extends UnionPageController { 241 | /// Creates a page controller. 242 | /// 243 | /// The [initialPage], [keepPage], and [viewportFraction] arguments must not be null. 244 | UnionOuterPageController({ 245 | int initialPage = 0, 246 | bool keepPage = true, 247 | double viewportFraction = 1.0, 248 | }) : super( 249 | initialPage: initialPage, 250 | keepPage: keepPage, 251 | viewportFraction: viewportFraction); 252 | 253 | @override 254 | ScrollPosition createScrollPosition(ScrollPhysics physics, 255 | ScrollContext context, ScrollPosition oldPosition) { 256 | return UnionOuterScrollPosition( 257 | physics: physics, 258 | context: context, 259 | initialPage: initialPage, 260 | keepPage: keepPage, 261 | viewportFraction: viewportFraction, 262 | oldPosition: oldPosition, 263 | ); 264 | } 265 | } 266 | 267 | class _ForceImplicitScrollPhysics extends ScrollPhysics { 268 | const _ForceImplicitScrollPhysics({ 269 | @required this.allowImplicitScrolling, 270 | ScrollPhysics parent, 271 | }) : assert(allowImplicitScrolling != null), 272 | super(parent: parent); 273 | 274 | @override 275 | _ForceImplicitScrollPhysics applyTo(ScrollPhysics ancestor) { 276 | return _ForceImplicitScrollPhysics( 277 | allowImplicitScrolling: allowImplicitScrolling, 278 | parent: buildParent(ancestor), 279 | ); 280 | } 281 | 282 | @override 283 | final bool allowImplicitScrolling; 284 | } 285 | -------------------------------------------------------------------------------- /lib/src/notification/union_scroll_notification.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/gestures.dart'; 2 | import 'package:flutter/rendering.dart'; 3 | import 'package:flutter/widgets.dart'; 4 | 5 | /// A [Notification] related to scrolling. 6 | /// 7 | /// [Scrollable] widgets notify their ancestors about scrolling-related changes. 8 | /// The notifications have the following lifecycle: 9 | /// 10 | /// * A [UnionScrollStartNotification], which indicates that the widget has started 11 | /// scrolling. 12 | /// * Zero or more [UnionScrollUpdateNotification]s, which indicate that the widget 13 | /// has changed its scroll position, mixed with zero or more 14 | /// [OverscrollNotification]s, which indicate that the widget has not changed 15 | /// its scroll position because the change would have caused its scroll 16 | /// position to go outside its scroll bounds. 17 | /// * Interspersed with the [UnionScrollUpdateNotification]s and 18 | /// [OverscrollNotification]s are zero or more [UserScrollNotification]s, 19 | /// which indicate that the user has changed the direction in which they are 20 | /// scrolling. 21 | /// * A [UnionScrollEndNotification], which indicates that the widget has stopped 22 | /// scrolling. 23 | /// * A [UnionUserScrollNotification], with a [UnionUserScrollNotification.direction] of 24 | /// [ScrollDirection.idle]. 25 | /// 26 | /// Notifications bubble up through the tree, which means a given 27 | /// [NotificationListener] will receive notifications for all descendant 28 | /// [Scrollable] widgets. To focus on notifications from the nearest 29 | /// [Scrollable] descendant, check that the [depth] property of the notification 30 | /// is zero. 31 | /// 32 | /// When a scroll notification is received by a [NotificationListener], the 33 | /// listener will have already completed build and layout, and it is therefore 34 | /// too late for that widget to call [State.setState]. Any attempt to adjust the 35 | /// build or layout based on a scroll notification would result in a layout that 36 | /// lagged one frame behind, which is a poor user experience. Scroll 37 | /// notifications are therefore primarily useful for paint effects (since paint 38 | /// happens after layout). The [GlowingOverscrollIndicator] and [Scrollbar] 39 | /// widgets are examples of paint effects that use scroll notifications. 40 | /// 41 | /// To drive layout based on the scroll position, consider listening to the 42 | /// [ScrollPosition] directly (or indirectly via a [ScrollController]). 43 | abstract class UnionScrollNotification extends LayoutChangedNotification 44 | with ViewportNotificationMixin { 45 | /// Initializes fields for subclasses. 46 | UnionScrollNotification({ 47 | @required this.metrics, 48 | @required this.context, 49 | @required this.index, 50 | }); 51 | 52 | /// A description of a [Scrollable]'s contents, useful for modeling the state 53 | /// of its viewport. 54 | final ScrollMetrics metrics; 55 | 56 | /// The build context of the widget that fired this notification. 57 | /// 58 | /// This can be used to find the scrollable's render objects to determine the 59 | /// size of the viewport, for instance. 60 | final BuildContext context; 61 | 62 | /// index of [UnionPageView] children 63 | int index = -1; 64 | 65 | @override 66 | void debugFillDescription(List description) { 67 | super.debugFillDescription(description); 68 | description.add('$metrics'); 69 | } 70 | } 71 | 72 | /// A notification that a [Scrollable] widget has started scrolling. 73 | /// 74 | /// See also: 75 | /// 76 | /// * [UnionScrollEndNotification], which indicates that scrolling has stopped. 77 | /// * [UnionScrollNotification], which describes the notification lifecycle. 78 | class UnionScrollStartNotification extends UnionScrollNotification { 79 | /// Creates a notification that a [Scrollable] widget has started scrolling. 80 | UnionScrollStartNotification({ 81 | @required ScrollMetrics metrics, 82 | @required BuildContext context, 83 | @required int index, 84 | this.dragDetails, 85 | }) : super(metrics: metrics, context: context, index: index); 86 | 87 | /// If the [Scrollable] started scrolling because of a drag, the details about 88 | /// that drag start. 89 | /// 90 | /// Otherwise, null. 91 | final DragStartDetails dragDetails; 92 | 93 | @override 94 | void debugFillDescription(List description) { 95 | super.debugFillDescription(description); 96 | if (dragDetails != null) description.add('$dragDetails'); 97 | } 98 | 99 | static UnionScrollStartNotification merge( 100 | {BuildContext context, 101 | @required ScrollStartNotification notification, 102 | @required int index}) { 103 | return UnionScrollStartNotification( 104 | metrics: notification.metrics, 105 | context: context ?? notification.context, 106 | index: index, 107 | dragDetails: notification.dragDetails); 108 | } 109 | } 110 | 111 | /// A notification that a [Scrollable] widget has changed its scroll position. 112 | /// 113 | /// See also: 114 | /// 115 | /// * [UnionOverscrollNotification], which indicates that a [Scrollable] widget 116 | /// has not changed its scroll position because the change would have caused 117 | /// its scroll position to go outside its scroll bounds. 118 | /// * [UnionScrollNotification], which describes the notification lifecycle. 119 | class UnionScrollUpdateNotification extends UnionScrollNotification { 120 | /// Creates a notification that a [Scrollable] widget has changed its scroll 121 | /// position. 122 | UnionScrollUpdateNotification({ 123 | @required ScrollMetrics metrics, 124 | @required BuildContext context, 125 | @required int index, 126 | this.dragDetails, 127 | this.scrollDelta, 128 | }) : super(metrics: metrics, context: context, index: index); 129 | 130 | /// If the [Scrollable] changed its scroll position because of a drag, the 131 | /// details about that drag update. 132 | /// 133 | /// Otherwise, null. 134 | final DragUpdateDetails dragDetails; 135 | 136 | /// The distance by which the [Scrollable] was scrolled, in logical pixels. 137 | final double scrollDelta; 138 | 139 | @override 140 | void debugFillDescription(List description) { 141 | super.debugFillDescription(description); 142 | description.add('scrollDelta: $scrollDelta'); 143 | if (dragDetails != null) description.add('$dragDetails'); 144 | } 145 | 146 | static UnionScrollUpdateNotification merge( 147 | {BuildContext context, 148 | @required ScrollUpdateNotification notification, 149 | @required int index}) { 150 | return UnionScrollUpdateNotification( 151 | metrics: notification.metrics, 152 | context: context ?? notification.context, 153 | index: index, 154 | dragDetails: notification.dragDetails, 155 | scrollDelta: notification.scrollDelta); 156 | } 157 | } 158 | 159 | /// A notification that a [Scrollable] widget has not changed its scroll position 160 | /// because the change would have caused its scroll position to go outside of 161 | /// its scroll bounds. 162 | /// 163 | /// See also: 164 | /// 165 | /// * [UnionScrollUpdateNotification], which indicates that a [Scrollable] widget 166 | /// has changed its scroll position. 167 | /// * [UnionScrollNotification], which describes the notification lifecycle. 168 | class UnionOverscrollNotification extends UnionScrollNotification { 169 | /// Creates a notification that a [Scrollable] widget has changed its scroll 170 | /// position outside of its scroll bounds. 171 | UnionOverscrollNotification({ 172 | @required ScrollMetrics metrics, 173 | @required BuildContext context, 174 | @required int index, 175 | this.dragDetails, 176 | @required this.overscroll, 177 | this.velocity = 0.0, 178 | }) : assert(overscroll != null), 179 | assert(overscroll.isFinite), 180 | assert(overscroll != 0.0), 181 | assert(velocity != null), 182 | super(metrics: metrics, context: context, index: index); 183 | 184 | /// If the [Scrollable] overscrolled because of a drag, the details about that 185 | /// drag update. 186 | /// 187 | /// Otherwise, null. 188 | final DragUpdateDetails dragDetails; 189 | 190 | /// The number of logical pixels that the [Scrollable] avoided scrolling. 191 | /// 192 | /// This will be negative for overscroll on the "start" side and positive for 193 | /// overscroll on the "end" side. 194 | final double overscroll; 195 | 196 | /// The velocity at which the [ScrollPosition] was changing when this 197 | /// overscroll happened. 198 | /// 199 | /// This will typically be 0.0 for touch-driven overscrolls, and positive 200 | /// for overscrolls that happened from a [BallisticScrollActivity] or 201 | /// [DrivenScrollActivity]. 202 | final double velocity; 203 | 204 | @override 205 | void debugFillDescription(List description) { 206 | super.debugFillDescription(description); 207 | description.add('overscroll: ${overscroll.toStringAsFixed(1)}'); 208 | description.add('velocity: ${velocity.toStringAsFixed(1)}'); 209 | if (dragDetails != null) description.add('$dragDetails'); 210 | } 211 | 212 | static UnionOverscrollNotification merge( 213 | {BuildContext context, 214 | @required OverscrollNotification notification, 215 | @required int index}) { 216 | return UnionOverscrollNotification( 217 | metrics: notification.metrics, 218 | context: context ?? notification.context, 219 | index: index, 220 | dragDetails: notification.dragDetails, 221 | overscroll: notification.overscroll, 222 | velocity: notification.velocity, 223 | ); 224 | } 225 | } 226 | 227 | /// A notification that a [Scrollable] widget has stopped scrolling. 228 | /// 229 | /// See also: 230 | /// 231 | /// * [UnionScrollStartNotification], which indicates that scrolling has started. 232 | /// * [UnionScrollNotification], which describes the notification lifecycle. 233 | class UnionScrollEndNotification extends UnionScrollNotification { 234 | /// Creates a notification that a [Scrollable] widget has stopped scrolling. 235 | UnionScrollEndNotification({ 236 | @required ScrollMetrics metrics, 237 | @required BuildContext context, 238 | @required int index, 239 | this.dragDetails, 240 | }) : super(metrics: metrics, context: context, index: index); 241 | 242 | /// If the [Scrollable] stopped scrolling because of a drag, the details about 243 | /// that drag end. 244 | /// 245 | /// Otherwise, null. 246 | /// 247 | /// If a drag ends with some residual velocity, a typical [ScrollPhysics] will 248 | /// start a ballistic scroll, which delays the [UnionScrollEndNotification] until 249 | /// the ballistic simulation completes, at which time [dragDetails] will 250 | /// be null. If the residual velocity is too small to trigger ballistic 251 | /// scrolling, then the [UnionScrollEndNotification] will be dispatched immediately 252 | /// and [dragDetails] will be non-null. 253 | final DragEndDetails dragDetails; 254 | 255 | @override 256 | void debugFillDescription(List description) { 257 | super.debugFillDescription(description); 258 | if (dragDetails != null) description.add('$dragDetails'); 259 | } 260 | 261 | static UnionScrollEndNotification merge({ 262 | BuildContext context, 263 | @required ScrollEndNotification notification, 264 | @required int index, 265 | }) { 266 | return UnionScrollEndNotification( 267 | metrics: notification.metrics, 268 | context: context ?? notification.context, 269 | index: index, 270 | dragDetails: notification.dragDetails, 271 | ); 272 | } 273 | } 274 | 275 | /// A notification that the user has changed the direction in which they are 276 | /// scrolling. 277 | /// 278 | /// See also: 279 | /// 280 | /// * [UnionScrollNotification], which describes the notification lifecycle. 281 | class UnionUserScrollNotification extends UnionScrollNotification { 282 | /// Creates a notification that the user has changed the direction in which 283 | /// they are scrolling. 284 | UnionUserScrollNotification({ 285 | @required ScrollMetrics metrics, 286 | @required BuildContext context, 287 | @required int index, 288 | this.direction, 289 | }) : super(metrics: metrics, context: context, index: index); 290 | 291 | /// The direction in which the user is scrolling. 292 | final ScrollDirection direction; 293 | 294 | @override 295 | void debugFillDescription(List description) { 296 | super.debugFillDescription(description); 297 | description.add('direction: $direction'); 298 | } 299 | 300 | static UnionUserScrollNotification merge({ 301 | BuildContext context, 302 | @required UserScrollNotification notification, 303 | @required int index, 304 | }) { 305 | return UnionUserScrollNotification( 306 | metrics: notification.metrics, 307 | context: context ?? notification.context, 308 | index: index, 309 | direction: notification.direction, 310 | ); 311 | } 312 | } 313 | 314 | /// A predicate for [UnionScrollNotification], used to customize widgets that 315 | /// listen to notifications from their children. 316 | typedef NestScrollNotificationPredicate = bool Function( 317 | UnionScrollNotification notification); 318 | 319 | /// A [NestScrollNotificationPredicate] that checks whether 320 | /// `notification.depth == 0`, which means that the notification did not bubble 321 | /// through any intervening scrolling widgets. 322 | bool defaultUnionScrollNotificationPredicate( 323 | UnionScrollNotification notification) { 324 | return notification.depth == 0; 325 | } 326 | -------------------------------------------------------------------------------- /lib/src/inner/union_inner_page_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/gestures.dart'; 2 | import 'package:flutter/rendering.dart'; 3 | import 'package:flutter/widgets.dart'; 4 | import 'package:union_tabs/src/notification/page_controller.dart'; 5 | import 'package:union_tabs/src/notification/page_scroll_physics.dart'; 6 | 7 | import 'union_inner_scrollable.dart'; 8 | import 'union_tabs_provider.dart'; 9 | 10 | // Having this global (mutable) page controller is a bit of a hack. We need it 11 | // to plumb in the factory for _UnionPagePosition, but it will end up accumulating 12 | // a large list of scroll positions. As long as you don't try to actually 13 | // control the scroll positions, everything should be fine. 14 | final UnionPageController _defaultPageController = UnionPageController(); 15 | const UnionPageScrollPhysics _kPagePhysics = UnionPageScrollPhysics(); 16 | 17 | class _ForceImplicitScrollPhysics extends ScrollPhysics { 18 | const _ForceImplicitScrollPhysics({ 19 | @required this.allowImplicitScrolling, 20 | ScrollPhysics parent, 21 | }) : assert(allowImplicitScrolling != null), 22 | super(parent: parent); 23 | 24 | @override 25 | _ForceImplicitScrollPhysics applyTo(ScrollPhysics ancestor) { 26 | return _ForceImplicitScrollPhysics( 27 | allowImplicitScrolling: allowImplicitScrolling, 28 | parent: buildParent(ancestor), 29 | ); 30 | } 31 | 32 | @override 33 | final bool allowImplicitScrolling; 34 | } 35 | 36 | /// A scrollable list that works page by page. 37 | /// 38 | /// Each child of a page view is forced to be the same size as the viewport. 39 | /// 40 | /// You can use a [UnionPageController] to control which page is visible in the view. 41 | /// In addition to being able to control the pixel offset of the content inside 42 | /// the [UnionInnerPageView], a [UnionPageController] also lets you control the offset in terms 43 | /// of pages, which are increments of the viewport size. 44 | /// 45 | /// The [UnionPageController] can also be used to control the 46 | /// [UnionPageController.initialPage], which determines which page is shown when the 47 | /// [UnionInnerPageView] is first constructed, and the [PageController.viewportFraction], 48 | /// which determines the size of the pages as a fraction of the viewport size. 49 | /// 50 | /// {@youtube 560 315 https://www.youtube.com/watch?v=J1gE9xvph-A} 51 | /// 52 | /// See also: 53 | /// 54 | /// * [UnionPageController], which controls which page is visible in the view. 55 | /// * [SingleChildScrollView], when you need to make a single child scrollable. 56 | /// * [ListView], for a scrollable list of boxes. 57 | /// * [GridView], for a scrollable grid of boxes. 58 | /// * [ScrollNotification] and [NotificationListener], which can be used to watch 59 | /// the scroll position without using a [ScrollController]. 60 | class UnionInnerPageView extends StatefulWidget { 61 | /// Creates a scrollable list that works page by page from an explicit [List] 62 | /// of widgets. 63 | /// 64 | /// This constructor is appropriate for page views with a small number of 65 | /// children because constructing the [List] requires doing work for every 66 | /// child that could possibly be displayed in the page view, instead of just 67 | /// those children that are actually visible. 68 | /// 69 | /// {@template flutter.widgets.pageView.allowImplicitScrolling} 70 | /// The [allowImplicitScrolling] parameter must not be null. If true, the 71 | /// [PageView] will participate in accessibility scrolling more like a 72 | /// [ListView], where implicit scroll actions will move to the next page 73 | /// rather than into the contents of the [PageView]. 74 | /// {@endtemplate} 75 | UnionInnerPageView({ 76 | Key key, 77 | this.scrollDirection = Axis.horizontal, 78 | this.reverse = false, 79 | UnionPageController controller, 80 | this.physics, 81 | this.pageSnapping = true, 82 | this.onPageChanged, 83 | List children = const [], 84 | this.dragStartBehavior = DragStartBehavior.start, 85 | this.allowImplicitScrolling = false, 86 | this.restorationId, 87 | this.clipBehavior = Clip.hardEdge, 88 | }) : assert(allowImplicitScrolling != null), 89 | assert(clipBehavior != null), 90 | controller = controller ?? _defaultPageController, 91 | childrenDelegate = SliverChildListDelegate(children), 92 | super(key: key); 93 | 94 | /// Creates a scrollable list that works page by page using widgets that are 95 | /// created on demand. 96 | /// 97 | /// This constructor is appropriate for page views with a large (or infinite) 98 | /// number of children because the builder is called only for those children 99 | /// that are actually visible. 100 | /// 101 | /// Providing a non-null [itemCount] lets the [UnionInnerPageView] compute the maximum 102 | /// scroll extent. 103 | /// 104 | /// [itemBuilder] will be called only with indices greater than or equal to 105 | /// zero and less than [itemCount]. 106 | /// 107 | /// [UnionInnerPageView.builder] by default does not support child reordering. If 108 | /// you are planning to change child order at a later time, consider using 109 | /// [UnionInnerPageView] or [UnionInnerPageView.custom]. 110 | UnionInnerPageView.builder({ 111 | Key key, 112 | this.scrollDirection = Axis.horizontal, 113 | this.reverse = false, 114 | UnionPageController controller, 115 | this.physics, 116 | this.pageSnapping = true, 117 | this.onPageChanged, 118 | @required IndexedWidgetBuilder itemBuilder, 119 | int itemCount, 120 | this.dragStartBehavior = DragStartBehavior.start, 121 | this.allowImplicitScrolling = false, 122 | this.restorationId, 123 | this.clipBehavior = Clip.hardEdge, 124 | }) : assert(allowImplicitScrolling != null), 125 | assert(clipBehavior != null), 126 | controller = controller ?? _defaultPageController, 127 | childrenDelegate = 128 | SliverChildBuilderDelegate(itemBuilder, childCount: itemCount), 129 | super(key: key); 130 | 131 | /// Creates a scrollable list that works page by page with a custom child 132 | /// model. 133 | /// 134 | /// {@tool sample} 135 | /// 136 | /// This [UnionInnerPageView] uses a custom [SliverChildBuilderDelegate] to support child 137 | /// reordering. 138 | /// 139 | /// ```dart 140 | /// class MyPageView extends StatefulWidget { 141 | /// @override 142 | /// _MyPageViewState createState() => _MyPageViewState(); 143 | /// } 144 | /// 145 | /// class _MyPageViewState extends State { 146 | /// List items = ['1', '2', '3', '4', '5']; 147 | /// 148 | /// void _reverse() { 149 | /// setState(() { 150 | /// items = items.reversed.toList(); 151 | /// }); 152 | /// } 153 | /// 154 | /// @override 155 | /// Widget build(BuildContext context) { 156 | /// return Scaffold( 157 | /// body: SafeArea( 158 | /// child: UnionPageView.custom( 159 | /// childrenDelegate: SliverChildBuilderDelegate( 160 | /// (BuildContext context, int index) { 161 | /// return KeepAlive( 162 | /// data: items[index], 163 | /// key: ValueKey(items[index]), 164 | /// ); 165 | /// }, 166 | /// childCount: items.length, 167 | /// findChildIndexCallback: (Key key) { 168 | /// final ValueKey valueKey = key; 169 | /// final String data = valueKey.value; 170 | /// return items.indexOf(data); 171 | /// } 172 | /// ), 173 | /// ), 174 | /// ), 175 | /// bottomNavigationBar: BottomAppBar( 176 | /// child: Row( 177 | /// mainAxisAlignment: MainAxisAlignment.center, 178 | /// children: [ 179 | /// FlatButton( 180 | /// onPressed: () => _reverse(), 181 | /// child: Text('Reverse items'), 182 | /// ), 183 | /// ], 184 | /// ), 185 | /// ), 186 | /// ); 187 | /// } 188 | /// } 189 | /// 190 | /// class KeepAlive extends StatefulWidget { 191 | /// const KeepAlive({Key key, this.data}) : super(key: key); 192 | /// 193 | /// final String data; 194 | /// 195 | /// @override 196 | /// _KeepAliveState createState() => _KeepAliveState(); 197 | /// } 198 | /// 199 | /// class _KeepAliveState extends State with AutomaticKeepAliveClientMixin{ 200 | /// @override 201 | /// bool get wantKeepAlive => true; 202 | /// 203 | /// @override 204 | /// Widget build(BuildContext context) { 205 | /// super.build(context); 206 | /// return Text(widget.data); 207 | /// } 208 | /// } 209 | /// ``` 210 | /// {@end-tool} 211 | UnionInnerPageView.custom({ 212 | Key key, 213 | this.scrollDirection = Axis.horizontal, 214 | this.reverse = false, 215 | UnionPageController controller, 216 | this.physics, 217 | this.pageSnapping = true, 218 | this.onPageChanged, 219 | @required this.childrenDelegate, 220 | this.dragStartBehavior = DragStartBehavior.start, 221 | this.allowImplicitScrolling = false, 222 | this.restorationId, 223 | this.clipBehavior = Clip.hardEdge, 224 | }) : assert(childrenDelegate != null), 225 | assert(allowImplicitScrolling != null), 226 | assert(clipBehavior != null), 227 | controller = controller ?? _defaultPageController, 228 | super(key: key); 229 | 230 | /// Controls whether the widget's pages will respond to 231 | /// [RenderObject.showOnScreen], which will allow for implicit accessibility 232 | /// scrolling. 233 | /// 234 | /// With this flag set to false, when accessibility focus reaches the end of 235 | /// the current page and the user attempts to move it to the next element, the 236 | /// focus will traverse to the next widget outside of the page view. 237 | /// 238 | /// With this flag set to true, when accessibility focus reaches the end of 239 | /// the current page and user attempts to move it to the next element, focus 240 | /// will traverse to the next page in the page view. 241 | final bool allowImplicitScrolling; 242 | 243 | /// {@macro flutter.widgets.scrollable.restorationId} 244 | final String restorationId; 245 | 246 | /// The axis along which the page view scrolls. 247 | /// 248 | /// Defaults to [Axis.horizontal]. 249 | final Axis scrollDirection; 250 | 251 | /// Whether the page view scrolls in the reading direction. 252 | /// 253 | /// For example, if the reading direction is left-to-right and 254 | /// [scrollDirection] is [Axis.horizontal], then the page view scrolls from 255 | /// left to right when [reverse] is false and from right to left when 256 | /// [reverse] is true. 257 | /// 258 | /// Similarly, if [scrollDirection] is [Axis.vertical], then the page view 259 | /// scrolls from top to bottom when [reverse] is false and from bottom to top 260 | /// when [reverse] is true. 261 | /// 262 | /// Defaults to false. 263 | final bool reverse; 264 | 265 | /// An object that can be used to control the position to which this page 266 | /// view is scrolled. 267 | final UnionPageController controller; 268 | 269 | /// How the page view should respond to user input. 270 | /// 271 | /// For example, determines how the page view continues to animate after the 272 | /// user stops dragging the page view. 273 | /// 274 | /// The physics are modified to snap to page boundaries using 275 | /// [UnionInnerPageScrollPhysics] prior to being used. 276 | /// 277 | /// Defaults to matching platform conventions. 278 | final ScrollPhysics physics; 279 | 280 | /// Set to false to disable page snapping, useful for custom scroll behavior. 281 | final bool pageSnapping; 282 | 283 | /// Called whenever the page in the center of the viewport changes. 284 | final ValueChanged onPageChanged; 285 | 286 | /// A delegate that provides the children for the [UnionInnerPageView]. 287 | /// 288 | /// The [UnionInnerPageView.custom] constructor lets you specify this delegate 289 | /// explicitly. The [UnionInnerPageView] and [UnionInnerPageView.builder] constructors create a 290 | /// [childrenDelegate] that wraps the given [List] and [IndexedWidgetBuilder], 291 | /// respectively. 292 | final SliverChildDelegate childrenDelegate; 293 | 294 | /// {@macro flutter.widgets.scrollable.dragStartBehavior} 295 | final DragStartBehavior dragStartBehavior; 296 | 297 | /// {@macro flutter.widgets.Clip} 298 | /// 299 | /// Defaults to [Clip.hardEdge]. 300 | final Clip clipBehavior; 301 | 302 | @override 303 | _UnionInnerPageViewState createState() => _UnionInnerPageViewState(); 304 | } 305 | 306 | class _UnionInnerPageViewState extends State { 307 | int _lastReportedPage = 0; 308 | 309 | @override 310 | void initState() { 311 | super.initState(); 312 | _lastReportedPage = widget.controller.initialPage; 313 | } 314 | 315 | AxisDirection _getDirection(BuildContext context) { 316 | switch (widget.scrollDirection) { 317 | case Axis.horizontal: 318 | assert(debugCheckHasDirectionality(context)); 319 | final TextDirection textDirection = Directionality.of(context); 320 | final AxisDirection axisDirection = 321 | textDirectionToAxisDirection(textDirection); 322 | return widget.reverse 323 | ? flipAxisDirection(axisDirection) 324 | : axisDirection; 325 | case Axis.vertical: 326 | return widget.reverse ? AxisDirection.up : AxisDirection.down; 327 | } 328 | return null; 329 | } 330 | 331 | @override 332 | Widget build(BuildContext context) { 333 | final AxisDirection axisDirection = _getDirection(context); 334 | final ScrollPhysics physics = _ForceImplicitScrollPhysics( 335 | allowImplicitScrolling: widget.allowImplicitScrolling, 336 | ).applyTo(widget.pageSnapping 337 | ? _kPagePhysics.applyTo(widget.physics) 338 | : widget.physics); 339 | 340 | return TabBarOverScrollStateProvider(builder: (context) { 341 | return NotificationListener( 342 | onNotification: (ScrollNotification notification) { 343 | if (notification.depth == 0 && 344 | widget.onPageChanged != null && 345 | notification is ScrollUpdateNotification) { 346 | final PageMetrics metrics = notification.metrics as PageMetrics; 347 | final int currentPage = metrics.page.round(); 348 | if (currentPage != _lastReportedPage) { 349 | _lastReportedPage = currentPage; 350 | widget.onPageChanged(currentPage); 351 | } 352 | } else if (notification is OverscrollNotification) { 353 | TabBarOverScrollStateProvider.of(notification.context) 354 | ?.setOverScroll(true); 355 | } else if (notification is ScrollEndNotification) { 356 | TabBarOverScrollStateProvider.of(notification.context) 357 | ?.setOverScroll(false); 358 | } 359 | return false; 360 | }, 361 | child: UnionInnerScrollable( 362 | dragStartBehavior: widget.dragStartBehavior, 363 | axisDirection: axisDirection, 364 | controller: widget.controller, 365 | physics: physics, 366 | restorationId: widget.restorationId, 367 | viewportBuilder: (BuildContext context, ViewportOffset position) { 368 | return Viewport( 369 | // TODO(dnfield): we should provide a way to set cacheExtent 370 | // independent of implicit scrolling: 371 | // https://github.com/flutter/flutter/issues/45632 372 | cacheExtent: widget.allowImplicitScrolling ? 1.0 : 0.0, 373 | cacheExtentStyle: CacheExtentStyle.viewport, 374 | axisDirection: axisDirection, 375 | offset: position, 376 | clipBehavior: widget.clipBehavior, 377 | slivers: [ 378 | SliverFillViewport( 379 | viewportFraction: widget.controller.viewportFraction, 380 | delegate: widget.childrenDelegate, 381 | ), 382 | ], 383 | ); 384 | }, 385 | ), 386 | ); 387 | }); 388 | } 389 | 390 | @override 391 | void debugFillProperties(DiagnosticPropertiesBuilder description) { 392 | super.debugFillProperties(description); 393 | description 394 | .add(EnumProperty('scrollDirection', widget.scrollDirection)); 395 | description.add( 396 | FlagProperty('reverse', value: widget.reverse, ifTrue: 'reversed')); 397 | description.add(DiagnosticsProperty( 398 | 'controller', widget.controller, 399 | showName: false)); 400 | description.add(DiagnosticsProperty( 401 | 'physics', widget.physics, 402 | showName: false)); 403 | description.add(FlagProperty('pageSnapping', 404 | value: widget.pageSnapping, ifFalse: 'snapping disabled')); 405 | description.add(FlagProperty('allowImplicitScrolling', 406 | value: widget.allowImplicitScrolling, 407 | ifTrue: 'allow implicit scrolling')); 408 | } 409 | } 410 | -------------------------------------------------------------------------------- /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 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 12 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; 13 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 14 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; 15 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 16 | 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; }; 17 | 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; 18 | 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; 19 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 20 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 21 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXCopyFilesBuildPhase section */ 25 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 26 | isa = PBXCopyFilesBuildPhase; 27 | buildActionMask = 2147483647; 28 | dstPath = ""; 29 | dstSubfolderSpec = 10; 30 | files = ( 31 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, 32 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, 33 | ); 34 | name = "Embed Frameworks"; 35 | runOnlyForDeploymentPostprocessing = 0; 36 | }; 37 | /* End PBXCopyFilesBuildPhase section */ 38 | 39 | /* Begin PBXFileReference section */ 40 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 41 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 42 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 43 | 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; 44 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 45 | 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 46 | 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 47 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 48 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 49 | 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; 50 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 51 | 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 52 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 53 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 54 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 55 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56 | /* End PBXFileReference section */ 57 | 58 | /* Begin PBXFrameworksBuildPhase section */ 59 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 60 | isa = PBXFrameworksBuildPhase; 61 | buildActionMask = 2147483647; 62 | files = ( 63 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, 64 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, 65 | ); 66 | runOnlyForDeploymentPostprocessing = 0; 67 | }; 68 | /* End PBXFrameworksBuildPhase section */ 69 | 70 | /* Begin PBXGroup section */ 71 | 9740EEB11CF90186004384FC /* Flutter */ = { 72 | isa = PBXGroup; 73 | children = ( 74 | 3B80C3931E831B6300D905FE /* App.framework */, 75 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 76 | 9740EEBA1CF902C7004384FC /* Flutter.framework */, 77 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 78 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 79 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 80 | ); 81 | name = Flutter; 82 | sourceTree = ""; 83 | }; 84 | 97C146E51CF9000F007C117D = { 85 | isa = PBXGroup; 86 | children = ( 87 | 9740EEB11CF90186004384FC /* Flutter */, 88 | 97C146F01CF9000F007C117D /* Runner */, 89 | 97C146EF1CF9000F007C117D /* Products */, 90 | CF3B75C9A7D2FA2A4C99F110 /* Frameworks */, 91 | ); 92 | sourceTree = ""; 93 | }; 94 | 97C146EF1CF9000F007C117D /* Products */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | 97C146EE1CF9000F007C117D /* Runner.app */, 98 | ); 99 | name = Products; 100 | sourceTree = ""; 101 | }; 102 | 97C146F01CF9000F007C117D /* Runner */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */, 106 | 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */, 107 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 108 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 109 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 110 | 97C147021CF9000F007C117D /* Info.plist */, 111 | 97C146F11CF9000F007C117D /* Supporting Files */, 112 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 113 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 114 | ); 115 | path = Runner; 116 | sourceTree = ""; 117 | }; 118 | 97C146F11CF9000F007C117D /* Supporting Files */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | 97C146F21CF9000F007C117D /* main.m */, 122 | ); 123 | name = "Supporting Files"; 124 | sourceTree = ""; 125 | }; 126 | /* End PBXGroup section */ 127 | 128 | /* Begin PBXNativeTarget section */ 129 | 97C146ED1CF9000F007C117D /* Runner */ = { 130 | isa = PBXNativeTarget; 131 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 132 | buildPhases = ( 133 | 9740EEB61CF901F6004384FC /* Run Script */, 134 | 97C146EA1CF9000F007C117D /* Sources */, 135 | 97C146EB1CF9000F007C117D /* Frameworks */, 136 | 97C146EC1CF9000F007C117D /* Resources */, 137 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 138 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 139 | ); 140 | buildRules = ( 141 | ); 142 | dependencies = ( 143 | ); 144 | name = Runner; 145 | productName = Runner; 146 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 147 | productType = "com.apple.product-type.application"; 148 | }; 149 | /* End PBXNativeTarget section */ 150 | 151 | /* Begin PBXProject section */ 152 | 97C146E61CF9000F007C117D /* Project object */ = { 153 | isa = PBXProject; 154 | attributes = { 155 | LastUpgradeCheck = 1020; 156 | ORGANIZATIONNAME = "The Chromium Authors"; 157 | TargetAttributes = { 158 | 97C146ED1CF9000F007C117D = { 159 | CreatedOnToolsVersion = 7.3.1; 160 | }; 161 | }; 162 | }; 163 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 164 | compatibilityVersion = "Xcode 3.2"; 165 | developmentRegion = en; 166 | hasScannedForEncodings = 0; 167 | knownRegions = ( 168 | en, 169 | Base, 170 | ); 171 | mainGroup = 97C146E51CF9000F007C117D; 172 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 173 | projectDirPath = ""; 174 | projectRoot = ""; 175 | targets = ( 176 | 97C146ED1CF9000F007C117D /* Runner */, 177 | ); 178 | }; 179 | /* End PBXProject section */ 180 | 181 | /* Begin PBXResourcesBuildPhase section */ 182 | 97C146EC1CF9000F007C117D /* Resources */ = { 183 | isa = PBXResourcesBuildPhase; 184 | buildActionMask = 2147483647; 185 | files = ( 186 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 187 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 188 | 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */, 189 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 190 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 191 | ); 192 | runOnlyForDeploymentPostprocessing = 0; 193 | }; 194 | /* End PBXResourcesBuildPhase section */ 195 | 196 | /* Begin PBXShellScriptBuildPhase section */ 197 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 198 | isa = PBXShellScriptBuildPhase; 199 | buildActionMask = 2147483647; 200 | files = ( 201 | ); 202 | inputPaths = ( 203 | ); 204 | name = "Thin Binary"; 205 | outputPaths = ( 206 | ); 207 | runOnlyForDeploymentPostprocessing = 0; 208 | shellPath = /bin/sh; 209 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; 210 | }; 211 | 9740EEB61CF901F6004384FC /* Run Script */ = { 212 | isa = PBXShellScriptBuildPhase; 213 | buildActionMask = 2147483647; 214 | files = ( 215 | ); 216 | inputPaths = ( 217 | ); 218 | name = "Run Script"; 219 | outputPaths = ( 220 | ); 221 | runOnlyForDeploymentPostprocessing = 0; 222 | shellPath = /bin/sh; 223 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 224 | }; 225 | /* End PBXShellScriptBuildPhase section */ 226 | 227 | /* Begin PBXSourcesBuildPhase section */ 228 | 97C146EA1CF9000F007C117D /* Sources */ = { 229 | isa = PBXSourcesBuildPhase; 230 | buildActionMask = 2147483647; 231 | files = ( 232 | 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */, 233 | 97C146F31CF9000F007C117D /* main.m in Sources */, 234 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 235 | ); 236 | runOnlyForDeploymentPostprocessing = 0; 237 | }; 238 | /* End PBXSourcesBuildPhase section */ 239 | 240 | /* Begin PBXVariantGroup section */ 241 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 242 | isa = PBXVariantGroup; 243 | children = ( 244 | 97C146FB1CF9000F007C117D /* Base */, 245 | ); 246 | name = Main.storyboard; 247 | sourceTree = ""; 248 | }; 249 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 250 | isa = PBXVariantGroup; 251 | children = ( 252 | 97C147001CF9000F007C117D /* Base */, 253 | ); 254 | name = LaunchScreen.storyboard; 255 | sourceTree = ""; 256 | }; 257 | /* End PBXVariantGroup section */ 258 | 259 | /* Begin XCBuildConfiguration section */ 260 | 249021D3217E4FDB00AE95B9 /* Profile */ = { 261 | isa = XCBuildConfiguration; 262 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 263 | buildSettings = { 264 | ALWAYS_SEARCH_USER_PATHS = NO; 265 | CLANG_ANALYZER_NONNULL = YES; 266 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 267 | CLANG_CXX_LIBRARY = "libc++"; 268 | CLANG_ENABLE_MODULES = YES; 269 | CLANG_ENABLE_OBJC_ARC = YES; 270 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 271 | CLANG_WARN_BOOL_CONVERSION = YES; 272 | CLANG_WARN_COMMA = YES; 273 | CLANG_WARN_CONSTANT_CONVERSION = YES; 274 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 275 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 276 | CLANG_WARN_EMPTY_BODY = YES; 277 | CLANG_WARN_ENUM_CONVERSION = YES; 278 | CLANG_WARN_INFINITE_RECURSION = YES; 279 | CLANG_WARN_INT_CONVERSION = YES; 280 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 281 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 282 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 283 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 284 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 285 | CLANG_WARN_STRICT_PROTOTYPES = YES; 286 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 287 | CLANG_WARN_UNREACHABLE_CODE = YES; 288 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 289 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 290 | COPY_PHASE_STRIP = NO; 291 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 292 | ENABLE_NS_ASSERTIONS = NO; 293 | ENABLE_STRICT_OBJC_MSGSEND = YES; 294 | GCC_C_LANGUAGE_STANDARD = gnu99; 295 | GCC_NO_COMMON_BLOCKS = YES; 296 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 297 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 298 | GCC_WARN_UNDECLARED_SELECTOR = YES; 299 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 300 | GCC_WARN_UNUSED_FUNCTION = YES; 301 | GCC_WARN_UNUSED_VARIABLE = YES; 302 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 303 | MTL_ENABLE_DEBUG_INFO = NO; 304 | SDKROOT = iphoneos; 305 | TARGETED_DEVICE_FAMILY = "1,2"; 306 | VALIDATE_PRODUCT = YES; 307 | }; 308 | name = Profile; 309 | }; 310 | 249021D4217E4FDB00AE95B9 /* Profile */ = { 311 | isa = XCBuildConfiguration; 312 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 313 | buildSettings = { 314 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 315 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 316 | ENABLE_BITCODE = NO; 317 | FRAMEWORK_SEARCH_PATHS = ( 318 | "$(inherited)", 319 | "$(PROJECT_DIR)/Flutter", 320 | ); 321 | INFOPLIST_FILE = Runner/Info.plist; 322 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 323 | LIBRARY_SEARCH_PATHS = ( 324 | "$(inherited)", 325 | "$(PROJECT_DIR)/Flutter", 326 | ); 327 | PRODUCT_BUNDLE_IDENTIFIER = com.wilin.example; 328 | PRODUCT_NAME = "$(TARGET_NAME)"; 329 | VERSIONING_SYSTEM = "apple-generic"; 330 | }; 331 | name = Profile; 332 | }; 333 | 97C147031CF9000F007C117D /* Debug */ = { 334 | isa = XCBuildConfiguration; 335 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 336 | buildSettings = { 337 | ALWAYS_SEARCH_USER_PATHS = NO; 338 | CLANG_ANALYZER_NONNULL = YES; 339 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 340 | CLANG_CXX_LIBRARY = "libc++"; 341 | CLANG_ENABLE_MODULES = YES; 342 | CLANG_ENABLE_OBJC_ARC = YES; 343 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 344 | CLANG_WARN_BOOL_CONVERSION = YES; 345 | CLANG_WARN_COMMA = YES; 346 | CLANG_WARN_CONSTANT_CONVERSION = YES; 347 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 348 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 349 | CLANG_WARN_EMPTY_BODY = YES; 350 | CLANG_WARN_ENUM_CONVERSION = YES; 351 | CLANG_WARN_INFINITE_RECURSION = YES; 352 | CLANG_WARN_INT_CONVERSION = YES; 353 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 354 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 355 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 356 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 357 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 358 | CLANG_WARN_STRICT_PROTOTYPES = YES; 359 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 360 | CLANG_WARN_UNREACHABLE_CODE = YES; 361 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 362 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 363 | COPY_PHASE_STRIP = NO; 364 | DEBUG_INFORMATION_FORMAT = dwarf; 365 | ENABLE_STRICT_OBJC_MSGSEND = YES; 366 | ENABLE_TESTABILITY = YES; 367 | GCC_C_LANGUAGE_STANDARD = gnu99; 368 | GCC_DYNAMIC_NO_PIC = NO; 369 | GCC_NO_COMMON_BLOCKS = YES; 370 | GCC_OPTIMIZATION_LEVEL = 0; 371 | GCC_PREPROCESSOR_DEFINITIONS = ( 372 | "DEBUG=1", 373 | "$(inherited)", 374 | ); 375 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 376 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 377 | GCC_WARN_UNDECLARED_SELECTOR = YES; 378 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 379 | GCC_WARN_UNUSED_FUNCTION = YES; 380 | GCC_WARN_UNUSED_VARIABLE = YES; 381 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 382 | MTL_ENABLE_DEBUG_INFO = YES; 383 | ONLY_ACTIVE_ARCH = YES; 384 | SDKROOT = iphoneos; 385 | TARGETED_DEVICE_FAMILY = "1,2"; 386 | }; 387 | name = Debug; 388 | }; 389 | 97C147041CF9000F007C117D /* Release */ = { 390 | isa = XCBuildConfiguration; 391 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 392 | buildSettings = { 393 | ALWAYS_SEARCH_USER_PATHS = NO; 394 | CLANG_ANALYZER_NONNULL = YES; 395 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 396 | CLANG_CXX_LIBRARY = "libc++"; 397 | CLANG_ENABLE_MODULES = YES; 398 | CLANG_ENABLE_OBJC_ARC = YES; 399 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 400 | CLANG_WARN_BOOL_CONVERSION = YES; 401 | CLANG_WARN_COMMA = YES; 402 | CLANG_WARN_CONSTANT_CONVERSION = YES; 403 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 404 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 405 | CLANG_WARN_EMPTY_BODY = YES; 406 | CLANG_WARN_ENUM_CONVERSION = YES; 407 | CLANG_WARN_INFINITE_RECURSION = YES; 408 | CLANG_WARN_INT_CONVERSION = YES; 409 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 410 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 411 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 412 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 413 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 414 | CLANG_WARN_STRICT_PROTOTYPES = YES; 415 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 416 | CLANG_WARN_UNREACHABLE_CODE = YES; 417 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 418 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 419 | COPY_PHASE_STRIP = NO; 420 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 421 | ENABLE_NS_ASSERTIONS = NO; 422 | ENABLE_STRICT_OBJC_MSGSEND = YES; 423 | GCC_C_LANGUAGE_STANDARD = gnu99; 424 | GCC_NO_COMMON_BLOCKS = YES; 425 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 426 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 427 | GCC_WARN_UNDECLARED_SELECTOR = YES; 428 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 429 | GCC_WARN_UNUSED_FUNCTION = YES; 430 | GCC_WARN_UNUSED_VARIABLE = YES; 431 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 432 | MTL_ENABLE_DEBUG_INFO = NO; 433 | SDKROOT = iphoneos; 434 | TARGETED_DEVICE_FAMILY = "1,2"; 435 | VALIDATE_PRODUCT = YES; 436 | }; 437 | name = Release; 438 | }; 439 | 97C147061CF9000F007C117D /* Debug */ = { 440 | isa = XCBuildConfiguration; 441 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 442 | buildSettings = { 443 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 444 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 445 | ENABLE_BITCODE = NO; 446 | FRAMEWORK_SEARCH_PATHS = ( 447 | "$(inherited)", 448 | "$(PROJECT_DIR)/Flutter", 449 | ); 450 | INFOPLIST_FILE = Runner/Info.plist; 451 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 452 | LIBRARY_SEARCH_PATHS = ( 453 | "$(inherited)", 454 | "$(PROJECT_DIR)/Flutter", 455 | ); 456 | PRODUCT_BUNDLE_IDENTIFIER = com.wilin.example; 457 | PRODUCT_NAME = "$(TARGET_NAME)"; 458 | VERSIONING_SYSTEM = "apple-generic"; 459 | }; 460 | name = Debug; 461 | }; 462 | 97C147071CF9000F007C117D /* Release */ = { 463 | isa = XCBuildConfiguration; 464 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 465 | buildSettings = { 466 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 467 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 468 | ENABLE_BITCODE = NO; 469 | FRAMEWORK_SEARCH_PATHS = ( 470 | "$(inherited)", 471 | "$(PROJECT_DIR)/Flutter", 472 | ); 473 | INFOPLIST_FILE = Runner/Info.plist; 474 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 475 | LIBRARY_SEARCH_PATHS = ( 476 | "$(inherited)", 477 | "$(PROJECT_DIR)/Flutter", 478 | ); 479 | PRODUCT_BUNDLE_IDENTIFIER = com.wilin.example; 480 | PRODUCT_NAME = "$(TARGET_NAME)"; 481 | VERSIONING_SYSTEM = "apple-generic"; 482 | }; 483 | name = Release; 484 | }; 485 | /* End XCBuildConfiguration section */ 486 | 487 | /* Begin XCConfigurationList section */ 488 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 489 | isa = XCConfigurationList; 490 | buildConfigurations = ( 491 | 97C147031CF9000F007C117D /* Debug */, 492 | 97C147041CF9000F007C117D /* Release */, 493 | 249021D3217E4FDB00AE95B9 /* Profile */, 494 | ); 495 | defaultConfigurationIsVisible = 0; 496 | defaultConfigurationName = Release; 497 | }; 498 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 499 | isa = XCConfigurationList; 500 | buildConfigurations = ( 501 | 97C147061CF9000F007C117D /* Debug */, 502 | 97C147071CF9000F007C117D /* Release */, 503 | 249021D4217E4FDB00AE95B9 /* Profile */, 504 | ); 505 | defaultConfigurationIsVisible = 0; 506 | defaultConfigurationName = Release; 507 | }; 508 | /* End XCConfigurationList section */ 509 | }; 510 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 511 | } 512 | --------------------------------------------------------------------------------