├── .gitignore
├── .metadata
├── README.md
├── android
├── app
│ ├── build.gradle
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── kotlin
│ │ └── com
│ │ │ └── kuky
│ │ │ └── demo
│ │ │ └── flutterartsdemosapp
│ │ │ └── MainActivity.kt
│ │ └── res
│ │ ├── drawable
│ │ ├── ic_app_icon.png
│ │ └── launch_background.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ └── values
│ │ ├── strings.xml
│ │ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ └── gradle-wrapper.properties
└── settings.gradle
├── fonts
└── third_part_icon.ttf
├── images
├── ali.jpg
├── app_bar_hor.jpg
├── app_icon.png
├── ava_default.png
├── lm.jpg
├── login_bg.png
└── timg.jpg
├── ios
├── Flutter
│ ├── AppFrameworkInfo.plist
│ ├── Debug.xcconfig
│ └── Release.xcconfig
├── Runner.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── xcschemes
│ │ └── Runner.xcscheme
├── Runner.xcworkspace
│ └── contents.xcworkspacedata
└── Runner
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ ├── AppIcon.appiconset
│ │ ├── Contents.json
│ │ ├── Icon-App-1024x1024@1x.png
│ │ ├── Icon-App-20x20@1x.png
│ │ ├── Icon-App-20x20@2x.png
│ │ ├── Icon-App-20x20@3x.png
│ │ ├── Icon-App-29x29@1x.png
│ │ ├── Icon-App-29x29@2x.png
│ │ ├── Icon-App-29x29@3x.png
│ │ ├── Icon-App-40x40@1x.png
│ │ ├── Icon-App-40x40@2x.png
│ │ ├── Icon-App-40x40@3x.png
│ │ ├── Icon-App-60x60@2x.png
│ │ ├── Icon-App-60x60@3x.png
│ │ ├── Icon-App-76x76@1x.png
│ │ ├── Icon-App-76x76@2x.png
│ │ └── Icon-App-83.5x83.5@2x.png
│ └── LaunchImage.imageset
│ │ ├── Contents.json
│ │ ├── LaunchImage.png
│ │ ├── LaunchImage@2x.png
│ │ ├── LaunchImage@3x.png
│ │ └── README.md
│ ├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
│ ├── Info.plist
│ └── main.m
├── lib
├── application.dart
├── bloc
│ ├── bloc_provider.dart
│ ├── count_provider.dart
│ ├── counter_bloc.dart
│ ├── language_bloc.dart
│ └── stream_main.dart
├── bloc_network
│ ├── random_user.dart
│ ├── random_user.g.dart
│ ├── user_bloc.dart
│ └── user_page_main.dart
├── colsed
│ ├── fuli_bloc.dart
│ ├── fuli_model.dart
│ └── fuli_page_main.dart
├── custom_routes.dart
├── db_utils.dart
├── http_utils.dart
├── localizations
│ ├── base_localization.dart
│ ├── demo_localizations.dart
│ ├── localization_en.dart
│ └── localization_zh.dart
├── main.dart
├── pages
│ ├── animation_main.dart
│ ├── app_bar_main.dart
│ ├── button_main.dart
│ ├── checkbox_switch_main.dart
│ ├── column_main.dart
│ ├── custom_scroll_main.dart
│ ├── custom_view_main.dart
│ ├── data_persistence_main.dart
│ ├── expansion_tile_main.dart
│ ├── gesture_deep.dart
│ ├── gesture_main.dart
│ ├── gridview_main.dart
│ ├── http_main.dart
│ ├── image_main.dart
│ ├── listview_main.dart
│ ├── login_home_page.dart
│ ├── nested_scroll_main.dart
│ ├── prompt_main.dart
│ ├── router_main.dart
│ ├── scroll_controller_main.dart
│ ├── scrollable_main.dart
│ ├── single_child_scroll_main.dart
│ ├── sliver_main.dart
│ ├── stack_main.dart
│ ├── staggered_animation_main.dart
│ ├── suspension_main.dart
│ ├── text_field_main.dart
│ └── text_main.dart
├── third_icons.dart
└── widget
│ ├── flutter_suspension.dart
│ └── suspension
│ ├── suspension_list.dart
│ ├── suspension_util.dart
│ └── suspension_view.dart
└── pubspec.yaml
/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.lock
4 | *.log
5 | *.pyc
6 | *.swp
7 | .DS_Store
8 | .atom/
9 | .buildlog/
10 | .history
11 | .svn/
12 |
13 | # IntelliJ related
14 | *.iml
15 | *.ipr
16 | *.iws
17 | .idea/
18 |
19 | # Visual Studio Code related
20 | .vscode/
21 |
22 | # Flutter/Dart/Pub related
23 | **/doc/api/
24 | .dart_tool/
25 | .flutter-plugins
26 | .packages
27 | .pub-cache/
28 | .pub/
29 | build/
30 |
31 | # Android related
32 | **/android/**/gradle-wrapper.jar
33 | **/android/.gradle
34 | **/android/captures/
35 | **/android/gradlew
36 | **/android/gradlew.bat
37 | **/android/local.properties
38 | **/android/**/GeneratedPluginRegistrant.java
39 |
40 | # iOS/XCode related
41 | **/ios/**/*.mode1v3
42 | **/ios/**/*.mode2v3
43 | **/ios/**/*.moved-aside
44 | **/ios/**/*.pbxuser
45 | **/ios/**/*.perspectivev3
46 | **/ios/**/*sync/
47 | **/ios/**/.sconsign.dblite
48 | **/ios/**/.tags*
49 | **/ios/**/.vagrant/
50 | **/ios/**/DerivedData/
51 | **/ios/**/Icon?
52 | **/ios/**/Pods/
53 | **/ios/**/.symlinks/
54 | **/ios/**/profile
55 | **/ios/**/xcuserdata
56 | **/ios/.generated/
57 | **/ios/Flutter/App.framework
58 | **/ios/Flutter/Flutter.framework
59 | **/ios/Flutter/Generated.xcconfig
60 | **/ios/Flutter/app.flx
61 | **/ios/Flutter/app.zip
62 | **/ios/Flutter/flutter_assets/
63 | **/ios/ServiceDefinitions.json
64 | **/ios/Runner/GeneratedPluginRegistrant.*
65 |
66 | # Exceptions to above rules.
67 | !**/ios/**/default.mode1v3
68 | !**/ios/**/default.mode2v3
69 | !**/ios/**/default.pbxuser
70 | !**/ios/**/default.perspectivev3
71 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
72 |
--------------------------------------------------------------------------------
/.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: 1407091bfb5bb535630d4d596541817737da8412
8 | channel: stable
9 |
10 | project_type: app
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ### flutter_arts_demos_app
2 |
3 | 这个仓库用于托管 `Flutter` 系列文章的 `demo` 代码,查看文章直接点击链接查看
4 | [Flutter 入门指北系列](https://www.jianshu.com/nb/34950817)
5 |
6 |
7 | ### Getting Started
8 |
9 | This project is a starting point for a Flutter application.
10 |
11 | A few resources to get you started if this is your first Flutter project:
12 |
13 | - [Lab: Write your first Flutter app](https://flutter.io/docs/get-started/codelab)
14 | - [Cookbook: Useful Flutter samples](https://flutter.io/docs/cookbook)
15 |
16 | For help getting started with Flutter, view our
17 | [online documentation](https://flutter.io/docs), which offers tutorials,
18 | samples, guidance on mobile development, and a full API reference.
19 |
--------------------------------------------------------------------------------
/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | def localProperties = new Properties()
2 | def localPropertiesFile = rootProject.file('local.properties')
3 | if (localPropertiesFile.exists()) {
4 | localPropertiesFile.withReader('UTF-8') { reader ->
5 | localProperties.load(reader)
6 | }
7 | }
8 |
9 | def flutterRoot = localProperties.getProperty('flutter.sdk')
10 | if (flutterRoot == null) {
11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12 | }
13 |
14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15 | if (flutterVersionCode == null) {
16 | flutterVersionCode = '1'
17 | }
18 |
19 | def flutterVersionName = localProperties.getProperty('flutter.versionName')
20 | if (flutterVersionName == null) {
21 | flutterVersionName = '1.0'
22 | }
23 |
24 | apply plugin: 'com.android.application'
25 | apply plugin: 'kotlin-android'
26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27 |
28 | android {
29 | compileSdkVersion 28
30 |
31 | sourceSets {
32 | main.java.srcDirs += 'src/main/kotlin'
33 | }
34 |
35 | lintOptions {
36 | disable 'InvalidPackage'
37 | }
38 |
39 | defaultConfig {
40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
41 | applicationId "com.kuky.demo.flutterartsdemosapp"
42 | minSdkVersion 16
43 | targetSdkVersion 28
44 | versionCode flutterVersionCode.toInteger()
45 | versionName flutterVersionName
46 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
47 | }
48 |
49 | buildTypes {
50 | release {
51 | // TODO: Add your own signing config for the release build.
52 | // Signing with the debug keys for now, so `flutter run --release` works.
53 | signingConfig signingConfigs.debug
54 | }
55 | }
56 | }
57 |
58 | flutter {
59 | source '../..'
60 | }
61 |
62 | dependencies {
63 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
64 | testImplementation 'junit:junit:4.12'
65 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
66 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
67 | }
68 |
--------------------------------------------------------------------------------
/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
9 |
10 |
11 |
12 |
13 |
18 |
23 |
30 |
34 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/android/app/src/main/kotlin/com/kuky/demo/flutterartsdemosapp/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.kuky.demo.flutterartsdemosapp
2 |
3 | import android.os.Bundle
4 |
5 | import io.flutter.app.FlutterActivity
6 | import io.flutter.plugins.GeneratedPluginRegistrant
7 |
8 | class MainActivity: FlutterActivity() {
9 | override fun onCreate(savedInstanceState: Bundle?) {
10 | super.onCreate(savedInstanceState)
11 | GeneratedPluginRegistrant.registerWith(this)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable/ic_app_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/android/app/src/main/res/drawable/ic_app_icon.png
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Art Demos
4 |
--------------------------------------------------------------------------------
/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext.kotlin_version = '1.3.11'
3 | repositories {
4 | google()
5 | jcenter()
6 | }
7 |
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.3.2'
10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | google()
17 | jcenter()
18 | }
19 | }
20 |
21 | rootProject.buildDir = '../build'
22 | subprojects {
23 | project.buildDir = "${rootProject.buildDir}/${project.name}"
24 | }
25 | subprojects {
26 | project.evaluationDependsOn(':app')
27 | }
28 |
29 | task clean(type: Delete) {
30 | delete rootProject.buildDir
31 | }
32 |
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 24 21:42:41 CST 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/fonts/third_part_icon.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/fonts/third_part_icon.ttf
--------------------------------------------------------------------------------
/images/ali.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/images/ali.jpg
--------------------------------------------------------------------------------
/images/app_bar_hor.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/images/app_bar_hor.jpg
--------------------------------------------------------------------------------
/images/app_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/images/app_icon.png
--------------------------------------------------------------------------------
/images/ava_default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/images/ava_default.png
--------------------------------------------------------------------------------
/images/lm.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/images/lm.jpg
--------------------------------------------------------------------------------
/images/login_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/images/login_bg.png
--------------------------------------------------------------------------------
/images/timg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/images/timg.jpg
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ios/Runner/AppDelegate.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | @interface AppDelegate : FlutterAppDelegate
5 |
6 | @end
7 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "20x20",
5 | "idiom" : "iphone",
6 | "filename" : "Icon-App-20x20@2x.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "20x20",
11 | "idiom" : "iphone",
12 | "filename" : "Icon-App-20x20@3x.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "Icon-App-29x29@1x.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "29x29",
23 | "idiom" : "iphone",
24 | "filename" : "Icon-App-29x29@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "29x29",
29 | "idiom" : "iphone",
30 | "filename" : "Icon-App-29x29@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "40x40",
35 | "idiom" : "iphone",
36 | "filename" : "Icon-App-40x40@2x.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "40x40",
41 | "idiom" : "iphone",
42 | "filename" : "Icon-App-40x40@3x.png",
43 | "scale" : "3x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "Icon-App-60x60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "Icon-App-60x60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "20x20",
59 | "idiom" : "ipad",
60 | "filename" : "Icon-App-20x20@1x.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "20x20",
65 | "idiom" : "ipad",
66 | "filename" : "Icon-App-20x20@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "29x29",
71 | "idiom" : "ipad",
72 | "filename" : "Icon-App-29x29@1x.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "29x29",
77 | "idiom" : "ipad",
78 | "filename" : "Icon-App-29x29@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "40x40",
83 | "idiom" : "ipad",
84 | "filename" : "Icon-App-40x40@1x.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "40x40",
89 | "idiom" : "ipad",
90 | "filename" : "Icon-App-40x40@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "76x76",
95 | "idiom" : "ipad",
96 | "filename" : "Icon-App-76x76@1x.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "76x76",
101 | "idiom" : "ipad",
102 | "filename" : "Icon-App-76x76@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "83.5x83.5",
107 | "idiom" : "ipad",
108 | "filename" : "Icon-App-83.5x83.5@2x.png",
109 | "scale" : "2x"
110 | },
111 | {
112 | "size" : "1024x1024",
113 | "idiom" : "ios-marketing",
114 | "filename" : "Icon-App-1024x1024@1x.png",
115 | "scale" : "1x"
116 | }
117 | ],
118 | "info" : {
119 | "version" : 1,
120 | "author" : "xcode"
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kukyxs/flutter_arts_demos_app/8bf525c797e0fe5a4a4397402fa855b369a6947e/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/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.
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/ios/Runner/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | flutter_arts_demos_app
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | $(FLUTTER_BUILD_NAME)
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(FLUTTER_BUILD_NUMBER)
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UISupportedInterfaceOrientations
30 |
31 | UIInterfaceOrientationPortrait
32 | UIInterfaceOrientationLandscapeLeft
33 | UIInterfaceOrientationLandscapeRight
34 |
35 | UISupportedInterfaceOrientations~ipad
36 |
37 | UIInterfaceOrientationPortrait
38 | UIInterfaceOrientationPortraitUpsideDown
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 | UIViewControllerBasedStatusBarAppearance
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/lib/application.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_arts_demos_app/http_utils.dart';
2 |
3 | class Application {
4 | static HttpUtils http;
5 | }
6 |
--------------------------------------------------------------------------------
/lib/bloc/bloc_provider.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | abstract class BaseBloc {
4 | void dispose();
5 | }
6 |
7 | class BlocProvider extends StatefulWidget {
8 | final Widget child;
9 | final T bloc;
10 |
11 | BlocProvider({Key key, @required this.child, @required this.bloc}) : super(key: key);
12 |
13 | @override
14 | _BlocProviderState createState() => _BlocProviderState();
15 |
16 | static T of(BuildContext context) {
17 | final type = _typeOf>();
18 | BlocProvider provider = context.ancestorWidgetOfExactType(type);
19 | return provider.bloc;
20 | }
21 |
22 | static Type _typeOf() => T;
23 | }
24 |
25 | class _BlocProviderState extends State> {
26 |
27 | @override
28 | void dispose() {
29 | widget.bloc.dispose();
30 | super.dispose();
31 | }
32 |
33 | @override
34 | Widget build(BuildContext context) {
35 | return widget.child;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/lib/bloc/count_provider.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | class CountProvider with ChangeNotifier {
4 | int _value = 0;
5 |
6 | int get value => _value;
7 |
8 | void changeValue(int value) {
9 | _value = value;
10 | notifyListeners();
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/lib/bloc/counter_bloc.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_arts_demos_app/bloc/bloc_provider.dart';
2 | import 'package:rxdart/rxdart.dart';
3 |
4 | class CounterBloc extends BaseBloc {
5 | int _count = 0;
6 |
7 | int get count => _count;
8 |
9 | // rx
10 | BehaviorSubject _countController = BehaviorSubject();
11 |
12 | Observable get countStream => Observable(_countController.stream);
13 |
14 | void dispatch(int value) {
15 | _count = value;
16 | _countController.add(_count);
17 | }
18 |
19 | // stream
20 | // StreamController _countController = StreamController.broadcast();
21 |
22 | // Stream get countStream => _countController.stream;
23 |
24 | // void dispatch(int value) {
25 | // _count = value;
26 | // _countController.sink.add(_count);
27 | // }
28 |
29 | @override
30 | void dispose() {
31 | _countController.close();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/lib/bloc/language_bloc.dart:
--------------------------------------------------------------------------------
1 | import 'bloc_provider.dart';
2 | import 'package:flutter/material.dart';
3 | import 'package:rxdart/rxdart.dart';
4 |
5 | class LanguageBloc extends BaseBloc {
6 |
7 | Locale _currentLanguage;
8 |
9 | Locale get currentLanguage => _currentLanguage;
10 |
11 | BehaviorSubject _localeController = BehaviorSubject();
12 |
13 | Observable get localeStream => Observable(_localeController.stream);
14 |
15 | changeLanguage(Locale locale) {
16 | _currentLanguage = locale;
17 | _localeController.add(locale);
18 | }
19 |
20 | @override
21 | void dispose() {
22 | _localeController?.close();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/lib/bloc/stream_main.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_arts_demos_app/bloc/count_provider.dart';
3 | import 'package:provide/provide.dart';
4 |
5 | //void main() => runApp(StreamApp());
6 |
7 | void main() {
8 | final providers = Providers()
9 | ..provide(Provider.function((_) => CountProvider()));
10 | runApp(ProviderNode(child: StreamApp(), providers: providers));
11 | }
12 |
13 | class StreamApp extends StatelessWidget {
14 | @override
15 | Widget build(BuildContext context) {
16 | // return BlocProvider(
17 | // child: MaterialApp(
18 | // debugShowCheckedModeBanner: false,
19 | // home: StreamHome(),
20 | // ),
21 | // bloc: CounterBloc());
22 | return MaterialApp(
23 | debugShowCheckedModeBanner: false,
24 | home: StreamHome(),
25 | );
26 | }
27 | }
28 |
29 | class StreamHome extends StatelessWidget {
30 | @override
31 | Widget build(BuildContext context) {
32 | return Scaffold(
33 | body: SafeArea(
34 | child: Container(
35 | alignment: Alignment.center,
36 | child: Provide(builder: (_, widget, countProvider) => Text('${countProvider.value}')),
37 | )),
38 | floatingActionButton: FloatingActionButton(
39 | onPressed: () =>
40 | Provide.value(context).changeValue(
41 | Provide.value(context).value + 1),
42 | child: Icon(Icons.add)),
43 | );
44 | }
45 | }
46 |
47 | //class StreamHome extends StatelessWidget {
48 | // @override
49 | // Widget build(BuildContext context) {
50 | // final CounterBloc _bloc = BlocProvider.of(context);
51 | // return Scaffold(
52 | // body: SafeArea(
53 | // child: Container(
54 | // alignment: Alignment.center,
55 | // child: StreamBuilder(
56 | // initialData: _bloc.count,
57 | // stream: _bloc.countStream,
58 | // builder: (_, snapshot) => Text('${snapshot.data}', style: TextStyle(fontSize: 20.0)),
59 | // ),
60 | // )),
61 | // floatingActionButton:
62 | // FloatingActionButton(onPressed: () => _bloc.dispatch(_bloc.count + 1), child: Icon(Icons.add)),
63 | // );
64 | // }
65 | //}
66 |
67 | //class StreamHome extends StatefulWidget {
68 | // @override
69 | // _StreamHomeState createState() => _StreamHomeState();
70 | //}
71 | //
72 | //class _StreamHomeState extends State {
73 | // // 定义一个全局的 `StreamController`
74 | // StreamController _controller = StreamController.broadcast();
75 | // // `sink` 用于传入新的数据
76 | // Sink _sink;
77 | // int _counter = 0;
78 | //
79 | //// StreamSubscription _subscription;
80 | //
81 | // @override
82 | // void initState() {
83 | // super.initState();
84 | //
85 | // _sink = _controller.sink;
86 | //
87 | //// _subscription = _controller.stream.where((value) => value > 10).take(5).listen((data) => print('Listen: $data'));
88 | ////
89 | //// List.generate(20, (index) => _sink.add(index));
90 | ////
91 | //// _sink.add('A');
92 | //// _sink.add(11);
93 | //// _subscription.pause();
94 | //// _sink.add(11.16);
95 | //// _subscription.resume();
96 | //// _sink.add([1, 2, 3]);
97 | //// _sink.add({'a': 1, 'b': 2});
98 | // }
99 | //
100 | // @override
101 | // void dispose() {
102 | // super.dispose();
103 | // // 需要销毁资源
104 | // _sink.close();
105 | // _controller.close();
106 | //// _subscription.cancel();
107 | // }
108 | //
109 | // @override
110 | // Widget build(BuildContext context) {
111 | // return Scaffold(
112 | // body: SafeArea(
113 | // child: Container(
114 | // alignment: Alignment.center,
115 | // child: StreamBuilder(
116 | // builder: (_, snapshot) => Text('${snapshot.data}', style: TextStyle(fontSize: 24.0)),
117 | // stream: _controller.stream, // stream 在 StreamBuilder 销毁的时候会自动销毁
118 | // initialData: _counter,
119 | // ),
120 | // )),
121 | // // 通过 `sink` 传入新的数据,去通知 `stream` 更新到 builder 中
122 | // floatingActionButton: FloatingActionButton(
123 | // onPressed: () => _sink.add(_counter++),
124 | // child: Icon(Icons.add),
125 | // ),
126 | // );
127 | // }
128 | //}
129 |
--------------------------------------------------------------------------------
/lib/bloc_network/random_user.dart:
--------------------------------------------------------------------------------
1 | import 'package:json_annotation/json_annotation.dart';
2 |
3 | part 'random_user.g.dart';
4 |
5 | @JsonSerializable()
6 | class RandomUserModel {
7 | InfoBean info;
8 | List results;
9 |
10 | RandomUserModel();
11 |
12 | factory RandomUserModel.fromJson(json) => _$RandomUserModelFromJson(json);
13 |
14 | static Map toJson(RandomUserModel model) => _$RandomUserModelToJson(model);
15 |
16 | static RandomUserModel fromMap(Map map) {
17 | RandomUserModel user = new RandomUserModel();
18 | user.info = InfoBean.fromMap(map['info']);
19 | user.results = UserInfo.fromMapList(map['results']);
20 | return user;
21 | }
22 |
23 | static List fromMapList(dynamic mapList) {
24 | List list = new List(mapList.length);
25 | for (int i = 0; i < mapList.length; i++) {
26 | list[i] = fromMap(mapList[i]);
27 | }
28 | return list;
29 | }
30 | }
31 |
32 | @JsonSerializable()
33 | class InfoBean {
34 | String seed;
35 | String version;
36 | int results;
37 | int page;
38 |
39 | InfoBean();
40 |
41 | factory InfoBean.fromJson(json) => _$InfoBeanFromJson(json);
42 |
43 | static toJson(InfoBean info) => _$InfoBeanToJson(info);
44 |
45 | static InfoBean fromMap(Map map) {
46 | InfoBean infoBean = new InfoBean();
47 | infoBean.seed = map['seed'];
48 | infoBean.version = map['version'];
49 | infoBean.results = map['results'];
50 | infoBean.page = map['page'];
51 | return infoBean;
52 | }
53 |
54 | static List fromMapList(dynamic mapList) {
55 | List list = new List(mapList.length);
56 | for (int i = 0; i < mapList.length; i++) {
57 | list[i] = fromMap(mapList[i]);
58 | }
59 | return list;
60 | }
61 | }
62 |
63 | @JsonSerializable()
64 | class UserInfo {
65 | String gender;
66 | String email;
67 | String phone;
68 | String cell;
69 | String nat;
70 | DobBean dob;
71 | IdBean id;
72 | LocationBean location;
73 | LoginBean login;
74 | NameBean name;
75 | PictureBean picture;
76 | RegisteredBean registered;
77 |
78 | UserInfo();
79 |
80 | factory UserInfo.fromJson(json) => _$UserInfoFromJson(json);
81 |
82 | static toJson(UserInfo user) => _$UserInfoToJson(user);
83 |
84 | static UserInfo fromMap(Map map) {
85 | UserInfo resultsListBean = new UserInfo();
86 | resultsListBean.gender = map['gender'];
87 | resultsListBean.email = map['email'];
88 | resultsListBean.phone = map['phone'];
89 | resultsListBean.cell = map['cell'];
90 | resultsListBean.nat = map['nat'];
91 | resultsListBean.dob = DobBean.fromMap(map['dob']);
92 | resultsListBean.id = IdBean.fromMap(map['id']);
93 | resultsListBean.location = LocationBean.fromMap(map['location']);
94 | resultsListBean.login = LoginBean.fromMap(map['login']);
95 | resultsListBean.name = NameBean.fromMap(map['name']);
96 | resultsListBean.picture = PictureBean.fromMap(map['picture']);
97 | resultsListBean.registered = RegisteredBean.fromMap(map['registered']);
98 | return resultsListBean;
99 | }
100 |
101 | static List fromMapList(dynamic mapList) {
102 | List list = new List(mapList.length);
103 | for (int i = 0; i < mapList.length; i++) {
104 | list[i] = fromMap(mapList[i]);
105 | }
106 | return list;
107 | }
108 | }
109 |
110 | @JsonSerializable()
111 | class DobBean {
112 | String date;
113 | int age;
114 |
115 | DobBean();
116 |
117 | factory DobBean.fromJson(json) => _$DobBeanFromJson(json);
118 |
119 | static toJson(DobBean dob) => _$DobBeanToJson(dob);
120 |
121 | static DobBean fromMap(Map map) {
122 | DobBean dobBean = new DobBean();
123 | dobBean.date = map['date'];
124 | dobBean.age = map['age'];
125 | return dobBean;
126 | }
127 |
128 | static List fromMapList(dynamic mapList) {
129 | List list = new List(mapList.length);
130 | for (int i = 0; i < mapList.length; i++) {
131 | list[i] = fromMap(mapList[i]);
132 | }
133 | return list;
134 | }
135 | }
136 |
137 | @JsonSerializable()
138 | class IdBean {
139 | String name;
140 | String value;
141 |
142 | IdBean();
143 |
144 | factory IdBean.fromJson(json) => _$IdBeanFromJson(json);
145 |
146 | static toJson(IdBean id) => _$IdBeanToJson(id);
147 |
148 | static IdBean fromMap(Map map) {
149 | IdBean idBean = new IdBean();
150 | idBean.name = map['name'];
151 | idBean.value = map['value'];
152 | return idBean;
153 | }
154 |
155 | static List fromMapList(dynamic mapList) {
156 | List list = new List(mapList.length);
157 | for (int i = 0; i < mapList.length; i++) {
158 | list[i] = fromMap(mapList[i]);
159 | }
160 | return list;
161 | }
162 | }
163 |
164 | @JsonSerializable()
165 | class LocationBean {
166 | String street;
167 | String city;
168 | String state;
169 | String postcode;
170 | CoordinatesBean coordinates;
171 | TimezoneBean timezone;
172 |
173 | LocationBean();
174 |
175 | factory LocationBean.fromJson(json) => _$LocationBeanFromJson(json);
176 |
177 | static toJson(LocationBean location) => _$LocationBeanToJson(location);
178 |
179 | static LocationBean fromMap(Map map) {
180 | LocationBean locationBean = new LocationBean();
181 | locationBean.street = map['street'];
182 | locationBean.city = map['city'];
183 | locationBean.state = map['state'];
184 | locationBean.postcode = '${map['postcode']}';
185 | locationBean.coordinates = CoordinatesBean.fromMap(map['coordinates']);
186 | locationBean.timezone = TimezoneBean.fromMap(map['timezone']);
187 | return locationBean;
188 | }
189 |
190 | static List fromMapList(dynamic mapList) {
191 | List list = new List(mapList.length);
192 | for (int i = 0; i < mapList.length; i++) {
193 | list[i] = fromMap(mapList[i]);
194 | }
195 | return list;
196 | }
197 | }
198 |
199 | @JsonSerializable()
200 | class LoginBean {
201 | String uuid;
202 | String username;
203 | String password;
204 | String salt;
205 | String md5;
206 | String sha1;
207 | String sha256;
208 |
209 | LoginBean();
210 |
211 | factory LoginBean.fromJson(json) => _$LoginBeanFromJson(json);
212 |
213 | static toJson(LoginBean login) => _$LoginBeanToJson(login);
214 |
215 | static LoginBean fromMap(Map map) {
216 | LoginBean loginBean = new LoginBean();
217 | loginBean.uuid = map['uuid'];
218 | loginBean.username = map['username'];
219 | loginBean.password = map['password'];
220 | loginBean.salt = map['salt'];
221 | loginBean.md5 = map['md5'];
222 | loginBean.sha1 = map['sha1'];
223 | loginBean.sha256 = map['sha256'];
224 | return loginBean;
225 | }
226 |
227 | static List fromMapList(dynamic mapList) {
228 | List list = new List(mapList.length);
229 | for (int i = 0; i < mapList.length; i++) {
230 | list[i] = fromMap(mapList[i]);
231 | }
232 | return list;
233 | }
234 | }
235 |
236 | @JsonSerializable()
237 | class NameBean {
238 | String title;
239 | String first;
240 | String last;
241 |
242 | NameBean();
243 |
244 | factory NameBean.fromJson(json) => _$NameBeanFromJson(json);
245 |
246 | static toJson(NameBean name) => _$NameBeanToJson(name);
247 |
248 | static NameBean fromMap(Map map) {
249 | NameBean nameBean = new NameBean();
250 | nameBean.title = map['title'];
251 | nameBean.first = map['first'];
252 | nameBean.last = map['last'];
253 | return nameBean;
254 | }
255 |
256 | static List fromMapList(dynamic mapList) {
257 | List list = new List(mapList.length);
258 | for (int i = 0; i < mapList.length; i++) {
259 | list[i] = fromMap(mapList[i]);
260 | }
261 | return list;
262 | }
263 | }
264 |
265 | @JsonSerializable()
266 | class PictureBean {
267 | String large;
268 | String medium;
269 | String thumbnail;
270 |
271 | PictureBean();
272 |
273 | factory PictureBean.fromJson(json) => _$PictureBeanFromJson(json);
274 |
275 | static toJson(PictureBean pic) => _$PictureBeanToJson(pic);
276 |
277 | static PictureBean fromMap(Map map) {
278 | PictureBean pictureBean = new PictureBean();
279 | pictureBean.large = map['large'];
280 | pictureBean.medium = map['medium'];
281 | pictureBean.thumbnail = map['thumbnail'];
282 | return pictureBean;
283 | }
284 |
285 | static List fromMapList(dynamic mapList) {
286 | List list = new List(mapList.length);
287 | for (int i = 0; i < mapList.length; i++) {
288 | list[i] = fromMap(mapList[i]);
289 | }
290 | return list;
291 | }
292 | }
293 |
294 | @JsonSerializable()
295 | class RegisteredBean {
296 | String date;
297 | int age;
298 |
299 | RegisteredBean();
300 |
301 | factory RegisteredBean.fromJson(json) => _$RegisteredBeanFromJson(json);
302 |
303 | static toJson(RegisteredBean register) => _$RegisteredBeanToJson(register);
304 |
305 | static RegisteredBean fromMap(Map map) {
306 | RegisteredBean registeredBean = new RegisteredBean();
307 | registeredBean.date = map['date'];
308 | registeredBean.age = map['age'];
309 | return registeredBean;
310 | }
311 |
312 | static List fromMapList(dynamic mapList) {
313 | List list = new List(mapList.length);
314 | for (int i = 0; i < mapList.length; i++) {
315 | list[i] = fromMap(mapList[i]);
316 | }
317 | return list;
318 | }
319 | }
320 |
321 | @JsonSerializable()
322 | class CoordinatesBean {
323 | String latitude;
324 | String longitude;
325 |
326 | CoordinatesBean();
327 |
328 | factory CoordinatesBean.fromJson(json) => _$CoordinatesBeanFromJson(json);
329 |
330 | static toJson(CoordinatesBean coordinates) => _$CoordinatesBeanToJson(coordinates);
331 |
332 | static CoordinatesBean fromMap(Map map) {
333 | CoordinatesBean coordinatesBean = new CoordinatesBean();
334 | coordinatesBean.latitude = map['latitude'];
335 | coordinatesBean.longitude = map['longitude'];
336 | return coordinatesBean;
337 | }
338 |
339 | static List fromMapList(dynamic mapList) {
340 | List list = new List(mapList.length);
341 | for (int i = 0; i < mapList.length; i++) {
342 | list[i] = fromMap(mapList[i]);
343 | }
344 | return list;
345 | }
346 | }
347 |
348 | @JsonSerializable()
349 | class TimezoneBean {
350 | String offset;
351 | String description;
352 |
353 | TimezoneBean();
354 |
355 | factory TimezoneBean.fromJson(json) => _$TimezoneBeanFromJson(json);
356 |
357 | static toJson(TimezoneBean tz) => _$TimezoneBeanToJson(tz);
358 |
359 | static TimezoneBean fromMap(Map map) {
360 | TimezoneBean timezoneBean = new TimezoneBean();
361 | timezoneBean.offset = map['offset'];
362 | timezoneBean.description = map['description'];
363 | return timezoneBean;
364 | }
365 |
366 | static List fromMapList(dynamic mapList) {
367 | List list = new List(mapList.length);
368 | for (int i = 0; i < mapList.length; i++) {
369 | list[i] = fromMap(mapList[i]);
370 | }
371 | return list;
372 | }
373 | }
374 |
--------------------------------------------------------------------------------
/lib/bloc_network/random_user.g.dart:
--------------------------------------------------------------------------------
1 | // GENERATED CODE - DO NOT MODIFY BY HAND
2 |
3 | part of 'random_user.dart';
4 |
5 | // **************************************************************************
6 | // JsonSerializableGenerator
7 | // **************************************************************************
8 |
9 | RandomUserModel _$RandomUserModelFromJson(Map json) {
10 | return RandomUserModel()
11 | ..info = json['info'] == null
12 | ? null
13 | : InfoBean.fromJson(json['info'] as Map)
14 | ..results = (json['results'] as List)
15 | ?.map((e) =>
16 | e == null ? null : UserInfo.fromJson(e as Map))
17 | ?.toList();
18 | }
19 |
20 | Map _$RandomUserModelToJson(RandomUserModel instance) =>
21 | {'info': instance.info, 'results': instance.results};
22 |
23 | InfoBean _$InfoBeanFromJson(Map json) {
24 | return InfoBean()
25 | ..seed = json['seed'] as String
26 | ..version = json['version'] as String
27 | ..results = json['results'] as int
28 | ..page = json['page'] as int;
29 | }
30 |
31 | Map _$InfoBeanToJson(InfoBean instance) => {
32 | 'seed': instance.seed,
33 | 'version': instance.version,
34 | 'results': instance.results,
35 | 'page': instance.page
36 | };
37 |
38 | UserInfo _$UserInfoFromJson(Map json) {
39 | return UserInfo()
40 | ..gender = json['gender'] as String
41 | ..email = json['email'] as String
42 | ..phone = json['phone'] as String
43 | ..cell = json['cell'] as String
44 | ..nat = json['nat'] as String
45 | ..dob = json['dob'] == null
46 | ? null
47 | : DobBean.fromJson(json['dob'] as Map)
48 | ..id = json['id'] == null
49 | ? null
50 | : IdBean.fromJson(json['id'] as Map)
51 | ..location = json['location'] == null
52 | ? null
53 | : LocationBean.fromJson(json['location'] as Map)
54 | ..login = json['login'] == null
55 | ? null
56 | : LoginBean.fromJson(json['login'] as Map)
57 | ..name = json['name'] == null
58 | ? null
59 | : NameBean.fromJson(json['name'] as Map)
60 | ..picture = json['picture'] == null
61 | ? null
62 | : PictureBean.fromJson(json['picture'] as Map)
63 | ..registered = json['registered'] == null
64 | ? null
65 | : RegisteredBean.fromJson(json['registered'] as Map);
66 | }
67 |
68 | Map _$UserInfoToJson(UserInfo instance) => {
69 | 'gender': instance.gender,
70 | 'email': instance.email,
71 | 'phone': instance.phone,
72 | 'cell': instance.cell,
73 | 'nat': instance.nat,
74 | 'dob': instance.dob,
75 | 'id': instance.id,
76 | 'location': instance.location,
77 | 'login': instance.login,
78 | 'name': instance.name,
79 | 'picture': instance.picture,
80 | 'registered': instance.registered
81 | };
82 |
83 | DobBean _$DobBeanFromJson(Map json) {
84 | return DobBean()
85 | ..date = json['date'] as String
86 | ..age = json['age'] as int;
87 | }
88 |
89 | Map _$DobBeanToJson(DobBean instance) =>
90 | {'date': instance.date, 'age': instance.age};
91 |
92 | IdBean _$IdBeanFromJson(Map json) {
93 | return IdBean()
94 | ..name = json['name'] as String
95 | ..value = json['value'] as String;
96 | }
97 |
98 | Map _$IdBeanToJson(IdBean instance) =>
99 | {'name': instance.name, 'value': instance.value};
100 |
101 | LocationBean _$LocationBeanFromJson(Map json) {
102 | return LocationBean()
103 | ..street = json['street'] as String
104 | ..city = json['city'] as String
105 | ..state = json['state'] as String
106 | ..postcode = json['postcode'] as String
107 | ..coordinates = json['coordinates'] == null
108 | ? null
109 | : CoordinatesBean.fromJson(json['coordinates'] as Map)
110 | ..timezone = json['timezone'] == null
111 | ? null
112 | : TimezoneBean.fromJson(json['timezone'] as Map);
113 | }
114 |
115 | Map _$LocationBeanToJson(LocationBean instance) =>
116 | {
117 | 'street': instance.street,
118 | 'city': instance.city,
119 | 'state': instance.state,
120 | 'postcode': instance.postcode,
121 | 'coordinates': instance.coordinates,
122 | 'timezone': instance.timezone
123 | };
124 |
125 | LoginBean _$LoginBeanFromJson(Map json) {
126 | return LoginBean()
127 | ..uuid = json['uuid'] as String
128 | ..username = json['username'] as String
129 | ..password = json['password'] as String
130 | ..salt = json['salt'] as String
131 | ..md5 = json['md5'] as String
132 | ..sha1 = json['sha1'] as String
133 | ..sha256 = json['sha256'] as String;
134 | }
135 |
136 | Map _$LoginBeanToJson(LoginBean instance) => {
137 | 'uuid': instance.uuid,
138 | 'username': instance.username,
139 | 'password': instance.password,
140 | 'salt': instance.salt,
141 | 'md5': instance.md5,
142 | 'sha1': instance.sha1,
143 | 'sha256': instance.sha256
144 | };
145 |
146 | NameBean _$NameBeanFromJson(Map json) {
147 | return NameBean()
148 | ..title = json['title'] as String
149 | ..first = json['first'] as String
150 | ..last = json['last'] as String;
151 | }
152 |
153 | Map _$NameBeanToJson(NameBean instance) => {
154 | 'title': instance.title,
155 | 'first': instance.first,
156 | 'last': instance.last
157 | };
158 |
159 | PictureBean _$PictureBeanFromJson(Map json) {
160 | return PictureBean()
161 | ..large = json['large'] as String
162 | ..medium = json['medium'] as String
163 | ..thumbnail = json['thumbnail'] as String;
164 | }
165 |
166 | Map _$PictureBeanToJson(PictureBean instance) =>
167 | {
168 | 'large': instance.large,
169 | 'medium': instance.medium,
170 | 'thumbnail': instance.thumbnail
171 | };
172 |
173 | RegisteredBean _$RegisteredBeanFromJson(Map json) {
174 | return RegisteredBean()
175 | ..date = json['date'] as String
176 | ..age = json['age'] as int;
177 | }
178 |
179 | Map _$RegisteredBeanToJson(RegisteredBean instance) =>
180 | {'date': instance.date, 'age': instance.age};
181 |
182 | CoordinatesBean _$CoordinatesBeanFromJson(Map json) {
183 | return CoordinatesBean()
184 | ..latitude = json['latitude'] as String
185 | ..longitude = json['longitude'] as String;
186 | }
187 |
188 | Map _$CoordinatesBeanToJson(CoordinatesBean instance) =>
189 | {
190 | 'latitude': instance.latitude,
191 | 'longitude': instance.longitude
192 | };
193 |
194 | TimezoneBean _$TimezoneBeanFromJson(Map json) {
195 | return TimezoneBean()
196 | ..offset = json['offset'] as String
197 | ..description = json['description'] as String;
198 | }
199 |
200 | Map _$TimezoneBeanToJson(TimezoneBean instance) =>
201 | {
202 | 'offset': instance.offset,
203 | 'description': instance.description
204 | };
205 |
--------------------------------------------------------------------------------
/lib/bloc_network/user_bloc.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_arts_demos_app/application.dart';
2 | import 'package:flutter_arts_demos_app/bloc/bloc_provider.dart';
3 | import 'package:flutter_arts_demos_app/bloc_network/random_user.dart';
4 | import 'package:rxdart/rxdart.dart';
5 |
6 | class UserBloc extends BaseBloc {
7 | RandomUserModel _user;
8 |
9 | RandomUserModel get user => _user;
10 |
11 | BehaviorSubject _controller = BehaviorSubject();
12 |
13 | Observable get stream => Observable(_controller.stream);
14 |
15 | updateUserInfo() {
16 | Application.http.getRequest('/api').then((response) {
17 | RandomUserModel model = RandomUserModel.fromMap(response.data);
18 | _user = model;
19 | _controller.add(model);
20 | });
21 | }
22 |
23 | @override
24 | void dispose() {
25 | _controller?.close();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/lib/bloc_network/user_page_main.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/cupertino.dart';
2 | import 'package:flutter/material.dart';
3 | import 'package:flutter_arts_demos_app/bloc/bloc_provider.dart';
4 | import 'package:flutter_arts_demos_app/bloc_network/random_user.dart';
5 | import 'package:flutter_arts_demos_app/bloc_network/user_bloc.dart';
6 |
7 | class UserPageDemo extends StatelessWidget {
8 | String _upperFirst(String content) {
9 | assert(content != null && content.isNotEmpty);
10 | return '${content.substring(0, 1).toUpperCase()}${content.substring(1)}';
11 | }
12 |
13 | Widget _userLocation(String info) => Padding(
14 | padding: const EdgeInsets.only(top: 4.0),
15 | child: Text(info, style: TextStyle(color: Colors.white, fontSize: 16.0)));
16 |
17 | @override
18 | Widget build(BuildContext context) {
19 | UserBloc _bloc = BlocProvider.of(context);
20 | _bloc.updateUserInfo();
21 |
22 | return Scaffold(
23 | body: StreamBuilder(
24 | builder: (_, AsyncSnapshot snapshot) => Container(
25 | alignment: Alignment.center,
26 | decoration: BoxDecoration(
27 | gradient: LinearGradient(
28 | begin: Alignment.topCenter,
29 | end: Alignment.bottomCenter,
30 | colors: [Colors.blue[600], Colors.blue[400]])),
31 | child: !snapshot.hasData
32 | ? CupertinoActivityIndicator(radius: 12.0)
33 | : Column(mainAxisAlignment: MainAxisAlignment.center, children: [
34 | InkWell(
35 | child: ClipOval(
36 | child: FadeInImage.assetNetwork(
37 | placeholder: 'images/ava_default.png', image: snapshot.data.results[0].picture.large),
38 | ),
39 | onTap: () => _bloc.updateUserInfo()),
40 | Padding(
41 | padding: const EdgeInsets.only(top: 20.0),
42 | child: Text(
43 | '${_upperFirst(snapshot.data.results[0].name.first)} ${_upperFirst(snapshot.data.results[0].name.last)}',
44 | style: TextStyle(color: Colors.white, fontSize: 24.0)),
45 | ),
46 | Text('${snapshot.data.results[0].email}',
47 | style: TextStyle(color: Colors.white, fontSize: 18.0)),
48 | _userLocation('${snapshot.data.results[0].location.street}'),
49 | _userLocation('${_upperFirst(snapshot.data.results[0].location.city)}'),
50 | _userLocation('${_upperFirst(snapshot.data.results[0].location.state)}'),
51 | ]),
52 | ),
53 | initialData: _bloc.user,
54 | stream: _bloc.stream),
55 | );
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/lib/colsed/fuli_bloc.dart:
--------------------------------------------------------------------------------
1 | import 'package:dio/dio.dart';
2 | import 'package:flutter_arts_demos_app/application.dart';
3 | import 'package:flutter_arts_demos_app/bloc/bloc_provider.dart';
4 | import 'package:flutter_arts_demos_app/colsed/fuli_model.dart';
5 | import 'package:rxdart/rxdart.dart';
6 |
7 | class FuliBloc extends BaseBloc {
8 | List _models = [];
9 | int _page = 1;
10 |
11 | List get fuLi => _models;
12 |
13 | int get page => _page;
14 |
15 | BehaviorSubject> _controller = BehaviorSubject();
16 |
17 | Observable> get stream => Observable(_controller.stream);
18 |
19 | increasePage() => _page++;
20 |
21 | refreshFuli(List models) {
22 | _models.clear();
23 | _models.addAll(models);
24 | _controller.add(_models);
25 | }
26 |
27 | loadMoreFuli(List models) {
28 | _models.addAll(models);
29 | _controller.add(_models);
30 | }
31 |
32 | Future> requestFuli(int page) async {
33 | Response resp = await Application.http.getRequest('http://adr.meizitu.net/wp-json/wp/v2/posts',
34 | params: {'page': page, 'per_page': 10}, callback: (msg) => print(msg));
35 | return resp != null ? FuliModel.fromMapList(resp.data) : [];
36 | }
37 |
38 | @override
39 | void dispose() {
40 | _controller?.close();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/lib/colsed/fuli_model.dart:
--------------------------------------------------------------------------------
1 | class FuliModel {
2 | String title;
3 |
4 | // ignore: non_constant_identifier_names
5 | String thumb_src;
6 |
7 | // ignore: non_constant_identifier_names
8 | String thumb_src_min;
9 | int id;
10 |
11 | // ignore: non_constant_identifier_names
12 | int img_num;
13 |
14 | static FuliModel fromMap(Map map) {
15 | FuliModel model = new FuliModel();
16 | model.title = map['title'];
17 | model.thumb_src = map['thumb_src'];
18 | model.thumb_src_min = map['thumb_src_min'];
19 | model.id = map['id'];
20 | model.img_num = map['img_num'];
21 | return model;
22 | }
23 |
24 | static List fromMapList(dynamic mapList) {
25 | List list = new List(mapList.length);
26 | for (int i = 0; i < mapList.length; i++) {
27 | list[i] = fromMap(mapList[i]);
28 | }
29 | return list;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/lib/colsed/fuli_page_main.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/cupertino.dart';
2 | import 'package:flutter/material.dart';
3 | import 'package:flutter_arts_demos_app/bloc/bloc_provider.dart';
4 | import 'package:flutter_arts_demos_app/colsed/fuli_bloc.dart';
5 | import 'package:flutter_arts_demos_app/colsed/fuli_model.dart';
6 | import 'package:flutter_easyrefresh/easy_refresh.dart';
7 | import 'package:flutter_easyrefresh/ball_pulse_footer.dart';
8 |
9 | class FuliPage extends StatefulWidget {
10 | @override
11 | _FuliPageState createState() => _FuliPageState();
12 | }
13 |
14 | class _FuliPageState extends State {
15 | ScrollController _controller = ScrollController();
16 | GlobalKey _refreshKey = GlobalKey();
17 | GlobalKey _footerKey = GlobalKey();
18 | FuliBloc _bloc;
19 |
20 | @override
21 | void initState() {
22 | super.initState();
23 | _bloc = BlocProvider.of(context);
24 | _request();
25 | }
26 |
27 | _request() async {
28 | List fulis = await _bloc.requestFuli(_bloc.page);
29 | _bloc.page == 1 ? _bloc.refreshFuli(fulis) : _bloc.loadMoreFuli(fulis);
30 | _bloc.increasePage();
31 | }
32 |
33 | @override
34 | Widget build(BuildContext context) {
35 | return Scaffold(
36 | body: StreamBuilder(
37 | builder: (_, AsyncSnapshot> snapshot) => Container(
38 | alignment: Alignment.center,
39 | child: !snapshot.hasData
40 | ? CupertinoActivityIndicator(radius: 12.0)
41 | : EasyRefresh(
42 | key: _refreshKey,
43 | refreshFooter: BallPulseFooter(key: _footerKey),
44 | loadMore: () {
45 | _request();
46 | },
47 | child: GridView.count(
48 | crossAxisSpacing: 8.0,
49 | mainAxisSpacing: 4.0,
50 | childAspectRatio: 0.5,
51 | controller: _controller,
52 | crossAxisCount: 2,
53 | children: snapshot.data
54 | .map(
55 | (p) => Column(
56 | children: [
57 | FadeInImage.assetNetwork(
58 | placeholder: 'images/ali.jpg',
59 | image: '${p.thumb_src}',
60 | fit: BoxFit.cover,
61 | ),
62 | Padding(
63 | padding: const EdgeInsets.only(top: 8.0),
64 | child:
65 | Text('${p.title}', style: TextStyle(fontSize: 14.0, color: Colors.black)))
66 | ],
67 | ),
68 | )
69 | .toList(),
70 | )),
71 | ),
72 | stream: _bloc.stream,
73 | initialData: _bloc.fuLi,
74 | ),
75 | );
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/lib/custom_routes.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | class ScalePageRoute extends PageRouteBuilder {
4 | final Widget widget;
5 |
6 | ScalePageRoute(this.widget)
7 | : super(
8 | transitionDuration: Duration(milliseconds: 500),
9 | pageBuilder: (context, anim, _) => widget,
10 | transitionsBuilder: (context, anim, _, child) => ScaleTransition(
11 | scale: Tween(begin: 0.0, end: 1.0).animate(anim),
12 | child: child,
13 | ));
14 | }
15 |
16 | class FadeInPageRoute extends PageRouteBuilder {
17 | final Widget widget;
18 |
19 | FadeInPageRoute(this.widget)
20 | : super(
21 | transitionDuration: Duration(milliseconds: 1000),
22 | pageBuilder: (context, animation, _) => widget,
23 | transitionsBuilder: (context, animation, _, child) => FadeTransition(
24 | opacity: Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation(parent: animation, curve: Curves.ease)),
25 | child: child,
26 | ));
27 | }
28 |
29 | class RotateScalePageRoute extends PageRouteBuilder {
30 | final Widget widget;
31 |
32 | RotateScalePageRoute(this.widget)
33 | : super(
34 | transitionDuration: Duration(milliseconds: 500),
35 | pageBuilder: (context, animation, _) => widget,
36 | transitionsBuilder: (context, animation, _, child) => RotationTransition(
37 |
38 | /// turns 值表示旋转 turns * 2π
39 | turns: Tween(begin: 0.0, end: 1.0).animate(
40 | CurvedAnimation(parent: animation, curve: Curves.ease),
41 | ),
42 | child: ScaleTransition(
43 | scale: Tween(begin: 0.1, end: 1.0).animate(
44 | CurvedAnimation(parent: animation, curve: Curves.ease),
45 | ),
46 | child: child,
47 | )));
48 | }
49 |
--------------------------------------------------------------------------------
/lib/db_utils.dart:
--------------------------------------------------------------------------------
1 | import 'package:path/path.dart';
2 | import 'package:sqflite/sqflite.dart';
3 |
4 | class DatabaseUtils {
5 | final String _tableStudent = 'student';
6 |
7 | static Database _database; // 创建单例,防止重复打开消耗内存
8 |
9 | static DatabaseUtils _instance;
10 |
11 | static DatabaseUtils get instance => DatabaseUtils();
12 |
13 | DatabaseUtils._internal() {
14 | getDatabasesPath().then((path) async {
15 | _database = await openDatabase(join(path, 'demo.db'), version: 2, onCreate: (db, version) {
16 | // 创建数据库的时候在这边调用
17 | db.execute('create table $_tableStudent('
18 | 'id integer primary key,'
19 | 'name text not null,'
20 | 'weight real not null,'
21 | 'age integer not null default 0,'
22 | 'gender integer not null default 0)');
23 |
24 | // 更新升级增加的字段
25 | db.execute('alter table $_tableStudent add column birthday text');
26 | }, onUpgrade: (db, oldVersion, newVersion) {
27 | // 更新升级数据库的时候在这操作
28 | if (oldVersion == 1) db.execute('alter table $_tableStudent add column birthday text');
29 | }, onOpen: (db) {
30 | // 打开数据库时候的回调
31 | print('${db.path}');
32 | });
33 | });
34 | }
35 |
36 | factory DatabaseUtils() {
37 | if (_instance == null) _instance = DatabaseUtils._internal();
38 | return _instance;
39 | }
40 |
41 | Future insertStudent(StudentDbModel student) async => _database.insert(_tableStudent, student.toMap());
42 |
43 | // 批量操作需要通过 batch 实现,最后需要 commit 提交
44 | Future insertStudents(List students) async {
45 | var batch = _database.batch();
46 | students.forEach((s) => insertStudent(s));
47 | batch.commit();
48 | }
49 |
50 | // 删除操作
51 | Future deleteStudent(int id) => _database.rawDelete('delete from $_tableStudent where id = ?', [id]);
52 |
53 | // 更新数据操作
54 | Future updateStudentAge(int id, int age) =>
55 | _database.rawUpdate('update $_tableStudent set age = ? where id = ?', [age, id]);
56 |
57 | Future updateStudentGender(int id, int gender) =>
58 | _database.rawUpdate('update $_tableStudent set gender = ? where id = ?', [gender, id]);
59 |
60 | // 查询
61 | Future> queryStudents() async {
62 | List students = [];
63 | List