├── .gitignore ├── .metadata ├── README.md ├── android ├── .gitignore ├── app │ ├── build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── studyyoun │ │ │ │ └── mdemo1 │ │ │ │ └── MainActivity.java │ │ └── res │ │ │ ├── drawable │ │ │ └── launch_background.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values │ │ │ └── styles.xml │ │ │ └── xml │ │ │ └── network_security_config.xml │ │ └── profile │ │ └── AndroidManifest.xml ├── build.gradle ├── gradle.properties └── settings.gradle ├── images └── 2.0 │ ├── comment_icon.png │ ├── friend_icon.png │ ├── like_icon.png │ ├── like_icon_2.png │ ├── link_icon.png │ ├── logo.jpg │ ├── my_add_icon.png │ ├── my_man_icon.png │ ├── my_meun_icon.png │ ├── my_phone_icon.png │ ├── my_qq_icon.png │ ├── my_question_icon.png │ ├── my_setting_icon.png │ ├── my_title.png │ ├── my_weixin_icon.png │ ├── no_select_icon.png │ ├── qq_icon.png │ ├── qq_zon_icon.png │ ├── s01.jpeg │ ├── s02.jpeg │ ├── select_icon.png │ ├── tab1.png │ ├── tab1fill.png │ ├── tab2.png │ ├── tab2fill.png │ ├── tab3.png │ ├── tab3fill.png │ ├── tab4.png │ ├── tab4fill.png │ ├── transpond_icon.png │ ├── weibo_icon.png │ ├── welcome_bg.jpeg │ └── wexin_icon.png ├── ios ├── .gitignore ├── Flutter │ ├── AppFrameworkInfo.plist │ ├── Debug.xcconfig │ └── Release.xcconfig ├── Podfile ├── Podfile.lock ├── 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 │ ├── RunnerDebug.entitlements │ ├── RunnerProfile.entitlements │ ├── RunnerRelease.entitlements │ └── main.m ├── lib ├── base │ ├── base_page.dart │ ├── common_founction.dart │ └── common_user_helper.dart ├── bean │ └── bean_video.dart ├── demo │ ├── appbar │ │ ├── appbar_home_page.dart │ │ ├── book │ │ │ └── appbar_data1.dart │ │ └── main_appbar.dart │ ├── button │ │ ├── button_home_page.dart │ │ └── main_button.dart │ ├── checkbox │ │ ├── check_home_page.dart │ │ └── main_check.dart │ ├── clip │ │ ├── clip_home_page.dart │ │ └── main_clip.dart │ ├── column │ │ ├── column_home_page.dart │ │ ├── main_column.dart │ │ ├── row_and_column_home_page.dart │ │ ├── row_home_page.dart │ │ └── stack_home_page.dart │ ├── container │ │ ├── container_home_page.dart │ │ ├── dio_main_page.dart │ │ └── main_container.dart │ ├── demo_home_page.dart │ ├── dio │ │ ├── common_response.dart │ │ ├── cuestom_interceptor.dart │ │ ├── dio_main_page.dart │ │ └── user_bean.dart │ ├── gest │ │ ├── gesture_home_page.dart │ │ └── main_gesture.dart │ ├── gridview │ │ ├── gridview_home_page.dart │ │ ├── gridview_home_page2.dart │ │ ├── gridview_home_page3.dart │ │ ├── gridview_home_page4.dart │ │ ├── gridview_home_page5.dart │ │ ├── gridview_home_page6.dart │ │ └── main_gridview.dart │ ├── image │ │ ├── image_home_page.dart │ │ ├── image_loc_home_page.dart │ │ └── main_image.dart │ ├── language │ │ ├── language_config.dart │ │ ├── language_data.dart │ │ ├── language_data2.dart │ │ ├── language_data3.dart │ │ ├── language_data4.dart │ │ ├── language_data5.dart │ │ ├── language_data6.dart │ │ ├── language_data7.dart │ │ ├── language_data8.dart │ │ ├── language_data9.dart │ │ └── main_language.dart │ ├── listview │ │ ├── listview_home_page.dart │ │ ├── listviewb_home_page.dart │ │ ├── listviews_home_page.dart │ │ ├── listviewsw_home_page.dart │ │ └── main_listview.dart │ ├── main_demo.dart │ ├── otherview │ │ ├── main_other.dart │ │ ├── progress_home_page.dart │ │ └── slider_home_page.dart │ ├── provide │ │ ├── test_model.dart │ │ ├── test_provide.dart │ │ ├── test_provide2.dart │ │ └── test_them_model.dart │ ├── radio │ │ ├── main_radio.dart │ │ └── radio_home_page.dart │ ├── refresh │ │ ├── indicator_home_page.dart │ │ └── main_refresh.dart │ ├── routes │ │ ├── error_page.dart │ │ ├── first_page.dart │ │ ├── main_routes.dart │ │ ├── my_navigator_observes.dart │ │ ├── navigator_utils.dart │ │ └── scend_page.dart │ ├── scaffold │ │ ├── book │ │ │ ├── scffold_data1.dart │ │ │ ├── scffold_data10.dart │ │ │ ├── scffold_data11.dart │ │ │ ├── scffold_data12.dart │ │ │ ├── scffold_data13.dart │ │ │ ├── scffold_data14.dart │ │ │ ├── scffold_data15.dart │ │ │ ├── scffold_data2.dart │ │ │ ├── scffold_data3.dart │ │ │ ├── scffold_data4.dart │ │ │ ├── scffold_data5.dart │ │ │ ├── scffold_data6.dart │ │ │ ├── scffold_data7.dart │ │ │ ├── scffold_data8.dart │ │ │ ├── scffold_data9.dart │ │ │ └── scffold_home_item1.dart │ │ ├── emal_itme_page.dart │ │ ├── home_item_page.dart │ │ ├── main_scaffold.dart │ │ ├── people_item_page.dart │ │ └── scffold_home_page.dart │ ├── scroll │ │ ├── customscroll_demo_page.dart │ │ ├── customscroll_home_page.dart │ │ ├── main_scroll.dart │ │ ├── netscroll_home_page.dart │ │ └── scroll_home_page.dart │ ├── splash │ │ └── splash_main_page.dart │ ├── switch │ │ ├── main_switch.dart │ │ └── switch_home_page.dart │ ├── text │ │ ├── main_text.dart │ │ ├── text_hom_page.dart │ │ └── text_rich_hom_page.dart │ ├── text_deom.dart │ ├── text_deom2.dart │ ├── textfeild │ │ ├── main_textfield.dart │ │ ├── textfield_hom_page.dart │ │ ├── textfield_hom_page2.dart │ │ ├── textfield_hom_page3.dart │ │ ├── textfield_hom_page4.dart │ │ ├── textfield_hom_page5.dart │ │ ├── textfield_hom_page6.dart │ │ └── textfield_hom_page7.dart │ ├── theme │ │ ├── color_filtered.dart │ │ ├── first_them_page.dart │ │ ├── main_select_theme.dart │ │ ├── provide_config.dart │ │ ├── test_info.dart │ │ ├── them_config.dart │ │ └── them_data.dart │ └── theme2 │ │ ├── customscroll_demo_page.dart │ │ ├── main.dart │ │ ├── provide_config.dart │ │ └── them_config.dart ├── guid_page.dart ├── home_page.dart ├── index_page.dart ├── main.dart ├── main │ ├── item │ │ ├── findI_item_page.dart │ │ ├── find_video_page.dart │ │ ├── home_item_page.dart │ │ ├── home_item_page2.dart │ │ ├── home_item_page3.dart │ │ └── home_item_page4.dart │ ├── main_find2_pages.dart │ ├── main_find3_pages.dart │ ├── main_find_pages.dart │ ├── main_forum_pages.dart │ ├── main_home_pages.dart │ └── main_my_pages.dart ├── test.dart └── utils │ ├── route_utils.dart │ └── sp_utils.dart ├── pubspec.lock ├── pubspec.yaml └── test └── widget_test.dart /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .packages 28 | .pub-cache/ 29 | .pub/ 30 | /build/ 31 | 32 | # Web related 33 | lib/generated_plugin_registrant.dart 34 | 35 | # Exceptions to above rules. 36 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 37 | -------------------------------------------------------------------------------- /.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: 856a90e67c9284124d44d2be6c785bacd3a1c772 8 | channel: beta 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # edu_flutter_ui_base 2 | Flutter 从入门实践到开发一个APP之UI基础篇 源代码 3 | 4 | **重要消息** 5 | 6 | * [精通点的可以查看这里 精述](https://gitbook.cn/gitchat/author/5ae043915efcf9715e37c733) 7 | * [Flutter 从入门实践到开发一个APP之UI基础篇 视频](https://edu.csdn.net/course/detail/25543) 8 | * [flutter从入门 到精通 系列文章](https://blog.csdn.net/zl18603543572/article/details/93532582) 9 | 10 | *** 11 | 12 | ### 源代码说明 lib 目录下 13 | 14 | * demo.appbar flutter中AppBar的详细使用 15 | * demo.language MaterialApp 中多语言环境配制 16 | * demo.scaffold flutter 中 Scaffold 组件的详细综述 17 | * demo.routes MateriaAapp组件routes配制 18 | * demo.text flutter 中文本显示 Text 组件的详细使用 19 | * textFeild flutter文本输入框TextField详细综述 20 | * demo.theme MaterialApp 的 ThemData精讲1 以及应用内多主题配色 21 | 22 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | -------------------------------------------------------------------------------- /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 | 29 | 30 | compileSdkVersion 28 31 | 32 | lintOptions { 33 | disable 'InvalidPackage' 34 | } 35 | 36 | defaultConfig { 37 | 38 | applicationId "com.studyyoun.mdemo1" 39 | minSdkVersion 16 40 | targetSdkVersion 28 41 | versionCode flutterVersionCode.toInteger() 42 | ///appversionName 43 | versionName flutterVersionName 44 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 45 | //清单文件配置选项 46 | manifestPlaceholders = [ 47 | JPUSH_PKGNAME : applicationId, 48 | JPUSH_APPKEY : "92757fe67fd8c71eef92fbe2", // NOTE: JPush 上注册的包名对应的 Appkey. 49 | JPUSH_CHANNEL : "developer-default", //暂时填写默认值即可. 50 | ] 51 | } 52 | 53 | buildTypes { 54 | release { 55 | // TODO: Add your own signing config for the release build. 56 | // Signing with the debug keys for now, so `flutter run --release` works. 57 | signingConfig signingConfigs.debug 58 | } 59 | } 60 | } 61 | 62 | flutter { 63 | source '../..' 64 | } 65 | 66 | dependencies { 67 | testImplementation 'junit:junit:4.12' 68 | androidTestImplementation 'androidx.test:runner:1.1.1' 69 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' 70 | } 71 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 10 | 11 | 19 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/studyyoun/mdemo1/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.studyyoun.mdemo1; 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 | -------------------------------------------------------------------------------- /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/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /android/app/src/main/res/xml/network_security_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | google() 4 | jcenter() 5 | } 6 | 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:3.5.0' 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 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.enableR8=true 3 | android.useAndroidX=true 4 | android.enableJetifier=true 5 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /images/2.0/comment_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/comment_icon.png -------------------------------------------------------------------------------- /images/2.0/friend_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/friend_icon.png -------------------------------------------------------------------------------- /images/2.0/like_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/like_icon.png -------------------------------------------------------------------------------- /images/2.0/like_icon_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/like_icon_2.png -------------------------------------------------------------------------------- /images/2.0/link_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/link_icon.png -------------------------------------------------------------------------------- /images/2.0/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/logo.jpg -------------------------------------------------------------------------------- /images/2.0/my_add_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/my_add_icon.png -------------------------------------------------------------------------------- /images/2.0/my_man_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/my_man_icon.png -------------------------------------------------------------------------------- /images/2.0/my_meun_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/my_meun_icon.png -------------------------------------------------------------------------------- /images/2.0/my_phone_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/my_phone_icon.png -------------------------------------------------------------------------------- /images/2.0/my_qq_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/my_qq_icon.png -------------------------------------------------------------------------------- /images/2.0/my_question_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/my_question_icon.png -------------------------------------------------------------------------------- /images/2.0/my_setting_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/my_setting_icon.png -------------------------------------------------------------------------------- /images/2.0/my_title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/my_title.png -------------------------------------------------------------------------------- /images/2.0/my_weixin_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/my_weixin_icon.png -------------------------------------------------------------------------------- /images/2.0/no_select_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/no_select_icon.png -------------------------------------------------------------------------------- /images/2.0/qq_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/qq_icon.png -------------------------------------------------------------------------------- /images/2.0/qq_zon_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/qq_zon_icon.png -------------------------------------------------------------------------------- /images/2.0/s01.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/s01.jpeg -------------------------------------------------------------------------------- /images/2.0/s02.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/s02.jpeg -------------------------------------------------------------------------------- /images/2.0/select_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/select_icon.png -------------------------------------------------------------------------------- /images/2.0/tab1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/tab1.png -------------------------------------------------------------------------------- /images/2.0/tab1fill.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/tab1fill.png -------------------------------------------------------------------------------- /images/2.0/tab2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/tab2.png -------------------------------------------------------------------------------- /images/2.0/tab2fill.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/tab2fill.png -------------------------------------------------------------------------------- /images/2.0/tab3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/tab3.png -------------------------------------------------------------------------------- /images/2.0/tab3fill.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/tab3fill.png -------------------------------------------------------------------------------- /images/2.0/tab4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/tab4.png -------------------------------------------------------------------------------- /images/2.0/tab4fill.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/tab4fill.png -------------------------------------------------------------------------------- /images/2.0/transpond_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/transpond_icon.png -------------------------------------------------------------------------------- /images/2.0/weibo_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/weibo_icon.png -------------------------------------------------------------------------------- /images/2.0/welcome_bg.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/welcome_bg.jpeg -------------------------------------------------------------------------------- /images/2.0/wexin_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/images/2.0/wexin_icon.png -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1v3 2 | *.mode2v3 3 | *.moved-aside 4 | *.pbxuser 5 | *.perspectivev3 6 | **/*sync/ 7 | .sconsign.dblite 8 | .tags* 9 | **/.vagrant/ 10 | **/DerivedData/ 11 | Icon? 12 | **/Pods/ 13 | **/.symlinks/ 14 | profile 15 | xcuserdata 16 | **/.generated/ 17 | Flutter/App.framework 18 | Flutter/Flutter.framework 19 | Flutter/Flutter.podspec 20 | Flutter/Generated.xcconfig 21 | Flutter/app.flx 22 | Flutter/app.zip 23 | Flutter/flutter_assets/ 24 | Flutter/flutter_export_environment.sh 25 | ServiceDefinitions.json 26 | Runner/GeneratedPluginRegistrant.* 27 | 28 | # Exceptions to above rules. 29 | !default.mode1v3 30 | !default.mode2v3 31 | !default.pbxuser 32 | !default.perspectivev3 33 | -------------------------------------------------------------------------------- /ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def parse_KV_file(file, separator='=') 14 | file_abs_path = File.expand_path(file) 15 | if !File.exists? file_abs_path 16 | return []; 17 | end 18 | generated_key_values = {} 19 | skip_line_start_symbols = ["#", "/"] 20 | File.foreach(file_abs_path) do |line| 21 | next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } 22 | plugin = line.split(pattern=separator) 23 | if plugin.length == 2 24 | podname = plugin[0].strip() 25 | path = plugin[1].strip() 26 | podpath = File.expand_path("#{path}", file_abs_path) 27 | generated_key_values[podname] = podpath 28 | else 29 | puts "Invalid plugin specification: #{line}" 30 | end 31 | end 32 | generated_key_values 33 | end 34 | 35 | target 'Runner' do 36 | # Flutter Pod 37 | 38 | copied_flutter_dir = File.join(__dir__, 'Flutter') 39 | copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework') 40 | copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec') 41 | unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path) 42 | # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet. 43 | # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration. 44 | # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist. 45 | 46 | generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig') 47 | unless File.exist?(generated_xcode_build_settings_path) 48 | raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first" 49 | end 50 | generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path) 51 | cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR']; 52 | 53 | unless File.exist?(copied_framework_path) 54 | FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir) 55 | end 56 | unless File.exist?(copied_podspec_path) 57 | FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir) 58 | end 59 | end 60 | 61 | # Keep pod path relative so it can be checked into Podfile.lock. 62 | pod 'Flutter', :path => 'Flutter' 63 | 64 | # Plugin Pods 65 | 66 | # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock 67 | # referring to absolute paths on developers' machines. 68 | system('rm -rf .symlinks') 69 | system('mkdir -p .symlinks/plugins') 70 | plugin_pods = parse_KV_file('../.flutter-plugins') 71 | plugin_pods.each do |name, path| 72 | symlink = File.join('.symlinks', 'plugins', name) 73 | File.symlink(path, symlink) 74 | pod name, :path => File.join(symlink, 'ios') 75 | end 76 | end 77 | 78 | # Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. 79 | install! 'cocoapods', :disable_input_output_paths => true 80 | 81 | post_install do |installer| 82 | installer.pods_project.targets.each do |target| 83 | target.build_configurations.each do |config| 84 | config.build_settings['ENABLE_BITCODE'] = 'NO' 85 | end 86 | end 87 | end 88 | -------------------------------------------------------------------------------- /ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - custom_refresh_plugin (0.0.1): 3 | - Flutter 4 | - Flutter (1.0.0) 5 | - flutter_guidance_plugin (0.0.1): 6 | - Flutter 7 | - fluttertoast (0.0.2): 8 | - Flutter 9 | - FMDB (2.7.5): 10 | - FMDB/standard (= 2.7.5) 11 | - FMDB/standard (2.7.5) 12 | - JCore (2.1.8) 13 | - JPush (3.2.8): 14 | - JCore (< 3.0.0, >= 2.0.0) 15 | - jpush_flutter (0.0.2): 16 | - Flutter 17 | - JPush 18 | - shared_preferences_web (0.0.1): 19 | - Flutter 20 | - sqflite (0.0.1): 21 | - Flutter 22 | - FMDB (~> 2.7.2) 23 | 24 | DEPENDENCIES: 25 | - custom_refresh_plugin (from `.symlinks/plugins/custom_refresh_plugin/ios`) 26 | - Flutter (from `Flutter`) 27 | - flutter_guidance_plugin (from `.symlinks/plugins/flutter_guidance_plugin/ios`) 28 | - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`) 29 | - jpush_flutter (from `.symlinks/plugins/jpush_flutter/ios`) 30 | - shared_preferences_web (from `.symlinks/plugins/shared_preferences_web/ios`) 31 | - sqflite (from `.symlinks/plugins/sqflite/ios`) 32 | 33 | SPEC REPOS: 34 | trunk: 35 | - FMDB 36 | - JCore 37 | - JPush 38 | 39 | EXTERNAL SOURCES: 40 | custom_refresh_plugin: 41 | :path: ".symlinks/plugins/custom_refresh_plugin/ios" 42 | Flutter: 43 | :path: Flutter 44 | flutter_guidance_plugin: 45 | :path: ".symlinks/plugins/flutter_guidance_plugin/ios" 46 | fluttertoast: 47 | :path: ".symlinks/plugins/fluttertoast/ios" 48 | jpush_flutter: 49 | :path: ".symlinks/plugins/jpush_flutter/ios" 50 | shared_preferences_web: 51 | :path: ".symlinks/plugins/shared_preferences_web/ios" 52 | sqflite: 53 | :path: ".symlinks/plugins/sqflite/ios" 54 | 55 | SPEC CHECKSUMS: 56 | custom_refresh_plugin: 6cf6eade81b0591b0ab28662247bef05eaa53446 57 | Flutter: 0e3d915762c693b495b44d77113d4970485de6ec 58 | flutter_guidance_plugin: 53300db18f05527c516f7e8f8708ce927b45dd44 59 | fluttertoast: b644586ef3b16f67fae9a1f8754cef6b2d6b634b 60 | FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a 61 | JCore: a7f1dead960d77a97717c73ea8b0aa5b33706491 62 | JPush: 8ce888d6dedfa417e90c8b6bc87405a16ce2e699 63 | jpush_flutter: 69133df35eaf9135e540549b154d992c44f8ee44 64 | shared_preferences_web: 141cce0c3ed1a1c5bf2a0e44f52d31eeb66e5ea9 65 | sqflite: 4001a31ff81d210346b500c55b17f4d6c7589dd0 66 | 67 | PODFILE CHECKSUM: 3dbe063e9c90a5d7c9e4e76e70a821b9e2c1d271 68 | 69 | COCOAPODS: 1.9.3 70 | -------------------------------------------------------------------------------- /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 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : FlutterAppDelegate 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /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/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/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/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/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/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/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/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/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/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/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/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/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/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/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/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/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/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/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/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/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/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/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/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/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/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/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/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/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/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/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/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaolongs/edu_flutter_ui_base/18341c5b98d59848eaaa2c0e152655795802dd2b/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 | $(DEVELOPMENT_LANGUAGE) 7 | NSAppTransportSecurity 8 | 9 | NSAllowsArbitraryLoads 10 | 11 | 12 | CFBundleExecutable 13 | $(EXECUTABLE_NAME) 14 | CFBundleIdentifier 15 | $(PRODUCT_BUNDLE_IDENTIFIER) 16 | CFBundleInfoDictionaryVersion 17 | 6.0 18 | CFBundleName 19 | mdemo1 20 | CFBundlePackageType 21 | APPL 22 | CFBundleShortVersionString 23 | $(FLUTTER_BUILD_NAME) 24 | CFBundleSignature 25 | ???? 26 | CFBundleVersion 27 | $(FLUTTER_BUILD_NUMBER) 28 | LSRequiresIPhoneOS 29 | 30 | UILaunchStoryboardName 31 | LaunchScreen 32 | UIMainStoryboardFile 33 | Main 34 | UISupportedInterfaceOrientations 35 | 36 | UIInterfaceOrientationPortrait 37 | UIInterfaceOrientationLandscapeLeft 38 | UIInterfaceOrientationLandscapeRight 39 | 40 | UISupportedInterfaceOrientations~ipad 41 | 42 | UIInterfaceOrientationPortrait 43 | UIInterfaceOrientationPortraitUpsideDown 44 | UIInterfaceOrientationLandscapeLeft 45 | UIInterfaceOrientationLandscapeRight 46 | 47 | UIViewControllerBasedStatusBarAppearance 48 | 49 | 50 | NSPhotoLibraryUsageDescription 51 | 需要您的同意,APP才能访问相册 52 | 53 | NSCameraUsageDescription 54 | 需要您的同意,APP才能访问相机 55 | 56 | NSMicrophoneUsageDescription 57 | 需要您的同意,APP才能访问麦克风 58 | 59 | NSLocationUsageDescription 60 | 需要您的同意, APP才能访问位置 61 | 62 | NSLocationWhenInUseUsageDescription 63 | App需要您的同意, APP才能在使用期间访问位置 64 | 65 | NSLocationAlwaysUsageDescription 66 | App需要您的同意, APP才能始终访问位置 67 | 68 | NSCalendarsUsageDescription 69 | App需要您的同意, APP才能访问日历 70 | 71 | NSRemindersUsageDescription 72 | 需要您的同意, APP才能访问提醒事项 73 | 74 | NSMotionUsageDescription 75 | 需要您的同意, APP才能访问运动与健身 76 | 77 | NSHealthUpdateUsageDescription 78 | 需要您的同意, APP才能访问健康更新 79 | 80 | NSHealthShareUsageDescription 81 | 需要您的同意, APP才能访问健康分享 82 | 83 | NSBluetoothPeripheralUsageDescription 84 | 需要您的同意, APP才能访问蓝牙 85 | 86 | NSAppleMusicUsageDescription 87 | 需要您的同意, APP才能访问媒体资料库 88 | 89 | 90 | -------------------------------------------------------------------------------- /ios/Runner/RunnerDebug.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | aps-environment 6 | development 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner/RunnerProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | aps-environment 6 | development 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner/RunnerRelease.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | aps-environment 6 | development 7 | 8 | 9 | -------------------------------------------------------------------------------- /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/base/base_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/foundation.dart'; 4 | import 'package:mdemo1/utils/route_utils.dart'; 5 | import 'package:pull_to_refresh/pull_to_refresh.dart'; 6 | import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart' as extended; 7 | import '../home_page.dart'; 8 | 9 | ///基类 10 | /// 1[pushPage] 打开页面方法 11 | /// 2 [pushRePage]打开页面 并替换当前显示页面 12 | /// 3 [popPage] 关闭当前页面 13 | abstract class BasePage extends State { 14 | ///打开页面 15 | void pushPage(Widget page) { 16 | RouteUtils.pushPage(context, page); 17 | } 18 | 19 | ///打开页面 并替换当前显示页面 20 | void pushRePage(Widget page) { 21 | RouteUtils.pushRePage(context, page); 22 | } 23 | 24 | ///关闭当前页面 25 | void popPage() { 26 | RouteUtils.popPage(context); 27 | } 28 | 29 | ///打开首页面 30 | void pushHomePage(){ 31 | pushRePage(HomePage()); 32 | } 33 | 34 | 35 | ///NestedScrollViewRefresh 设置下拉刷新 36 | Widget buildNestedScrollViewRefresh(extended.NestedScrollView scrollView,Function refreshCallback){ 37 | return NestedScrollViewRefreshIndicator(child: scrollView,onRefresh:refreshCallback ,); 38 | } 39 | 40 | 41 | RefreshController refreshController = new RefreshController(); 42 | final RefreshIndicator defaultHeader = 43 | defaultTargetPlatform == TargetPlatform.iOS 44 | ? ClassicHeader(height: 66,) 45 | : MaterialClassicHeader(); 46 | 47 | Widget buildSmartRefresh(Widget childWidth) { 48 | return SmartRefresher( 49 | ///控制器 50 | controller: refreshController, 51 | ///上拉加载更多数据 52 | enablePullUp: true, 53 | ///下拉刷新数据 54 | enablePullDown: true, 55 | ///下拉刷新回调 56 | onRefresh: onRefresh, 57 | ///上拉加载更多回调 58 | onLoading: onLoading, 59 | child: childWidth, 60 | header: defaultHeader, 61 | 62 | ); 63 | } 64 | 65 | 66 | onRefresh() async { 67 | Future.delayed(Duration(milliseconds: 3000), () { 68 | refreshController.refreshCompleted(); 69 | }); 70 | } 71 | 72 | onLoading() async { 73 | Future.delayed(Duration(milliseconds: 3000), () { 74 | // refreshController.loadComplete(); 75 | // refreshController.loadFailed(); 76 | refreshController.loadNoData(); 77 | }); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /lib/base/common_founction.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:fluttertoast/fluttertoast.dart'; 3 | 4 | /// 页面中间弹框 5 | void showCenterToast(String message,{ToastGravity toastGravity=ToastGravity.CENTER}) { 6 | /// 根据消息长度决定自动消失时间 7 | double multiplier = .5; 8 | int timeInSecForIos = (multiplier * (message.length * 0.06 + 0.5)).round(); 9 | Fluttertoast.showToast( 10 | msg: message, 11 | textColor: Colors.white, 12 | backgroundColor: Colors.black87, 13 | gravity: toastGravity, 14 | /// 只针对iOS生效的消失时间 15 | timeInSecForIos: timeInSecForIos, 16 | ); 17 | } 18 | -------------------------------------------------------------------------------- /lib/base/common_user_helper.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | /// true 为用户已登录 8 | bool userIsLogin(){ 9 | return false; 10 | } -------------------------------------------------------------------------------- /lib/bean/bean_video.dart: -------------------------------------------------------------------------------- 1 | 2 | class VideoModel { 3 | ///视频名称 4 | String videoName =''; 5 | ///视频链接 6 | String videoUrl =''; 7 | ///视频截图 8 | String videoImag =''; 9 | ///是否关注 10 | bool isAttention =false; 11 | ///关注的个数 12 | num attentCount =0; 13 | ///是否喜欢 14 | bool isLike = false; 15 | ///点赞的个数 16 | num pariseCount = 0; 17 | ///分享的次数 18 | num shareCount=0; 19 | } 20 | -------------------------------------------------------------------------------- /lib/demo/appbar/book/appbar_data1.dart: -------------------------------------------------------------------------------- 1 | ///4.1 AppBar的基本使用 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | ///应用入口
 6 | main() => runApp( MaterialApp(home: FirstPage(),theme: ThemeData(primaryTextTheme: ),)); 7 | 8 | 9 | 10 | class FirstPage extends StatefulWidget { 11 | @override 12 | State createState() { 13 | return FirstPagetate(); 14 | } 15 | } 16 | class FirstPagetate extends State { 17 | @override 18 | Widget build(BuildContext context) { 19 | ///Scaffold 用来搭建页面的主体结构 20 | return Scaffold( 21 | ///标题 22 | appBar: AppBar(title: Text("首页标题"),textTheme:TextTheme() ,), 23 | ///页面的主内容区 24 | body: Center(child: Text("首页面"),),); 25 | } 26 | } -------------------------------------------------------------------------------- /lib/demo/appbar/main_appbar.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | import 'appbar_home_page.dart'; 7 | 8 | ///flutter应用程序中的入口函数 9 | void main()=>runApp(AppBarApp()); 10 | ///应用的根布局 11 | class AppBarApp extends StatelessWidget{ 12 | @override 13 | Widget build(BuildContext context) { 14 | ///构建Materia Desin 风格的应用程序 15 | return MaterialApp( 16 | ///Android应用程序中任务栏中显示应用的名称 17 | title: "AppBar 配制", 18 | ///默认的首页面 19 | home: AppBarHomePage(), 20 | ); 21 | } 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /lib/demo/button/button_home_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | class ButtonHomePage extends StatefulWidget { 5 | @override 6 | State createState() { 7 | return ButtonHomePagePageState(); 8 | } 9 | } 10 | 11 | class ButtonHomePagePageState extends State { 12 | @override 13 | Widget build(BuildContext context) { 14 | return Scaffold( 15 | appBar: new AppBar( 16 | title: Text("demo.button 配制"), 17 | ), 18 | ///线性布局 19 | body: Column(crossAxisAlignment: CrossAxisAlignment.center,children: [ 20 | 21 | SizedBox(height: 20,), 22 | buildMaterialButton(), 23 | SizedBox(height: 20,), 24 | FlatButton(child: Text("FlatButton"),onPressed: (){},onLongPress: (){},), 25 | RaisedButton(child: Text("RaisedButton"),onPressed: (){},), 26 | OutlineButton(child: Text("OutlineButton"),onPressed: (){},), 27 | IconButton(icon: Icon(Icons.home),onPressed: (){},), 28 | 29 | 30 | ],) 31 | ); 32 | } 33 | 34 | MaterialButton buildMaterialButton() { 35 | return MaterialButton( 36 | ///按钮的背景 37 | color: Colors.blue, 38 | 39 | child: Text("按钮"), 40 | ///点击回调函数 41 | onPressed: (){ 42 | print("按钮点击"); 43 | }, 44 | ///按钮按下时回调 value = true 45 | ///按钮抬起时回调 value = false 46 | ///要先于 onPressed 47 | onHighlightChanged: (value){ 48 | print("按钮点击 Hight $value"); 49 | }, 50 | ///定义按钮的基色,以及按钮的最小尺寸 51 | ///ButtonTextTheme.accent 按钮显示的文本 ThemeData.accentColor(MaterialApp组件中的theme属性配制的) 52 | ///ButtonTextTheme. normal 按钮显示的文本 黑色或者白色 具体取决于ThemeData.brightness Brightness.dark 53 | ///ButtonTextTheme.primary 按钮的显示的文本 ThemeData.primaryColr 54 | textTheme: ButtonTextTheme.primary, 55 | ///配制按钮上文本的颜色 56 | textColor: Colors.deepOrange, 57 | ///未设置点击时的背景颜色 58 | disabledColor:Colors.yellow , 59 | ///按钮点击下的颜色 60 | highlightColor:Colors.deepPurple, 61 | ///水波方的颜色 62 | splashColor: Colors.green, 63 | ///按钮的阴影 64 | elevation: 10, 65 | ///按钮按下时的阴影高度 66 | highlightElevation: 20, 67 | ///未设置点击时的阴影高度 68 | disabledElevation: 5.0, 69 | ///用来设置按钮的边框的样式 70 | /// Border.all(color: Colors.deepOrange,width: 2.5,style: BorderStyle.solid) 四个边框 71 | /// Border(bottom: BorderSide(color: Colors.deepOrange,width: 2.5,style: BorderStyle.solid)) 可以分别设置边框 72 | /// 用来设置底部边框的 73 | /// UnderlineInputBorder(borderSide: BorderSide(color: Colors.deepOrange,width: 2.5,style: BorderStyle.solid),borderRadius: BorderRadius.circular(10)) 74 | /// 用来设置圆角矩形边框 75 | /// RoundedRectangleBorder(side: BorderSide.none,borderRadius: BorderRadius.all(Radius.circular(20))) 76 | /// 用来设置圆形边框 77 | /// CircleBorder(side: BorderSide(width: 2,color:Colors.red )), 78 | /// 椭圆形边框 StadiumBorder(side: BorderSide(width: 2,color: Colors.red)) 79 | /// 设置 多边形 BeveledRectangleBorder(side: BorderSide(width: 2,color: Colors.red),borderRadius: BorderRadius.all(Radius.circular(20))) 80 | /// 81 | shape: Border.all(color: Colors.deepOrange,width: 2.5,style: BorderStyle.solid), 82 | height: 44.0, 83 | minWidth: 140, 84 | ); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /lib/demo/button/main_button.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | import 'button_home_page.dart'; 7 | 8 | ///flutter应用程序中的入口函数 9 | void main()=>runApp(TextFieldMainApp()); 10 | ///应用的根布局 11 | class TextFieldMainApp extends StatelessWidget{ 12 | @override 13 | Widget build(BuildContext context) { 14 | ///构建Materia Desin 风格的应用程序 15 | return MaterialApp( 16 | ///Android应用程序中任务栏中显示应用的名称 17 | title: "Container 配制", 18 | theme: ThemeData( 19 | accentColor: Colors.deepPurple, 20 | ///默认是 Brightness.light 21 | brightness: Brightness.light, 22 | ), 23 | ///默认的首页面 24 | home: ButtonHomePage(), 25 | ); 26 | 27 | } 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /lib/demo/checkbox/check_home_page.dart: -------------------------------------------------------------------------------- 1 | 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | class CheckHomePage extends StatefulWidget { 6 | @override 7 | State createState() { 8 | return CheckHomePageState(); 9 | } 10 | } 11 | 12 | class CheckHomePageState extends State { 13 | bool check = false; 14 | bool checka = false; 15 | bool checkb = false; 16 | @override 17 | Widget build(BuildContext context) { 18 | return Scaffold( 19 | appBar: new AppBar( 20 | title: Text(" 配制"), 21 | ), 22 | 23 | ///线性布局 24 | body: Column( 25 | children: [ 26 | Container( 27 | height: 100, 28 | margin: EdgeInsets.all(12), 29 | padding: EdgeInsets.all(20), 30 | color: Colors.grey[400], 31 | child: Row( 32 | children: [ 33 | Checkbox( 34 | ///状态回调 35 | onChanged: (value) { 36 | setState(() { 37 | check = value; 38 | }); 39 | }, 40 | 41 | /// true Checkbox是选中状态 42 | value: check, 43 | 44 | ///选中的背景颜色 45 | activeColor: Colors.red, 46 | ), 47 | Text("请同意用户协议") 48 | ], 49 | ), 50 | ), 51 | Container( 52 | margin: EdgeInsets.all(12), 53 | color: Colors.grey[400], 54 | child: CheckboxListTile( 55 | secondary: Image.asset("images/2.0/logo.jpg"), 56 | title: Text("这是测试选中"), 57 | subtitle: Text("这是二级标题"), 58 | /// true Checkbox 选中 59 | value: checka, 60 | ///Checkbox 状态改变的时候回调 61 | onChanged: (value){ 62 | print("回调了$value"); 63 | setState(() { 64 | checka=value; 65 | }); 66 | },), 67 | ), 68 | 69 | Container( 70 | height: 100, 71 | margin: EdgeInsets.all(12), 72 | padding: EdgeInsets.only(left: 16), 73 | color: Colors.grey[400], 74 | ///手势监听 75 | child: GestureDetector( 76 | onTap: (){ 77 | setState(() { 78 | checkb=!checkb; 79 | }); 80 | }, 81 | child: Row( 82 | children: [ 83 | Image.asset(checkb?"images/2.0/no_select_icon.png":"images/2.0/select_icon.png",width: 22,height: 22,), 84 | SizedBox(width: 12,), 85 | Text("请同意用户协议") 86 | ], 87 | ), 88 | ), 89 | 90 | ), 91 | 92 | Container( 93 | height: 100, 94 | margin: EdgeInsets.all(12), 95 | ///手势监听 96 | child: InkWell( 97 | onTap: (){ 98 | setState(() { 99 | checkb=!checkb; 100 | }); 101 | }, 102 | child: Row( 103 | children: [ 104 | SizedBox(width: 12,), 105 | Image.asset(checkb?"images/2.0/no_select_icon.png":"images/2.0/select_icon.png",width: 22,height: 22,), 106 | SizedBox(width: 12,), 107 | Text("请同意用户协议") 108 | ], 109 | ), 110 | ), 111 | 112 | ), 113 | ], 114 | ), 115 | ); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /lib/demo/checkbox/main_check.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | import 'check_home_page.dart'; 7 | 8 | ///flutter应用程序中的入口函数 9 | void main()=>runApp(ImageMainApp()); 10 | ///应用的根布局 11 | class ImageMainApp extends StatelessWidget{ 12 | @override 13 | Widget build(BuildContext context) { 14 | ///构建Materia Desin 风格的应用程序 15 | return MaterialApp( 16 | ///Android应用程序中任务栏中显示应用的名称 17 | title: " 配制", 18 | theme: ThemeData( 19 | accentColor: Colors.deepPurple, 20 | ///默认是 Brightness.light 21 | brightness: Brightness.light, 22 | ), 23 | ///默认的首页面 24 | home: CheckHomePage(), 25 | // home: ImageLocalHomePage(), 26 | ); 27 | 28 | 29 | 30 | } 31 | } 32 | 33 | 34 | -------------------------------------------------------------------------------- /lib/demo/clip/main_clip.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | import 'clip_home_page.dart'; 5 | 6 | ///flutter应用程序中的入口函数 7 | void main() => runApp(ClipMainApp()); 8 | 9 | ///应用的根布局 10 | class ClipMainApp extends StatelessWidget { 11 | @override 12 | Widget build(BuildContext context) { 13 | ///构建Materia Desin 风格的应用程序 14 | return MaterialApp( 15 | ///Android应用程序中任务栏中显示应用的名称 16 | title: "配制", 17 | theme: ThemeData( 18 | accentColor: Colors.blue, 19 | 20 | ///默认是 Brightness.light 21 | brightness: Brightness.light, 22 | ), 23 | 24 | ///默认的首页面 25 | home: ClipHomePage(), 26 | ); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/demo/column/column_home_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | class ColumnPage extends StatefulWidget { 5 | @override 6 | State createState() { 7 | return ColumnPagePageState(); 8 | } 9 | } 10 | 11 | class ColumnPagePageState extends State { 12 | @override 13 | Widget build(BuildContext context) { 14 | return Scaffold( 15 | appBar: new AppBar( 16 | title: Text("Column 配制"), 17 | ), 18 | ///线性布局 19 | ///布局竖直方向上的Widget 呈线性的排列方式 20 | /// 默认 在 height 是填充 父布局 21 | /// 默认 在 width 是包裹 子Widget 22 | /// 当 Column 的父布局 width 有明确的宽度限制时 Column 本身的 width 也是填充父布局的 23 | /// Column 中子 Widget 是默认的 水平居中的 24 | body: SizedBox(width: 330,height: 540, 25 | child: Column( 26 | /// MainAxisSize.min 设置在没有父Widget高度限制时 设置为此项 Column 在竖直方向上包裹子 Widget 27 | /// 默认是 MainAxisSize.max 28 | mainAxisSize: MainAxisSize.min, 29 | ///在次方向上靠左对齐 30 | /// CrossAxisAlignment.end 水平方向的右边 31 | /// CrossAxisAlignment.center 水平方向的居中 默认 32 | /// CrossAxisAlignment.start 水平方向的左边 33 | crossAxisAlignment: CrossAxisAlignment.start, 34 | /// 在主方向上对齐设置 35 | /// MainAxisAlignment.end 竖直方向的下边 36 | /// MainAxisAlignment.center 竖直方向的中间 37 | /// MainAxisAlignment.start 竖直方向的上边 38 | mainAxisAlignment: MainAxisAlignment.start, 39 | ///文字的绘制方向 40 | ///TextDirection.ltr left to right 从左向右 41 | textDirection: TextDirection.ltr, 42 | 43 | ///权重适配 44 | children: [ 45 | ///当 flex 相等时 Expanded 平分高度 46 | Expanded(flex: 3, child: Container(color: Colors.blue, 47 | width: 220, 48 | height: 128, 49 | margin: EdgeInsets.only(top: 20, left: 12),),), 50 | Expanded(flex: 1, child: 51 | Container(color: Colors.blue, 52 | width: 220, 53 | height: 28, 54 | margin: EdgeInsets.only(top: 20, left: 12,),),), 55 | ],), 56 | ), 57 | ); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /lib/demo/column/main_column.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:mdemo1/demo/column/stack_home_page.dart'; 6 | 7 | ///flutter应用程序中的入口函数 8 | void main()=>runApp(ColumnMainApp()); 9 | ///应用的根布局 10 | class ColumnMainApp extends StatelessWidget{ 11 | @override 12 | Widget build(BuildContext context) { 13 | ///构建Materia Desin 风格的应用程序 14 | return MaterialApp( 15 | ///Android应用程序中任务栏中显示应用的名称 16 | title: "Container 配制", 17 | theme: ThemeData( 18 | accentColor: Colors.deepPurple, 19 | ///默认是 Brightness.light 20 | brightness: Brightness.light, 21 | ), 22 | ///默认的首页面 23 | // home: ColumnPage(), 24 | // home: RowHomePage(), 25 | // home: RowAndColumnHomePage(), 26 | home: StackHomePage(), 27 | ); 28 | 29 | 30 | 31 | } 32 | } 33 | 34 | 35 | -------------------------------------------------------------------------------- /lib/demo/column/row_and_column_home_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | class RowAndColumnHomePage extends StatefulWidget { 5 | @override 6 | State createState() { 7 | // TODO: implement createState 8 | return RowHomePageState(); 9 | } 10 | } 11 | 12 | class RowHomePageState extends State { 13 | @override 14 | Widget build(BuildContext context) { 15 | return Scaffold( 16 | appBar: AppBar( 17 | title: Text("Row Column 混合配制"), 18 | ), 19 | body: Column( 20 | children: [ 21 | Container(height: 48,child: Row(children: [ 22 | Expanded(flex: 1,child: Text("热点1",textAlign: TextAlign.center,),), 23 | Expanded(flex: 1,child:Text("热点2",textAlign: TextAlign.center),), 24 | Expanded(flex: 1,child:Text("热点3",textAlign: TextAlign.center),), 25 | Expanded(flex: 1,child: Text("热点4",textAlign: TextAlign.center),), 26 | ],),), 27 | Container(color: Colors.grey,height: 1,), 28 | ], 29 | ), 30 | 31 | floatingActionButton: FloatingActionButton(onPressed: (){},), 32 | ); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /lib/demo/column/row_home_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | class RowHomePage extends StatefulWidget { 5 | @override 6 | State createState() { 7 | // TODO: implement createState 8 | return RowHomePageState(); 9 | } 10 | } 11 | 12 | class RowHomePageState extends State { 13 | @override 14 | Widget build(BuildContext context) { 15 | return Scaffold( 16 | appBar: AppBar( 17 | title: Text("Row配制"), 18 | ), 19 | 20 | /// Row 用于线性布局 在水平方向上排列子Widget 21 | /// Row 的主方向是水平方向 22 | /// 默认情况下 没父布局的高宽限制的时候 在主方向(水平方向上是填充父布局的)在次方向(竖直方向)包裹 23 | /// 24 | body: SizedBox( 25 | height: 400, 26 | width: 400, 27 | child: Row( 28 | ///MainAxisSize.min 设置主方向上的内容包裹 29 | ///默认是max 填充的 30 | mainAxisSize: MainAxisSize.max, 31 | ///关于对齐方面 Row 中的所有的子Widget 在次方向(竖直方向上居中对齐) 32 | crossAxisAlignment: CrossAxisAlignment.center, 33 | ///方向 34 | mainAxisAlignment: MainAxisAlignment.start, 35 | children: [ 36 | Expanded(flex: 2,child: Container(color: Colors.blue,width: 100,height: 120,),), 37 | Expanded(flex: 1,child: Container(color: Colors.blue,width: 28,height: 120,margin: EdgeInsets.only(left: 20),),) 38 | ], 39 | ), 40 | ), 41 | ); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /lib/demo/column/stack_home_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | class StackHomePage extends StatefulWidget { 5 | @override 6 | State createState() { 7 | // TODO: implement createState 8 | return RowHomePageState(); 9 | } 10 | } 11 | 12 | class RowHomePageState extends State { 13 | @override 14 | Widget build(BuildContext context) { 15 | 16 | 17 | num sWidth =MediaQuery.of(context).size.width; 18 | num sHeight =MediaQuery.of(context).size.height; 19 | 20 | return Scaffold( 21 | appBar: AppBar( 22 | title: Text("Stack 配制"), 23 | ), 24 | 25 | /// Stack 默认是包裹子 Widget 26 | body: Container( 27 | width: sWidth, 28 | height: sHeight, 29 | child: Stack( 30 | ///排列所有的子 Widget 31 | alignment: Alignment.center, 32 | children: [ 33 | Container( 34 | width: 300, 35 | height: 300, 36 | color: Colors.grey, 37 | ), 38 | Positioned( 39 | bottom: 150, 40 | right: 10, 41 | child: Container( 42 | width: 200, 43 | height: 120, 44 | color: Colors.yellow, 45 | ), 46 | ) 47 | ], 48 | ), 49 | ), 50 | ); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /lib/demo/container/main_container.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | import 'container_home_page.dart'; 7 | 8 | ///flutter应用程序中的入口函数 9 | void main()=>runApp(TextFieldMainApp()); 10 | ///应用的根布局 11 | class TextFieldMainApp extends StatelessWidget{ 12 | @override 13 | Widget build(BuildContext context) { 14 | ///构建Materia Desin 风格的应用程序 15 | return MaterialApp( 16 | ///Android应用程序中任务栏中显示应用的名称 17 | title: "Container 配制", 18 | ///默认的首页面 19 | home: ContainerHomePage(), 20 | ); 21 | 22 | } 23 | } 24 | 25 | 26 | -------------------------------------------------------------------------------- /lib/demo/dio/common_response.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | class CommonResponse{ 4 | int code; 5 | dynamic data; 6 | String message; 7 | 8 | static CommonResponse fromJson(Map json){ 9 | CommonResponse commonResponse = new CommonResponse(); 10 | 11 | commonResponse.code = json["code"]; 12 | 13 | commonResponse.message = json["message"]; 14 | 15 | commonResponse.data = json["data"]; 16 | 17 | return commonResponse; 18 | 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /lib/demo/dio/cuestom_interceptor.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:dio/dio.dart'; 4 | 5 | class CuestomInterceptor extends InterceptorsWrapper{ 6 | ///拦截 发送的信息 7 | @override 8 | Future onRequest(RequestOptions options) { 9 | 10 | print("请求链接是 ${options.path}"); 11 | print("请求方法是 ${options.method}"); 12 | 13 | if(options.method=="GET") { 14 | print("请求参数是 ${options.queryParameters.toString()}"); 15 | }else{ 16 | print("请求参数是 ${options.data.toString()}"); 17 | } 18 | print("请求Content-typ 是 ${options.contentType}"); 19 | 20 | 21 | return super.onRequest(options); 22 | } 23 | ///拦截 响应的信息 24 | @override 25 | Future onResponse(Response response) { 26 | 27 | return super.onResponse(response); 28 | } 29 | ///拦截错误的信息 30 | @override 31 | Future onError(DioError err) { 32 | return super.onError(err); 33 | } 34 | } -------------------------------------------------------------------------------- /lib/demo/dio/user_bean.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | class UserBean{ 5 | String userName; 6 | String realName; 7 | int age; 8 | int id; 9 | 10 | static UserBean fromJson(Map data){ 11 | 12 | ///解析第二层 13 | UserBean userBean = new UserBean(); 14 | userBean.id = data["id"]; 15 | userBean.age = data["age"]; 16 | userBean.userName= data["userName"]; 17 | userBean.realName = data["realName"]; 18 | return userBean; 19 | 20 | } 21 | } -------------------------------------------------------------------------------- /lib/demo/gest/main_gesture.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | import 'gesture_home_page.dart'; 7 | 8 | ///flutter应用程序中的入口函数 9 | void main()=>runApp(ImageMainApp()); 10 | ///应用的根布局 11 | class ImageMainApp extends StatelessWidget{ 12 | @override 13 | Widget build(BuildContext context) { 14 | ///构建Materia Desin 风格的应用程序 15 | return MaterialApp( 16 | ///Android应用程序中任务栏中显示应用的名称 17 | title: " 配制", 18 | theme: ThemeData( 19 | accentColor: Colors.white, 20 | ///默认是 Brightness.light 21 | brightness: Brightness.light, 22 | ), 23 | ///默认的首页面 24 | home: GesturePage(), 25 | // home: ImageLocalHomePage(), 26 | ); 27 | 28 | 29 | 30 | } 31 | } 32 | 33 | 34 | -------------------------------------------------------------------------------- /lib/demo/gridview/gridview_home_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:cached_network_image/cached_network_image.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | class GridViewPage extends StatefulWidget { 6 | @override 7 | State createState() { 8 | return GridViewPageState(); 9 | } 10 | } 11 | 12 | class GridViewPageState extends State { 13 | @override 14 | void initState() { 15 | super.initState(); 16 | } 17 | 18 | @override 19 | Widget build(BuildContext context) { 20 | return Scaffold( 21 | appBar: AppBar( 22 | title: Text("GridView"), 23 | ), 24 | body: GridView( 25 | ///设置GridView 的滑动方向 26 | /// Axis.horizontal 水平方向滑动 (左右 水平方向为主方向) 27 | /// Axis.vertical 竖直方向滑动 (上下 竖直方向为主方向) 28 | scrollDirection: Axis.vertical, 29 | ///设置内边距 30 | padding: EdgeInsets.all(10), 31 | ///当内容不足的时候 用来配置是否可以滑动 32 | /// false 内容不足的时候是不可滑动的 33 | /// true 任何时间都可以滑动 34 | primary: true, 35 | /// BouncingScrollPhysics 有回弹效果 36 | /// ClampingScrollPhysics 没回弹道果 37 | /// NeverScrollableScrollPhysics 设置不可滑动 38 | /// AlwaysScrollableScrollPhysics 设置为永远可以滑动 39 | physics:BouncingScrollPhysics(), 40 | ///设置内容包裹 41 | shrinkWrap: false, 42 | /// 配制GridView的展示样式 43 | /// SliverGridDelegateWithFixedCrossAxisCount 固定列数 GridView.count 44 | /// SliverGridDelegateWithMaxCrossAxisExtent 不固定列数GridView.extent 45 | gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( 46 | ///列数控制 47 | crossAxisCount: 3, 48 | ///滑动方向为 竖直方向时 列与列之间的间隔 49 | crossAxisSpacing: 15, 50 | ///滑动方向为 竖直方向时 行与行之间的间隔 51 | mainAxisSpacing: 20, 52 | ///宽与高的比例 53 | childAspectRatio: 0.5, 54 | ), 55 | ///用来配制GridView 子条目 56 | /// 720 4 (720 -15 )/4 57 | children: [ 58 | Container( 59 | color: Colors.blue, 60 | width: 300, 61 | ), 62 | Container( 63 | color: Colors.blue, 64 | ), 65 | Container( 66 | color: Colors.blue, 67 | ), 68 | Container( 69 | color: Colors.blue, 70 | ), 71 | Container( 72 | color: Colors.blue, 73 | ), 74 | Container( 75 | color: Colors.blue, 76 | ), 77 | Container( 78 | color: Colors.blue, 79 | ), 80 | Container( 81 | color: Colors.blue, 82 | ), 83 | Container( 84 | color: Colors.blue, 85 | ), 86 | Container( 87 | color: Colors.blue, 88 | ), 89 | Container( 90 | color: Colors.blue, 91 | ), 92 | Container( 93 | color: Colors.blue, 94 | ), 95 | ], 96 | ), 97 | ); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /lib/demo/gridview/gridview_home_page2.dart: -------------------------------------------------------------------------------- 1 | import 'package:cached_network_image/cached_network_image.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | class GridViewPage2 extends StatefulWidget { 6 | @override 7 | State createState() { 8 | return GridViewPageState(); 9 | } 10 | } 11 | 12 | class GridViewPageState extends State { 13 | @override 14 | void initState() { 15 | super.initState(); 16 | } 17 | 18 | @override 19 | Widget build(BuildContext context) { 20 | 21 | ///获取屏幕尺寸信息 22 | double width = MediaQuery.of(context).size.width; 23 | double height= MediaQuery.of(context).size.height; 24 | 25 | double devicePixelRatio = MediaQuery.of(context).devicePixelRatio; 26 | 27 | /// 375 28 | print("widht is $width and height is $height devicePixelRatio is $devicePixelRatio"); 29 | 30 | 31 | return Scaffold( 32 | appBar: AppBar( 33 | title: Text("GridView"), 34 | ), 35 | body: GridView( 36 | ///设置GridView 的滑动方向 37 | /// Axis.horizontal 水平方向滑动 (左右 水平方向为主方向) 38 | /// Axis.vertical 竖直方向滑动 (上下 竖直方向为主方向) 39 | scrollDirection: Axis.vertical, 40 | ///设置内边距 41 | padding: EdgeInsets.all(10), 42 | ///当内容不足的时候 用来配置是否可以滑动 43 | /// false 内容不足的时候是不可滑动的 44 | /// true 任何时间都可以滑动 45 | primary: true, 46 | /// BouncingScrollPhysics 有回弹效果 47 | /// ClampingScrollPhysics 没回弹道果 48 | /// NeverScrollableScrollPhysics 设置不可滑动 49 | /// AlwaysScrollableScrollPhysics 设置为永远可以滑动 50 | physics:BouncingScrollPhysics(), 51 | ///设置内容包裹 52 | shrinkWrap: false, 53 | /// 配制GridView的展示样式 54 | /// SliverGridDelegateWithFixedCrossAxisCount 固定列数 55 | /// SliverGridDelegateWithMaxCrossAxisExtent 不固定列数 56 | gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( 57 | 58 | /// 最大宽度 59 | maxCrossAxisExtent: 200, 60 | ///滑动方向为 竖直方向时 列与列之间的间隔 61 | crossAxisSpacing: 10, 62 | ///滑动方向为 竖直方向时 行与行之间的间隔 63 | mainAxisSpacing: 20, 64 | ///宽与高的比例 65 | childAspectRatio: 0.5, 66 | ), 67 | ///用来配制GridView 子条目 68 | /// 720 4 (720 -15 )/4 69 | children: [ 70 | Container( 71 | color: Colors.grey, 72 | width: 300, 73 | ), 74 | Container( 75 | color: Colors.grey, 76 | ), 77 | Container( 78 | color: Colors.grey, 79 | ), 80 | Container( 81 | color: Colors.grey, 82 | ), 83 | Container( 84 | color: Colors.grey, 85 | ), 86 | Container( 87 | color: Colors.grey, 88 | ), 89 | Container( 90 | color: Colors.grey, 91 | ), 92 | Container( 93 | color: Colors.grey, 94 | ), 95 | Container( 96 | color: Colors.grey, 97 | ), 98 | Container( 99 | color: Colors.grey, 100 | ), 101 | Container( 102 | color: Colors.grey, 103 | ), 104 | Container( 105 | color: Colors.grey, 106 | ), 107 | ], 108 | ), 109 | ); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /lib/demo/gridview/gridview_home_page3.dart: -------------------------------------------------------------------------------- 1 | import 'package:cached_network_image/cached_network_image.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | class GridViewPage3 extends StatefulWidget { 6 | @override 7 | State createState() { 8 | return GridViewPageState(); 9 | } 10 | } 11 | 12 | class GridViewPageState extends State { 13 | @override 14 | void initState() { 15 | super.initState(); 16 | } 17 | 18 | @override 19 | Widget build(BuildContext context) { 20 | ///获取屏幕尺寸信息 21 | double width = MediaQuery.of(context).size.width; 22 | double height = MediaQuery.of(context).size.height; 23 | 24 | double devicePixelRatio = MediaQuery.of(context).devicePixelRatio; 25 | 26 | /// 375 27 | print( 28 | "widht is $width and height is $height devicePixelRatio is $devicePixelRatio"); 29 | 30 | return Scaffold( 31 | appBar: AppBar( 32 | title: Text("GridView"), 33 | ), 34 | 35 | ///SliverGridDelegateWithFixedCrossAxisCount 36 | ///创建固定列数的 GridView 37 | body: GridView.count( 38 | ///配制列数 39 | crossAxisCount: 3, 40 | crossAxisSpacing: 10, 41 | mainAxisSpacing: 10, 42 | childAspectRatio: 0.5, 43 | children: [ 44 | Container( 45 | color: Colors.blue, 46 | ), 47 | Container( 48 | color: Colors.blue, 49 | ), 50 | Container( 51 | color: Colors.blue, 52 | ), 53 | Container( 54 | color: Colors.blue, 55 | ), 56 | Container( 57 | color: Colors.blue, 58 | ), 59 | Container( 60 | color: Colors.blue, 61 | ), 62 | ], 63 | ), 64 | ); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /lib/demo/gridview/gridview_home_page4.dart: -------------------------------------------------------------------------------- 1 | import 'package:cached_network_image/cached_network_image.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | class GridViewPage4 extends StatefulWidget { 6 | @override 7 | State createState() { 8 | return GridViewPageState(); 9 | } 10 | } 11 | 12 | class GridViewPageState extends State { 13 | @override 14 | void initState() { 15 | super.initState(); 16 | } 17 | 18 | @override 19 | Widget build(BuildContext context) { 20 | ///获取屏幕尺寸信息 21 | double width = MediaQuery.of(context).size.width; 22 | double height = MediaQuery.of(context).size.height; 23 | 24 | double devicePixelRatio = MediaQuery.of(context).devicePixelRatio; 25 | 26 | /// 375 27 | print( 28 | "widht is $width and height is $height devicePixelRatio is $devicePixelRatio"); 29 | 30 | return Scaffold( 31 | appBar: AppBar( 32 | title: Text("GridView"), 33 | ), 34 | 35 | ///SliverGridDelegateWithFixedCrossAxisCount 36 | ///创建不固定列数的 GridView 37 | body: GridView.extent( 38 | ///配制 子 Widget 的最大宽度 39 | maxCrossAxisExtent: 200, 40 | crossAxisSpacing: 10, 41 | mainAxisSpacing: 10, 42 | childAspectRatio: 0.5, 43 | children: [ 44 | Container( 45 | color: Colors.blue, 46 | ), 47 | Container( 48 | color: Colors.blue, 49 | ), 50 | Container( 51 | color: Colors.blue, 52 | ), 53 | Container( 54 | color: Colors.blue, 55 | ), 56 | Container( 57 | color: Colors.blue, 58 | ), 59 | Container( 60 | color: Colors.blue, 61 | ), 62 | ], 63 | ), 64 | ); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /lib/demo/gridview/gridview_home_page5.dart: -------------------------------------------------------------------------------- 1 | import 'package:cached_network_image/cached_network_image.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | class GridViewPage5 extends StatefulWidget { 6 | @override 7 | State createState() { 8 | return GridViewPageState(); 9 | } 10 | } 11 | 12 | class GridViewPageState extends State { 13 | @override 14 | void initState() { 15 | super.initState(); 16 | } 17 | 18 | @override 19 | Widget build(BuildContext context) { 20 | ///获取屏幕尺寸信息 21 | double width = MediaQuery.of(context).size.width; 22 | double height = MediaQuery.of(context).size.height; 23 | 24 | double devicePixelRatio = MediaQuery.of(context).devicePixelRatio; 25 | 26 | /// 375 27 | print( 28 | "widht is $width and height is $height devicePixelRatio is $devicePixelRatio"); 29 | 30 | return Scaffold( 31 | appBar: AppBar( 32 | title: Text("GridView"), 33 | ), 34 | body: GridView.builder( 35 | /// 配制GridView的展示样式 36 | /// SliverGridDelegateWithFixedCrossAxisCount 固定列数 GridView.count 37 | /// SliverGridDelegateWithMaxCrossAxisExtent 不固定列数GridView.extent 38 | gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( 39 | ///列数控制 40 | crossAxisCount: 3, 41 | ///滑动方向为 竖直方向时 列与列之间的间隔 42 | crossAxisSpacing: 15, 43 | ///滑动方向为 竖直方向时 行与行之间的间隔 44 | mainAxisSpacing: 20, 45 | ///宽与高的比例 46 | childAspectRatio: 0.5, 47 | ), 48 | ///用来构建 子 Widget 的样式 49 | itemBuilder: (BuildContext context,int index){ 50 | if(index==0){ 51 | return Container(color: Colors.blue,child: Text("item $index",style: TextStyle(color: Colors.white),),); 52 | } 53 | return Container(color: Colors.grey,child: Text("item $index",style: TextStyle(color: Colors.red),),); 54 | }, 55 | ), 56 | ); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /lib/demo/gridview/gridview_home_page6.dart: -------------------------------------------------------------------------------- 1 | import 'package:cached_network_image/cached_network_image.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | class GridViewPage6 extends StatefulWidget { 6 | @override 7 | State createState() { 8 | return GridViewPageState(); 9 | } 10 | } 11 | 12 | class GridViewPageState extends State { 13 | @override 14 | void initState() { 15 | super.initState(); 16 | } 17 | 18 | @override 19 | Widget build(BuildContext context) { 20 | ///获取屏幕尺寸信息 21 | double width = MediaQuery.of(context).size.width; 22 | double height = MediaQuery.of(context).size.height; 23 | 24 | double devicePixelRatio = MediaQuery.of(context).devicePixelRatio; 25 | 26 | /// 375 27 | print( 28 | "widht is $width and height is $height devicePixelRatio is $devicePixelRatio"); 29 | 30 | return Scaffold( 31 | appBar: AppBar( 32 | title: Text("GridView"), 33 | ), 34 | body: GridView.custom( 35 | /// 配制GridView的展示样式 36 | /// SliverGridDelegateWithFixedCrossAxisCount 固定列数 GridView.count 37 | /// SliverGridDelegateWithMaxCrossAxisExtent 不固定列数GridView.extent 38 | gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( 39 | ///列数控制 40 | crossAxisCount: 3, 41 | 42 | ///滑动方向为 竖直方向时 列与列之间的间隔 43 | crossAxisSpacing: 15, 44 | 45 | ///滑动方向为 竖直方向时 行与行之间的间隔 46 | mainAxisSpacing: 20, 47 | 48 | ///宽与高的比例 49 | childAspectRatio: 0.5, 50 | ), 51 | 52 | ///用来构建 子 Widget 的样式 53 | childrenDelegate: CustomSliverChildBuilderDelegate( 54 | (BuildContext context, int index) { 55 | return Container( 56 | color: Colors.blue, 57 | child: Text("item $index"), 58 | ); 59 | }, 60 | 61 | ///配制个数 62 | childCount: 100, 63 | ), 64 | ), 65 | ); 66 | } 67 | } 68 | 69 | class CustomSliverChildBuilderDelegate extends SliverChildBuilderDelegate { 70 | CustomSliverChildBuilderDelegate(builder, {childCount}) 71 | : super(builder, childCount: childCount); 72 | 73 | @override 74 | void didFinishLayout(int firstIndex, int lastIndex) { 75 | super.didFinishLayout(firstIndex, lastIndex); 76 | print("didFinishLayout $firstIndex $lastIndex"); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /lib/demo/gridview/main_gridview.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | import 'gridview_home_page.dart'; 5 | import 'gridview_home_page2.dart'; 6 | import 'gridview_home_page3.dart'; 7 | import 'gridview_home_page4.dart'; 8 | import 'gridview_home_page5.dart'; 9 | import 'gridview_home_page6.dart'; 10 | 11 | 12 | ///flutter应用程序中的入口函数 13 | void main() => runApp(ImageMainApp()); 14 | 15 | ///应用的根布局 16 | class ImageMainApp extends StatelessWidget { 17 | @override 18 | Widget build(BuildContext context) { 19 | ///构建Materia Desin 风格的应用程序 20 | return MaterialApp( 21 | ///Android应用程序中任务栏中显示应用的名称 22 | title: "配制", 23 | theme: ThemeData( 24 | accentColor: Colors.blue, 25 | 26 | ///默认是 Brightness.light 27 | brightness: Brightness.light, 28 | ), 29 | 30 | ///默认的首页面 31 | home: GridViewPage6(), 32 | ); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /lib/demo/image/image_loc_home_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | class ImageLocalHomePage extends StatefulWidget { 5 | @override 6 | State createState() { 7 | return ImageHomePagePageState(); 8 | } 9 | } 10 | 11 | /// 加载本图片 12 | class ImageHomePagePageState extends State { 13 | 14 | 15 | @override 16 | Widget build(BuildContext context) { 17 | return Scaffold( 18 | appBar: new AppBar( 19 | title: Text("Image 配制"), 20 | ), 21 | 22 | ///线性布局 23 | body: Column( 24 | children: [ 25 | ///AssetImage 用来加载 项目中的图片 26 | Image(image:AssetImage("images/2.0/logo.jpg"),), 27 | Image.asset("images/2.0/logo.jpg"), 28 | 29 | ], 30 | ), 31 | ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/demo/image/main_image.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'image_home_page.dart'; 6 | ///flutter应用程序中的入口函数 7 | void main()=>runApp(ImageMainApp()); 8 | ///应用的根布局 9 | class ImageMainApp extends StatelessWidget{ 10 | @override 11 | Widget build(BuildContext context) { 12 | ///构建Materia Desin 风格的应用程序 13 | return MaterialApp( 14 | ///Android应用程序中任务栏中显示应用的名称 15 | title: "Image 配制", 16 | theme: ThemeData( 17 | accentColor: Colors.deepPurple, 18 | ///默认是 Brightness.light 19 | brightness: Brightness.light, 20 | ), 21 | ///默认的首页面 22 | home: ImageHomePage(), 23 | // home: ImageLocalHomePage(), 24 | ); 25 | 26 | 27 | 28 | } 29 | } 30 | 31 | 32 | -------------------------------------------------------------------------------- /lib/demo/language/language_config.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | ///2.9.5 配置自定义语言配置代理
MyLocationsLanguageDelegates的实现 4 | import 'package:flutter/cupertino.dart'; 5 | import 'package:flutter/foundation.dart'; 6 | 7 | class MyLocationsLanguageDelegates extends LocalizationsDelegate{ 8 | 9 | ///创建默认构造 10 | const MyLocationsLanguageDelegates(); 11 | ///创建静态构造 12 | static MyLocationsLanguageDelegates delegate = new MyLocationsLanguageDelegates(); 13 | 14 | @override 15 | bool isSupported(Locale locale) { 16 | ///判断是否支持 ['en','zh'] 其中的一个 17 | return ['en','zh'].contains(locale.languageCode); 18 | } 19 | 20 | ///通过load方法关联我们自定义的多语言配制文件MyLocationsLanguages的 21 | @override 22 | Future load(Locale locale) { 23 | ///异步初始化MyLocationsLanguages 24 | return SynchronousFuture(MyLocationsLanguages(locale)); 25 | } 26 | 27 | @override 28 | bool shouldReload(LocalizationsDelegate old) { 29 | ///是否需要重载 30 | return false; 31 | } 32 | } 33 | 34 | ///2.9.5 配置自定义语言配置代理
 多语言环境文字文件 35 | ///定义程序中使用到的文字 多语言适配 36 | class MyLocationsLanguages { 37 | 38 | ///记录当前应用程序使用到的本地化配制 39 | final Locale locale; 40 | 41 | MyLocationsLanguages(this.locale); 42 | 43 | ///定义一个静态方法来初始化 MyLocationsLanguages 44 | static of(BuildContext context){ 45 | return Localizations.of(context, MyLocationsLanguages); 46 | } 47 | 48 | ///定义多语言环境支持数据 49 | static Map> localValue = { 50 | 51 | ///英文支持 52 | 'en': { 53 | 'enlish' : "Select English", 54 | 'Chinese':"Select Chinese", 55 | 'ShowDate':"Show Date", 56 | }, 57 | ///中文支持 58 | 'zh': { 59 | 'enlish' : "选择英语", 60 | 'Chinese':"选择中文", 61 | 'ShowDate':"显示日期", 62 | }, 63 | }; 64 | 65 | 66 | ///外部引用的方法 67 | get button1{ 68 | return localValue[locale.languageCode]['button1']; 69 | } 70 | get button2{ 71 | return localValue[locale.languageCode]['button2']; 72 | } 73 | get button3{ 74 | return localValue[locale.languageCode]['button3']; 75 | } 76 | 77 | get selectChinese{ 78 | return localValue[locale.languageCode]['Chinese']; 79 | } 80 | 81 | get selectEnlish{ 82 | return localValue[locale.languageCode]['enlish']; 83 | } 84 | 85 | get selectShowDate{ 86 | return localValue[locale.languageCode]['ShowDate']; 87 | } 88 | } -------------------------------------------------------------------------------- /lib/demo/language/language_data4.dart: -------------------------------------------------------------------------------- 1 | 2 | ///2.9.1 配置日期组件显示为中文 默认创建的项目 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | ///应用入口
 7 | main() => runApp(themDataFunction()); 8 | 9 | MaterialApp themDataFunction() { 10 | return MaterialApp(home: FirstThemPage(),); 11 | } 12 | 13 | 14 | class FirstThemPage extends StatefulWidget { 15 | @override 16 | State createState() { 17 | throw UnimplementedError(); 18 | } 19 | 20 | } 21 | 22 | class FirstThemState extends State { 23 | @override 24 | Widget build(BuildContext context) { 25 | return Scaffold(body: Center(child: FlatButton(onPressed: () { 26 | ///显示日期组件
 27 | showDatePicker(context: context, 28 | //初始日期设置为现在
 29 | initialDate: new DateTime.now(), 30 | firstDate: new DateTime.now().subtract(new Duration(days: 30)), 31 | lastDate: new DateTime.now().add(new Duration(days: 30))).then(( 32 | v) {}); 33 | }, 34 | child: Text("显示日期"),),),); 35 | } 36 | } -------------------------------------------------------------------------------- /lib/demo/language/language_data5.dart: -------------------------------------------------------------------------------- 1 | 2 | ///2.9.1 配置日期组件显示为中文 MaterialApp配置中文语言环境设置 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_localizations/flutter_localizations.dart'; 6 | 7 | ///应用入口
 8 | main() => runApp(themDataFunction()); 9 | 10 | MaterialApp themDataFunction() { 11 | return MaterialApp(home: FirstThemPage(), 12 | localizationsDelegates: [ 13 | 14 | ///初始化默认的 Material 组件本地化
 15 | GlobalMaterialLocalizations.delegate, 16 | //初始化默认的 通用 Widget 组件本地化
 17 | GlobalWidgetsLocalizations.delegate, 18 | ], 19 | 20 | ///当前区域,如果为null则使用系统区域一般用于语言切换
 21 | ///传入两个参数,语言代码,国家代码
 22 | ///这里配制为中国
 23 | locale: Locale('zh', 'CN'), 24 | 25 | ///定义当前应用程序所支持的语言环境
 26 | supportedLocales: [ 27 | const Locale('en', 'US'),// English 英文
 28 | const Locale('de', 'DE'), // 德语
 29 | const Locale('zh', 'CN'), // 中文, 30 | ],); 31 | } 32 | 33 | 34 | class FirstThemPage extends StatefulWidget { 35 | @override 36 | State createState() { 37 | return FirstThemState(); 38 | } 39 | 40 | } 41 | 42 | class FirstThemState extends State { 43 | @override 44 | Widget build(BuildContext context) { 45 | return Scaffold(body: Center(child: FlatButton(onPressed: () { 46 | ///显示日期组件
 47 | showDatePicker(context: context, 48 | //初始日期设置为现在
 49 | initialDate: new DateTime.now(), 50 | firstDate: new DateTime.now().subtract(new Duration(days: 30)), 51 | lastDate: new DateTime.now().add(new Duration(days: 30))).then(( 52 | v) {}); 53 | }, 54 | child: Text("显示日期"),),),); 55 | } 56 | } -------------------------------------------------------------------------------- /lib/demo/language/language_data6.dart: -------------------------------------------------------------------------------- 1 | 2 | ///2.9.2 配置应用不适配的系统语言默认为英文 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_localizations/flutter_localizations.dart'; 6 | 7 | ///应用入口
 8 | main() => runApp(themDataFunction()); 9 | 10 | MaterialApp themDataFunction() { 11 | return MaterialApp(home: FirstThemPage(), 12 | localizationsDelegates: [ 13 | ///初始化默认的 Material 组件本地化
 14 | GlobalMaterialLocalizations.delegate, 15 | //初始化默认的 通用 Widget 组件本地化
 16 | GlobalWidgetsLocalizations.delegate, 17 | ], 18 | 19 | ///当前区域,如果为null则使用系统区域一般用于语言切换
 20 | ///传入两个参数,语言代码,国家代码
 21 | ///这里配制为中国
 22 | locale: Locale('zh', 'CN'), 23 | 24 | ///定义当前应用程序所支持的语言环境
 25 | supportedLocales: [ 26 | const Locale('en', 'US'),// English 英文
 27 | const Locale('de', 'DE'), // 德语
 28 | const Locale('zh', 'CN'), // 中文, 29 | ], 30 | localeResolutionCallback:(Locale sysLocale, Iterable supportedLocales) { 31 | ///locale 反回当前系统的语言环境
 32 | ///supportedLocales 返回 supportedLocales 中配制的语言环境支持的配置
 33 | ///判断应用程序是否支持当前系统语言
 34 | List locals = []; 35 | List list = supportedLocales.toList(); 36 | for(int i=0;i createState() { 53 | return FirstThemState(); 54 | } 55 | 56 | } 57 | 58 | class FirstThemState extends State { 59 | @override 60 | Widget build(BuildContext context) { 61 | return Scaffold(body: Center(child: FlatButton(onPressed: () { 62 | ///显示日期组件
 63 | showDatePicker(context: context, 64 | //初始日期设置为现在
 65 | initialDate: new DateTime.now(), 66 | firstDate: new DateTime.now().subtract(new Duration(days: 30)), 67 | lastDate: new DateTime.now().add(new Duration(days: 30))).then(( 68 | v) {}); 69 | }, 70 | child: Text("显示日期"),),),); 71 | } 72 | } -------------------------------------------------------------------------------- /lib/demo/listview/listview_home_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:cached_network_image/cached_network_image.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | class ListViewPage extends StatefulWidget { 6 | @override 7 | State createState() { 8 | return ListViewPageState(); 9 | } 10 | } 11 | 12 | class ListViewPageState extends State{ 13 | 14 | 15 | @override 16 | void initState() { 17 | super.initState(); 18 | 19 | } 20 | 21 | @override 22 | Widget build(BuildContext context) { 23 | return Scaffold( 24 | appBar: AppBar( 25 | title: Text("ListView"), 26 | ), 27 | ///用来加载 列表式布局 28 | body:ListView( 29 | ///子Widget 的方向 30 | scrollDirection: Axis.vertical, 31 | ///包裹 32 | shrinkWrap: false, 33 | /// 回弹弹效果 34 | physics: BouncingScrollPhysics(), 35 | children: [ 36 | Container(color: Colors.grey,height: 164,width:400,margin: EdgeInsets.all(10),), 37 | Container(color: Colors.grey,height: 164,width:400,margin: EdgeInsets.all(10),), 38 | Container(color: Colors.grey,height: 164,width:400,margin: EdgeInsets.all(10),), 39 | Container(color: Colors.grey,height: 24,width:400,margin: EdgeInsets.all(10),), 40 | Container(color: Colors.grey,height: 164,width:400,margin: EdgeInsets.all(10),), 41 | Container(color: Colors.grey,height: 164,width:400,margin: EdgeInsets.all(10),), 42 | ], 43 | ) 44 | ); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /lib/demo/listview/listviewb_home_page.dart: -------------------------------------------------------------------------------- 1 | 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | class ListViewBPage extends StatefulWidget { 6 | @override 7 | State createState() { 8 | return ListViewPageState(); 9 | } 10 | } 11 | 12 | class ListViewPageState extends State { 13 | List list = []; 14 | 15 | @override 16 | void initState() { 17 | super.initState(); 18 | 19 | for (int i = 0; i < 100; i++) { 20 | list.add("iteme $i"); 21 | } 22 | } 23 | 24 | @override 25 | Widget build(BuildContext context) { 26 | return Scaffold( 27 | appBar: AppBar( 28 | title: Text("ListView b"), 29 | ), 30 | 31 | ///用来加载 列表式布局 32 | body: ListView.builder( 33 | ///用来构建 子条目 34 | /// index 是条目的角标 35 | itemBuilder: (BuildContext context, num index) { 36 | return Container( 37 | color: Colors.grey[300], 38 | height: 88, 39 | margin: EdgeInsets.all(5), 40 | child: Text(list[index]), 41 | ); 42 | }, 43 | ///数据的个数 44 | itemCount: list.length, 45 | ), 46 | ); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /lib/demo/listview/listviewsw_home_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/foundation.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:pull_to_refresh/pull_to_refresh.dart'; 5 | 6 | class ListViewSWPage extends StatefulWidget { 7 | @override 8 | State createState() { 9 | return ListViewPageState(); 10 | } 11 | } 12 | 13 | class ListViewPageState extends State { 14 | List list = []; 15 | 16 | RefreshController refreshController = new RefreshController(); 17 | 18 | Widget defaultHeader = defaultTargetPlatform == TargetPlatform.iOS 19 | ? ClassicHeader( 20 | idleText: "下拉刷新", 21 | releaseText: "释放刷新", 22 | refreshingText: "刷新中", 23 | failedText: "刷新失败", 24 | completeText: "刷新成功", 25 | ) 26 | : MaterialClassicHeader(); 27 | 28 | final LoadIndicator defaultFooter = ClassicFooter( 29 | failedText: "加载失败", 30 | idleText: "上拉加载更多", 31 | canLoadingText: "松手加载", 32 | loadingText: "加载中", 33 | noDataText: "暂无更多数据", 34 | ); 35 | 36 | @override 37 | void initState() { 38 | super.initState(); 39 | 40 | for (int i = 0; i < 30; i++) { 41 | list.add("iteme $i"); 42 | } 43 | } 44 | 45 | @override 46 | Widget build(BuildContext context) { 47 | return Scaffold( 48 | appBar: AppBar( 49 | title: Text("ListView sw"), 50 | ), 51 | body: SmartRefresher( 52 | header: defaultHeader, 53 | footer: defaultFooter, 54 | 55 | ///是否可以上拉加载 56 | enablePullUp: true, 57 | 58 | ///是否可以下拉刷新 59 | enablePullDown: true, 60 | 61 | ///控制器 62 | controller: refreshController, 63 | child: buildListView(), 64 | onRefresh: () { 65 | print("下拉刷新回调"); 66 | Future.delayed(new Duration(milliseconds: 3000), () { 67 | refreshController.refreshCompleted(); 68 | }); 69 | }, 70 | onLoading: () { 71 | print("上拉加载回调"); 72 | Future.delayed(new Duration(milliseconds: 3000), () { 73 | refreshController.loadComplete(); 74 | }); 75 | }, 76 | ), 77 | ); 78 | } 79 | 80 | ///用来加载 列表式布局 自带分隔线 81 | Widget buildListView() { 82 | return ListView.builder( 83 | ///用来构建 子条目 84 | /// index 是条目的角标 85 | itemBuilder: (BuildContext context, num index) { 86 | return Container( 87 | margin: EdgeInsets.all(5), 88 | padding: EdgeInsets.all(10), 89 | color: Colors.grey[300], 90 | height: 88, 91 | child: Text(list[index]), 92 | ); 93 | }, 94 | 95 | ///数据的个数 96 | itemCount: list.length, 97 | ); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /lib/demo/listview/main_listview.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | import 'listview_home_page.dart'; 5 | import 'listviewb_home_page.dart'; 6 | import 'listviews_home_page.dart'; 7 | import 'listviewsw_home_page.dart'; 8 | 9 | ///flutter应用程序中的入口函数 10 | void main() => runApp(ImageMainApp()); 11 | 12 | ///应用的根布局 13 | class ImageMainApp extends StatelessWidget { 14 | @override 15 | Widget build(BuildContext context) { 16 | ///构建Materia Desin 风格的应用程序 17 | return MaterialApp( 18 | ///Android应用程序中任务栏中显示应用的名称 19 | title: "配制", 20 | theme: ThemeData( 21 | accentColor: Colors.blue, 22 | 23 | ///默认是 Brightness.light 24 | brightness: Brightness.light, 25 | ), 26 | 27 | ///默认的首页面 28 | // home: ListViewPage(), 29 | // home: ListViewBPage(), 30 | // home: ListViewSPage(), 31 | home: ListViewSWPage(), 32 | ); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /lib/demo/main_demo.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | import 'demo_home_page.dart'; 7 | 8 | ///flutter应用程序中的入口函数 9 | void main()=>runApp(ImageMainApp()); 10 | ///应用的根布局 11 | class ImageMainApp extends StatelessWidget{ 12 | @override 13 | Widget build(BuildContext context) { 14 | ///构建Materia Desin 风格的应用程序 15 | return MaterialApp( 16 | ///Android应用程序中任务栏中显示应用的名称 17 | title: "Image 配制", 18 | theme: ThemeData( 19 | accentColor: Colors.deepPurple, 20 | ///默认是 Brightness.light 21 | brightness: Brightness.light, 22 | ), 23 | ///默认的首页面 24 | home: DemoHomePage(), 25 | // home: ImageLocalHomePage(), 26 | ); 27 | 28 | 29 | 30 | } 31 | } 32 | 33 | 34 | -------------------------------------------------------------------------------- /lib/demo/otherview/main_other.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:mdemo1/demo/otherview/progress_home_page.dart'; 4 | 5 | ///flutter应用程序中的入口函数 6 | void main() => runApp(ClipMainApp()); 7 | 8 | ///应用的根布局 9 | class ClipMainApp extends StatelessWidget { 10 | @override 11 | Widget build(BuildContext context) { 12 | ///构建Materia Desin 风格的应用程序 13 | return MaterialApp( 14 | ///Android应用程序中任务栏中显示应用的名称 15 | title: "配制", 16 | theme: ThemeData( 17 | accentColor: Colors.blue, 18 | 19 | ///默认是 Brightness.light 20 | brightness: Brightness.light, 21 | ), 22 | ///默认的首页面 23 | // home: SliderHomePage(), 24 | home: ProgressHomePage(), 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/demo/otherview/progress_home_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:cached_network_image/cached_network_image.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | class ProgressHomePage extends StatefulWidget { 6 | @override 7 | State createState() { 8 | return ProgressHomePagePageState(); 9 | } 10 | } 11 | 12 | class ProgressHomePagePageState extends State { 13 | @override 14 | void initState() { 15 | super.initState(); 16 | } 17 | 18 | double sliderVlaue = 50; 19 | 20 | @override 21 | Widget build(BuildContext context) { 22 | double width = MediaQuery.of(context).size.width; 23 | return Scaffold( 24 | appBar: AppBar( 25 | title: Text("ProgressHomePage"), 26 | ), 27 | body: SingleChildScrollView( 28 | child: Column( 29 | children: [ 30 | Text("圆形"), 31 | Container( 32 | width: width, 33 | height: 300, 34 | alignment: Alignment.center, 35 | color: Colors.grey, 36 | child: SizedBox( 37 | width: 44, 38 | height: 44, 39 | child: CircularProgressIndicator( 40 | ///背景色 41 | backgroundColor: Colors.white, 42 | /// 前景色 43 | /// AlwaysStoppedAnimation 动画的类型 Always 总是 Stopped 停止 44 | valueColor:AlwaysStoppedAnimation(Colors.red), 45 | ), 46 | ), 47 | ), 48 | Text("条形"), 49 | Container( 50 | width: width, 51 | height: 300, 52 | alignment: Alignment.center, 53 | color: Colors.grey, 54 | child: LinearProgressIndicator( 55 | ///背景色 56 | backgroundColor: Colors.white, 57 | /// 前景色 58 | valueColor:AlwaysStoppedAnimation(Colors.red), 59 | ), 60 | ) 61 | ], 62 | ), 63 | ), 64 | ); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /lib/demo/otherview/slider_home_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:cached_network_image/cached_network_image.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | class SliderHomePage extends StatefulWidget { 6 | @override 7 | State createState() { 8 | return SliderHomePageState(); 9 | } 10 | } 11 | 12 | class SliderHomePageState extends State { 13 | @override 14 | void initState() { 15 | super.initState(); 16 | } 17 | 18 | double sliderVlaue = 50; 19 | 20 | @override 21 | Widget build(BuildContext context) { 22 | double width = MediaQuery.of(context).size.width; 23 | return Scaffold( 24 | appBar: AppBar( 25 | title: Text("SliderHome"), 26 | ), 27 | body: SingleChildScrollView( 28 | child: Column( 29 | children: [ 30 | Container( 31 | width: width, 32 | height: 300, 33 | alignment: Alignment.center, 34 | color: Colors.grey, 35 | 36 | /// Slider 是fluter 应用开发中的滑动条 37 | /// value 38 | child: Slider( 39 | ///当前进度值 40 | value: sliderVlaue, 41 | 42 | ///最小值 43 | min: 0, 44 | 45 | ///最大值 46 | max: 100, 47 | 48 | ///滑动时回调 49 | onChanged: (value) { 50 | setState(() { 51 | sliderVlaue = value; 52 | },); 53 | }, 54 | activeColor: Colors.red, 55 | inactiveColor: Colors.blue, 56 | label: "这是滑动的", 57 | ), 58 | ) 59 | ], 60 | ), 61 | ), 62 | ); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /lib/demo/provide/test_model.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | ///代码块2-8-2-2 4 | 5 | import 'package:flutter/widgets.dart'; 6 | 7 | ///ChangeNotifier 消息监听者与notifyListeners()结合实现消息通信 8 | ///类似iOS中的notify与Android中的广播 9 | class TestModel extends ChangeNotifier{ 10 | ///定义数据变量 11 | ///这里定义变量使用下划线开头,限制了当前变量只能在本TestModel类中进行访问使用 12 | ///所以提供了一个get方法来使外部来调用 13 | ///个人认为这种思想起源于Java中的面向对象 14 | String _testTitle = "这是初始化数据"; 15 | String get getTestTitle => _testTitle; 16 | 17 | ///修改文字 18 | void updateText(String message) { 19 | _testTitle = message; 20 | ///发送文本修改的消息通知 21 | notifyListeners(); 22 | } 23 | } -------------------------------------------------------------------------------- /lib/demo/provide/test_provide.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:mdemo1/demo/provide/test_model.dart'; 6 | 7 | 8 | ///2.8.2 浅谈Provider进行状态管理 配置数据模型
 9 | import 'package:provider/provider.dart'; 10 | 11 | void main() { 12 | ///程序入口函数 13 | runApp( 14 | ///将Provider配制在程序的最顶层 15 | ChangeNotifierProvider.value( 16 | ///value就是监听的数据模型对象 17 | value: TestModel(), 18 | ///这里最好是根widget 19 | child: MyProvideApp(), 20 | ) 21 | ); 22 | } 23 | 24 | ///2.8.2 浅谈Provider进行状态管理 引用数据并实现数据的修改 25 | class MyProvideApp extends StatefulWidget { 26 | @override 27 | State createState() { 28 | return MyAppState(); 29 | } 30 | } 31 | 32 | class MyAppState extends State { 33 | @override 34 | Widget build(BuildContext context) { 35 | return MaterialApp(home: Scaffold(body: Center(child: Column( 36 | mainAxisSize: MainAxisSize.min, children: [ 37 | 38 | ///这里通过调用 Provider.of(context).getTestTitle 来获取数据 39 | ///这里通过<>中配置的泛型类别来区分所识别的数据模型 40 | Text("这里是测试使用的数据:${Provider.of(context).getTestTitle}"), 41 | 42 | ///SizedBox用来占一个高度为30的空位 43 | SizedBox(height: 30,), 44 | ///FlatButton 这是一个按钮 45 | FlatButton(child: Text("点击修改文本"), onPressed: () { 46 | ///Provider.of(context, listen: false)来调用updateText方法更新数据; 47 | ///这里通过<>中配置的泛型类别来区分所识别的数据类型 48 | Provider.of(context, listen: false).updateText("哈哈 我来了"); 49 | },) 50 | 51 | ],),),)); 52 | } 53 | } -------------------------------------------------------------------------------- /lib/demo/provide/test_provide2.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:mdemo1/demo/provide/test_model.dart'; 6 | 7 | 8 | ///2.8.3 Provider进行多数据模型状态管理 9 | import 'package:provider/provider.dart'; 10 | 11 | void main() { 12 | ///程序入口函数 13 | runApp( 14 | MultiProvider( 15 | child: MyProvideApp(), 16 | providers: [ 17 | ///在这里可配置多个数据模型的Provider 18 | ///将Provider配制在程序的最顶层 19 | ChangeNotifierProvider.value( 20 | ///value就是监听的数据模型对象 21 | value: TestModel(), 22 | ///这里最好是根widget 23 | ), 24 | ///在这里还可以配置其他的ChangeNotifierProvider 25 | 26 | ],), 27 | 28 | ); 29 | } 30 | 31 | ///代码块2-8-2-4 32 | class MyProvideApp extends StatefulWidget { 33 | @override 34 | State createState() { 35 | return MyAppState(); 36 | } 37 | 38 | } 39 | 40 | class MyAppState extends State { 41 | @override 42 | Widget build(BuildContext context) { 43 | return MaterialApp(home: Scaffold(body: Center(child: Column( 44 | mainAxisSize: MainAxisSize.min, children: [ 45 | 46 | ///这里通过调用 Provider.of(context).getTestTitle 来获取数据 47 | ///这里通过<>中配置的泛型类别来区分所识别的数据模型 48 | Text("这里是测试使用的数据:${Provider.of(context).getTestTitle}"), 49 | 50 | ///SizedBox用来占一个高度为30的空位 51 | SizedBox(height: 30,), 52 | ///FlatButton 这是一个按钮 53 | FlatButton(child: Text("点击修改文本"), onPressed: () { 54 | ///Provider.of(context, listen: false)来调用updateText方法更新数据; 55 | ///这里通过<>中配置的泛型类别来区分所识别的数据类型 56 | Provider.of(context, listen: false).updateText("哈哈 我来了"); 57 | },) 58 | 59 | ],),),)); 60 | } 61 | 62 | } -------------------------------------------------------------------------------- /lib/demo/provide/test_them_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | ///代码块2-8-2-2 4 | 5 | import 'package:flutter/widgets.dart'; 6 | 7 | ///ChangeNotifier 消息监听者与notifyListeners()结合实现消息通信 8 | ///类似iOS中的notify与Android中的广播 9 | class TestThemModel extends ChangeNotifier { 10 | ///定义主题 11 | ThemeData defalutThemData = new ThemeData(); 12 | 13 | ///修改文字 14 | void selectTheme(int themeIndex) { 15 | 16 | ///发送主题修改的消息通知 17 | notifyListeners(); 18 | 19 | 20 | } 21 | } 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /lib/demo/radio/main_radio.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | import 'radio_home_page.dart'; 7 | 8 | ///flutter应用程序中的入口函数 9 | void main()=>runApp(ImageMainApp()); 10 | ///应用的根布局 11 | class ImageMainApp extends StatelessWidget{ 12 | @override 13 | Widget build(BuildContext context) { 14 | ///构建Materia Desin 风格的应用程序 15 | return MaterialApp( 16 | ///Android应用程序中任务栏中显示应用的名称 17 | title: " 配制", 18 | theme: ThemeData( 19 | accentColor: Colors.white, 20 | ///默认是 Brightness.light 21 | brightness: Brightness.light, 22 | ), 23 | ///默认的首页面 24 | home: RadioHomePage(), 25 | // home: ImageLocalHomePage(), 26 | ); 27 | 28 | 29 | 30 | } 31 | } 32 | 33 | 34 | -------------------------------------------------------------------------------- /lib/demo/refresh/main_refresh.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | import 'indicator_home_page.dart'; 7 | 8 | ///flutter应用程序中的入口函数 9 | void main()=>runApp(ImageMainApp()); 10 | ///应用的根布局 11 | class ImageMainApp extends StatelessWidget{ 12 | @override 13 | Widget build(BuildContext context) { 14 | ///构建Materia Desin 风格的应用程序 15 | return MaterialApp( 16 | ///Android应用程序中任务栏中显示应用的名称 17 | title: "配制", 18 | theme: ThemeData( 19 | accentColor: Colors.blue, 20 | ///默认是 Brightness.light 21 | brightness: Brightness.light, 22 | ), 23 | ///默认的首页面 24 | home: IndicatorPage(), 25 | // home: ImageLocalHomePage(), 26 | ); 27 | 28 | 29 | 30 | } 31 | } 32 | 33 | 34 | -------------------------------------------------------------------------------- /lib/demo/routes/error_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | class ErrorPage extends StatefulWidget { 5 | @override 6 | State createState() { 7 | return ErrorPageState(); 8 | } 9 | } 10 | 11 | class ErrorPageState extends State { 12 | @override 13 | Widget build(BuildContext context) { 14 | return Scaffold( 15 | appBar: AppBar( 16 | title: Text("404"), 17 | ), 18 | body: Center( 19 | child: Text( 20 | "页面找不到了 ~~", 21 | style: TextStyle(color: Colors.red), 22 | ), 23 | ), 24 | ); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/demo/routes/main_routes.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:mdemo1/demo/routes/scend_page.dart'; 4 | 5 | import 'error_page.dart'; 6 | import 'first_page.dart'; 7 | import 'my_navigator_observes.dart'; 8 | 9 | ///精讲 路由的启动类 10 | void main() => runApp(RoutesApp()); 11 | 12 | ///定义根目录 13 | class RoutesApp extends StatelessWidget { 14 | @override 15 | Widget build(BuildContext context) { 16 | // Navigator.of(context).push(new MaterialPageRoute(builder: (_) { 17 | // //ScendPage就是我们要打开的目标页面 18 | // return new ScendPage(); 19 | // }),); 20 | // 21 | // // 带返回值 22 | // Navigator.of(context).pushNamed('/router/second').then((value) { 23 | // // 这里的 value 就是 打开的 /router/second对应的页面关闭时回传的数据 24 | // }); 25 | return 26 | MaterialApp( 27 | 28 | ///配制路由规则 29 | routes: { 30 | ///默认页面 31 | "/":(BuildContext context) => FirstPage(), 32 | "/first": (BuildContext context) => FirstPage(), 33 | "/scend": (BuildContext context) => ScendPage(), 34 | }, 35 | 36 | ///配制显示默认页面的第二种方式 37 | // home: FirstPage(), 38 | ///配制显示默认页面的第三种方式 39 | // initialRoute: "/first", 40 | 41 | ///配制404 页面 42 | onGenerateRoute: (RouteSettings settings) { 43 | return new MaterialPageRoute( 44 | builder: (BuildContext contex) => ErrorPage()); 45 | }, 46 | 47 | ///兼听所有的页面路由 48 | navigatorObservers: [ 49 | ///创建自定义路由兼听 50 | MyNavigatorObservers(), 51 | ], 52 | ); 53 | } 54 | } 55 | 56 | -------------------------------------------------------------------------------- /lib/demo/routes/my_navigator_observes.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | 3 | class MyNavigatorObservers extends NavigatorObserver { 4 | /// 当调用Navigator.push时回调 5 | @override 6 | void didPush(Route route, Route previousRoute) { 7 | super.didPush(route, previousRoute); 8 | 9 | print("didPush目标的路由名称是 " + route.settings.name.toString()); 10 | print("didPush目标的路由是否是InitialRoute配置的初始化路由 " + route.settings.isInitialRoute.toString()); 11 | print("didPush目标的路由携带的参数 " + route.settings.arguments.toString()); 12 | 13 | if (previousRoute != null) { 14 | print("上一个路由的名称是 " + 15 | previousRoute.settings.name.toString()); 16 | }else{ 17 | ///当为第一个初始化页面时 previousRoute是为null的 18 | } 19 | 20 | } 21 | 22 | /// 当调用Navigator.pop时回调 23 | @override 24 | void didPop(Route route, Route previousRoute) { 25 | super.didPop(route, previousRoute); 26 | print("didPop 目标的路由名称是 " + route.settings.name.toString()); 27 | print("didPop 目标的路由是否是InitialRoute配置的初始化路由 "); 28 | print("didPop 目标的路由携带的参数 " + route.settings.arguments.toString()); 29 | 30 | if (previousRoute != null) { 31 | print("didPop 上一个路由的名称是 " + 32 | previousRoute.settings.name.toString()); 33 | }else{ 34 | ///当为第一个初始化页面时 previousRoute是为null的 35 | } 36 | 37 | } 38 | 39 | /// 当调用Navigator.Remove时回调 40 | @override 41 | void didRemove(Route route, Route previousRoute) { 42 | super.didRemove(route, previousRoute); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /lib/demo/routes/navigator_utils.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | class NavigatorUtils { 7 | ///关闭当前页面 8 | ///[context]当前页面的Context 9 | ///[parameters]回传上一个页面的参数 10 | static pop(BuildContext context, {parameters}) { 11 | if (Navigator.canPop(context)) { 12 | Navigator.of(context).pop(parameters); 13 | } else { 14 | ///最后一个页面不可pop 15 | } 16 | } 17 | 18 | ///[context]当前页面的Context 19 | ///[routeName]目标页面的路由名称 20 | ///[paramtes]向目标页面传的参数 21 | ///[callback]目标页面关闭时的回调函数 22 | static pushName(BuildContext context, String routeName, 23 | {paramtes, Function callback}) { 24 | Navigator.of(context) 25 | .pushNamed(routeName, arguments: paramtes) 26 | .then((value) { 27 | if (callback != null) { 28 | callback(value); 29 | } 30 | }); 31 | } 32 | 33 | ///动态路由方法封装 34 | ///[context]当前页面的Context 35 | ///[routeName]目标页面的路由名称 36 | ///[paramtes]向目标页面传的参数 37 | ///[callback]目标页面关闭时的回调函数 38 | static pushPage(BuildContext context, Widget page, 39 | {String routeName, paramtes, Function callback}) { 40 | PageRoute pageRoute; 41 | ///是导入io包 42 | if(Platform.isIOS){ 43 | ///ios平台使用支持滑动关闭页面的路由控制 44 | pageRoute =new CupertinoPageRoute(builder: (_) { 45 | return page; 46 | }, settings: RouteSettings(name: routeName, arguments: paramtes),); 47 | }else { 48 | ///Android等其他平台使用Material风格的路由控制 49 | pageRoute =new MaterialPageRoute(builder: (_) { 50 | return page; 51 | }, settings: RouteSettings(name: routeName, arguments: paramtes),); 52 | } 53 | ///压栈 54 | Navigator.of(context).push(pageRoute).then(( 55 | value) { 56 | ///目标页面关闭时回调函数与回传参数 57 | if (callback != null) { 58 | callback(value); 59 | } 60 | }); 61 | } 62 | 63 | 64 | static pushPageRelpact(BuildContext context, Widget page, 65 | {String routeName, paramtes, Function callback}) { 66 | PageRoute pageRoute; 67 | ///是导入io包 68 | if(Platform.isIOS){ 69 | ///ios平台使用支持滑动关闭页面的路由控制 70 | pageRoute =new CupertinoPageRoute(builder: (_) { 71 | return page; 72 | }, settings: RouteSettings(name: routeName, arguments: paramtes),); 73 | }else { 74 | ///Android等其他平台使用Material风格的路由控制 75 | pageRoute =new MaterialPageRoute(builder: (_) { 76 | return page; 77 | }, settings: RouteSettings(name: routeName, arguments: paramtes),); 78 | } 79 | ///压栈 80 | Navigator.of(context).pushReplacement(pageRoute).then(( 81 | value) { 82 | ///目标页面关闭时回调函数与回传参数 83 | if (callback != null) { 84 | callback(value); 85 | } 86 | }); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /lib/demo/routes/scend_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | class ScendPage extends StatefulWidget { 5 | @override 6 | State createState() { 7 | return ScendPageState(); 8 | } 9 | } 10 | 11 | class ScendPageState extends State { 12 | 13 | ///页面创建时执行的第一个方法 14 | @override 15 | void initState() { 16 | super.initState(); 17 | } 18 | ///页面创建执行的第二个方法 19 | ///页面 State、Context已绑定 20 | @override 21 | void didChangeDependencies() { 22 | super.didChangeDependencies(); 23 | ///获取路由信息 24 | RouteSettings routeSettings = ModalRoute.of(context).settings; 25 | if(routeSettings!=null){ 26 | ///获取传递的参数 27 | Map arguments = routeSettings.arguments; 28 | if(arguments!=null){ 29 | print("接收到参数 ${arguments["title"]}"); 30 | } 31 | } 32 | } 33 | @override 34 | Widget build(BuildContext context) { 35 | return Scaffold( 36 | appBar: AppBar( 37 | title: Text("第二个页面"), 38 | ), 39 | body: Center( 40 | child: FlatButton( 41 | child: Text("点击返回第一个页面"), 42 | onPressed: (){ 43 | ///这里是向上一个页面回传的数据 44 | Map resultMap = new Map(); 45 | resultMap["result"]="AESC"; 46 | Navigator.of(context).pop(resultMap); 47 | }, 48 | ), 49 | ), 50 | ); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /lib/demo/scaffold/book/scffold_data1.dart: -------------------------------------------------------------------------------- 1 | ///2.1 Scaffold的基本使用 内容主体页面 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | ///应用入口
 6 | main() => runApp(themDataFunction()); 7 | 8 | MaterialApp themDataFunction() { 9 | return MaterialApp(home: FirstPage(),); 10 | } 11 | 12 | 13 | class FirstPage extends StatefulWidget { 14 | @override 15 | State createState() { 16 | return FirstThemState(); 17 | } 18 | } 19 | class FirstThemState extends State { 20 | @override 21 | Widget build(BuildContext context) { 22 | ///Scaffold 用来搭建页面的主体结构 23 | return Scaffold( 24 | ///页面的主内容区 25 | ///可以是单独的StatefulWidget 也可以是当前页面构建的如Text文本组件 26 | body: Center(child: Text("启动页面"),),); 27 | } 28 | } -------------------------------------------------------------------------------- /lib/demo/scaffold/book/scffold_data10.dart: -------------------------------------------------------------------------------- 1 | 2 | ///3.3 bottomNavigationBar配制底部导航栏菜单 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | ///应用入口
 7 | main() => 8 | runApp(MaterialApp( 9 | home: FirstPage(),),); 10 | 11 | class FirstPage extends StatefulWidget { 12 | @override 13 | State createState() { 14 | return FirstThemState(); 15 | } 16 | } 17 | class FirstThemState extends State { 18 | @override 19 | Widget build(BuildContext context) { 20 | ///Scaffold 用来搭建页面的主体结构 21 | return Scaffold( 22 | ///页面的头部 23 | appBar: AppBar(title: Text("标题"),), 24 | ///页面的主内容区 25 | ///可以是单独的StatefulWidget 也可以是当前页面构建的如Text文本组件 26 | body: Center(child: Text("当前选中的页面是$_tabIndex"),), 27 | bottomNavigationBar: buildBottomNavigation(), 28 | ); 29 | } 30 | 31 | ///选中的标签 32 | int _tabIndex =0; 33 | ///图标区 34 | List normalIcon = [ 35 | Icon(Icons.home), 36 | Icon(Icons.message), 37 | Icon(Icons.people) 38 | ]; 39 | 40 | List normalTitle =[ 41 | "首页", 42 | "消息", 43 | "我的" 44 | ]; 45 | 46 | ///构建底部导航栏 47 | BottomNavigationBar buildBottomNavigation(){ 48 | 49 | return new BottomNavigationBar( 50 | items: [ 51 | new BottomNavigationBarItem( 52 | icon: normalIcon[0], title: Text(normalTitle[0])), 53 | new BottomNavigationBarItem( 54 | icon: normalIcon[1], title: Text(normalTitle[1])), 55 | new BottomNavigationBarItem( 56 | icon: normalIcon[2], title: Text(normalTitle[2])), 57 | ], 58 | ///显示效果 59 | type: BottomNavigationBarType.shifting, 60 | ///当前选中的页面 61 | currentIndex: _tabIndex, 62 | ///导航栏的背景颜色 63 | backgroundColor: Colors.white, 64 | ///选中时图标与文字的颜色 65 | // fixedColor: Colors.deepPurple, 66 | ///选中时图标与文字的颜色 67 | selectedItemColor: Colors.blue, 68 | ///未选中时图标与文字的颜色 69 | unselectedItemColor: Colors.grey, 70 | ///图标的大小 71 | iconSize: 24.0, 72 | ///点击事件 73 | onTap: (index) { 74 | setState(() { 75 | _tabIndex = index; 76 | }); 77 | }, 78 | ); 79 | } 80 | } 81 | 82 | 83 | -------------------------------------------------------------------------------- /lib/demo/scaffold/book/scffold_data11.dart: -------------------------------------------------------------------------------- 1 | 2 | ///3.3 bottomNavigationBar配制底部导航栏菜单 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:mdemo1/demo/scaffold/book/scffold_home_item1.dart'; 6 | 7 | ///应用入口
 8 | main() => 9 | runApp(MaterialApp( 10 | home: FirstPage(),),); 11 | 12 | class FirstPage extends StatefulWidget { 13 | @override 14 | State createState() { 15 | return FirstThemState(); 16 | } 17 | } 18 | class FirstThemState extends State { 19 | 20 | ///选中的标签 21 | int _tabIndex =0; 22 | ///图标区 23 | List normalIcon = [ 24 | Icon(Icons.home), 25 | Icon(Icons.message), 26 | Icon(Icons.people) 27 | ]; 28 | 29 | List normalTitle =[ 30 | "首页", 31 | "消息", 32 | "我的" 33 | ]; 34 | 35 | List bodyWidgetList=[ 36 | ScffoldHomeItemPage(0), 37 | ScffoldHomeItemPage1(1), 38 | ScffoldHomeItemPage2(2), 39 | ]; 40 | 41 | @override 42 | Widget build(BuildContext context) { 43 | ///Scaffold 用来搭建页面的主体结构 44 | return Scaffold( 45 | ///页面的头部 46 | appBar: AppBar(title: Text("标题"),), 47 | ///页面的主内容区 48 | ///可以是单独的StatefulWidget 也可以是当前页面构建的如Text文本组件 49 | body:bodyWidgetList[_tabIndex], 50 | ///底部导航栏 51 | bottomNavigationBar: buildBottomNavigation(), 52 | ); 53 | } 54 | 55 | 56 | ///构建底部导航栏 57 | BottomNavigationBar buildBottomNavigation(){ 58 | 59 | return new BottomNavigationBar( 60 | items: [ 61 | new BottomNavigationBarItem( 62 | icon: normalIcon[0], title: Text(normalTitle[0])), 63 | new BottomNavigationBarItem( 64 | icon: normalIcon[1], title: Text(normalTitle[1])), 65 | new BottomNavigationBarItem( 66 | icon: normalIcon[2], title: Text(normalTitle[2])), 67 | ], 68 | ///显示效果 69 | type: BottomNavigationBarType.fixed, 70 | ///当前选中的页面 71 | currentIndex: _tabIndex, 72 | ///导航栏的背景颜色 73 | backgroundColor: Colors.white, 74 | ///选中时图标与文字的颜色 75 | // fixedColor: Colors.deepPurple, 76 | ///选中时图标与文字的颜色 77 | selectedItemColor: Colors.blue, 78 | ///未选中时图标与文字的颜色 79 | unselectedItemColor: Colors.grey, 80 | ///图标的大小 81 | iconSize: 24.0, 82 | ///点击事件 83 | onTap: (index) { 84 | setState(() { 85 | _tabIndex = index; 86 | }); 87 | }, 88 | ); 89 | } 90 | } 91 | 92 | 93 | -------------------------------------------------------------------------------- /lib/demo/scaffold/book/scffold_data12.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:mdemo1/demo/scaffold/book/scffold_home_item1.dart'; 6 | 7 | ///应用入口
 8 | main() => 9 | runApp(MaterialApp( 10 | home: FirstPage(),),); 11 | 12 | class FirstPage extends StatefulWidget { 13 | @override 14 | State createState() { 15 | return FirstThemState(); 16 | } 17 | } 18 | class FirstThemState extends State { 19 | 20 | ///选中的标签 21 | int _tabIndex =0; 22 | ///图标区 23 | List normalIcon = [ 24 | Icon(Icons.home), 25 | Icon(Icons.message), 26 | Icon(Icons.people) 27 | ]; 28 | 29 | List normalTitle =[ 30 | "首页", 31 | "消息", 32 | "我的" 33 | ]; 34 | 35 | 36 | ///3.4.4 bottomNavigationBar页面保活解决方案 37 | @override 38 | Widget build(BuildContext context) { 39 | ///Scaffold 用来搭建页面的主体结构 40 | return Scaffold( 41 | ///页面的头部 42 | appBar: AppBar(title: Text("标题"),), 43 | ///页面的主内容区 44 | body:buildBodyFunction(), 45 | ///底部导航栏 46 | bottomNavigationBar: buildBottomNavigation(), 47 | ); 48 | } 49 | 50 | Widget buildBodyFunction(){ 51 | ///帧布局结合透明布局 52 | return Stack(children: [ 53 | Opacity(opacity: _tabIndex==0?1:0,child: ScffoldHomeItemPage(0),), 54 | Opacity(opacity: _tabIndex==1?1:0,child: ScffoldHomeItemPage(1),), 55 | Opacity(opacity: _tabIndex==2?1:0,child: ScffoldHomeItemPage(2),), 56 | ],); 57 | } 58 | 59 | ///构建底部导航栏 60 | BottomNavigationBar buildBottomNavigation(){ 61 | 62 | return new BottomNavigationBar( 63 | items: [ 64 | new BottomNavigationBarItem( 65 | icon: normalIcon[0], title: Text(normalTitle[0])), 66 | new BottomNavigationBarItem( 67 | icon: normalIcon[1], title: Text(normalTitle[1])), 68 | new BottomNavigationBarItem( 69 | icon: normalIcon[2], title: Text(normalTitle[2])), 70 | ], 71 | ///显示效果 72 | type: BottomNavigationBarType.fixed, 73 | ///当前选中的页面 74 | currentIndex: _tabIndex, 75 | ///导航栏的背景颜色 76 | backgroundColor: Colors.white, 77 | ///选中时图标与文字的颜色 78 | // fixedColor: Colors.deepPurple, 79 | ///选中时图标与文字的颜色 80 | selectedItemColor: Colors.blue, 81 | ///未选中时图标与文字的颜色 82 | unselectedItemColor: Colors.grey, 83 | ///图标的大小 84 | iconSize: 24.0, 85 | ///点击事件 86 | onTap: (index) { 87 | setState(() { 88 | _tabIndex = index; 89 | }); 90 | }, 91 | ); 92 | } 93 | } 94 | 95 | 96 | -------------------------------------------------------------------------------- /lib/demo/scaffold/book/scffold_data15.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:mdemo1/demo/scaffold/book/scffold_home_item1.dart'; 6 | 7 | ///应用入口
 8 | main() => 9 | runApp(MaterialApp( 10 | home: FirstPage(),),); 11 | 12 | class FirstPage extends StatefulWidget { 13 | @override 14 | State createState() { 15 | return FirstThemState(); 16 | } 17 | } 18 | class FirstThemState extends State { 19 | 20 | ///选中的标签 21 | int _tabIndex =0; 22 | ///图标区 23 | List normalIcon = [ 24 | Icon(Icons.home), 25 | Icon(Icons.message), 26 | Icon(Icons.people) 27 | ]; 28 | 29 | List normalTitle =[ 30 | "首页", 31 | "消息", 32 | "我的" 33 | ]; 34 | 35 | 36 | ///3.6 底部标签栏bottomSheet 37 | @override 38 | Widget build(BuildContext context) { 39 | ///Scaffold 用来搭建页面的主体结构 40 | return Scaffold( 41 | ///页面的头部 42 | appBar: AppBar(title: Text("标题"),), 43 | ///页面的主内容区 44 | body:buildBodyFunction(), 45 | 46 | ///固定的标签栏 47 | bottomSheet: Container( 48 | color: Colors.blue, height: 44, child: Row(children: [ 49 | Container(margin: EdgeInsets.only(left: 10, right: 2), 50 | color: Colors.white, 51 | child: Text("标签1"),), 52 | Container(margin: EdgeInsets.only(left: 10, right: 2), 53 | color: Colors.white, 54 | child: Text("标签1"),), 55 | Container(margin: EdgeInsets.only(left: 10, right: 2), 56 | color: Colors.white, 57 | child: Text("标签1"),), 58 | Container(margin: EdgeInsets.only(left: 10, right: 2), 59 | color: Colors.white, 60 | child: Text("标签1"),), 61 | 62 | ],),), 63 | ///底部导航栏 64 | bottomNavigationBar: buildBottomNavigation(), 65 | ); 66 | } 67 | 68 | Widget buildBodyFunction(){ 69 | ///帧布局结合透明布局 70 | return Stack(children: [ 71 | Opacity(opacity: _tabIndex==0?1:0,child: ScffoldHomeItemPage(0),), 72 | Opacity(opacity: _tabIndex==1?1:0,child: ScffoldHomeItemPage(1),), 73 | Opacity(opacity: _tabIndex==2?1:0,child: ScffoldHomeItemPage(2),), 74 | ],); 75 | } 76 | 77 | ///构建底部导航栏 78 | BottomNavigationBar buildBottomNavigation(){ 79 | 80 | return new BottomNavigationBar( 81 | items: [ 82 | new BottomNavigationBarItem( 83 | icon: normalIcon[0], title: Text(normalTitle[0])), 84 | new BottomNavigationBarItem( 85 | icon: normalIcon[1], title: Text(normalTitle[1])), 86 | new BottomNavigationBarItem( 87 | icon: normalIcon[2], title: Text(normalTitle[2])), 88 | ], 89 | ///显示效果 90 | type: BottomNavigationBarType.fixed, 91 | ///当前选中的页面 92 | currentIndex: _tabIndex, 93 | ///导航栏的背景颜色 94 | backgroundColor: Colors.white, 95 | ///选中时图标与文字的颜色 96 | // fixedColor: Colors.deepPurple, 97 | ///选中时图标与文字的颜色 98 | selectedItemColor: Colors.blue, 99 | ///未选中时图标与文字的颜色 100 | unselectedItemColor: Colors.grey, 101 | ///图标的大小 102 | iconSize: 24.0, 103 | ///点击事件 104 | onTap: (index) { 105 | setState(() { 106 | _tabIndex = index; 107 | }); 108 | }, 109 | ); 110 | } 111 | } 112 | 113 | 114 | -------------------------------------------------------------------------------- /lib/demo/scaffold/book/scffold_data2.dart: -------------------------------------------------------------------------------- 1 | ///2.1 Scaffold的基本使用 有APPBar的页面 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | ///应用入口
 6 | main() => runApp(themDataFunction()); 7 | 8 | MaterialApp themDataFunction() { 9 | return MaterialApp(home: FirstPage(),); 10 | } 11 | 12 | 13 | class FirstPage extends StatefulWidget { 14 | @override 15 | State createState() { 16 | return FirstThemState(); 17 | } 18 | } 19 | 20 | class FirstThemState extends State { 21 | @override 22 | Widget build(BuildContext context) { 23 | ///Scaffold 用来搭建页面的主体结构 24 | return Scaffold( 25 | ///页面的头部 26 | appBar: AppBar(title: Text("标题"),), 27 | ///页面的主内容区 28 | ///可以是单独的StatefulWidget 也可以是当前页面构建的如Text文本组件 29 | body: Center(child: Text("显示日期"),),); 30 | } 31 | } -------------------------------------------------------------------------------- /lib/demo/scaffold/book/scffold_data3.dart: -------------------------------------------------------------------------------- 1 | ///2.3 Scaffold 悬浮按钮 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | ///应用入口
 6 | main() => runApp(themDataFunction()); 7 | 8 | MaterialApp themDataFunction() { 9 | return MaterialApp(home: FirstPage(),); 10 | } 11 | 12 | class FirstPage extends StatefulWidget { 13 | @override 14 | State createState() { 15 | return FirstThemState(); 16 | } 17 | } 18 | class FirstThemState extends State { 19 | @override 20 | Widget build(BuildContext context) { 21 | ///Scaffold 用来搭建页面的主体结构 22 | return Scaffold( 23 | ///页面的头部 24 | appBar: AppBar(title: Text("标题"),), 25 | ///页面的主内容区 26 | ///可以是单独的StatefulWidget 也可以是当前页面构建的如Text文本组件 27 | body: Center(child: Text("显示日期"),), 28 | ///悬浮按钮 29 | floatingActionButton: buildFAB5(),); 30 | } 31 | 32 | ///3.2.1 FloatingActionButton的类型 regular类型 33 | ///通过new Object方式来创建悬浮按钮 为regular类型 34 | FloatingActionButton buildFAB1(){ 35 | return FloatingActionButton( 36 | ///一般建议使用Icon 37 | child: Icon(Icons.add), onPressed: () { 38 | print("点击了悬浮按钮"); 39 | },); 40 | } 41 | 42 | ///3.2.1 FloatingActionButton的类型 mini类型 43 | ///通过new Object方式来创建悬浮按钮 为mini类型 44 | FloatingActionButton buildFAB2() { 45 | return FloatingActionButton( 46 | ///一般建议使用Icon 47 | child: Icon(Icons.add), onPressed: () { 48 | print("点击了悬浮按钮"); 49 | }, 50 | ///默认是false 51 | mini: true,); 52 | } 53 | 54 | ///3.2.1 FloatingActionButton的类型 extended类型 55 | ///通过 FloatingActionButton.extended方式来创建悬浮按钮 56 | FloatingActionButton buildFAB3() { 57 | return FloatingActionButton.extended( 58 | ///通过icon来配制显示的图标 59 | icon: Icon(Icons.add), onPressed: () { 60 | print("点击了悬浮按钮"); 61 | }, 62 | ///通过labe来添加文本信息 63 | label: Text("添加信息"),); 64 | } 65 | 66 | ///3.2.2 FloatingActionButton的常用属性使用分析 67 | FloatingActionButton buildFAB4(){ 68 | return FloatingActionButton( 69 | child: Icon(Icons.add), onPressed: () { 70 | print("点击了悬浮按钮"); 71 | }, 72 | tooltip: "这里是FAB哈!", 73 | ); 74 | } 75 | 76 | ///3.2.2 FloatingActionButton的常用属性使用分析 颜色配置 77 | FloatingActionButton buildFAB5(){ 78 | return FloatingActionButton( 79 | child: Icon(Icons.add), 80 | ///点击事件响应 81 | onPressed: () {}, 82 | ///背景色为红色 83 | backgroundColor: Colors.red, 84 | ///点击水波纹颜色为黄色 85 | splashColor: Colors.yellow, 86 | ///前景色为紫色 87 | foregroundColor: Colors.deepPurple, 88 | ); 89 | } 90 | 91 | } 92 | 93 | 94 | -------------------------------------------------------------------------------- /lib/demo/scaffold/book/scffold_data4.dart: -------------------------------------------------------------------------------- 1 | ///2.3 Scaffold 悬浮按钮 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | ///应用入口
 6 | main() => runApp(themDataFunction()); 7 | 8 | MaterialApp themDataFunction() { 9 | ///3.2.2 FloatingActionButton的常用属性使用分析 MaterialApp中主题配制 10 | return MaterialApp( 11 | home: FirstPage(), 12 | ///主题配置 13 | theme: ThemeData( 14 | ///FAB悬浮按钮主题样式配置 15 | floatingActionButtonTheme: FloatingActionButtonThemeData( 16 | ///背景色为红色 17 | backgroundColor: Colors.red, 18 | ///点击水波纹颜色为黄色 19 | splashColor: Colors.yellow, 20 | ///前景色为紫色 21 | foregroundColor: Colors.deepPurple, 22 | ///默认显示下的阴影高度 23 | elevation: 6.0, 24 | ///点按下去时阴影的高度 25 | highlightElevation: 10.0, 26 | ///不可被点击时的阴影的高度 27 | disabledElevation: 1.0, 28 | ), 29 | ),); 30 | } 31 | 32 | class FirstPage extends StatefulWidget { 33 | @override 34 | State createState() { 35 | return FirstThemState(); 36 | } 37 | } 38 | class FirstThemState extends State { 39 | @override 40 | Widget build(BuildContext context) { 41 | ///Scaffold 用来搭建页面的主体结构 42 | return Scaffold( 43 | ///页面的头部 44 | appBar: AppBar(title: Text("标题"),), 45 | ///页面的主内容区 46 | ///可以是单独的StatefulWidget 也可以是当前页面构建的如Text文本组件 47 | body: Center(child: Text("显示日期"),), 48 | ///悬浮按钮 49 | floatingActionButton: buildFAB1(),); 50 | } 51 | 52 | ///3.2.1 FloatingActionButton的类型 regular类型 53 | ///通过new Object方式来创建悬浮按钮 为regular类型 54 | FloatingActionButton buildFAB1(){ 55 | return FloatingActionButton( 56 | child: Icon(Icons.add), onPressed: () {},); 57 | } 58 | } 59 | 60 | 61 | -------------------------------------------------------------------------------- /lib/demo/scaffold/book/scffold_data5.dart: -------------------------------------------------------------------------------- 1 | ///2.3 Scaffold 悬浮按钮 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | ///应用入口
 6 | main() => runApp(themDataFunction()); 7 | 8 | MaterialApp themDataFunction() { 9 | ///3.2.2 FloatingActionButton的常用属性使用分析 MaterialApp中主题配制 10 | return MaterialApp( 11 | home: FirstPage(), 12 | ///主题配置 13 | theme: ThemeData( 14 | ///FAB悬浮按钮主题样式配置 15 | floatingActionButtonTheme: FloatingActionButtonThemeData( 16 | ///背景色为红色 17 | backgroundColor: Colors.red, 18 | ///点击水波纹颜色为黄色 19 | splashColor: Colors.yellow, 20 | ///前景色为紫色 21 | foregroundColor: Colors.deepPurple, 22 | ///默认显示下的阴影高度 23 | elevation: 6.0, 24 | ///点按下去时阴影的高度 25 | highlightElevation: 10.0, 26 | ///不可被点击时的阴影的高度 27 | disabledElevation: 1.0, 28 | ///用来指定FAB的形状 29 | shape:RoundedRectangleBorder( 30 | /// borderRadius: BorderRadius.all(Radius.circular(4)) 31 | ), 32 | ), 33 | ),); 34 | } 35 | 36 | class FirstPage extends StatefulWidget { 37 | @override 38 | State createState() { 39 | return FirstThemState(); 40 | } 41 | } 42 | class FirstThemState extends State { 43 | @override 44 | Widget build(BuildContext context) { 45 | ///Scaffold 用来搭建页面的主体结构 46 | return Scaffold( 47 | ///页面的头部 48 | appBar: AppBar(title: Text("标题"),), 49 | ///页面的主内容区 50 | ///可以是单独的StatefulWidget 也可以是当前页面构建的如Text文本组件 51 | body: Center(child: Text("显示日期"),), 52 | ///悬浮按钮 53 | floatingActionButton: buildFAB1(),); 54 | } 55 | 56 | ///3.2.1 FloatingActionButton的类型 regular类型 57 | ///通过new Object方式来创建悬浮按钮 为regular类型 58 | FloatingActionButton buildFAB1(){ 59 | return FloatingActionButton( 60 | child: Icon(Icons.add), onPressed: () {},); 61 | } 62 | } 63 | 64 | 65 | -------------------------------------------------------------------------------- /lib/demo/scaffold/book/scffold_data6.dart: -------------------------------------------------------------------------------- 1 | ///2.3 Scaffold 悬浮按钮 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | ///应用入口
 6 | main() => runApp(themDataFunction()); 7 | 8 | MaterialApp themDataFunction() { 9 | ///3.2.3 FloatingActionButton的常用属性使用分析 shape属性分析 10 | return MaterialApp( 11 | home: FirstPage6(), 12 | 13 | ///主题配置 14 | theme: ThemeData( 15 | 16 | ///FAB悬浮按钮主题样式配置 17 | floatingActionButtonTheme: FloatingActionButtonThemeData( 18 | 19 | ///背景色为红色 20 | backgroundColor: Colors.red, 21 | 22 | ///点击水波纹颜色为黄色 23 | splashColor: Colors.yellow, 24 | 25 | ///前景色为紫色 26 | foregroundColor: Colors.deepPurple, 27 | 28 | ///默认显示下的阴影高度 29 | elevation: 6.0, 30 | 31 | ///点按下去时阴影的高度 32 | highlightElevation: 10.0, 33 | 34 | ///不可被点击时的阴影的高度 35 | disabledElevation: 1.0, 36 | 37 | ///用来指定FAB的形状 38 | shape: fabShapeBorder(), 39 | ), 40 | ),); 41 | } 42 | 43 | ///默认创建使用的shape 44 | ShapeBorder fabShapeBorder() { 45 | return CircleBorder(); 46 | } 47 | 48 | ///3.2.3 FAB的shape属性分析 默认创建使用的shape 49 | ShapeBorder fabShapeBorder1() { 50 | ///圆形 51 | return CircleBorder( 52 | 53 | ///配置边框 54 | side: BorderSide( 55 | 56 | ///边框颜色 57 | color: Colors.blue, 58 | 59 | ///边框的宽度 60 | width: 4.0, 61 | 62 | ///边框的新式 solid为实线,none为不显示边框 63 | style: BorderStyle.solid), 64 | ); 65 | } 66 | 67 | ///3.2.3 FAB的shape属性分析 使用圆角矩形shape 68 | ShapeBorder fabShapeBorder2() { 69 | ///圆形 70 | return RoundedRectangleBorder( 71 | 72 | ///设置四周的圆角 73 | borderRadius: BorderRadius.circular(10), 74 | ); 75 | } 76 | 77 | ///3.2.3 FAB的shape属性分析 使用圆角矩形shape 78 | ShapeBorder fabShapeBorder3() { 79 | ///圆形 80 | return RoundedRectangleBorder( 81 | 82 | ///设置左上角的圆角 83 | borderRadius: BorderRadius.only(topLeft: Radius.elliptical(10, 20)), 84 | ); 85 | } 86 | 87 | class FirstPage6 extends StatefulWidget { 88 | @override 89 | State createState() { 90 | return FirstThemState(); 91 | } 92 | } 93 | 94 | class FirstThemState extends State { 95 | @override 96 | Widget build(BuildContext context) { 97 | ///Scaffold 用来搭建页面的主体结构 98 | return Scaffold( 99 | 100 | ///页面的头部 101 | appBar: AppBar(title: Text("标题"),), 102 | 103 | ///页面的主内容区 104 | ///可以是单独的StatefulWidget 也可以是当前页面构建的如Text文本组件 105 | body: Center(child: Text("显示日期"),), 106 | 107 | ///悬浮按钮 108 | floatingActionButton: buildFAB(), 109 | floatingActionButtonLocation: FloatingActionButtonLocation.endTop, 110 | ); 111 | } 112 | 113 | ///3.2.1 FloatingActionButton的类型 regular类型 114 | ///通过new Object方式来创建悬浮按钮 为regular类型 115 | FloatingActionButton buildFAB() { 116 | return FloatingActionButton( 117 | mini: true, 118 | materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, 119 | child: Icon(Icons.add), onPressed: () {},); 120 | } 121 | } 122 | 123 | 124 | -------------------------------------------------------------------------------- /lib/demo/scaffold/book/scffold_data7.dart: -------------------------------------------------------------------------------- 1 | ///3.3 drawer配制侧拉页面 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | ///应用入口
 6 | main() => runApp(themDataFunction()); 7 | 8 | MaterialApp themDataFunction() { 9 | ///3.2.3 FloatingActionButton的常用属性使用分析 shape属性分析 10 | return MaterialApp( 11 | home: FirstPage6(),); 12 | } 13 | 14 | class FirstPage6 extends StatefulWidget { 15 | @override 16 | State createState() { 17 | return FirstThemState(); 18 | } 19 | } 20 | 21 | class FirstThemState extends State { 22 | @override 23 | Widget build(BuildContext context) { 24 | ///Scaffold 用来搭建页面的主体结构 25 | return Scaffold( 26 | 27 | ///左侧侧拉页面 28 | drawer: buildDrawer2(), 29 | 30 | ///右侧侧拉页面 31 | endDrawer: buildDrawer(), 32 | 33 | ///页面的头部 34 | appBar: AppBar(title: Text("标题"),), 35 | 36 | ///页面的主内容区 37 | ///可以是单独的StatefulWidget 也可以是当前页面构建的如Text文本组件 38 | body: Center(child: Text("显示日期"),), 39 | ); 40 | } 41 | 42 | ///3.3 drawer配制侧拉页面 UserAccountsDrawerHeader组件 43 | Container buildDrawer2() { 44 | ///Container可看做是一个容器,用来包裹一些Widget 45 | return Container( 46 | ///背景颜色 47 | color: Colors.white, 48 | width: 200, 49 | ///Column可以让子Widgt在垂直方向线性排列 50 | child: Column( 51 | children: [ 52 | UserAccountsDrawerHeader( 53 | ///显示的二级标题 54 | accountEmail: Text('928***994@qq.com'), 55 | ///显示的小标题 56 | accountName: Text('这里是Drawer'), 57 | ///小箭头点击响应 58 | onDetailsPressed: () {}, 59 | ///当前显示的背景图片 60 | currentAccountPicture: CircleAvatar( 61 | child: Icon(Icons.message), 62 | ), 63 | ), 64 | ], 65 | ), 66 | ); 67 | } 68 | 69 | ///封装方法 70 | Container buildDrawer() { 71 | ///Container可看做是一个容器,用来包裹一些Widget 72 | return Container( 73 | 74 | ///背景颜色 75 | color: Colors.white, 76 | width: 200, 77 | 78 | ///Column可以让子Widgt在垂直方向线性排列 79 | child: Column( 80 | children: [ 81 | Container(color: Colors.blue, height: 200, child: Text("这是一个Text"),), 82 | Container(color: Colors.red, height: 200, child: Text("这是一个Text2"),), 83 | ], 84 | ), 85 | ); 86 | } 87 | } 88 | 89 | 90 | -------------------------------------------------------------------------------- /lib/demo/scaffold/book/scffold_data8.dart: -------------------------------------------------------------------------------- 1 | ///3.3 drawer配制侧拉页面 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | ///应用入口
 6 | main() => runApp(themDataFunction()); 7 | 8 | MaterialApp themDataFunction() { 9 | ///3.2.3 FloatingActionButton的常用属性使用分析 shape属性分析 10 | return MaterialApp( 11 | home: FirstPage6(),); 12 | } 13 | 14 | class FirstPage6 extends StatefulWidget { 15 | @override 16 | State createState() { 17 | return FirstThemState(); 18 | } 19 | } 20 | 21 | class FirstThemState extends State { 22 | @override 23 | Widget build(BuildContext context) { 24 | ///Scaffold 用来搭建页面的主体结构 25 | return Scaffold( 26 | ///左侧侧拉页面 27 | drawer: buildDrawer(), 28 | ///右侧侧拉页面 29 | endDrawer: buildDrawer(), 30 | ///页面的头部 31 | appBar: AppBar(title: Text("标题"),), 32 | ///页面的主内容区 33 | ///可以是单独的StatefulWidget 也可以是当前页面构建的如Text文本组件 34 | body: Center(child: Text("显示日期"),), 35 | ); 36 | } 37 | 38 | ///3.3 drawer配制侧拉页面 自定义的DrawerHeader 39 | Container buildDrawer() { 40 | ///Container可看做是一个容器,用来包裹一些Widget 41 | return Container( 42 | ///背景颜色 43 | color: Colors.white, 44 | width: 200, 45 | ///Column可以让子Widgt在垂直方向线性排列 46 | child: Column( 47 | children: [ 48 | DrawerHeader( 49 | margin: EdgeInsets.zero, 50 | ///设置Header的上下左右内边距为0 51 | padding: EdgeInsets.zero, 52 | ///显示的具体的内容 53 | child: buildDrawerBody(), 54 | ///侧拉页面滑出的动画效果 先快后慢 55 | curve: Curves.fastOutSlowIn, 56 | ), 57 | ], 58 | ), 59 | ); 60 | } 61 | 62 | ///Stack为帧布局页面Widget可重合显示 63 | Stack buildDrawerBody() { 64 | return Stack( 65 | children: [ 66 | ///可以用来设置背景图片 67 | Container(color: Colors.grey,), 68 | ///Align用来对齐组件 69 | Align( 70 | ///底部左对齐 71 | alignment: FractionalOffset.bottomLeft, 72 | ///设置用户的显示信息 73 | child: Container( 74 | ///底部外边跑为12 75 | margin: EdgeInsets.only(bottom: 12), 76 | child: Row( 77 | children: [ 78 | SizedBox(width: 12,), 79 | ///圆形的头像 80 | CircleAvatar( 81 | child: Icon(Icons.message), 82 | ), 83 | SizedBox(width: 16,), 84 | Column( 85 | 86 | ///使用Column线性布局包裹子Widget大小 87 | mainAxisSize: MainAxisSize.min, 88 | children: [ 89 | Text("这里是用户的姓名了"), 90 | SizedBox(height: 8,), 91 | Text("这里是用户的简介了"), 92 | ], 93 | ), 94 | ], 95 | ),),) 96 | ], 97 | ); 98 | } 99 | } 100 | 101 | 102 | -------------------------------------------------------------------------------- /lib/demo/scaffold/book/scffold_data9.dart: -------------------------------------------------------------------------------- 1 | 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | ///应用入口
 6 | main() => runApp(themDataFunction()); 7 | 8 | MaterialApp themDataFunction() { 9 | return MaterialApp( 10 | home: FirstPage6(),); 11 | } 12 | 13 | class FirstPage6 extends StatefulWidget { 14 | @override 15 | State createState() { 16 | return FirstThemState(); 17 | } 18 | } 19 | 20 | ///3.3.3 按钮点击打开与关闭侧拉页面 修改默认配置到AppBar上的按钮 21 | ///3.3.3 按钮点击打开与关闭侧拉页面 配置Scaffold.of(context) 22 | class FirstThemState extends State { 23 | @override 24 | Widget build(BuildContext context) { 25 | ///Scaffold 用来搭建页面的主体结构 26 | return Scaffold( 27 | drawerEdgeDragWidth: 0, 28 | ///左侧侧拉页面 29 | drawer: buildDrawer(), 30 | ///右侧侧拉页面 31 | endDrawer: buildDrawer(), 32 | 33 | ///页面的头部 34 | appBar: AppBar(title: Text("标题"), 35 | 36 | leading: Builder(builder: (BuildContext context) { 37 | return InkWell(onTap: () { 38 | /// 打开左侧拉页面 39 | Scaffold.of(context).openDrawer(); 40 | }, child: Icon(Icons.add),); 41 | }),), 42 | 43 | ///页面的主内容区 44 | ///可以是单独的StatefulWidget 也可以是当前页面构建的如Text文本组件 45 | body: Center(child: Text("显示日期"),), 46 | ); 47 | } 48 | 49 | ///3.3 drawer配制侧拉页面 自定义的DrawerHeader 50 | Container buildDrawer() { 51 | ///Container可看做是一个容器,用来包裹一些Widget 52 | return Container( 53 | ///背景颜色 54 | color: Colors.white, 55 | width: 200, 56 | ///Column可以让子Widgt在垂直方向线性排列 57 | child: Column( 58 | children: [ 59 | DrawerHeader( 60 | margin: EdgeInsets.zero, 61 | ///设置Header的上下左右内边距为0 62 | padding: EdgeInsets.zero, 63 | ///显示的具体的内容 64 | child: buildDrawerBody(), 65 | ///侧拉页面滑出的动画效果 先快后慢 66 | curve: Curves.fastOutSlowIn, 67 | ), 68 | 69 | FlatButton(child: Text("关闭"),onPressed: (){ 70 | Navigator.of(context).pop(); 71 | },) 72 | ], 73 | ), 74 | ); 75 | } 76 | 77 | ///Stack为帧布局页面Widget可重合显示 78 | Stack buildDrawerBody() { 79 | return Stack( 80 | children: [ 81 | ///可以用来设置背景图片 82 | Container(color: Colors.grey,), 83 | ///Align用来对齐组件 84 | Align( 85 | ///底部左对齐 86 | alignment: FractionalOffset.bottomLeft, 87 | ///设置用户的显示信息 88 | child: Container( 89 | ///底部外边跑为12 90 | margin: EdgeInsets.only(bottom: 12), 91 | child: Row( 92 | children: [ 93 | SizedBox(width: 12,), 94 | ///圆形的头像 95 | CircleAvatar( 96 | child: Icon(Icons.message), 97 | ), 98 | SizedBox(width: 16,), 99 | Column( 100 | ///使用Column线性布局包裹子Widget大小 101 | mainAxisSize: MainAxisSize.min, 102 | children: [ 103 | Text("这里是用户的姓名了"), 104 | SizedBox(height: 8,), 105 | Text("这里是用户的简介了"), 106 | ], 107 | ), 108 | ], 109 | ),),) 110 | ], 111 | ); 112 | } 113 | } 114 | 115 | 116 | -------------------------------------------------------------------------------- /lib/demo/scaffold/book/scffold_home_item1.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | 7 | 8 | ///3.4.3bottomNavigationBar结合独立的StatefulWidget使用 首页面 9 | class ScffoldHomeItemPage extends StatefulWidget { 10 | ///页面标识 11 | int pageIndex; 12 | ///构造函数 13 | ScffoldHomeItemPage(this.pageIndex,{Key key}) : super(key: key); 14 | @override 15 | State createState() { 16 | return ScffoldHomeItemState(); 17 | } 18 | } 19 | class ScffoldHomeItemState extends State { 20 | 21 | ///页面创建时初始化函数 22 | @override 23 | void initState() { 24 | super.initState(); 25 | print("页面创建${widget.pageIndex}"); 26 | } 27 | 28 | @override 29 | Widget build(BuildContext context) { 30 | return Center(child: Text("当前页面标识为${widget.pageIndex}"), 31 | ); 32 | } 33 | 34 | ///页面销毁时回调函数 35 | @override 36 | void dispose() { 37 | super.dispose(); 38 | print("页面消失${widget.pageIndex}"); 39 | } 40 | } 41 | 42 | 43 | ///3.4.3bottomNavigationBar结合独立的StatefulWidget使用 44 | class ScffoldHomeItemPage1 extends StatefulWidget { 45 | ///页面标识 46 | int pageIndex; 47 | ///构造函数 48 | ScffoldHomeItemPage1(this.pageIndex,{Key key}) : super(key: key); 49 | @override 50 | State createState() { 51 | return ScffoldHomeItemState1(); 52 | } 53 | } 54 | class ScffoldHomeItemState1 extends State { 55 | 56 | ///页面创建时初始化函数 57 | @override 58 | void initState() { 59 | super.initState(); 60 | print("页面创建${widget.pageIndex}"); 61 | } 62 | 63 | @override 64 | Widget build(BuildContext context) { 65 | return Center(child: Text("当前页面标识为${widget.pageIndex}"), 66 | ); 67 | } 68 | 69 | ///页面销毁时回调函数 70 | @override 71 | void dispose() { 72 | super.dispose(); 73 | print("页面消失${widget.pageIndex}"); 74 | } 75 | } 76 | 77 | 78 | 79 | 80 | ///我的页面 81 | class ScffoldHomeItemPage2 extends StatefulWidget { 82 | ///页面标识 83 | int pageIndex; 84 | ///构造函数 85 | ScffoldHomeItemPage2(this.pageIndex,{Key key}) : super(key: key); 86 | @override 87 | State createState() { 88 | return ScffoldHomeItemState2(); 89 | } 90 | } 91 | class ScffoldHomeItemState2 extends State { 92 | ///页面创建时初始化函数 93 | @override 94 | void initState() { 95 | super.initState(); 96 | print("页面创建${widget.pageIndex}"); 97 | } 98 | 99 | @override 100 | Widget build(BuildContext context) { 101 | return Center(child: Text("当前页面标识为${widget.pageIndex}"), 102 | ); 103 | } 104 | 105 | ///页面销毁时回调函数 106 | @override 107 | void dispose() { 108 | super.dispose(); 109 | print("页面消失${widget.pageIndex}"); 110 | } 111 | } 112 | 113 | 114 | -------------------------------------------------------------------------------- /lib/demo/scaffold/emal_itme_page.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | import 'package:flutter/cupertino.dart'; 5 | import 'package:flutter/material.dart'; 6 | 7 | class EmalItemPage extends StatelessWidget{ 8 | @override 9 | Widget build(BuildContext context) { 10 | 11 | return Center(child: Text("emal page",style: TextStyle(color: Colors.red),),); 12 | } 13 | 14 | } -------------------------------------------------------------------------------- /lib/demo/scaffold/home_item_page.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | class HomeItemPage extends StatefulWidget{ 7 | @override 8 | State createState() { 9 | 10 | return HomeItemPageState(); 11 | } 12 | 13 | } 14 | 15 | class HomeItemPageState extends State{ 16 | @override 17 | Widget build(BuildContext context) { 18 | 19 | return Builder( 20 | builder: (BuildContext context) { 21 | return Center( 22 | child: Column( 23 | children: [ 24 | FlatButton( 25 | child: Text("打开左滑菜单"), 26 | onPressed: () { 27 | ///打开左滑菜单 28 | Scaffold.of(context).openDrawer(); 29 | }, 30 | ), 31 | FlatButton( 32 | child: Text("打开右滑菜单"), 33 | onPressed: () { 34 | ///打开右滑菜单 35 | Scaffold.of(context).openEndDrawer(); 36 | }, 37 | ), 38 | ], 39 | ), 40 | ); 41 | }, 42 | ); 43 | } 44 | 45 | } -------------------------------------------------------------------------------- /lib/demo/scaffold/main_scaffold.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:mdemo1/demo/scaffold/scffold_home_page.dart'; 6 | 7 | ///flutter应用程序中的入口函数 8 | void main()=>runApp(ScffoldApp()); 9 | ///应用的根布局 10 | class ScffoldApp extends StatelessWidget{ 11 | @override 12 | Widget build(BuildContext context) { 13 | ///构建Materia Desin 风格的应用程序 14 | return MaterialApp( 15 | ///Android应用程序中任务栏中显示应用的名称 16 | title: "demo.scaffold 配制", 17 | ///默认的首页面 18 | home: ScffoldHomePage(), 19 | ); 20 | } 21 | } 22 | 23 | 24 | -------------------------------------------------------------------------------- /lib/demo/scaffold/people_item_page.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | class PeopleItemPage extends StatelessWidget{ 7 | @override 8 | Widget build(BuildContext context) { 9 | // TODO: implement build 10 | return Center(child: Text("people page",style: TextStyle(color: Colors.blue),),); 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /lib/demo/scroll/customscroll_demo_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:cached_network_image/cached_network_image.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | class CustomScrollDemoPage extends StatefulWidget { 6 | @override 7 | State createState() { 8 | return ScrollHomePageState(); 9 | } 10 | } 11 | 12 | class ScrollHomePageState extends State with SingleTickerProviderStateMixin { 13 | String imageUrl = 14 | "http://file02.16sucai.com/d/file/2015/0408/779334da99e40adb587d0ba715eca102.jpg"; 15 | 16 | @override 17 | void initState() { 18 | // TODO: implement initState 19 | super.initState(); 20 | } 21 | 22 | @override 23 | Widget build(BuildContext context) { 24 | return Scaffold( 25 | 26 | ///SingleChildScrollView 27 | ///NestedScrollView 28 | ///CustomScrollView 29 | /// 处理滑动 30 | body: CustomScrollView( 31 | slivers: [ 32 | SliverAppBar( 33 | backgroundColor: Colors.pink, 34 | pinned: true, 35 | snap: false, 36 | floating: true, 37 | leading: Icon(Icons.home), 38 | actions: [Icon(Icons.menu)], 39 | title: Text("这里是标题"), 40 | expandedHeight: 180, 41 | flexibleSpace: FlexibleSpaceBar( 42 | background: Row( 43 | children: [ 44 | Expanded( 45 | child: Image.network( 46 | imageUrl, 47 | fit: BoxFit.cover, 48 | ), 49 | ) 50 | ], 51 | ), 52 | ), 53 | ), 54 | SliverList( 55 | delegate: 56 | SliverChildBuilderDelegate((BuildContext context, num index) { 57 | return Container( 58 | height: 44, 59 | margin: EdgeInsets.only(bottom: 10), 60 | child: Text("item- $index"), 61 | ); 62 | }, childCount: 100), 63 | ) 64 | ], 65 | )); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /lib/demo/scroll/customscroll_home_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:cached_network_image/cached_network_image.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | class CustomScrollHomePage extends StatefulWidget { 6 | @override 7 | State createState() { 8 | return ScrollHomePageState(); 9 | } 10 | } 11 | 12 | class ScrollHomePageState extends State with SingleTickerProviderStateMixin { 13 | List _list = new List(); 14 | List myColors = new List(); 15 | 16 | String imageUrl = 17 | "https://timgsa.baidu.com/timg?demo.image&quality=80&size=b9999_10000&sec=1578583093&di=0bf687d9589dc5c6c0778de9576ee077&imgtype=jpg&er=1&src=http%3A%2F%2Ffile.mumayi.com%2Fforum%2F201403%2F28%2F111010vhgc45hkh41f1mfd.jpg"; 18 | 19 | TabController tabController; 20 | 21 | @override 22 | void initState() { 23 | // TODO: implement initState 24 | super.initState(); 25 | tabController = new TabController(length: 3, vsync: this); 26 | _list.add("政府"); 27 | _list.add("部门11"); 28 | _list.add("部门22"); 29 | myColors.add(Colors.red); 30 | myColors.add(Colors.lightBlue); 31 | myColors.add(Colors.lightBlue); 32 | } 33 | 34 | @override 35 | Widget build(BuildContext context) { 36 | return Scaffold( 37 | appBar: new AppBar( 38 | title: Text(" 配制"), 39 | ), 40 | 41 | ///SingleChildScrollView 42 | ///NestedScrollView 43 | /// 处理滑动 44 | body: CustomScrollView( 45 | ///反弹效果 46 | physics: BouncingScrollPhysics(), 47 | slivers: [ 48 | SliverAppBar( 49 | title: Text("讲解组合滑动"), 50 | ), 51 | 52 | SliverPadding( 53 | padding: EdgeInsets.all(5), 54 | ), 55 | 56 | ///九宫格 57 | SliverGrid( 58 | gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( 59 | ///九宫格的列数 60 | crossAxisCount: 3, 61 | 62 | ///子Widget 宽与高的比值 63 | childAspectRatio: 2.0, 64 | 65 | ///主方向的 两个 子Widget 之间的间距 66 | mainAxisSpacing: 10, 67 | 68 | /// 次方向 子Widget 之间的间距 69 | crossAxisSpacing: 10, 70 | ), 71 | delegate: new SliverChildBuilderDelegate( 72 | (BuildContext context, num index) { 73 | return Container( 74 | color: Colors.blue, 75 | child: Text("grid $index"), 76 | ); 77 | }, childCount: 10), 78 | ), 79 | SliverPadding( 80 | padding: EdgeInsets.all(5), 81 | ), 82 | SliverFixedExtentList( 83 | itemExtent: 40, 84 | delegate: new SliverChildBuilderDelegate( 85 | (BuildContext context, num index) { 86 | return Container(color: Colors.red, child: Text("list $index"),margin: EdgeInsets.only(bottom: 10),); 87 | }, childCount: 40), 88 | ) 89 | ], 90 | ), 91 | ); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /lib/demo/scroll/main_scroll.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | import 'customscroll_demo_page.dart'; 7 | import 'customscroll_home_page.dart'; 8 | import 'netscroll_home_page.dart'; 9 | import 'scroll_home_page.dart'; 10 | 11 | ///flutter应用程序中的入口函数 12 | void main()=>runApp(SwitchMainApp()); 13 | ///应用的根布局 14 | class SwitchMainApp extends StatelessWidget{ 15 | @override 16 | Widget build(BuildContext context) { 17 | ///构建Materia Desin 风格的应用程序 18 | return MaterialApp( 19 | ///Android应用程序中任务栏中显示应用的名称 20 | title: " 配制", 21 | theme: ThemeData( 22 | accentColor: Colors.blue, 23 | ///默认是 Brightness.light 24 | brightness: Brightness.light, 25 | ), 26 | ///默认的首页面 27 | // home: ScrollHomePage(), 28 | // home: NetScrollHomePage(), 29 | // home: CustomScrollHomePage(), 30 | home: CustomScrollDemoPage(), 31 | ); 32 | 33 | 34 | 35 | 36 | } 37 | } 38 | 39 | 40 | -------------------------------------------------------------------------------- /lib/demo/scroll/netscroll_home_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:cached_network_image/cached_network_image.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | class NetScrollHomePage extends StatefulWidget { 6 | @override 7 | State createState() { 8 | return ScrollHomePageState(); 9 | } 10 | } 11 | 12 | class ScrollHomePageState extends State with SingleTickerProviderStateMixin { 13 | bool selecA = false; 14 | bool selecB = true; 15 | String imageUrl = 16 | "https://timgsa.baidu.com/timg?demo.image&quality=80&size=b9999_10000&sec=1578583093&di=0bf687d9589dc5c6c0778de9576ee077&imgtype=jpg&er=1&src=http%3A%2F%2Ffile.mumayi.com%2Fforum%2F201403%2F28%2F111010vhgc45hkh41f1mfd.jpg"; 17 | 18 | TabController tabController; 19 | 20 | @override 21 | void initState() { 22 | // TODO: implement initState 23 | super.initState(); 24 | tabController = new TabController(length: 3, vsync: this); 25 | } 26 | @override 27 | Widget build(BuildContext context) { 28 | return Scaffold( 29 | appBar: new AppBar( 30 | title: Text(" 配制"), 31 | ), 32 | 33 | /// 处理滑动 34 | body: NestedScrollView( 35 | headerSliverBuilder: (BuildContext context, bool b) { 36 | return [ 37 | SliverAppBar( 38 | ///标题 39 | // title: Text(" 配制"), 40 | // leading: Icon(Icons.home), 41 | // actions: [ 42 | // Icon(Icons.share), 43 | // ], 44 | 45 | ///true SliverAppBar 不会滑动 46 | pinned: true, 47 | ///是否随着滑动隐藏标题 48 | floating: true, 49 | ///SliverAppBar展开的高度 50 | expandedHeight: 160, 51 | flexibleSpace: FlexibleSpaceBar( 52 | // title: Text("FlexibleSpaceBar title"), 53 | centerTitle: true, 54 | background: Container( 55 | color: Colors.blue[300], 56 | child: Column( 57 | mainAxisSize: MainAxisSize.min, 58 | children: [ 59 | Container(height: 120,child: Image.network(imageUrl,fit: BoxFit.fill,height: 160,width: 400,),), 60 | ], 61 | ), 62 | ), 63 | ), 64 | bottom: TabBar( 65 | controller: tabController, 66 | tabs: [ 67 | new Tab(text: "标签一",), 68 | new Tab(text: "标签二",), 69 | new Tab(text: "标签三",), 70 | ], 71 | ), 72 | ), 73 | ]; 74 | }, 75 | 76 | ///主体部分 77 | body: TabBarView(controller:tabController,children: [ 78 | 79 | SingleChildScrollView(child: Container(alignment: Alignment.bottomLeft,child: Text("这是第一个页面"),height: 1000,),), 80 | Text("这是第二个页面",style: TextStyle(color: Colors.blue),), 81 | Text("这是第三个页面",style: TextStyle(color: Colors.red),), 82 | ],), 83 | ), 84 | ); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /lib/demo/scroll/scroll_home_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:cached_network_image/cached_network_image.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | class ScrollHomePage extends StatefulWidget { 6 | @override 7 | State createState() { 8 | return ScrollHomePageState(); 9 | } 10 | } 11 | 12 | class ScrollHomePageState extends State { 13 | bool selecA = false; 14 | bool selecB = true; 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | return Scaffold( 19 | appBar: new AppBar( 20 | title: Text(" 配制"), 21 | ), 22 | 23 | ///SingleChildScrollView 处理滑动视图,允许有一个子widget 在超出视图的情况滑动 24 | body: SingleChildScrollView( 25 | ///设置 SingleChildScrollView 滑动方向 竖直方向 Axis.vertical 26 | scrollDirection:Axis.horizontal , 27 | ///是否滑动到底部 true 滑动到底部 28 | reverse: false, 29 | ///设置内边距 30 | padding: EdgeInsets.all(20), 31 | ///设置滑动反弹效果 BouncingScrollPhysics 32 | /// 无滑动反弹效果 ClampingScrollPhysics 33 | /// SingleChildScrollView 不可滑动 NeverScrollableScrollPhysics 34 | physics:NeverScrollableScrollPhysics() , 35 | child: Container( 36 | width: 800, 37 | height: 800, 38 | color: Colors.grey, 39 | child: Text("这里是 SingleChildScrollView"), 40 | ), 41 | ), 42 | ); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /lib/demo/splash/splash_main_page.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'dart:async'; 5 | import 'package:flutter_guidance_plugin/flutter_guidance_plugin.dart'; 6 | import 'package:flutter/services.dart'; 7 | 8 | void main() => runApp(MaterialApp(home: MyApp(),)); 9 | 10 | class MyApp extends StatefulWidget { 11 | @override 12 | _MyAppState createState() => _MyAppState(); 13 | } 14 | 15 | class _MyAppState extends State { 16 | _randomBit(int len) { 17 | String scopeF = "123456789"; //首位 18 | String scopeC = "0123456789"; //中间 19 | String result = ""; 20 | for (int i = 0; i < len; i++) { 21 | if (i == 1) { 22 | result = scopeF[Random().nextInt(scopeF.length)]; 23 | } else { 24 | result = result + scopeC[Random().nextInt(scopeC.length)]; 25 | } 26 | } 27 | return result; 28 | } 29 | 30 | String result = ""; 31 | 32 | @override 33 | void initState() { 34 | // TODO: implement initState 35 | super.initState(); 36 | 37 | Future.delayed(Duration(milliseconds: 5),(){ 38 | show1(); 39 | }); 40 | } 41 | 42 | @override 43 | Widget build(BuildContext context) { 44 | return Scaffold( 45 | appBar: AppBar( 46 | title: Text("新手引导蒙版"), 47 | ), 48 | body: Row( 49 | children: [ 50 | Expanded( 51 | child: Column( 52 | mainAxisAlignment: MainAxisAlignment.start, 53 | crossAxisAlignment: CrossAxisAlignment.center, 54 | children: [ 55 | FlatButton( 56 | child: Text("再次显示 引导蒙版"), 57 | onPressed: () { 58 | show1(); 59 | }, 60 | ), 61 | FlatButton( 62 | child: Text("显示 可滑动的引导蒙版"), 63 | onPressed: () { 64 | show2(); 65 | }, 66 | ), 67 | ], 68 | ), 69 | ) 70 | ], 71 | ), 72 | ); 73 | } 74 | 75 | void show1() { 76 | List curvePointList = []; 77 | 78 | for (int i = 0; i < 23; i++) { 79 | CurvePoint curvePoint = CurvePoint(0, 0); 80 | curvePoint.x = double.parse("0.${_randomBit(3)}"); 81 | curvePoint.y = double.parse("0.${_randomBit(3)}"); 82 | curvePoint.tipsMessage = "这是引导消息内容$i"; 83 | curvePointList.add(curvePoint); 84 | } 85 | showBeginnerGuidance(context, curvePointList: curvePointList,logs: true); 86 | } 87 | 88 | void show2() { 89 | List curvePointList = []; 90 | 91 | for (int i = 0; i < 10; i++) { 92 | CurvePoint curvePoint = CurvePoint(0, 0); 93 | curvePoint.x = double.parse("0.${_randomBit(3)}"); 94 | curvePoint.y = double.parse("0.${_randomBit(3)}"); 95 | curvePoint.tipsMessage = "这是引导消息内容$i"; 96 | curvePointList.add(curvePoint); 97 | } 98 | showBeginnerGuidance(context, curvePointList: curvePointList,isSlide: true); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /lib/demo/switch/main_switch.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | import 'switch_home_page.dart'; 7 | 8 | ///flutter应用程序中的入口函数 9 | void main()=>runApp(SwitchMainApp()); 10 | ///应用的根布局 11 | class SwitchMainApp extends StatelessWidget{ 12 | @override 13 | Widget build(BuildContext context) { 14 | ///构建Materia Desin 风格的应用程序 15 | return MaterialApp( 16 | ///Android应用程序中任务栏中显示应用的名称 17 | title: " 配制", 18 | theme: ThemeData( 19 | accentColor: Colors.blue, 20 | ///默认是 Brightness.light 21 | brightness: Brightness.light, 22 | ), 23 | ///默认的首页面 24 | home: SwitchHomePage(), 25 | // home: ImageLocalHomePage(), 26 | ); 27 | 28 | 29 | 30 | } 31 | } 32 | 33 | 34 | -------------------------------------------------------------------------------- /lib/demo/switch/switch_home_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:cached_network_image/cached_network_image.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | class SwitchHomePage extends StatefulWidget { 6 | @override 7 | State createState() { 8 | return SwitchHomePageState(); 9 | } 10 | } 11 | 12 | class SwitchHomePageState extends State { 13 | bool selecA = false; 14 | bool selecB = true; 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | return Scaffold( 19 | appBar: new AppBar( 20 | title: Text(" 配制"), 21 | ), 22 | 23 | ///线性布局 24 | body: Column( 25 | children: [ 26 | 27 | ///开关 28 | SizedBox(width: 75,child: Switch( 29 | ///开关开启时圆点的颜色 30 | activeColor: Colors.blue, 31 | ///开关开启时开关底座的颜色 32 | activeTrackColor: Colors.yellow, 33 | /// 开关开启时圆点的背景图片 34 | activeThumbImage: AssetImage("images/2.0/no_select_icon.png"), 35 | ///开关关闭状态时的 圆点的颜色 36 | inactiveThumbColor: Colors.deepPurple, 37 | ///开关关闭状态时 底座的颜色 38 | inactiveTrackColor: Colors.green, 39 | ///开关关闭状态时 圆点的背景 40 | inactiveThumbImage: AssetImage("images/2.0/select_icon.png"), 41 | ///当前开关的状态 42 | value: selecA, 43 | materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, 44 | ///当开关的状态发生改变时会调用 45 | onChanged: (value){ 46 | 47 | setState(() { 48 | selecA = value; 49 | }); 50 | 51 | },),), 52 | 53 | SwitchListTile( 54 | value: selecB, 55 | onChanged: (vlaue){ 56 | setState(() { 57 | selecB=vlaue; 58 | }); 59 | }, 60 | title: Text("这是一级标题了"), 61 | subtitle: Text("这是二级标题了"), 62 | secondary: Image.asset("images/2.0/logo.jpg",width: 55,), 63 | ), 64 | Slider( 65 | value: 1, 66 | onChanged: (vlaue){ 67 | setState(() { 68 | 69 | }); 70 | }, 71 | ) 72 | ], 73 | ), 74 | ); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /lib/demo/text/main_text.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:mdemo1/demo/text/text_rich_hom_page.dart'; 6 | 7 | ///flutter应用程序中的入口函数 8 | void main()=>runApp(TextMainApp()); 9 | ///应用的根布局 10 | class TextMainApp extends StatelessWidget{ 11 | @override 12 | Widget build(BuildContext context) { 13 | ///构建Materia Desin 风格的应用程序 14 | return MaterialApp( 15 | ///Android应用程序中任务栏中显示应用的名称 16 | title: "Text 配制", 17 | ///默认的首页面 18 | // home: TextHomePage(), 19 | home: TextRichHomePage(), 20 | ); 21 | } 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /lib/demo/text/text_rich_hom_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/gestures.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | class TextRichHomePage extends StatefulWidget { 6 | @override 7 | State createState() { 8 | return TextRichHomePagePageState(); 9 | } 10 | } 11 | 12 | class TextRichHomePagePageState extends State { 13 | @override 14 | Widget build(BuildContext context) { 15 | return Scaffold( 16 | appBar: AppBar( 17 | title: Text("Text Rich 讲解"), 18 | ), 19 | body: Center( 20 | ///SizedBox 用来限制一个固定 width height 的空间 21 | child: SizedBox( 22 | width: 200, 23 | height: 200, 24 | child: Container( 25 | color: Colors.yellow, 26 | 27 | ///Alignment 用来对齐 Widget 28 | alignment: Alignment(0, 0), 29 | child: Text.rich(TextSpan( 30 | text: "这里是 TextSpan", 31 | style: TextStyle(color: Colors.deepPurple), 32 | children: [ 33 | TextSpan( 34 | text: "这是第二个", style: TextStyle(color: Colors.lightBlue)), 35 | TextSpan( 36 | /// TextSpan 的文本内容 37 | text: "这是第三个", 38 | ///设置 TextSpan 的文本样式 39 | style: TextStyle(color: Colors.green), 40 | ///设置TextSpan的点击事件 41 | recognizer: TapGestureRecognizer()..onTap = () { 42 | print("点击了第三个"); 43 | }), 44 | TextSpan(text: "这是第四个", style: TextStyle(color: Colors.white)), 45 | ], 46 | )), 47 | ), 48 | ), 49 | ), 50 | ); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /lib/demo/text_deom.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | import 'package:flutter/cupertino.dart'; 6 | import 'package:flutter/material.dart'; 7 | import 'package:mdemo1/demo/text_deom2.dart'; 8 | 9 | 10 | main()=>runApp(MaterialApp(home: TestDemo(),)); 11 | 12 | class TestDemo extends StatefulWidget { 13 | @override 14 | State createState() { 15 | return _TestDemoState(); 16 | } 17 | 18 | } 19 | 20 | 21 | class _TestDemoState extends State { 22 | 23 | 24 | Function(int index,String message) callback; 25 | 26 | @override 27 | void initState() { 28 | super.initState(); 29 | 30 | callback =(int index,String message ){ 31 | print("$index ${message}"); 32 | }; 33 | 34 | callback = initCallbackFunction; 35 | } 36 | 37 | 38 | initCallbackFunction(int index,String message ){ 39 | 40 | print("$index ${message}"); 41 | } 42 | 43 | @override 44 | Widget build(BuildContext context) { 45 | 46 | return Scaffold( 47 | appBar: AppBar(), 48 | body: FlatButton(child: Text("测试"),onPressed:(){ 49 | Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) { 50 | return TestDemo2(callback); 51 | })); 52 | },), 53 | ); 54 | } 55 | 56 | } -------------------------------------------------------------------------------- /lib/demo/text_deom2.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | import 'package:flutter/cupertino.dart'; 6 | import 'package:flutter/material.dart'; 7 | 8 | class TestDemo2 extends StatefulWidget { 9 | 10 | Function(int index, String message) callback; 11 | 12 | 13 | TestDemo2(this.callback); 14 | 15 | @override 16 | State createState() { 17 | return _TestDemoState(); 18 | } 19 | 20 | } 21 | 22 | 23 | class _TestDemoState extends State { 24 | 25 | @override 26 | void initState() { 27 | super.initState(); 28 | 29 | } 30 | 31 | 32 | 33 | @override 34 | Widget build(BuildContext context) { 35 | return Scaffold( 36 | appBar: AppBar(), 37 | body: FlatButton(child: Text("回调"),onPressed: (){ 38 | widget.callback(1,"这是测试数据"); 39 | },), 40 | ); 41 | } 42 | 43 | 44 | void test () async{ 45 | test2(); 46 | test2(); 47 | } 48 | void test2() async{ 49 | 50 | } 51 | } -------------------------------------------------------------------------------- /lib/demo/textfeild/main_textfield.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:mdemo1/demo/textfeild/textfield_hom_page7.dart'; 6 | 7 | ///flutter应用程序中的入口函数 8 | void main()=>runApp(TextFieldMainApp()); 9 | ///应用的根布局 10 | class TextFieldMainApp extends StatelessWidget{ 11 | @override 12 | Widget build(BuildContext context) { 13 | ///构建Materia Desin 风格的应用程序 14 | return MaterialApp( 15 | ///Android应用程序中任务栏中显示应用的名称 16 | title: "Text 配制", 17 | ///默认的首页面 18 | // home: TextFeildHomePage(), 19 | // home: TextFeildHomePage2(), 20 | ///TextField 焦点获取控制篇 21 | // home: TextFeildHomePage3(), 22 | // home: TextFeildHomePage4(), 23 | ///TextField 输入文本 decoration 配置边框样式以及提示文本分析篇 24 | // home: TextFeildHomePage5(), 25 | ///TextField TextEditingController 分析篇 26 | // home: TextFeildHomePage6(), 27 | home: TextFeildHomePage7(), 28 | ); 29 | 30 | } 31 | } 32 | 33 | 34 | -------------------------------------------------------------------------------- /lib/demo/textfeild/textfield_hom_page3.dart: -------------------------------------------------------------------------------- 1 | 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | ///整理 6 | ///TextField 焦点获取控制篇 7 | class TextFeildHomePage3 extends StatefulWidget { 8 | @override 9 | State createState() { 10 | return TextFeildHomePageState(); 11 | } 12 | } 13 | 14 | class TextFeildHomePageState extends State { 15 | 16 | ///用来控制 TextField 焦点的获取与关闭 17 | FocusNode focusNode = new FocusNode(); 18 | 19 | @override 20 | void initState() { 21 | super.initState(); 22 | 23 | ///添加获取焦点与失去焦点的兼听 24 | focusNode.addListener((){ 25 | ///当前兼听的 TextFeild 是否获取了输入焦点 26 | bool hasFocus = focusNode.hasFocus; 27 | ///当前 focusNode 是否添加了兼听 28 | bool hasListeners = focusNode.hasListeners; 29 | 30 | print("focusNode 兼听 hasFocus:$hasFocus hasListeners:$hasListeners"); 31 | }); 32 | 33 | /// WidgetsBinding 它能监听到第一帧绘制完成,第一帧绘制完成标志着已经Build完成 34 | WidgetsBinding.instance.addPostFrameCallback((_) { 35 | ///获取输入框焦点 36 | FocusScope.of(context).requestFocus(focusNode); 37 | }); 38 | } 39 | 40 | @override 41 | Widget build(BuildContext context) { 42 | return Scaffold( 43 | appBar: AppBar( 44 | title: Text("TextField 讲解"), 45 | actions: [ 46 | FlatButton(child: Text("获取"),onPressed: (){ 47 | FocusScope.of(context).requestFocus(focusNode); 48 | },), 49 | FlatButton(child: Text("失去"),onPressed: (){ 50 | focusNode.unfocus(); 51 | },), 52 | ], 53 | ), 54 | body: Container( 55 | ///SizedBox 用来限制一个固定 width height 的空间 56 | child: SizedBox( 57 | width: 400, 58 | height: 100, 59 | child: Container( 60 | color: Colors.white24, 61 | padding: EdgeInsets.all(10), 62 | ///Alignment 用来对齐 Widget 63 | alignment: Alignment(0, 0), 64 | ///文本输入框 65 | child: TextField( 66 | // autofocus: true, 67 | focusNode: focusNode, 68 | ), 69 | ), 70 | ), 71 | ), 72 | ); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /lib/demo/textfeild/textfield_hom_page4.dart: -------------------------------------------------------------------------------- 1 | 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | ///整理 6 | ///TextField 输入文本 textAlign 7 | class TextFeildHomePage4 extends StatefulWidget { 8 | @override 9 | State createState() { 10 | return TextFeildHomePageState(); 11 | } 12 | } 13 | 14 | class TextFeildHomePageState extends State { 15 | 16 | 17 | @override 18 | void initState() { 19 | super.initState(); 20 | 21 | } 22 | 23 | @override 24 | Widget build(BuildContext context) { 25 | return Scaffold( 26 | appBar: AppBar( 27 | title: Text("TextField 讲解"), 28 | ), 29 | body: Container( 30 | ///SizedBox 用来限制一个固定 width height 的空间 31 | child: SizedBox( 32 | width: 400, 33 | height: 100, 34 | child: Container( 35 | color: Colors.white24, 36 | padding: EdgeInsets.all(10), 37 | ///Alignment 用来对齐 Widget 38 | alignment: Alignment(0, 0), 39 | ///文本输入框 40 | child: TextField( 41 | ///输入框内输入文本 居中对齐 42 | ///设置文本的对齐方式 43 | // TextAlign.center 居中 44 | // TextAlign.left 靠左对齐 TextField默认使用 45 | // TextAlign.right 靠右对齐 46 | // TextAlign.justify 拉伸以结束的文本行以填充容器的宽度。即使用了decorationStyle才起效 47 | // TextAlign.start 针对 文字方向来使用 textDirection 48 | // TextDirection.ltr TextAlign.start 左对齐 49 | // TextDirection.rtl TextAlign.start 右对齐 50 | // TextAlign.end 51 | // TextDirection.ltr TextAlign.end 右对齐 52 | // TextDirection.rtl TextAlign.end 左对齐 53 | textAlign: TextAlign.start, 54 | /// 用来设置文字的绘制方向的 55 | /// TextDirection.ltr left to right 文字从左向右 56 | /// TextDirection.rtl right to left 文字从右向左 57 | textDirection: TextDirection.rtl, 58 | ), 59 | ), 60 | ), 61 | ), 62 | ); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /lib/demo/textfeild/textfield_hom_page6.dart: -------------------------------------------------------------------------------- 1 | 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | ///整理 6 | ///TextField TextEditingController 分析篇 7 | class TextFeildHomePage6 extends StatefulWidget { 8 | @override 9 | State createState() { 10 | return TextFeildHomePageState(); 11 | } 12 | } 13 | 14 | class TextFeildHomePageState extends State { 15 | 16 | ///用于文本输入框 17 | TextEditingController controller = new TextEditingController(); 18 | ///用来控制 TextField 焦点的获取与关闭 19 | FocusNode focusNode = new FocusNode(); 20 | 21 | @override 22 | void initState() { 23 | super.initState(); 24 | ///预设输入框的内容 25 | String preText = ""; 26 | 27 | ///控制 初始化的时候鼠标保持在文字最后 28 | controller = TextEditingController.fromValue( 29 | ///用来设置初始化时显示 30 | TextEditingValue( 31 | ///用来设置文本 controller.demo.text = "0000" 32 | text: preText, 33 | ///设置光标的位置 34 | selection: TextSelection.fromPosition( 35 | ///用来设置文本的位置 36 | TextPosition( 37 | affinity: TextAffinity.downstream, 38 | /// 光标向后移动的长度 39 | offset: preText.length),),), 40 | ); 41 | 42 | /// 添加兼听 当TextFeild 中内容发生变化时 回调 焦点变动 也会触发 43 | /// onChanged 当TextFeild文本发生改变时才会回调 44 | controller.addListener((){ 45 | ///获取输入的内容 46 | String currentStr = controller.text; 47 | print(" controller 兼听 $currentStr"); 48 | }); 49 | 50 | } 51 | 52 | @override 53 | Widget build(BuildContext context) { 54 | return Scaffold( 55 | appBar: AppBar( 56 | title: Text("TextField 讲解"), 57 | actions: [ 58 | FlatButton(child: Text("保存",style: TextStyle(color: Colors.white),),onPressed: (){ 59 | ///获取文本输入框的内容 60 | String inputText = controller.text; 61 | print("点击了保存 $inputText"); 62 | },) 63 | ], 64 | ), 65 | body: Center( 66 | ///SizedBox 用来限制一个固定 width height 的空间 67 | child: SizedBox( 68 | width: 400, 69 | height: 110, 70 | child: Container( 71 | color: Colors.white24, 72 | padding:EdgeInsets.all(10) , 73 | ///Alignment 用来对齐 Widget 74 | alignment: Alignment(0,0), 75 | ///文本输入框 76 | child: TextField( 77 | controller: controller, 78 | ///当TextField中输入的内容发生改变时回调 79 | onChanged: (value){ 80 | print("TextField 中输入的内容 $value"); 81 | }, 82 | ), 83 | ), 84 | ), 85 | ), 86 | ); 87 | } 88 | } -------------------------------------------------------------------------------- /lib/demo/textfeild/textfield_hom_page7.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | ///整理 5 | ///TextField texeStyle 输入文本样式 分析篇 6 | class TextFeildHomePage7 extends StatefulWidget { 7 | @override 8 | State createState() { 9 | return TextFeildHomePageState(); 10 | } 11 | } 12 | 13 | class TextFeildHomePageState extends State { 14 | @override 15 | void initState() { 16 | super.initState(); 17 | } 18 | 19 | @override 20 | Widget build(BuildContext context) { 21 | 22 | 23 | TextStyle commonStyle = buildCommonStyle(); 24 | 25 | 26 | return Scaffold( 27 | appBar: AppBar( 28 | title: Text("TextField 讲解"), 29 | ), 30 | body: Center( 31 | ///SizedBox 用来限制一个固定 width height 的空间 32 | child:Column(children: [ 33 | SizedBox( 34 | width: 400, 35 | height: 110, 36 | child: Container( 37 | color: Colors.white24, 38 | padding: EdgeInsets.all(10), 39 | ///Alignment 用来对齐 Widget 40 | alignment: Alignment(0, 0), 41 | ///文本输入框 42 | child: TextField( 43 | ///设置输入文本的样式 44 | style: commonStyle, 45 | ), 46 | ), 47 | ), 48 | Container(margin: EdgeInsets.only(top: 20,),width: 100, 49 | child: Text("这是显示文本组件Text page haha", style: commonStyle,),) 50 | ],), 51 | ), 52 | ); 53 | } 54 | 55 | TextStyle buildCommonStyle() { 56 | return TextStyle( 57 | textBaseline: TextBaseline.alphabetic, 58 | ///设置文字的颜色 59 | color: Colors.deepPurple, 60 | ///设置文字的大小 61 | fontSize: 32.0, 62 | ///用设置 Text 的线 63 | /// TextDecoration.none 没有 64 | /// TextDecoration.underline 下划线 65 | /// TextDecoration.overline 上划线 66 | /// TextDecoration.lineThrough 删除线 67 | decoration: TextDecoration.none, 68 | /// 设置下划线的颜色 69 | decorationColor: Colors.green, 70 | /// 设置下划线的样式 71 | /// TextDecorationStyle.dashed 设置为虚线 72 | /// TextDecorationStyle.solid 设置为实线 73 | /// TextDecorationStyle.double 两条实线 74 | /// TextDecorationStyle.wavy 波浪线 75 | decorationStyle: TextDecorationStyle.wavy, 76 | ///设置文字为粗体 77 | /// FontWeight.bold 粗体 78 | fontWeight: FontWeight.w600, 79 | ///设置 斜体 80 | fontStyle: FontStyle.normal, 81 | ///用来设置 单字之间的距离 82 | letterSpacing: 1.0, 83 | ///用来设置 单词之间的距离 84 | wordSpacing: 2.0, 85 | ///控制行高 倍数(默认行高的倍数)乘以fontSize做为行高 86 | height: 1.2, 87 | ///文本的背景颜色 88 | backgroundColor: Colors.grey, 89 | ///Decoration背景设定 90 | // shadows: 91 | ); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /lib/demo/theme/color_filtered.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | main() => runApp(themDataFunction()); 5 | 6 | MaterialApp themDataFunction() { 7 | return MaterialApp( 8 | theme: ThemeData(), 9 | themeMode: ThemeMode.light, 10 | darkTheme: ThemeData(), 11 | home: Scaffold( 12 | body: Center( 13 | child: Text("灰色"), 14 | ), 15 | ), 16 | ); 17 | } 18 | -------------------------------------------------------------------------------- /lib/demo/theme/first_them_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:mdemo1/demo/routes/scend_page.dart'; 4 | 5 | class FirstThemPage extends StatefulWidget { 6 | @override 7 | State createState() { 8 | return FirstPageState(); 9 | } 10 | } 11 | 12 | class FirstPageState extends State with SingleTickerProviderStateMixin { 13 | 14 | TabController tabController; 15 | @override 16 | void initState() { 17 | super.initState(); 18 | tabController= new TabController(length: 3, vsync: this); 19 | } 20 | @override 21 | Widget build(BuildContext context) { 22 | return Scaffold( 23 | appBar: AppBar( 24 | leading: IconButton( 25 | icon: Icon(Icons.menu), 26 | tooltip: 'tootips', 27 | onPressed: () => debugPrint('Navigreation button is pressed'), 28 | ), 29 | title: Text('导航'), 30 | actions: [ 31 | IconButton( 32 | icon: Icon(Icons.search), 33 | tooltip: '搜索', 34 | onPressed: () => debugPrint('Search button is pressed'), 35 | ), 36 | IconButton( 37 | icon: Icon(Icons.more_horiz), 38 | tooltip: '更多', 39 | onPressed: () => debugPrint('More button is pressed'), 40 | ) 41 | ], 42 | bottom: TabBar( 43 | controller: tabController, 44 | tabs: [ 45 | Tab(icon: Icon(Icons.home)), 46 | Tab(icon: Icon(Icons.message)), 47 | Tab(icon: Icon(Icons.library_add)), 48 | ], 49 | ), 50 | ), 51 | body: Column(children: [ 52 | Container(height: 200, width: 200), 53 | SizedBox(height: 20,), 54 | FlatButton(child: Text("这是一个Button"), onPressed: () {},), 55 | SizedBox(height: 20,), 56 | Switch(value: true, onChanged: (bool value) {},), 57 | Checkbox(onChanged: (bool value) { }, value: true,), 58 | Radio(groupValue: 1, onChanged: (int value) { },), 59 | ],), 60 | floatingActionButton: FloatingActionButton(onPressed: () { },child:Icon(Icons.add) ,), 61 | ); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /lib/demo/theme/main_select_theme.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:mdemo1/demo/theme/provide_config.dart'; 3 | import 'package:mdemo1/demo/theme/them_config.dart'; 4 | 5 | ///flutter 程序的入口函数 6 | ///执行runApp 方法 为应用程序创建了一个 root 根布局 7 | void main() => runApp(ProvideConfig.init(child: MyThemApp())); 8 | 9 | class MyThemApp extends StatelessWidget { 10 | @override 11 | Widget build(BuildContext context) { 12 | 13 | return ProvideConfig.connect(builder: (context, child,ThemConfigModel model) { 14 | ///每次通知数据刷新时,builder将会重新构建这个小部件。 15 | return MaterialApp( 16 | theme: model.defaultTheme, 17 | home: MyHomePage(), 18 | ); 19 | }); 20 | } 21 | } 22 | 23 | class MyHomePage extends StatefulWidget { 24 | MyHomePage({Key key, this.title}) : super(key: key); 25 | final String title; 26 | 27 | @override 28 | _MyHomePageState createState() => _MyHomePageState(); 29 | } 30 | 31 | class _MyHomePageState extends State { 32 | @override 33 | Widget build(BuildContext context) { 34 | return Scaffold( 35 | appBar: AppBar( 36 | title: Text("应用主题切换"), 37 | ), 38 | body: Center( 39 | child: Column( 40 | mainAxisAlignment: MainAxisAlignment.center, 41 | children: [ 42 | FlatButton( 43 | child: Text("亮色"), 44 | onPressed: () { 45 | print("点击了亮色"); 46 | 47 | ProvideConfig.value(context).setThem(0); 48 | }, 49 | ), 50 | FlatButton( 51 | child: Text("暗色"), 52 | onPressed: () { 53 | print("点击了暗色"); 54 | ProvideConfig.value(context).setThem(1); 55 | }, 56 | ), 57 | FlatButton( 58 | child: Text("紫色"), 59 | onPressed: () { 60 | print("点击了紫色"); 61 | ProvideConfig.value(context).setThem(2); 62 | }, 63 | ), 64 | ], 65 | ), 66 | ), 67 | ); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /lib/demo/theme/provide_config.dart: -------------------------------------------------------------------------------- 1 | 2 | import 'package:mdemo1/demo/theme/them_config.dart'; 3 | import 'package:provide/provide.dart'; 4 | class ProvideConfig{ 5 | 6 | ///用来初始化 Provider 以及 ThemConfigModel 7 | static init({child,dispose=false}){ 8 | ///初始化 providers 9 | final providers = Providers()..provide(Provider.value(ThemConfigModel())); 10 | /// [child] 指的是要进行 状态管理的子 Widget 11 | /// [providers] 状态的管理器 12 | return ProviderNode(child: child, providers: providers, dispose: dispose); 13 | } 14 | 15 | // 通过Provide小部件获取状态封装 16 | static connect({builder, child, scope}) { 17 | return Provide(builder: builder, child: child, scope: scope); 18 | } 19 | 20 | 21 | // 通过Provide.value(context)获取封装 22 | static T value(context, {scope}) { 23 | return Provide.value(context,scope: scope); 24 | } 25 | } -------------------------------------------------------------------------------- /lib/demo/theme/test_info.dart: -------------------------------------------------------------------------------- 1 | void fu() { 2 | 3 | 4 | } 5 | -------------------------------------------------------------------------------- /lib/demo/theme/them_config.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | ///用来定义程序中所使用到的颜色主题 4 | class ThemConfigModel with ChangeNotifier { 5 | 6 | ///亮色主题 7 | ///应用程序默认的主题 8 | final ThemeData lightTheme = ThemeData( 9 | 10 | ///亮色 11 | brightness: Brightness.light, 12 | 13 | ///主背景色 14 | primaryColor: Colors.blue, 15 | ); 16 | 17 | ///暗色主题 18 | final ThemeData dartTheme = ThemeData( 19 | 20 | ///暗色 21 | brightness: Brightness.dark, 22 | 23 | ///主背景色 24 | primaryColor: Colors.grey, 25 | ); 26 | 27 | ///紫色主题 28 | final ThemeData violetTheme = ThemeData( 29 | 30 | ///亮色 31 | brightness: Brightness.light, 32 | 33 | ///主背景色 34 | primaryColor: Colors.deepPurple, 35 | ); 36 | 37 | 38 | ThemeData defaultTheme = ThemeData( 39 | 40 | ///亮色 41 | brightness: Brightness.light, 42 | 43 | ///主背景色 44 | primaryColor: Colors.blue, 45 | ); 46 | 47 | void setThem(num index) { 48 | switch (index) { 49 | case 0: 50 | defaultTheme = lightTheme; 51 | break; 52 | case 1: 53 | defaultTheme = dartTheme; 54 | break; 55 | case 2 : 56 | defaultTheme = violetTheme; 57 | break; 58 | } 59 | 60 | ///使用 notifyListeners() 函数通知监听者以更新界面。 61 | notifyListeners(); 62 | } 63 | 64 | } -------------------------------------------------------------------------------- /lib/demo/theme/them_data.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:mdemo1/demo/routes/first_page.dart'; 4 | 5 | import 'first_them_page.dart'; 6 | 7 | main() => runApp(themDataFunction4()); 8 | 9 | MaterialApp themDataFunction() { 10 | return MaterialApp( 11 | theme: ThemeData(), 12 | themeMode: ThemeMode.light, 13 | darkTheme: ThemeData(), 14 | home: FirstThemPage(), 15 | ); 16 | } 17 | 18 | MaterialApp themDataFunction2() { 19 | return MaterialApp( 20 | theme: ThemeData( 21 | brightness: Brightness.light, 22 | primarySwatch: Colors.blue, 23 | primaryColor: Colors.deepPurple), 24 | themeMode: ThemeMode.light, 25 | darkTheme: ThemeData(brightness: Brightness.dark), 26 | home: FirstThemPage(), 27 | ); 28 | } 29 | 30 | MaterialApp themDataFunction3() { 31 | return MaterialApp( 32 | theme: ThemeData( 33 | brightness: Brightness.light, 34 | primarySwatch: Colors.blue, 35 | primaryColor: Colors.deepPurple, 36 | accentColor: Colors.red, 37 | focusColor: Colors.deepPurple, 38 | hoverColor: Colors.deepPurple, 39 | highlightColor: Colors.deepPurple, 40 | splashColor: Colors.deepPurple, 41 | textTheme: TextTheme(), 42 | primaryTextTheme: TextTheme(), 43 | accentTextTheme: TextTheme() 44 | ), 45 | themeMode: ThemeMode.light, 46 | home: FirstThemPage(), 47 | ); 48 | } 49 | MaterialApp themDataFunction4() { 50 | return MaterialApp( 51 | theme: ThemeData( 52 | brightness: Brightness.light, 53 | primarySwatch: Colors.blue, 54 | primaryColor: Colors.deepPurple, 55 | accentColor: Colors.red, 56 | focusColor: Colors.deepPurple, 57 | hoverColor: Colors.deepPurple, 58 | highlightColor: Colors.deepPurple, 59 | splashColor: Colors.deepPurple,), 60 | themeMode: ThemeMode.light, 61 | home: FirstThemPage(), 62 | ); 63 | } 64 | CupertinoApp themData3Function() { 65 | return CupertinoApp( 66 | theme: CupertinoThemeData(), 67 | ); 68 | } 69 | -------------------------------------------------------------------------------- /lib/demo/theme2/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:mdemo1/demo/theme2/provide_config.dart'; 3 | import 'package:mdemo1/demo/theme2/them_config.dart'; 4 | import 'customscroll_demo_page.dart'; 5 | 6 | 7 | 8 | 9 | 10 | void main() => runApp( 11 | 12 | ProvideConfig.init(child: MyApp()) 13 | 14 | ); 15 | 16 | class MyApp extends StatelessWidget { 17 | 18 | @override 19 | Widget build(BuildContext context) { 20 | return ProvideConfig.connect( 21 | builder: (context, child, ThemConfigModel model) { 22 | ///每次通知数据刷新时,builder将会重新构建这个小部件。 23 | return MaterialApp( 24 | title: '看看灰色应用', 25 | theme: model.defaultTheme, 26 | home: CustomScrollDemoPage(), 27 | ); 28 | }); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/demo/theme2/provide_config.dart: -------------------------------------------------------------------------------- 1 | 2 | import 'package:mdemo1/demo/theme2/them_config.dart'; 3 | import 'package:provide/provide.dart'; 4 | class ProvideConfig{ 5 | 6 | /** 7 | * Provide也是借助了InheritWidget,将共享状态放到顶层MaterialApp之上。 8 | * 底层部件通过Provier获取该状态,并通过混合ChangeNotifier通知依赖于该状态的组件刷新 9 | */ 10 | ///用来初始化 Provider 以及 ThemConfigModel 11 | static init({child,dispose=false}){ 12 | 13 | /** 14 | * Provider.value 将 ThemConfigModel 包裹成了 _ValueProvider 15 | * 并在它的内部提供了StreamController从而实现对数据进行流式操作。 16 | */ 17 | ///初始化 providers 18 | final providers = Providers()..provide(Provider.value(ThemConfigModel())); 19 | 20 | /** 21 | * ProviderNode封装了InheritWidget,并且提供了 一个providers容器用于放置状态 22 | * 23 | */ 24 | /// [child] 指的是要进行 状态管理的子 Widget 25 | /// [providers] 状态的管理器 26 | return ProviderNode(child: child, providers: providers, dispose: dispose); 27 | } 28 | 29 | // 通过Provide小部件获取状态封装 30 | static connect({builder, child, scope}) { 31 | return Provide(builder: builder, child: child, scope: scope); 32 | } 33 | 34 | 35 | // 通过Provide.value(context)获取封装 36 | static T value(context, {scope}) { 37 | /** 38 | * Provide也提供了两种获取State的方法。 39 | * 这里使用的是 Provide.value(context) 40 | * 这种方式实际上调用了context.inheritFromWidgetOfExactType找到顶层的_InheritedProviders来获取到顶层providers中的状态 41 | * 42 | */ 43 | return Provide.value(context,scope: scope); 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /lib/demo/theme2/them_config.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:flutter/material.dart'; 4 | 5 | ///用来定义程序中所使用到的颜色主题 6 | class ThemConfigModel with ChangeNotifier { 7 | 8 | ///亮色主题 9 | ///应用程序默认的主题 10 | final ThemeData lightTheme = ThemeData( 11 | ///亮色 12 | brightness: Brightness.light, 13 | ///主背景色 14 | primaryColor: Colors.white, 15 | buttonTheme: ButtonThemeData( 16 | buttonColor: Colors.blue, 17 | highlightColor: Colors.blue[700] 18 | ) 19 | ); 20 | 21 | ///暗色主题 22 | final ThemeData dartTheme = ThemeData( 23 | ///暗色 24 | brightness: Brightness.dark, 25 | ///主背景色 26 | primaryColor: Colors.grey, 27 | buttonTheme: ButtonThemeData( 28 | buttonColor: Colors.grey[700], 29 | highlightColor: Colors.grey[800] 30 | ), 31 | 32 | ); 33 | 34 | 35 | ThemeData defaultTheme; 36 | void setThem(num index) { 37 | switch (index) { 38 | case 0: 39 | defaultTheme = lightTheme; 40 | break; 41 | case 1: 42 | defaultTheme = dartTheme; 43 | break; 44 | default : 45 | defaultTheme = lightTheme; 46 | break; 47 | } 48 | 49 | ///使用 notifyListeners() 函数通知监听者以更新界面。 50 | notifyListeners(); 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_localizations/flutter_localizations.dart'; 3 | import 'package:jpush_flutter/jpush_flutter.dart'; 4 | import 'package:pull_to_refresh/pull_to_refresh.dart'; 5 | 6 | import 'index_page.dart'; 7 | 8 | ///程序入口 9 | void main() => runApp(RootApp()); 10 | 11 | class RootApp extends StatefulWidget { 12 | @override 13 | State createState() { 14 | return RottAppState(); 15 | } 16 | } 17 | 18 | class RottAppState extends State { 19 | ///根布局的初始化 20 | @override 21 | void initState() { 22 | super.initState(); 23 | 24 | ///创建 JPush 25 | JPush jpush = new JPush(); 26 | 27 | ///配置应用 Key 28 | jpush.setup( 29 | appKey: "", 30 | channel: "theChannel", 31 | production: false, 32 | 33 | /// 设置是否打印 debug 日志 34 | debug: true, 35 | ); 36 | jpush.applyPushAuthority( 37 | new NotificationSettingsIOS(sound: true, alert: true, badge: true)); 38 | } 39 | 40 | @override 41 | Widget build(BuildContext context) { 42 | ///来构建 43 | return MaterialApp( 44 | theme: ThemeData( 45 | buttonTheme: 46 | ), 47 | ///应用程序默认显示的页面 48 | home: IndexPage(), 49 | localizationsDelegates: [ 50 | ///初始化默认的 Material 组件本地化 51 | GlobalMaterialLocalizations.delegate, 52 | ///初始化默认的 通用 Widget 组件本地化 53 | GlobalWidgetsLocalizations.delegate, 54 | 55 | ///下拉刷新 56 | RefreshLocalizations.delegate, 57 | 58 | ], 59 | 60 | ///当前区域,如果为null则使用系统区域一般用于语言切换 61 | ///传入两个参数,语言代码,国家代码 62 | ///这里配制为中国 63 | locale: Locale('zh', 'CN'), 64 | 65 | ///定义当前应用程序所支持的语言环境 66 | supportedLocales: [ 67 | const Locale('en', 'US'), // English 英文 68 | const Locale('he', 'IL'), // Hebrew 西班牙 69 | const Locale('zh', 'CN'), // 中文, 70 | ], 71 | ); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /lib/test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import 'demo/language/language_data2.dart'; 4 | 5 | 6 | ///代码块2-8-2-3
 7 | import 'package:provider/provider.dart'; 8 | void main() { 9 | //程序入口函数
 10 | runApp(
 11 | ///将Provider配制在程序的最顶层
 ChangeNotifierProvider.value(
 ///value就是监听的数据模型对象
 value: TestModel(),
 ///这里最好是根widget
 child: MyApp(),
 )
 );
} 12 | } 13 | 14 | 15 | ///代码块 2-7-4-1 16 | ///2.7.4 accentColor 属性分析 17 | 18 | void fu() { 19 | ///2.7.4 accentColor 属性分析 20 | MaterialApp( 21 | theme: ThemeData( 22 | brightness: Brightness.light, 23 | primarySwatch: Colors.blue, 24 | primaryColor: Colors.deepPurple, 25 | accentColor: Colors.red), 26 | themeMode: ThemeMode.light, 27 | home: FirstThemPage(), 28 | ); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /lib/utils/route_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// 路由工具类 5 | /// 6 | class RouteUtils { 7 | ///跳转页面 8 | static void pushPage(BuildContext context, Widget page) { 9 | if (page == null) { 10 | return; 11 | } 12 | Navigator.of(context) 13 | .push(MaterialPageRoute(builder: (BuildContext context) => page)); 14 | } 15 | 16 | ///替换跳转页面 17 | static void pushRePage(BuildContext context, Widget page) { 18 | if (page == null) { 19 | return; 20 | } 21 | Navigator.of(context).pushReplacement( 22 | MaterialPageRoute(builder: (BuildContext context) => page)); 23 | } 24 | 25 | ///关闭当前显示的页面 26 | static void popPage(BuildContext context,){ 27 | Navigator.pop(context); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/utils/sp_utils.dart: -------------------------------------------------------------------------------- 1 | 2 | import 'package:shared_preferences/shared_preferences.dart'; 3 | 4 | class SPUtil { 5 | /// 异步保存 6 | static Future save(String key, String value) async { 7 | SharedPreferences sp = await SharedPreferences.getInstance(); 8 | sp.setString(key, value); 9 | } 10 | 11 | /// 异步读取 12 | static Future get(String key) async { 13 | SharedPreferences sp = await SharedPreferences.getInstance(); 14 | return sp.getString(key); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /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:mdemo1/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 15 | }); 16 | } 17 | --------------------------------------------------------------------------------