├── LICENSE ├── example ├── 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 │ │ │ │ ├── java │ │ │ │ │ └── io │ │ │ │ │ │ └── luodongseu │ │ │ │ │ │ └── example │ │ │ │ │ │ └── MainActivity.java │ │ │ │ └── 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 │ │ ├── Info.plist │ │ └── Base.lproj │ │ │ ├── Main.storyboard │ │ │ └── LaunchScreen.storyboard │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── WorkspaceSettings.xcsettings │ └── Runner.xcodeproj │ │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ │ ├── xcshareddata │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ │ └── project.pbxproj ├── .metadata ├── README.md ├── test │ └── widget_test.dart ├── .gitignore ├── pubspec.yaml ├── pubspec.lock └── lib │ └── main.dart ├── CHANGELOG.md ├── ezgif-5-c52876ed6242.gif ├── .metadata ├── .gitignore ├── pubspec.yaml ├── README.md ├── pubspec.lock └── lib └── flutter_sticky_table.dart /LICENSE: -------------------------------------------------------------------------------- 1 | TODO: Add your license here. 2 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [0.0.1] - TODO: Add release date. 2 | 3 | * TODO: Describe initial release. 4 | -------------------------------------------------------------------------------- /ezgif-5-c52876ed6242.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luodongseu/flutter_sticky_table/HEAD/ezgif-5-c52876ed6242.gif -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : FlutterAppDelegate 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luodongseu/flutter_sticky_table/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/luodongseu/flutter_sticky_table/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/luodongseu/flutter_sticky_table/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/luodongseu/flutter_sticky_table/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/luodongseu/flutter_sticky_table/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luodongseu/flutter_sticky_table/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luodongseu/flutter_sticky_table/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/luodongseu/flutter_sticky_table/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/luodongseu/flutter_sticky_table/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/luodongseu/flutter_sticky_table/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/luodongseu/flutter_sticky_table/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/luodongseu/flutter_sticky_table/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/luodongseu/flutter_sticky_table/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/luodongseu/flutter_sticky_table/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/luodongseu/flutter_sticky_table/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/luodongseu/flutter_sticky_table/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/luodongseu/flutter_sticky_table/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/luodongseu/flutter_sticky_table/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/luodongseu/flutter_sticky_table/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luodongseu/flutter_sticky_table/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/luodongseu/flutter_sticky_table/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luodongseu/flutter_sticky_table/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/luodongseu/flutter_sticky_table/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char* argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/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/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildSystemType 6 | Original 7 | 8 | 9 | -------------------------------------------------------------------------------- /.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: f36a35d20ac5dc2936cab6ccc60f5d9afa34466e 8 | channel: unknown 9 | 10 | project_type: package 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: f36a35d20ac5dc2936cab6ccc60f5d9afa34466e 8 | channel: unknown 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/io/luodongseu/example/MainActivity.java: -------------------------------------------------------------------------------- 1 | package io.luodongseu.example; 2 | 3 | import android.os.Bundle; 4 | import io.flutter.app.FlutterActivity; 5 | import io.flutter.plugins.GeneratedPluginRegistrant; 6 | 7 | public class MainActivity extends FlutterActivity { 8 | @Override 9 | protected void onCreate(Bundle savedInstanceState) { 10 | super.onCreate(savedInstanceState); 11 | GeneratedPluginRegistrant.registerWith(this); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/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/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | google() 4 | jcenter() 5 | } 6 | 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:3.2.1' 9 | } 10 | } 11 | 12 | allprojects { 13 | repositories { 14 | google() 15 | jcenter() 16 | } 17 | } 18 | 19 | rootProject.buildDir = '../build' 20 | subprojects { 21 | project.buildDir = "${rootProject.buildDir}/${project.name}" 22 | } 23 | subprojects { 24 | project.evaluationDependsOn(':app') 25 | } 26 | 27 | task clean(type: Delete) { 28 | delete rootProject.buildDir 29 | } 30 | -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility that Flutter provides. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | import 'package:example/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(MyApp()); 17 | 18 | // Verify that our counter starts at 0. 19 | expect(find.text('0'), findsOneWidget); 20 | expect(find.text('1'), findsNothing); 21 | 22 | // Tap the '+' icon and trigger a frame. 23 | await tester.tap(find.byIcon(Icons.add)); 24 | await tester.pump(); 25 | 26 | // Verify that our counter has incremented. 27 | expect(find.text('0'), findsNothing); 28 | expect(find.text('1'), findsOneWidget); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | example 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /example/ios/Runner/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 | -------------------------------------------------------------------------------- /.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/ServiceDefinitions.json 65 | **/ios/Runner/GeneratedPluginRegistrant.* 66 | 67 | # Exceptions to above rules. 68 | !**/ios/**/default.mode1v3 69 | !**/ios/**/default.mode2v3 70 | !**/ios/**/default.pbxuser 71 | !**/ios/**/default.perspectivev3 72 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 73 | -------------------------------------------------------------------------------- /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/ServiceDefinitions.json 65 | **/ios/Runner/GeneratedPluginRegistrant.* 66 | 67 | # Exceptions to above rules. 68 | !**/ios/**/default.mode1v3 69 | !**/ios/**/default.mode2v3 70 | !**/ios/**/default.pbxuser 71 | !**/ios/**/default.perspectivev3 72 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 73 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_sticky_table 2 | description: flutter table with sticky header and sticky left column 3 | version: 0.0.2 4 | author: luodongseu 5 | homepage: https://github.com/luodongseu/flutter_sticky_table 6 | 7 | environment: 8 | sdk: ">=2.1.0 <3.0.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | 14 | dev_dependencies: 15 | flutter_test: 16 | sdk: flutter 17 | 18 | # For information on the generic Dart part of this file, see the 19 | # following page: https://dart.dev/tools/pub/pubspec 20 | 21 | # The following section is specific to Flutter. 22 | flutter: 23 | 24 | # To add assets to your package, add an assets section, like this: 25 | # assets: 26 | # - images/a_dot_burr.jpeg 27 | # - images/a_dot_ham.jpeg 28 | # 29 | # For details regarding assets in packages, see 30 | # https://flutter.dev/assets-and-images/#from-packages 31 | # 32 | # An image asset can refer to one or more resolution-specific "variants", see 33 | # https://flutter.dev/assets-and-images/#resolution-aware. 34 | 35 | # To add custom fonts to your package, add a fonts section here, 36 | # in this "flutter" section. Each entry in this list should have a 37 | # "family" key with the font family name, and a "fonts" key with a 38 | # list giving the asset and other descriptors for the font. For 39 | # example: 40 | # fonts: 41 | # - family: Schyler 42 | # fonts: 43 | # - asset: fonts/Schyler-Regular.ttf 44 | # - asset: fonts/Schyler-Italic.ttf 45 | # style: italic 46 | # - family: Trajan Pro 47 | # fonts: 48 | # - asset: fonts/TrajanPro.ttf 49 | # - asset: fonts/TrajanPro_Bold.ttf 50 | # weight: 700 51 | # 52 | # For details regarding fonts in packages, see 53 | # https://flutter.dev/custom-fonts/#from-packages 54 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 9 | 13 | 20 | 24 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # flutter_sticky_table 2 | 3 | flutter table with sticky header and sticky left column 4 | 5 | ## Screenshots 6 | ![截图](https://github.com/luodongseu/flutter_sticky_table/blob/master/ezgif-5-c52876ed6242.gif) 7 | 8 | ## Getting Started 9 | 10 | ### add dependencies 11 | 12 | ``` 13 | flutter_sticky_table: any 14 | ``` 15 | 16 | ### import flutter_sticky_table 17 | 18 | ``` 19 | import 'package:flutter_sticky_table/flutter_sticky_table.dart'; 20 | ``` 21 | 22 | ### use table widget 23 | 24 | ``` 25 | /// first: define columns and data 26 | dynamic columns = [ 27 | new ColumnsProps('22', 'key1', 28 | alignment: Alignment.center, 29 | width: 80.0, 30 | color: Colors.yellow, 31 | headColor: Colors.cyan), 32 | new ColumnsProps('列23', 'key2', 33 | alignment: Alignment.centerLeft, width: 400.0), 34 | new ColumnsProps('列3', 'key3', alignment: Alignment.center), 35 | new ColumnsProps('列3', 'key3', alignment: Alignment.center, width: 200, 36 | render: (BuildContext c, dynamic d) { 37 | return new Material( 38 | child: new FlatButton( 39 | onPressed: () { 40 | showDialog(context: context, child: Text('aaa')); 41 | }, 42 | child: Text('button')), 43 | ); 44 | }), 45 | ]; 46 | dynamic data = [ 47 | {'key1': '1', 'key2': 'data2', 'key3': 'xx'}, 48 | {'key1': '11', 'key2': 'data22', 'key3': 'xxxx'}, 49 | {'key1': '111', 'key2': 'data22', 'key3': 'xxxxxx'} 50 | ]; 51 | 52 | /// second: use widget to show table 53 | new SingleChildScrollView( 54 | child: new Columns( 55 | children: [ 56 | ... 57 | StickyTable(stickyColumnCount: 1, 58 | columns: columns, 59 | data: data, 60 | showBorder: true), 61 | ... 62 | ] 63 | )); 64 | 65 | ``` 66 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 26 | 27 | android { 28 | compileSdkVersion 28 29 | 30 | lintOptions { 31 | disable 'InvalidPackage' 32 | } 33 | 34 | defaultConfig { 35 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 36 | applicationId "io.luodongseu.example" 37 | minSdkVersion 16 38 | targetSdkVersion 28 39 | versionCode flutterVersionCode.toInteger() 40 | versionName flutterVersionName 41 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 42 | } 43 | 44 | buildTypes { 45 | release { 46 | // TODO: Add your own signing config for the release build. 47 | // Signing with the debug keys for now, so `flutter run --release` works. 48 | signingConfig signingConfigs.debug 49 | } 50 | } 51 | } 52 | 53 | flutter { 54 | source '../..' 55 | } 56 | 57 | dependencies { 58 | testImplementation 'junit:junit:4.12' 59 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 60 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 61 | } 62 | -------------------------------------------------------------------------------- /example/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/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.1.0 <3.0.0" 18 | 19 | dependencies: 20 | flutter: 21 | sdk: flutter 22 | 23 | # The following adds the Cupertino Icons font to your application. 24 | # Use with the CupertinoIcons class for iOS style icons. 25 | # cupertino_icons: ^0.1.2 26 | flutter_sticky_table: 27 | path: ../ 28 | 29 | dev_dependencies: 30 | flutter_test: 31 | sdk: flutter 32 | 33 | 34 | # For information on the generic Dart part of this file, see the 35 | # following page: https://dart.dev/tools/pub/pubspec 36 | 37 | # The following section is specific to Flutter. 38 | flutter: 39 | 40 | # The following line ensures that the Material Icons font is 41 | # included with your application, so that you can use the icons in 42 | # the material Icons class. 43 | uses-material-design: true 44 | 45 | # To add assets to your application, add an assets section, like this: 46 | # assets: 47 | # - images/a_dot_burr.jpeg 48 | # - images/a_dot_ham.jpeg 49 | 50 | # An image asset can refer to one or more resolution-specific "variants", see 51 | # https://flutter.dev/assets-and-images/#resolution-aware. 52 | 53 | # For details regarding adding assets from package dependencies, see 54 | # https://flutter.dev/assets-and-images/#from-packages 55 | 56 | # To add custom fonts to your application, add a fonts section here, 57 | # in this "flutter" section. Each entry in this list should have a 58 | # "family" key with the font family name, and a "fonts" key with a 59 | # list giving the asset and other descriptors for the font. For 60 | # example: 61 | # fonts: 62 | # - family: Schyler 63 | # fonts: 64 | # - asset: fonts/Schyler-Regular.ttf 65 | # - asset: fonts/Schyler-Italic.ttf 66 | # style: italic 67 | # - family: Trajan Pro 68 | # fonts: 69 | # - asset: fonts/TrajanPro.ttf 70 | # - asset: fonts/TrajanPro_Bold.ttf 71 | # weight: 700 72 | # 73 | # For details regarding fonts from package dependencies, 74 | # see https://flutter.dev/custom-fonts/#from-packages 75 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 33 | 34 | 40 | 41 | 42 | 43 | 44 | 45 | 56 | 58 | 64 | 65 | 66 | 67 | 68 | 69 | 75 | 77 | 83 | 84 | 85 | 86 | 88 | 89 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /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.flutter-io.cn" 9 | source: hosted 10 | version: "2.2.0" 11 | boolean_selector: 12 | dependency: transitive 13 | description: 14 | name: boolean_selector 15 | url: "https://pub.flutter-io.cn" 16 | source: hosted 17 | version: "1.0.4" 18 | charcode: 19 | dependency: transitive 20 | description: 21 | name: charcode 22 | url: "https://pub.flutter-io.cn" 23 | source: hosted 24 | version: "1.1.2" 25 | collection: 26 | dependency: transitive 27 | description: 28 | name: collection 29 | url: "https://pub.flutter-io.cn" 30 | source: hosted 31 | version: "1.14.11" 32 | flutter: 33 | dependency: "direct main" 34 | description: flutter 35 | source: sdk 36 | version: "0.0.0" 37 | flutter_test: 38 | dependency: "direct dev" 39 | description: flutter 40 | source: sdk 41 | version: "0.0.0" 42 | matcher: 43 | dependency: transitive 44 | description: 45 | name: matcher 46 | url: "https://pub.flutter-io.cn" 47 | source: hosted 48 | version: "0.12.5" 49 | meta: 50 | dependency: transitive 51 | description: 52 | name: meta 53 | url: "https://pub.flutter-io.cn" 54 | source: hosted 55 | version: "1.1.6" 56 | path: 57 | dependency: transitive 58 | description: 59 | name: path 60 | url: "https://pub.flutter-io.cn" 61 | source: hosted 62 | version: "1.6.2" 63 | pedantic: 64 | dependency: transitive 65 | description: 66 | name: pedantic 67 | url: "https://pub.flutter-io.cn" 68 | source: hosted 69 | version: "1.7.0" 70 | quiver: 71 | dependency: transitive 72 | description: 73 | name: quiver 74 | url: "https://pub.flutter-io.cn" 75 | source: hosted 76 | version: "2.0.3" 77 | sky_engine: 78 | dependency: transitive 79 | description: flutter 80 | source: sdk 81 | version: "0.0.99" 82 | source_span: 83 | dependency: transitive 84 | description: 85 | name: source_span 86 | url: "https://pub.flutter-io.cn" 87 | source: hosted 88 | version: "1.5.5" 89 | stack_trace: 90 | dependency: transitive 91 | description: 92 | name: stack_trace 93 | url: "https://pub.flutter-io.cn" 94 | source: hosted 95 | version: "1.9.3" 96 | stream_channel: 97 | dependency: transitive 98 | description: 99 | name: stream_channel 100 | url: "https://pub.flutter-io.cn" 101 | source: hosted 102 | version: "2.0.0" 103 | string_scanner: 104 | dependency: transitive 105 | description: 106 | name: string_scanner 107 | url: "https://pub.flutter-io.cn" 108 | source: hosted 109 | version: "1.0.4" 110 | term_glyph: 111 | dependency: transitive 112 | description: 113 | name: term_glyph 114 | url: "https://pub.flutter-io.cn" 115 | source: hosted 116 | version: "1.1.0" 117 | test_api: 118 | dependency: transitive 119 | description: 120 | name: test_api 121 | url: "https://pub.flutter-io.cn" 122 | source: hosted 123 | version: "0.2.5" 124 | typed_data: 125 | dependency: transitive 126 | description: 127 | name: typed_data 128 | url: "https://pub.flutter-io.cn" 129 | source: hosted 130 | version: "1.1.6" 131 | vector_math: 132 | dependency: transitive 133 | description: 134 | name: vector_math 135 | url: "https://pub.flutter-io.cn" 136 | source: hosted 137 | version: "2.0.8" 138 | sdks: 139 | dart: ">=2.2.0 <3.0.0" 140 | -------------------------------------------------------------------------------- /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.flutter-io.cn" 9 | source: hosted 10 | version: "2.2.0" 11 | boolean_selector: 12 | dependency: transitive 13 | description: 14 | name: boolean_selector 15 | url: "https://pub.flutter-io.cn" 16 | source: hosted 17 | version: "1.0.4" 18 | charcode: 19 | dependency: transitive 20 | description: 21 | name: charcode 22 | url: "https://pub.flutter-io.cn" 23 | source: hosted 24 | version: "1.1.2" 25 | collection: 26 | dependency: transitive 27 | description: 28 | name: collection 29 | url: "https://pub.flutter-io.cn" 30 | source: hosted 31 | version: "1.14.11" 32 | flutter: 33 | dependency: "direct main" 34 | description: flutter 35 | source: sdk 36 | version: "0.0.0" 37 | flutter_sticky_table: 38 | dependency: "direct main" 39 | description: 40 | path: ".." 41 | relative: true 42 | source: path 43 | version: "0.0.1" 44 | flutter_test: 45 | dependency: "direct dev" 46 | description: flutter 47 | source: sdk 48 | version: "0.0.0" 49 | matcher: 50 | dependency: transitive 51 | description: 52 | name: matcher 53 | url: "https://pub.flutter-io.cn" 54 | source: hosted 55 | version: "0.12.5" 56 | meta: 57 | dependency: transitive 58 | description: 59 | name: meta 60 | url: "https://pub.flutter-io.cn" 61 | source: hosted 62 | version: "1.1.6" 63 | path: 64 | dependency: transitive 65 | description: 66 | name: path 67 | url: "https://pub.flutter-io.cn" 68 | source: hosted 69 | version: "1.6.2" 70 | pedantic: 71 | dependency: transitive 72 | description: 73 | name: pedantic 74 | url: "https://pub.flutter-io.cn" 75 | source: hosted 76 | version: "1.7.0" 77 | quiver: 78 | dependency: transitive 79 | description: 80 | name: quiver 81 | url: "https://pub.flutter-io.cn" 82 | source: hosted 83 | version: "2.0.3" 84 | sky_engine: 85 | dependency: transitive 86 | description: flutter 87 | source: sdk 88 | version: "0.0.99" 89 | source_span: 90 | dependency: transitive 91 | description: 92 | name: source_span 93 | url: "https://pub.flutter-io.cn" 94 | source: hosted 95 | version: "1.5.5" 96 | stack_trace: 97 | dependency: transitive 98 | description: 99 | name: stack_trace 100 | url: "https://pub.flutter-io.cn" 101 | source: hosted 102 | version: "1.9.3" 103 | stream_channel: 104 | dependency: transitive 105 | description: 106 | name: stream_channel 107 | url: "https://pub.flutter-io.cn" 108 | source: hosted 109 | version: "2.0.0" 110 | string_scanner: 111 | dependency: transitive 112 | description: 113 | name: string_scanner 114 | url: "https://pub.flutter-io.cn" 115 | source: hosted 116 | version: "1.0.4" 117 | term_glyph: 118 | dependency: transitive 119 | description: 120 | name: term_glyph 121 | url: "https://pub.flutter-io.cn" 122 | source: hosted 123 | version: "1.1.0" 124 | test_api: 125 | dependency: transitive 126 | description: 127 | name: test_api 128 | url: "https://pub.flutter-io.cn" 129 | source: hosted 130 | version: "0.2.5" 131 | typed_data: 132 | dependency: transitive 133 | description: 134 | name: typed_data 135 | url: "https://pub.flutter-io.cn" 136 | source: hosted 137 | version: "1.1.6" 138 | vector_math: 139 | dependency: transitive 140 | description: 141 | name: vector_math 142 | url: "https://pub.flutter-io.cn" 143 | source: hosted 144 | version: "2.0.8" 145 | sdks: 146 | dart: ">=2.2.0 <3.0.0" 147 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_sticky_table/flutter_sticky_table.dart'; 5 | 6 | void main() { 7 | // debugProfileBuildsEnabled = true; 8 | 9 | runApp(MyApp()); 10 | } 11 | 12 | class MyApp extends StatelessWidget { 13 | // This widget is the root of your application. 14 | @override 15 | Widget build(BuildContext context) { 16 | return MaterialApp( 17 | title: 'Flutter Sticky Table Demo', 18 | theme: ThemeData( 19 | // This is the theme of your application. 20 | // 21 | // Try running your application with "flutter run". You'll see the 22 | // application has a blue toolbar. Then, without quitting the app, try 23 | // changing the primarySwatch below to Colors.green and then invoke 24 | // "hot reload" (press "r" in the console where you ran "flutter run", 25 | // or simply save your changes to "hot reload" in a Flutter IDE). 26 | // Notice that the counter didn't reset back to zero; the application 27 | // is not restarted. 28 | primarySwatch: Colors.blue, 29 | ), 30 | home: MyHomePage(title: 'Flutter sticky table Home Page'), 31 | ); 32 | } 33 | } 34 | 35 | class MyHomePage extends StatefulWidget { 36 | MyHomePage({Key key, this.title}) : super(key: key); 37 | 38 | // This widget is the home page of your application. It is stateful, meaning 39 | // that it has a State object (defined below) that contains fields that affect 40 | // how it looks. 41 | 42 | // This class is the configuration for the state. It holds the values (in this 43 | // case the title) provided by the parent (in this case the App widget) and 44 | // used by the build method of the State. Fields in a Widget subclass are 45 | // always marked "final". 46 | 47 | final String title; 48 | 49 | @override 50 | _MyHomePageState createState() => _MyHomePageState(); 51 | } 52 | 53 | class _MyHomePageState extends State { 54 | int _counter = 0; 55 | 56 | void _incrementCounter() { 57 | setState(() { 58 | // This call to setState tells the Flutter framework that something has 59 | // changed in this State, which causes it to rerun the build method below 60 | // so that the display can reflect the updated values. If we changed 61 | // _counter without calling setState(), then the build method would not be 62 | // called again, and so nothing would appear to happen. 63 | _counter++; 64 | }); 65 | } 66 | 67 | List columns = []; 68 | List data = []; 69 | 70 | @override 71 | void initState() { 72 | // TODO: implement initState 73 | super.initState(); 74 | 75 | columns = [ 76 | ColumnsProps('c1', 'k1', 77 | customTitle: RaisedButton( 78 | onPressed: () { 79 | _counter++; 80 | setState(() {}); 81 | }, 82 | child: Text('btn1'))), 83 | ColumnsProps('c2', 'k2', 84 | width: 120.0, 85 | customTitle: RaisedButton( 86 | onPressed: () { 87 | _counter++; 88 | setState(() {}); 89 | }, 90 | child: Text('btn2')), render: (BuildContext c, dynamic value) { 91 | return Text( 92 | 'custom render: ${value["k2"]}', 93 | ); 94 | }), 95 | ColumnsProps('c3', 'k3', 96 | width: 500.0, 97 | customTitle: RaisedButton( 98 | onPressed: () { 99 | // This call to setState tells the Flutter framework that something has 100 | // changed in this State, which causes it to rerun the build method below 101 | // so that the display can reflect the updated values. If we changed 102 | // _counter without calling setState(), then the build method would not be 103 | // called again, and so nothing would appear to happen. 104 | _counter++; 105 | setState(() {}); 106 | }, 107 | child: Text('btn3'))), 108 | ColumnsProps('c4', 'k4'), 109 | ]; 110 | 111 | Future.delayed(Duration(seconds: 1), () { 112 | data = [ 113 | {"k1": "data01", "k2": "data02", "k3": "data03", "k4": "data04"}, 114 | {"k1": "data11", "k2": "data12", "k3": "data13", "k4": "data14"}, 115 | {"k1": "data21", "k2": "data22", "k3": "data23", "k4": "data24"}, 116 | {"k1": "data31", "k2": "data322", "k3": "data33", "k4": "data34"} 117 | ]; 118 | setState(() {}); 119 | }); 120 | } 121 | 122 | @override 123 | void dispose() { 124 | super.dispose(); 125 | } 126 | 127 | @override 128 | Widget build(BuildContext context) { 129 | // This method is rerun every time setState is called, for instance as done 130 | // by the _incrementCounter method above. 131 | // 132 | // The Flutter framework has been optimized to make rerunning build methods 133 | // fast, so that you can just rebuild anything that needs updating rather 134 | // than having to individually change instances of widgets. 135 | return Scaffold( 136 | appBar: AppBar( 137 | // Here we take the value from the MyHomePage object that was created by 138 | // the App.build method, and use it to set our appbar title. 139 | title: Text(widget.title), 140 | ), 141 | body: SingleChildScrollView( 142 | // Center is a layout widget. It takes a single child and positions it 143 | // in the middle of the parent. 144 | child: Column( 145 | // Column is also layout widget. It takes a list of children and 146 | // arranges them vertically. By default, it sizes itself to fit its 147 | // children horizontally, and tries to be as tall as its parent. 148 | // 149 | // Invoke "debug painting" (press "p" in the console, choose the 150 | // "Toggle Debug Paint" action from the Flutter Inspector in Android 151 | // Studio, or the "Toggle Debug Paint" command in Visual Studio Code) 152 | // to see the wireframe for each widget. 153 | // 154 | // Column has various properties to control how it sizes itself and 155 | // how it positions its children. Here we use mainAxisAlignment to 156 | // center the children vertically; the main axis here is the vertical 157 | // axis because Columns are vertical (the cross axis would be 158 | // horizontal). 159 | mainAxisAlignment: MainAxisAlignment.start, 160 | children: [ 161 | Text( 162 | 'You have pushed the button this many times:', 163 | ), 164 | Text( 165 | '$_counter', 166 | style: Theme.of(context).textTheme.display1, 167 | ), 168 | SizedBox( 169 | height: 50, 170 | child: Container( 171 | width: double.infinity, 172 | color: Colors.red.withOpacity(0.1), 173 | child: Text('Blank Screen Before'), 174 | ), 175 | ), 176 | Text('Table demo:'), 177 | StickyTable( 178 | columns: columns, 179 | data: data, 180 | stickyColumnCount: 1, 181 | showBorder: false, 182 | ), 183 | SizedBox( 184 | height: 1500, 185 | child: Container( 186 | width: double.infinity, 187 | color: Colors.red.withOpacity(0.1), 188 | child: Text('Blank Screen After'), 189 | ), 190 | ), 191 | ], 192 | ), 193 | ), 194 | floatingActionButton: FloatingActionButton( 195 | onPressed: _incrementCounter, 196 | tooltip: 'Increment', 197 | child: Icon(Icons.add), 198 | ), // This trailing comma makes auto-formatting nicer for build methods. 199 | ); 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /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 = 0910; 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 = English; 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_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 275 | CLANG_WARN_EMPTY_BODY = YES; 276 | CLANG_WARN_ENUM_CONVERSION = YES; 277 | CLANG_WARN_INFINITE_RECURSION = YES; 278 | CLANG_WARN_INT_CONVERSION = YES; 279 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 280 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 281 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 282 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 283 | CLANG_WARN_STRICT_PROTOTYPES = YES; 284 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 285 | CLANG_WARN_UNREACHABLE_CODE = YES; 286 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 287 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 288 | COPY_PHASE_STRIP = NO; 289 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 290 | ENABLE_NS_ASSERTIONS = NO; 291 | ENABLE_STRICT_OBJC_MSGSEND = YES; 292 | GCC_C_LANGUAGE_STANDARD = gnu99; 293 | GCC_NO_COMMON_BLOCKS = YES; 294 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 295 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 296 | GCC_WARN_UNDECLARED_SELECTOR = YES; 297 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 298 | GCC_WARN_UNUSED_FUNCTION = YES; 299 | GCC_WARN_UNUSED_VARIABLE = YES; 300 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 301 | MTL_ENABLE_DEBUG_INFO = NO; 302 | SDKROOT = iphoneos; 303 | TARGETED_DEVICE_FAMILY = "1,2"; 304 | VALIDATE_PRODUCT = YES; 305 | }; 306 | name = Profile; 307 | }; 308 | 249021D4217E4FDB00AE95B9 /* Profile */ = { 309 | isa = XCBuildConfiguration; 310 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 311 | buildSettings = { 312 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 313 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 314 | DEVELOPMENT_TEAM = S8QB4VV633; 315 | ENABLE_BITCODE = NO; 316 | FRAMEWORK_SEARCH_PATHS = ( 317 | "$(inherited)", 318 | "$(PROJECT_DIR)/Flutter", 319 | ); 320 | INFOPLIST_FILE = Runner/Info.plist; 321 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 322 | LIBRARY_SEARCH_PATHS = ( 323 | "$(inherited)", 324 | "$(PROJECT_DIR)/Flutter", 325 | ); 326 | PRODUCT_BUNDLE_IDENTIFIER = io.luodongseu.example; 327 | PRODUCT_NAME = "$(TARGET_NAME)"; 328 | VERSIONING_SYSTEM = "apple-generic"; 329 | }; 330 | name = Profile; 331 | }; 332 | 97C147031CF9000F007C117D /* Debug */ = { 333 | isa = XCBuildConfiguration; 334 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 335 | buildSettings = { 336 | ALWAYS_SEARCH_USER_PATHS = NO; 337 | CLANG_ANALYZER_NONNULL = YES; 338 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 339 | CLANG_CXX_LIBRARY = "libc++"; 340 | CLANG_ENABLE_MODULES = YES; 341 | CLANG_ENABLE_OBJC_ARC = YES; 342 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 343 | CLANG_WARN_BOOL_CONVERSION = YES; 344 | CLANG_WARN_COMMA = YES; 345 | CLANG_WARN_CONSTANT_CONVERSION = YES; 346 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 347 | CLANG_WARN_EMPTY_BODY = YES; 348 | CLANG_WARN_ENUM_CONVERSION = YES; 349 | CLANG_WARN_INFINITE_RECURSION = YES; 350 | CLANG_WARN_INT_CONVERSION = YES; 351 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 352 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 353 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 354 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 355 | CLANG_WARN_STRICT_PROTOTYPES = YES; 356 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 357 | CLANG_WARN_UNREACHABLE_CODE = YES; 358 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 359 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 360 | COPY_PHASE_STRIP = NO; 361 | DEBUG_INFORMATION_FORMAT = dwarf; 362 | ENABLE_STRICT_OBJC_MSGSEND = YES; 363 | ENABLE_TESTABILITY = YES; 364 | GCC_C_LANGUAGE_STANDARD = gnu99; 365 | GCC_DYNAMIC_NO_PIC = NO; 366 | GCC_NO_COMMON_BLOCKS = YES; 367 | GCC_OPTIMIZATION_LEVEL = 0; 368 | GCC_PREPROCESSOR_DEFINITIONS = ( 369 | "DEBUG=1", 370 | "$(inherited)", 371 | ); 372 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 373 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 374 | GCC_WARN_UNDECLARED_SELECTOR = YES; 375 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 376 | GCC_WARN_UNUSED_FUNCTION = YES; 377 | GCC_WARN_UNUSED_VARIABLE = YES; 378 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 379 | MTL_ENABLE_DEBUG_INFO = YES; 380 | ONLY_ACTIVE_ARCH = YES; 381 | SDKROOT = iphoneos; 382 | TARGETED_DEVICE_FAMILY = "1,2"; 383 | }; 384 | name = Debug; 385 | }; 386 | 97C147041CF9000F007C117D /* Release */ = { 387 | isa = XCBuildConfiguration; 388 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 389 | buildSettings = { 390 | ALWAYS_SEARCH_USER_PATHS = NO; 391 | CLANG_ANALYZER_NONNULL = YES; 392 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 393 | CLANG_CXX_LIBRARY = "libc++"; 394 | CLANG_ENABLE_MODULES = YES; 395 | CLANG_ENABLE_OBJC_ARC = YES; 396 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 397 | CLANG_WARN_BOOL_CONVERSION = YES; 398 | CLANG_WARN_COMMA = YES; 399 | CLANG_WARN_CONSTANT_CONVERSION = YES; 400 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 401 | CLANG_WARN_EMPTY_BODY = YES; 402 | CLANG_WARN_ENUM_CONVERSION = YES; 403 | CLANG_WARN_INFINITE_RECURSION = YES; 404 | CLANG_WARN_INT_CONVERSION = YES; 405 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 406 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 407 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 408 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 409 | CLANG_WARN_STRICT_PROTOTYPES = YES; 410 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 411 | CLANG_WARN_UNREACHABLE_CODE = YES; 412 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 413 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 414 | COPY_PHASE_STRIP = NO; 415 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 416 | ENABLE_NS_ASSERTIONS = NO; 417 | ENABLE_STRICT_OBJC_MSGSEND = YES; 418 | GCC_C_LANGUAGE_STANDARD = gnu99; 419 | GCC_NO_COMMON_BLOCKS = YES; 420 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 421 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 422 | GCC_WARN_UNDECLARED_SELECTOR = YES; 423 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 424 | GCC_WARN_UNUSED_FUNCTION = YES; 425 | GCC_WARN_UNUSED_VARIABLE = YES; 426 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 427 | MTL_ENABLE_DEBUG_INFO = NO; 428 | SDKROOT = iphoneos; 429 | TARGETED_DEVICE_FAMILY = "1,2"; 430 | VALIDATE_PRODUCT = YES; 431 | }; 432 | name = Release; 433 | }; 434 | 97C147061CF9000F007C117D /* Debug */ = { 435 | isa = XCBuildConfiguration; 436 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 437 | buildSettings = { 438 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 439 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 440 | ENABLE_BITCODE = NO; 441 | FRAMEWORK_SEARCH_PATHS = ( 442 | "$(inherited)", 443 | "$(PROJECT_DIR)/Flutter", 444 | ); 445 | INFOPLIST_FILE = Runner/Info.plist; 446 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 447 | LIBRARY_SEARCH_PATHS = ( 448 | "$(inherited)", 449 | "$(PROJECT_DIR)/Flutter", 450 | ); 451 | PRODUCT_BUNDLE_IDENTIFIER = io.luodongseu.example; 452 | PRODUCT_NAME = "$(TARGET_NAME)"; 453 | VERSIONING_SYSTEM = "apple-generic"; 454 | }; 455 | name = Debug; 456 | }; 457 | 97C147071CF9000F007C117D /* Release */ = { 458 | isa = XCBuildConfiguration; 459 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 460 | buildSettings = { 461 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 462 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 463 | ENABLE_BITCODE = NO; 464 | FRAMEWORK_SEARCH_PATHS = ( 465 | "$(inherited)", 466 | "$(PROJECT_DIR)/Flutter", 467 | ); 468 | INFOPLIST_FILE = Runner/Info.plist; 469 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 470 | LIBRARY_SEARCH_PATHS = ( 471 | "$(inherited)", 472 | "$(PROJECT_DIR)/Flutter", 473 | ); 474 | PRODUCT_BUNDLE_IDENTIFIER = io.luodongseu.example; 475 | PRODUCT_NAME = "$(TARGET_NAME)"; 476 | VERSIONING_SYSTEM = "apple-generic"; 477 | }; 478 | name = Release; 479 | }; 480 | /* End XCBuildConfiguration section */ 481 | 482 | /* Begin XCConfigurationList section */ 483 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 484 | isa = XCConfigurationList; 485 | buildConfigurations = ( 486 | 97C147031CF9000F007C117D /* Debug */, 487 | 97C147041CF9000F007C117D /* Release */, 488 | 249021D3217E4FDB00AE95B9 /* Profile */, 489 | ); 490 | defaultConfigurationIsVisible = 0; 491 | defaultConfigurationName = Release; 492 | }; 493 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 494 | isa = XCConfigurationList; 495 | buildConfigurations = ( 496 | 97C147061CF9000F007C117D /* Debug */, 497 | 97C147071CF9000F007C117D /* Release */, 498 | 249021D4217E4FDB00AE95B9 /* Profile */, 499 | ); 500 | defaultConfigurationIsVisible = 0; 501 | defaultConfigurationName = Release; 502 | }; 503 | /* End XCConfigurationList section */ 504 | }; 505 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 506 | } 507 | -------------------------------------------------------------------------------- /lib/flutter_sticky_table.dart: -------------------------------------------------------------------------------- 1 | library flutter_sticky_table; 2 | 3 | import 'dart:math'; 4 | 5 | import 'package:collection/collection.dart'; 6 | import 'package:flutter/material.dart'; 7 | import 'package:flutter/rendering.dart'; 8 | 9 | /// 默认的列宽度 10 | const defaultColumnWidth = 64.0; 11 | 12 | /// 默认的行高 13 | const defaultRowHeight = 64.0; 14 | 15 | /// 默认的padding 16 | const defaultPadding = 12.0; 17 | 18 | /// 默认的头部阴影大小 19 | const defaultHeaderElevation = 2.0; 20 | 21 | /// 默认的头部背景 22 | const defaultHeaderBackgroundColor = Color.fromRGBO(240, 240, 240, 1.0); 23 | 24 | /// 默认的内容背景 25 | const defaultBodyBackgroundColor = Color.fromRGBO(250, 250, 250, 1.0); 26 | 27 | /// 列的渲染器 28 | /// context: 上下文 29 | /// value: 表格内容 30 | /// key: 列的key 31 | typedef ColumnRender = Widget Function(BuildContext context, dynamic value); 32 | 33 | /// 列属性配置 34 | class ColumnsProps { 35 | /// 列头显示的标题 36 | final String title; 37 | 38 | /// 子元素 39 | final Widget customTitle; 40 | 41 | /// 列所在的字段索引 42 | final String dataIndex; 43 | 44 | /// 列的宽度,默认为defaultColumnWidth 45 | final double width; 46 | 47 | /// 列的高度,默认为defaultRowHeight 48 | // final double height; 49 | 50 | /// 自定义绘制表格内容(不包括表头) 51 | final ColumnRender render; 52 | 53 | /// 表格内容所在的定位方式(包括表头) 54 | final Alignment alignment; 55 | 56 | /// 表格内容的背景颜色 57 | final Color color; 58 | 59 | /// 头部背景颜色 60 | final Color headColor; 61 | 62 | ColumnsProps(this.title, this.dataIndex, 63 | {this.customTitle, 64 | this.width = 0.0, 65 | this.render, 66 | // this.height = 0.0, 67 | this.alignment = Alignment.centerLeft, 68 | this.headColor, 69 | this.color}); 70 | 71 | @override 72 | int get hashCode => super.hashCode; 73 | 74 | @override 75 | bool operator ==(other) { 76 | if (other is ColumnsProps) { 77 | ColumnsProps _other = other; 78 | return _other.title == title && 79 | // _other.customTitle == customTitle && 80 | _other.color == color && 81 | _other.width == width && 82 | _other.dataIndex == dataIndex && 83 | // _other.render == render && 84 | _other.alignment == alignment && 85 | _other.headColor == headColor; 86 | } 87 | return false; 88 | } 89 | 90 | String toString() { 91 | return '${this.title};${this.color};${this.width};${this.dataIndex};${this.alignment};${this.headColor}'; 92 | } 93 | 94 | static bool propsEquals(List c1, List c2) { 95 | if (c1 == null && c2 == null) { 96 | return true; 97 | } 98 | if (!(c1 != null && c2 != null)) { 99 | return false; 100 | } 101 | if (c1.length != c2.length) { 102 | return false; 103 | } 104 | for (int i = 0; i < c1.length; i++) { 105 | if (c1[i] != c2[i]) { 106 | return false; 107 | } 108 | } 109 | 110 | return true; 111 | } 112 | } 113 | 114 | /// 表格 115 | class StickyTable extends StatefulWidget { 116 | /// 固定列的数量(从0列开始计算) 117 | final int stickyColumnCount; 118 | 119 | /// 列的属性配置 120 | final List columns; 121 | 122 | /// 表格内容,列表 123 | final List data; 124 | 125 | /// 表头的背景颜色 126 | final Color headerBackgroundColor; 127 | 128 | /// 表格内容的背景颜色 129 | final Color bodyBackgroundColor; 130 | 131 | /// 是否显示边框 132 | final bool showBorder; 133 | 134 | StickyTable({ 135 | this.stickyColumnCount = 0, 136 | this.columns, 137 | this.data, 138 | this.headerBackgroundColor = defaultHeaderBackgroundColor, 139 | this.bodyBackgroundColor = defaultBodyBackgroundColor, 140 | this.showBorder = false, 141 | }); 142 | 143 | @override 144 | _StickyTableState createState() => _StickyTableState(); 145 | } 146 | 147 | class _StickyTableState extends State { 148 | ScrollController headerController = ScrollController(); 149 | ScrollController bodyController = ScrollController(); 150 | 151 | /// 是否显示头部的阴影 152 | /// @todo: 下个阶段实现左侧固定的阴影 153 | bool showHeaderElevation = false; 154 | 155 | /// 156 | /// 头部滚动监听器 157 | /// 用于计算当前header的偏移量,然后设置body的偏移量 158 | /// 调整body偏移位置的时候需要删除body的监听,否则会死锁监听滚动(jumpTo函数会调用notifyListener) 159 | /// 160 | void headerListener() { 161 | bodyController.removeListener(bodyListener); 162 | bodyController.jumpTo(headerController.offset); 163 | bodyController.addListener(bodyListener); 164 | } 165 | 166 | /// 167 | /// body滚动监听器 168 | /// 用于计算当前body的偏移量,然后设置head的偏移量 169 | /// 调整head偏移位置的时候需要删除head的监听,否则会死锁监听滚动(jumpTo函数会调用notifyListener) 170 | /// 171 | void bodyListener() { 172 | headerController.removeListener(headerListener); 173 | headerController.jumpTo(bodyController.offset); 174 | headerController.addListener(headerListener); 175 | } 176 | 177 | @override 178 | void initState() { 179 | super.initState(); 180 | 181 | /// 182 | /// 监听滚动,实现header和body同步滚动 183 | /// 184 | headerController.addListener(headerListener); 185 | bodyController.addListener(bodyListener); 186 | } 187 | 188 | @override 189 | void didUpdateWidget(StickyTable oldWidget) { 190 | super.didUpdateWidget(oldWidget); 191 | } 192 | 193 | @override 194 | Widget build(BuildContext context) { 195 | Widget sticky = StickyHeader( 196 | header: TableHeader( 197 | scrollController: headerController, 198 | stickyColumnCount: widget.stickyColumnCount, 199 | columns: widget.columns, 200 | showBorder: widget.showBorder, 201 | elevation: showHeaderElevation ? defaultHeaderElevation : 0.0, 202 | backgroundColor: widget.headerBackgroundColor), 203 | content: TableBody( 204 | scrollController: bodyController, 205 | stickyColumnCount: widget.stickyColumnCount, 206 | columns: widget.columns, 207 | showBorder: widget.showBorder, 208 | data: widget.data, 209 | backgroundColor: widget.bodyBackgroundColor), 210 | onScrolled: (v) { 211 | bool _showHeaderElevation = showHeaderElevation; 212 | _showHeaderElevation = v > 0; 213 | if (_showHeaderElevation != _showHeaderElevation && mounted) { 214 | setState(() { 215 | showHeaderElevation = v > 0; 216 | }); 217 | } 218 | }); 219 | 220 | return null != Scrollable.of(context) 221 | ? sticky 222 | : SingleChildScrollView( 223 | child: sticky, 224 | ); 225 | } 226 | } 227 | 228 | /// 表格内容信息 229 | class TableBody extends StatefulWidget { 230 | final ScrollController scrollController; 231 | 232 | final int stickyColumnCount; 233 | 234 | final List columns; 235 | 236 | final List data; 237 | 238 | final bool showBorder; 239 | 240 | final Color backgroundColor; 241 | 242 | const TableBody( 243 | {Key key, 244 | this.scrollController, 245 | this.columns, 246 | this.data, 247 | this.stickyColumnCount = 0, 248 | this.showBorder = false, 249 | this.backgroundColor}) 250 | : super(key: key); 251 | 252 | @override 253 | _TableBodyState createState() => _TableBodyState(); 254 | } 255 | 256 | class _TableBodyState extends State { 257 | List maxHeights = []; 258 | 259 | bool mounted = false; 260 | 261 | /// 横向是否已滚动 262 | bool isHorizontalScrolled = false; 263 | 264 | @override 265 | void initState() { 266 | super.initState(); 267 | mounted = true; 268 | 269 | widget.data.forEach((_) { 270 | maxHeights.add(0); 271 | }); 272 | 273 | widget.scrollController.addListener(() { 274 | var _isHorizontalScrolled = isHorizontalScrolled; 275 | if (widget.scrollController.offset != 0) { 276 | _isHorizontalScrolled = true; 277 | } else { 278 | _isHorizontalScrolled = false; 279 | } 280 | if (_isHorizontalScrolled != isHorizontalScrolled && mounted) { 281 | setState(() { 282 | isHorizontalScrolled = _isHorizontalScrolled; 283 | }); 284 | } 285 | }); 286 | } 287 | 288 | @override 289 | void dispose() { 290 | mounted = false; 291 | 292 | super.dispose(); 293 | } 294 | 295 | @override 296 | void didUpdateWidget(TableBody oldWidget) { 297 | super.didUpdateWidget(oldWidget); 298 | Function eq = const DeepCollectionEquality().equals; 299 | 300 | /// 如果数据没变化则不更新 301 | if (ColumnsProps.propsEquals(oldWidget.columns, widget.columns) && 302 | eq(oldWidget.data, widget.data)) { 303 | return; 304 | } 305 | 306 | /// 数据变化后重新计算最大高度 307 | maxHeights = []; 308 | widget.data.forEach((_) { 309 | maxHeights.add(0); 310 | }); 311 | if (mounted) setState(() {}); 312 | } 313 | 314 | /// 每个单元格控件 315 | Widget getCell(ColumnsProps c) { 316 | List rows = []; 317 | for (var i = 0; i < widget.data.length; i++) { 318 | dynamic value = widget.data[i]; 319 | rows.add(TableCell( 320 | render: null != c.render 321 | ? c.render(context, value) 322 | : Text(value[c.dataIndex] ?? ''), 323 | backgroundColor: c.color, 324 | width: c.width > 0 ? c.width : defaultColumnWidth, 325 | showBorder: widget.showBorder, 326 | alignment: c.alignment, 327 | height: maxHeights.length > i ? maxHeights[i] : null, 328 | onSized: (size) { 329 | if (maxHeights[i] == size.height) { 330 | return; 331 | } 332 | 333 | /// 取出每行最大高度 334 | maxHeights[i] = max(maxHeights[i], size.height); 335 | if (maxHeights.every((h) => h > 0)) { 336 | /// 重新绘制每个单元格的高度 337 | if (mounted) setState(() {}); 338 | } 339 | }, 340 | )); 341 | } 342 | return Container( 343 | child: Column( 344 | mainAxisSize: MainAxisSize.min, 345 | children: rows, 346 | ), 347 | color: widget.backgroundColor ?? defaultBodyBackgroundColor, 348 | ); 349 | } 350 | 351 | @override 352 | Widget build(BuildContext context) { 353 | if (null == widget.columns || 354 | widget.columns.length == 0 || 355 | widget.data == null || 356 | widget.data.length == 0) { 357 | return Container(); 358 | } 359 | 360 | return LayoutBuilder(builder: (BuildContext c, BoxConstraints constraints) { 361 | int _stickyColumnCount = 362 | min(widget.stickyColumnCount, widget.columns.length); 363 | 364 | /// 固定的列 365 | List stickyColumnProps = _stickyColumnCount > 0 366 | ? widget.columns.sublist(0, _stickyColumnCount) 367 | : []; 368 | 369 | /// 不固定的列 370 | List unStickyColumns = _stickyColumnCount > 0 371 | ? widget.columns.sublist(_stickyColumnCount) 372 | : widget.columns; 373 | 374 | double stickyWidth = 0.0; 375 | List stickyColumnWidgets = 376 | stickyColumnProps.map((ColumnsProps c) { 377 | stickyWidth += c.width > 0 ? c.width : defaultColumnWidth; 378 | return getCell(c); 379 | }).toList(); 380 | 381 | /// 固定宽度不能太大 382 | RenderBox boxRenderObject = context.findRenderObject(); 383 | if (boxRenderObject != null && 384 | null != boxRenderObject.constraints && 385 | boxRenderObject.constraints.maxWidth - defaultColumnWidth < 386 | stickyWidth) { 387 | print('固定表格列越界了,暂时不支持渲染...'); 388 | return Container(); 389 | } 390 | 391 | /// 非固定的列 392 | List unStickyColumnWidgets = 393 | unStickyColumns.map((ColumnsProps c) => getCell(c)).toList(); 394 | 395 | return Row( 396 | mainAxisSize: MainAxisSize.max, 397 | verticalDirection: VerticalDirection.down, 398 | crossAxisAlignment: CrossAxisAlignment.end, 399 | children: [ 400 | Container( 401 | // color: Colors.grey, 402 | child: Row( 403 | // mainAxisSize: MainAxisSize.min, 404 | children: stickyColumnWidgets, 405 | ), 406 | decoration: BoxDecoration(boxShadow: [ 407 | // BoxShadow( 408 | // color: Colors.black45, 409 | // offset: Offset(2.0, 0), 410 | // blurRadius: 0.8, 411 | // spreadRadius: 2.0, 412 | // ), 413 | ]), 414 | ), 415 | Expanded( 416 | child: ScrollConfiguration( 417 | behavior: NoOverScrollBehavior(), 418 | child: SingleChildScrollView( 419 | scrollDirection: Axis.horizontal, 420 | controller: widget.scrollController, 421 | child: Row( 422 | // mainAxisSize: MainAxisSize.min, 423 | // crossAxisAlignment: CrossAxisAlignment.stretch, 424 | children: unStickyColumnWidgets)))) 425 | ]); 426 | }); 427 | } 428 | } 429 | 430 | /// 表头 431 | class TableHeader extends StatefulWidget { 432 | final ScrollController scrollController; 433 | 434 | /// 固定列的数量 435 | final int stickyColumnCount; 436 | 437 | /// 所有列的配置 438 | final List columns; 439 | 440 | /// 背景色 441 | final Color backgroundColor; 442 | 443 | final bool showBorder; 444 | 445 | /// 阴影 446 | final double elevation; 447 | 448 | const TableHeader( 449 | {Key key, 450 | this.scrollController, 451 | this.stickyColumnCount = 0, 452 | this.columns, 453 | this.backgroundColor, 454 | this.showBorder = false, 455 | this.elevation = 0.0}) 456 | : super(key: key); 457 | 458 | @override 459 | _TableHeaderState createState() => _TableHeaderState(); 460 | } 461 | 462 | class _TableHeaderState extends State { 463 | double maxHeight = 0.0; 464 | 465 | bool mounted = false; 466 | 467 | @override 468 | void initState() { 469 | super.initState(); 470 | 471 | mounted = true; 472 | } 473 | 474 | @override 475 | void didUpdateWidget(TableHeader oldWidget) { 476 | super.didUpdateWidget(oldWidget); 477 | 478 | /// 如果数据没变化则不更新 479 | if (ColumnsProps.propsEquals(oldWidget.columns, widget.columns)) { 480 | return; 481 | } 482 | 483 | /// 数据变化后重新计算最大高度 484 | maxHeight = 0; 485 | if (mounted) setState(() {}); 486 | } 487 | 488 | @override 489 | void dispose() { 490 | mounted = false; 491 | 492 | super.dispose(); 493 | } 494 | 495 | /// 单元格 496 | Widget getCell(ColumnsProps c) { 497 | return TableCell( 498 | render: c.customTitle ?? Text(c.title), 499 | backgroundColor: c.headColor, 500 | width: c.width > 0 ? c.width : defaultColumnWidth, 501 | showBorder: widget.showBorder, 502 | alignment: c.alignment, 503 | height: maxHeight > 0 ? maxHeight : null, 504 | onSized: (size) { 505 | if (maxHeight > size.height || maxHeight == size.height) { 506 | return; 507 | } 508 | 509 | /// 取出每行最大高度 510 | maxHeight = size.height; 511 | 512 | /// 重新绘制每个单元格的高度 513 | if (mounted) setState(() {}); 514 | }, 515 | ); 516 | } 517 | 518 | @override 519 | Widget build(BuildContext context) { 520 | if (null == widget.columns || widget.columns.length == 0) { 521 | return Container(); 522 | } 523 | 524 | int _stickyColumnCount = 525 | min(widget.stickyColumnCount, widget.columns.length); 526 | 527 | /// 固定的列 528 | List stickyColumnProps = _stickyColumnCount > 0 529 | ? widget.columns.sublist(0, _stickyColumnCount) 530 | : []; 531 | double stickyWidth = 0.0; 532 | List stickyColumnWidgets = stickyColumnProps.map((ColumnsProps c) { 533 | stickyWidth += c.width > 0 ? c.width : defaultColumnWidth; 534 | return getCell(c); 535 | }).toList(); 536 | 537 | /// 固定宽度不能太大 538 | RenderBox boxRenderObject = context.findRenderObject(); 539 | if (boxRenderObject != null && 540 | null != boxRenderObject.constraints && 541 | boxRenderObject.constraints.maxWidth - defaultColumnWidth < 542 | stickyWidth) { 543 | print('固定表格列越界了,暂时不支持渲染...'); 544 | return Container(); 545 | } 546 | 547 | /// 不固定的列 548 | List unStickyColumns = _stickyColumnCount > 0 549 | ? widget.columns.sublist(_stickyColumnCount) 550 | : widget.columns; 551 | List unStickyColumnWidgets = 552 | unStickyColumns.map((ColumnsProps c) => getCell(c)).toList(); 553 | 554 | return Material( 555 | elevation: widget.elevation ?? 0.0, 556 | child: Container( 557 | child: Row( 558 | children: [] 559 | ..addAll(stickyColumnWidgets) 560 | ..add(Expanded( 561 | child: ScrollConfiguration( 562 | behavior: NoOverScrollBehavior(), 563 | child: SingleChildScrollView( 564 | scrollDirection: Axis.horizontal, 565 | controller: widget.scrollController, 566 | child: Row(children: unStickyColumnWidgets)))))), 567 | color: widget.backgroundColor ?? defaultHeaderBackgroundColor, 568 | )); 569 | } 570 | } 571 | 572 | /// 单元格控件 573 | class TableCell extends StatelessWidget { 574 | final double width; 575 | 576 | final Alignment alignment; 577 | 578 | final bool showBorder; 579 | 580 | final ValueChanged onSized; 581 | 582 | final Widget render; 583 | 584 | final double height; 585 | 586 | final Color backgroundColor; 587 | 588 | final Border customBorder; 589 | 590 | const TableCell( 591 | {Key key, 592 | this.width = 0.0, 593 | this.alignment = Alignment.centerLeft, 594 | this.showBorder = false, 595 | this.onSized, 596 | this.render, 597 | this.height, 598 | this.backgroundColor, 599 | this.customBorder}) 600 | : super(key: key); 601 | 602 | @override 603 | Widget build(BuildContext context) { 604 | WidgetsBinding.instance.addPostFrameCallback((_) { 605 | final RenderBox renderBoxRed = context.findRenderObject(); 606 | if (null != renderBoxRed && null != onSized) { 607 | onSized(renderBoxRed.size); 608 | } 609 | }); 610 | return Container( 611 | height: (height ?? 0.0) > 0.0 ? height : null, 612 | width: width > 0.0 ? width : defaultColumnWidth, 613 | padding: EdgeInsets.all(defaultPadding), 614 | alignment: alignment ?? Alignment.centerLeft, 615 | decoration: BoxDecoration( 616 | color: backgroundColor, 617 | border: showBorder 618 | ? Border.all(color: Colors.black12, width: 1.0) 619 | : customBorder, 620 | ), 621 | child: this.render, 622 | ); 623 | } 624 | } 625 | 626 | /// 627 | /// 固定头部控件,参考https://github.com/fluttercommunity/flutter_sticky_headers 628 | /// 629 | class StickyHeader extends MultiChildRenderObjectWidget { 630 | /// 631 | /// sticky效果的头部内容 632 | /// 633 | final Widget header; 634 | 635 | /// 636 | /// 内容 637 | /// 638 | final Widget content; 639 | 640 | final ValueChanged onScrolled; 641 | 642 | StickyHeader({ 643 | Key key, 644 | @required this.header, 645 | @required this.content, 646 | this.onScrolled, 647 | }) : super( 648 | key: key, 649 | // Note: The order of the children must be preserved for the RenderObject. 650 | children: [content, header], 651 | ); 652 | 653 | @override 654 | StickyHeaderRender createRenderObject(BuildContext context) { 655 | var scrollable = Scrollable.of(context); 656 | assert(scrollable != null); 657 | return StickyHeaderRender(scrollable: scrollable, onScrolled: onScrolled); 658 | } 659 | 660 | @override 661 | void updateRenderObject( 662 | BuildContext context, StickyHeaderRender renderObject) { 663 | renderObject 664 | .._scrollable = Scrollable.of(context) 665 | .._onScrolled = onScrolled; 666 | } 667 | } 668 | 669 | /// StickyHeader渲染器 670 | class StickyHeaderRender extends RenderBox 671 | with 672 | ContainerRenderObjectMixin, 673 | RenderBoxContainerDefaultsMixin { 674 | // short-hand to access the child RenderObjects 675 | 676 | ScrollableState _scrollable; 677 | 678 | ValueChanged _onScrolled; 679 | 680 | RenderBox get _headerBox => lastChild; 681 | 682 | RenderBox get _contentBox => firstChild; 683 | 684 | StickyHeaderRender( 685 | {@required ScrollableState scrollable, ValueChanged onScrolled}) 686 | : _scrollable = scrollable, 687 | _onScrolled = onScrolled; 688 | 689 | @override 690 | bool get isRepaintBoundary => true; 691 | 692 | @override 693 | void attach(PipelineOwner owner) { 694 | super.attach(owner); 695 | _scrollable.position?.addListener(() { 696 | markNeedsLayout(); 697 | 698 | final headerParentData = 699 | _headerBox.parentData as MultiChildLayoutParentData; 700 | if (null != _onScrolled) { 701 | _onScrolled(headerParentData.offset.dy); 702 | } 703 | }); 704 | } 705 | 706 | @override 707 | void detach() { 708 | _scrollable.position?.removeListener(markNeedsLayout); 709 | super.detach(); 710 | } 711 | 712 | set scrollableX(ScrollableState newValue) { 713 | assert(newValue != null); 714 | if (_scrollable == newValue) { 715 | return; 716 | } 717 | final ScrollableState oldValue = _scrollable; 718 | _scrollable = newValue; 719 | markNeedsLayout(); 720 | if (attached) { 721 | oldValue.position?.removeListener(markNeedsLayout); 722 | newValue.position?.addListener(markNeedsLayout); 723 | } 724 | } 725 | 726 | @override 727 | void performLayout() { 728 | // ensure we have header and content boxes 729 | assert(childCount == 2); 730 | 731 | // layout both header and content widget 732 | final childConstraints = constraints.loosen(); 733 | _headerBox.layout(childConstraints, parentUsesSize: true); 734 | _contentBox.layout(childConstraints, parentUsesSize: true); 735 | 736 | final headerHeight = _headerBox.size.height; 737 | final contentHeight = _contentBox.size.height; 738 | 739 | // determine size of ourselves based on content widget 740 | final width = max(constraints.minWidth, _contentBox.size.width); 741 | 742 | /// header与content并列 743 | final height = max(constraints.minHeight, headerHeight + contentHeight); 744 | 745 | size = Size(width, height); 746 | assert(size.width == constraints.constrainWidth(width)); 747 | assert(size.height == constraints.constrainHeight(height)); 748 | assert(size.isFinite); 749 | 750 | // place content underneath header 751 | final contentParentData = 752 | _contentBox.parentData as MultiChildLayoutParentData; 753 | 754 | /// 固定并列显示header 755 | contentParentData.offset = Offset(0.0, headerHeight); 756 | 757 | // determine by how much the header should be stuck to the top 758 | final double stuckXOffset = determineStuckXOffset(); 759 | 760 | // place header over content relative to scroll offset 761 | final double maxOffset = height - headerHeight; 762 | final headerParentData = 763 | _headerBox.parentData as MultiChildLayoutParentData; 764 | headerParentData.offset = 765 | Offset(0.0, max(0.0, min(-stuckXOffset, maxOffset))); 766 | } 767 | 768 | double determineStuckXOffset() { 769 | final scrollBox = _scrollable.context.findRenderObject(); 770 | if (scrollBox?.attached ?? false) { 771 | try { 772 | return localToGlobal(Offset.zero, ancestor: scrollBox).dy; 773 | } catch (e) { 774 | // ignore and fall-through and return 0.0 775 | } 776 | } 777 | return 0.0; 778 | } 779 | 780 | @override 781 | void setupParentData(RenderObject child) { 782 | super.setupParentData(child); 783 | if (child.parentData is! MultiChildLayoutParentData) { 784 | child.parentData = MultiChildLayoutParentData(); 785 | } 786 | } 787 | 788 | @override 789 | double computeMinIntrinsicWidth(double height) { 790 | return _contentBox.getMinIntrinsicWidth(height); 791 | } 792 | 793 | @override 794 | double computeMaxIntrinsicWidth(double height) { 795 | return _contentBox.getMaxIntrinsicWidth(height); 796 | } 797 | 798 | @override 799 | double computeMinIntrinsicHeight(double width) { 800 | return (_headerBox.getMinIntrinsicHeight(width) + 801 | _contentBox.getMinIntrinsicHeight(width)); 802 | } 803 | 804 | @override 805 | double computeMaxIntrinsicHeight(double width) { 806 | return (_headerBox.getMaxIntrinsicHeight(width) + 807 | _contentBox.getMaxIntrinsicHeight(width)); 808 | } 809 | 810 | @override 811 | double computeDistanceToActualBaseline(TextBaseline baseline) { 812 | return defaultComputeDistanceToHighestActualBaseline(baseline); 813 | } 814 | 815 | @override 816 | bool hitTestChildren(HitTestResult result, {Offset position}) { 817 | return defaultHitTestChildren(result, position: position); 818 | } 819 | 820 | @override 821 | void paint(PaintingContext context, Offset offset) { 822 | defaultPaint(context, offset); 823 | } 824 | } 825 | 826 | /// 827 | /// 无弹簧的scroll行为 828 | /// 829 | class NoOverScrollBehavior extends ScrollBehavior { 830 | @override 831 | Widget buildViewportChrome( 832 | BuildContext context, Widget child, AxisDirection axisDirection) { 833 | return child; 834 | } 835 | 836 | @override 837 | ScrollPhysics getScrollPhysics(BuildContext context) { 838 | return const ClampingScrollPhysics(); 839 | } 840 | } 841 | --------------------------------------------------------------------------------