├── .gitignore ├── FRouter ├── FRouter.dart └── test_frouter.dart ├── LICENSE ├── README-EN.md ├── README.md ├── code_plugins ├── README-CN.md ├── have_new_keywords │ ├── dart.json │ └── settings.jar ├── no_new_keywords │ ├── dart.json │ └── settings.jar └── readme.md ├── flutter-learning-doc-resources ├── Flutter有关博客讲解.md ├── Flutter相关译文.md └── 官方文档译文 │ └── Android开发者参考.md ├── pics ├── Dart的模板设置.png ├── Dart编辑模板字段.png ├── Dart语言.png ├── Dart语言在Flutter里面报错.png ├── Flutter Inspector1.png ├── Flutter Inspector2.png ├── Flutter和react native的对比.png ├── Run Console1.png ├── Run Console2.png ├── app.png ├── app2.png ├── app3.png ├── app4.png ├── app5.png ├── app6.png ├── donation.png ├── download-flutter.png ├── flutter-dos1.png ├── flutter-dos2.png ├── flutter-dos3.png ├── flutter-pits1.png ├── flutter-pits10.png ├── flutter-pits11.png ├── flutter-pits12.png ├── flutter-pits13.png ├── flutter-pits14.png ├── flutter-pits15.png ├── flutter-pits2.png ├── flutter-pits3.png ├── flutter-pits4.png ├── flutter-pits5.png ├── flutter-pits6.png ├── flutter-pits7.png ├── flutter-pits8.png ├── flutter-pits9.png ├── logo.png ├── path1.png ├── path2.png ├── plugin-dart.png ├── plugin-flutter.png ├── 公众号二维码.jpg └── 线性渐变封装图示.png ├── projects ├── dart_demo │ ├── .gitignore │ ├── .metadata │ ├── README.md │ ├── android │ │ ├── .gitignore │ │ ├── app │ │ │ ├── build.gradle │ │ │ └── src │ │ │ │ └── main │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── lzw │ │ │ │ │ └── dartdemo │ │ │ │ │ └── MainActivity.java │ │ │ │ └── res │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ └── values │ │ │ │ └── styles.xml │ │ ├── build.gradle │ │ ├── gradle.properties │ │ ├── gradlew │ │ ├── gradlew.bat │ │ └── settings.gradle │ ├── ios │ │ ├── .gitignore │ │ ├── Flutter │ │ │ ├── AppFrameworkInfo.plist │ │ │ ├── Debug.xcconfig │ │ │ └── Release.xcconfig │ │ ├── Runner.xcodeproj │ │ │ ├── project.pbxproj │ │ │ ├── project.xcworkspace │ │ │ │ └── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ └── xcschemes │ │ │ │ └── Runner.xcscheme │ │ ├── Runner.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ └── Runner │ │ │ ├── AppDelegate.h │ │ │ ├── AppDelegate.m │ │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ │ └── LaunchImage.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ └── README.md │ │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ │ ├── Info.plist │ │ │ └── main.m │ ├── lib │ │ ├── ConvertNumberToChineseMoneyWords.dart │ │ └── main.dart │ ├── pubspec.lock │ ├── pubspec.yaml │ └── test │ │ ├── 10-async_demo │ │ ├── 11-2-async&await │ │ │ ├── async_demo0.dart │ │ │ ├── async_demo01.dart │ │ │ ├── async_demo02.dart │ │ │ ├── async_demo03.dart │ │ │ └── async_demo04.dart │ │ ├── 11-3-define_asynchronous_function │ │ │ └── define_demo.dart │ │ ├── 11-4-stream │ │ │ └── stream_demo.dart │ │ └── test.txt │ │ ├── 11-generator │ │ └── generate_demo.dart │ │ ├── 12-isolate │ │ └── isolates_demo.dart │ │ ├── 3-variable_and_constant │ │ ├── 3-1-variable_and_constant1.dart │ │ ├── 3-2-variable_and_constant2.dart │ │ └── 3-3-variable_and_constant3.dart │ │ ├── 4-datas-type │ │ ├── 4-1-num_demo.dart │ │ ├── 4-2-String_demo.dart │ │ ├── 4-3-bool_demo.dart │ │ ├── 4-4-list_demo.dart │ │ ├── 4-5-map_demo.dart │ │ └── 4-6-runes_demo.dart │ │ ├── 5-opertors │ │ └── opertors_demo.dart │ │ ├── 6-control_flow_statements │ │ ├── 6-1-if_else │ │ │ └── if_else_demo.dart │ │ ├── 6-2-for │ │ │ ├── for_demo1.dart │ │ │ ├── for_demo2.dart │ │ │ ├── for_demo3.dart │ │ │ └── for_demo4.dart │ │ ├── 6-3-while&do_while │ │ │ └── while_demo.dart │ │ ├── 6-4-break&continue │ │ │ └── break&continue_demo.dart │ │ ├── 6-5-switch&case │ │ │ └── switch_case_demo.dart │ │ └── 6-6-assert │ │ │ └── assert_demo.dart │ │ ├── 7-exception │ │ └── exception_demo.dart │ │ ├── 8-class │ │ ├── 1-class-type │ │ │ ├── 1-common-class │ │ │ │ ├── 1-common_class.dart │ │ │ │ ├── 2-object_type.dart │ │ │ │ ├── 3-exdtend_a_class │ │ │ │ │ ├── 3-extends_demo.dart │ │ │ │ │ ├── 4-annotation_demo.dart │ │ │ │ │ └── 5-annotation_use.dart │ │ │ │ ├── 4-static_variable.dart │ │ │ │ ├── 5-operator_demo.dart │ │ │ │ └── 6-nosuchmethod_demo.dart │ │ │ ├── 2-abstract_class │ │ │ │ ├── 1-abstract_demo.dart │ │ │ │ └── 2-abstract_demo.dart │ │ │ ├── 3-callable_class │ │ │ │ └── callable_class_demo.dart │ │ │ ├── 4-enum │ │ │ │ └── enum_demo.dart │ │ │ └── 5-mixin │ │ │ │ ├── 1-create_mixin.dart │ │ │ │ ├── 2-use_mixin.dart │ │ │ │ └── 3-use_mixin2.dart │ │ ├── 2-generics │ │ │ ├── 1-why_use_enerics.dart │ │ │ ├── 2-use_list.dart │ │ │ ├── 3-with-constructor_params.dart │ │ │ ├── 4-generis_list.dart │ │ │ ├── 5-limit_params_type.dart │ │ │ └── 6-generis_methods.dart │ │ └── 3-functions │ │ │ ├── 1-common_functions │ │ │ ├── 1-method_write.dart │ │ │ ├── 10-method_abstract.dart │ │ │ ├── 11-method_static.dart │ │ │ ├── 2-choosable_functuons │ │ │ │ ├── method_choosable.dart │ │ │ │ ├── method_choosable2.dart │ │ │ │ ├── method_choosable3.dart │ │ │ │ └── method_choosable4.dart │ │ │ ├── 3-method_params.dart │ │ │ ├── 4-method_noname.dart │ │ │ ├── 5-method_resolution.dart │ │ │ ├── 6-method_closure.dart │ │ │ ├── 7-method_equals.dart │ │ │ ├── 8-method_alias.dart │ │ │ └── 9-get_and_set │ │ │ │ ├── get_set_demo1.dart │ │ │ │ └── get_set_demo2.dart │ │ │ ├── 2-constructor_functions │ │ │ ├── 1-constructor_common.dart │ │ │ ├── 2-constructor_params.dart │ │ │ ├── 3-constructor_default.dart │ │ │ ├── 4-constructor_named.dart │ │ │ ├── 5-constructor_not_extends.dart │ │ │ ├── 6-calling-process │ │ │ │ ├── calling-process1.dart │ │ │ │ ├── calling-process2.dart │ │ │ │ └── calling-process3.dart │ │ │ ├── 7-constructor_redirect.dart │ │ │ ├── 8-constructor_constant │ │ │ │ ├── constructor_constant1.dart │ │ │ │ └── constructor_constant2.dart │ │ │ └── 9-constructor_factory.dart │ │ │ └── 3-init_list │ │ │ ├── 1-init_list_demo1.dart │ │ │ ├── 2-init_list_demo2.dart │ │ │ ├── 3-init_list_demo3.dart │ │ │ ├── 4-init_list_demo4.dart │ │ │ └── 5-init_list_demo5.dart │ │ └── 9-library │ │ ├── libs │ │ ├── mylib.dart │ │ ├── otherlib.dart │ │ ├── otherlib2.dart │ │ ├── testlib1.dart │ │ └── testlib2.dart │ │ ├── test1.dart │ │ ├── test2.dart │ │ └── test3.dart ├── flutter-demo │ ├── .gitignore │ ├── .idea │ │ ├── codeStyles │ │ │ └── Project.xml │ │ ├── inspectionProfiles │ │ │ └── Project_Default.xml │ │ ├── libraries │ │ │ ├── Dart_Packages.xml │ │ │ ├── Dart_SDK.xml │ │ │ └── Flutter_Plugins.xml │ │ ├── markdown-navigator.xml │ │ ├── markdown-navigator │ │ │ └── profiles_settings.xml │ │ ├── misc.xml │ │ ├── modules.xml │ │ └── workspace.xml │ ├── .metadata │ ├── README.md │ ├── android │ │ ├── .gitignore │ │ ├── app │ │ │ ├── build.gradle │ │ │ └── src │ │ │ │ └── main │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── lzw │ │ │ │ │ └── flutterdemo │ │ │ │ │ └── MainActivity.java │ │ │ │ └── res │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ └── values │ │ │ │ └── styles.xml │ │ ├── build.gradle │ │ ├── gradle.properties │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ ├── gradlew │ │ ├── gradlew.bat │ │ └── settings.gradle │ ├── assets │ │ └── result.json │ ├── images │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ │ ├── demo.png │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ └── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ ├── ios │ │ ├── .gitignore │ │ ├── Flutter │ │ │ ├── AppFrameworkInfo.plist │ │ │ ├── Debug.xcconfig │ │ │ └── Release.xcconfig │ │ ├── Runner.xcodeproj │ │ │ ├── project.pbxproj │ │ │ ├── project.xcworkspace │ │ │ │ └── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ └── xcschemes │ │ │ │ └── Runner.xcscheme │ │ ├── Runner.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ └── Runner │ │ │ ├── AppDelegate.h │ │ │ ├── AppDelegate.m │ │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ │ └── LaunchImage.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ └── README.md │ │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ │ ├── Info.plist │ │ │ └── main.m │ ├── lib │ │ ├── CardDemo.dart │ │ ├── IO.dart │ │ ├── TabBar.dart │ │ ├── all_samples │ │ │ ├── dialog │ │ │ │ ├── alert_dialog_demo.dart │ │ │ │ ├── dialogs_demo.dart │ │ │ │ ├── simple_dialog_demo.dart │ │ │ │ └── snackbar_demo.dart │ │ │ ├── list │ │ │ │ ├── AllListViewDemo.dart │ │ │ │ ├── list_demo.dart │ │ │ │ ├── listview_customscrollview.dart │ │ │ │ ├── listview_dividers.dart │ │ │ │ ├── listview_gridview.dart │ │ │ │ ├── listview_horizontal.dart │ │ │ │ ├── listview_listtitle.dart │ │ │ │ ├── listview_longlist.dart │ │ │ │ ├── listview_multi_item.dart │ │ │ │ ├── listview_multi_level.dart │ │ │ │ ├── listview_radio_listtitle.dart │ │ │ │ ├── listview_simple.dart │ │ │ │ ├── listview_sliver.dart │ │ │ │ ├── sliver_vs_grid.dart │ │ │ │ ├── vertical_list_nested_horizontal_list.dart │ │ │ │ └── 说明.txt │ │ │ ├── main_page.dart │ │ │ ├── normal_page.dart │ │ │ └── router │ │ │ │ ├── navigator_encapsulation │ │ │ │ ├── navigator_util.dart │ │ │ │ └── test_navigator.dart │ │ │ │ ├── readme.md │ │ │ │ ├── router_all_sample │ │ │ │ ├── router_sample1.dart │ │ │ │ ├── router_sample2.dart │ │ │ │ ├── router_sample3.dart │ │ │ │ ├── router_sample4.dart │ │ │ │ └── router_sample5.dart │ │ │ │ └── router_easy_sample │ │ │ │ ├── demo1.dart │ │ │ │ ├── demo2.dart │ │ │ │ ├── demo3.dart │ │ │ │ ├── demo4.dart │ │ │ │ └── router_demo.dart │ │ ├── color_test.dart │ │ ├── image_network.dart │ │ ├── main.dart │ │ ├── main2.dart │ │ ├── page1.dart │ │ ├── page2.dart │ │ ├── page3.dart │ │ ├── progress.dart │ │ ├── readme.md │ │ └── view_demo │ │ │ ├── action │ │ │ ├── AnimatedListSample.dart │ │ │ ├── GestureDetectorDemo.dart │ │ │ ├── HandingTaps_And_ListView.dart │ │ │ ├── HandlingTaps.dart │ │ │ ├── OpacityAnimDemo.dart │ │ │ ├── basic_hero_animation.dart │ │ │ ├── hero_animation.dart │ │ │ ├── page4.dart │ │ │ └── page4_review.dart │ │ │ ├── list │ │ │ ├── ShoppingList.dart │ │ │ └── ShoppingListItem.dart │ │ │ ├── thirdlib │ │ │ └── Permissions.dart │ │ │ └── view │ │ │ ├── BoxDecorationDemo.dart │ │ │ ├── CenterDemo.dart │ │ │ ├── ChipsDemo.dart │ │ │ ├── ContainerDemo.dart │ │ │ ├── DecoratedBoxDemo.dart │ │ │ ├── FractionalOffsetUtil.dart │ │ │ ├── ImageDemo.dart │ │ │ ├── ListViewDemo.dart │ │ │ ├── OpacityDemo.dart │ │ │ ├── PopMenuButtonDemo.dart │ │ │ ├── RaisedButtonDemo.dart │ │ │ ├── RowAndColumnDemo.dart │ │ │ ├── StackDemo.dart │ │ │ ├── TextDemo.dart │ │ │ ├── TextFieldDemo1.dart │ │ │ └── TextFieldDemo2.dart │ ├── pics │ │ ├── list_demo.png │ │ ├── main_page.png │ │ ├── normal_page.png │ │ ├── router_demo.png │ │ ├── 可折叠的appbar+listview.gif │ │ └── 多级列表demo.png │ ├── pubspec.lock │ ├── pubspec.yaml │ ├── test │ │ ├── async.dart │ │ ├── dart1.dart │ │ ├── dart2.dart │ │ ├── dart3.dart │ │ ├── dart4.dart │ │ ├── dart5.dart │ │ ├── dart6.dart │ │ └── widget_test.dart │ └── util │ │ └── FractionalOffsetUtil.dart ├── flutter_adobe_logo │ ├── flutter_adobe_logo.dart │ └── sample.gif ├── flutter_white_screen │ ├── .gitignore │ ├── .metadata │ ├── README.md │ ├── android │ │ ├── app │ │ │ ├── build.gradle │ │ │ └── src │ │ │ │ └── main │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── awei │ │ │ │ │ └── flutterwhitescreen │ │ │ │ │ └── MainActivity.java │ │ │ │ └── res │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ └── values │ │ │ │ └── styles.xml │ │ ├── build.gradle │ │ ├── gradle.properties │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ └── gradle-wrapper.properties │ │ └── settings.gradle │ ├── ios │ │ ├── Flutter │ │ │ ├── AppFrameworkInfo.plist │ │ │ ├── Debug.xcconfig │ │ │ └── Release.xcconfig │ │ ├── Runner.xcodeproj │ │ │ ├── project.pbxproj │ │ │ ├── project.xcworkspace │ │ │ │ └── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ └── xcschemes │ │ │ │ └── Runner.xcscheme │ │ ├── Runner.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ └── Runner │ │ │ ├── AppDelegate.h │ │ │ ├── AppDelegate.m │ │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ │ └── LaunchImage.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ └── README.md │ │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ │ ├── Info.plist │ │ │ └── main.m │ ├── lib │ │ └── main.dart │ ├── pubspec.yaml │ ├── screenshots │ │ └── screenshots.gif │ └── test │ │ └── widget_test.dart ├── hub_demo │ ├── hub_demo.dart │ ├── sample.gif │ └── sample2.gif └── readme.md └── readme ├── Dart语法.md ├── Flutter从配置安装到填坑指南详解.md ├── Flutter和react native的对比.md ├── Flutter和原生Android控件对比.md ├── Flutter的需要与原生交互的一些常用库 ├── English_docs │ ├── Common libraries for Flutter.md │ ├── UI_libs.md │ ├── data_libs.md │ └── third_libs.md ├── Flutter的需要与原生交互的一些常用库.md ├── UI_libs.md ├── data_libs.md └── third_libs.md └── yarn,nodejs,npm,Flutter有关命令.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # IntelliJ 36 | *.iml 37 | .idea/workspace.xml 38 | .idea/tasks.xml 39 | .idea/gradle.xml 40 | .idea/assetWizardSettings.xml 41 | .idea/dictionaries 42 | .idea/libraries 43 | .idea/caches 44 | 45 | # Keystore files 46 | # Uncomment the following line if you do not want to check your keystore files in. 47 | #*.jks 48 | 49 | # External native build folder generated in Android Studio 2.2 and later 50 | .externalNativeBuild 51 | 52 | # Google Services (e.g. APIs or Firebase) 53 | google-services.json 54 | 55 | # Freeline 56 | freeline.py 57 | freeline/ 58 | freeline_project_description.json 59 | 60 | # fastlane 61 | fastlane/report.xml 62 | fastlane/Preview.html 63 | fastlane/screenshots 64 | fastlane/test_output 65 | fastlane/readme.md 66 | -------------------------------------------------------------------------------- /code_plugins/README-CN.md: -------------------------------------------------------------------------------- 1 | # 使用说明 2 | 3 | ### ▶【提示:】更多详细的图文使用详细讲解,请看我的博客:[Flutter代码模板,解放双手,提高开发效率必备](https://www.jianshu.com/p/4184745d6983) 4 | 5 | 6 | > 导入到Android Studio 或者 Intellij IDEA 7 | 8 | **Tips: 如果你不喜欢 `new`关键字, 你可以下载 [no_new_keywords/settings.jar](https://github.com/AweiLoveAndroid/Flutter-learning/blob/master/code_plugins/no_new_keywords/settings.jar) 文件, 否则请下载 [have_new_keywords/settings.jar](https://github.com/AweiLoveAndroid/Flutter-learning/blob/master/code_plugins/have_new_keywords/settings.jar) 这个文件。** 9 | 10 | 11 | > 导入到VSCode 12 | 13 | **Tips: 如果你不喜欢 `new`关键字, 你可以下载 [no_new_keywords/dart.json](https://github.com/AweiLoveAndroid/Flutter-learning/blob/master/code_plugins/no_new_keywords/dart.json) 文件, 否则请下载 [have_new_keywords/dart.json](https://github.com/AweiLoveAndroid/Flutter-learning/blob/master/code_plugins/have_new_keywords/dart.json) 这个文件。** -------------------------------------------------------------------------------- /code_plugins/have_new_keywords/settings.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/code_plugins/have_new_keywords/settings.jar -------------------------------------------------------------------------------- /code_plugins/no_new_keywords/settings.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/code_plugins/no_new_keywords/settings.jar -------------------------------------------------------------------------------- /flutter-learning-doc-resources/Flutter有关博客讲解.md: -------------------------------------------------------------------------------- 1 | # 我写的Flutter干货博客: 2 | 3 | #### [安卓开发方式的进化之路]( https://www.jianshu.com/p/44305a99c51a) 4 | 5 | #### [跨平台开发框架和工具集锦](https://www.jianshu.com/p/de459708d9ed) 6 | 7 | #### [Flutter从配置安装到填坑指南详解](https://www.jianshu.com/p/399c01657920) 8 | 9 | #### [老司机用一篇博客带你快速熟悉Dart语法](https://www.jianshu.com/p/3d927a7bf020) 10 | 11 | #### [Flutter学习总结系列----第一章、Flutter基础全面详解](https://www.jianshu.com/p/2c9867e737a1) 12 | 13 | #### [Flutter代码模板,解放双手,提高开发效率必备](https://www.jianshu.com/p/4184745d6983) 14 | 15 | #### [Flutter布局篇(1)--水平和垂直布局详解](https://www.jianshu.com/p/7511cb18a05e) 16 | 17 | #### [Flutter填坑全面总结](https://www.jianshu.com/p/22675c1632dc) 18 | 19 | #### [Flutter 的手势(GestureDetector)分析详解](https://www.jianshu.com/p/3b87ddb022af) 20 | 21 | #### [Flutter路由详解](https://www.jianshu.com/p/6e399b45bbb7) 22 | 23 | #### [手把手带你快速上手调试Flutter项目](https://www.jianshu.com/p/97c4df211791) 24 | 25 | ---- 26 | 27 | #### 简书博客:https://www.jianshu.com/u/f408bdadacce 28 | #### 掘金博客:https://juejin.im/user/5a07c6c0f265da430a501017 29 | #### 安卓巴士博客:http://www.apkbus.com/space-uid-944603.html -------------------------------------------------------------------------------- /flutter-learning-doc-resources/Flutter相关译文.md: -------------------------------------------------------------------------------- 1 | # Flutter相关译文 2 | 3 | [在 Google I/O 2018 观看 Flutter 的正确姿势 (wzasd 翻译)](https://juejin.im/post/5aebd7166fb9a07ab4587b3f) 4 | 5 | [为什么 Flutter 能最好地改变移动开发 (ALVINYEH 翻译)](https://juejin.im/post/5add65c46fb9a07aa541e97e) 6 | 7 | [Flutter 到底有多快?我开发了秒表应用来弄清楚。 (ALVINYEH 翻译)](https://juejin.im/post/5ad861566fb9a045ee01b48d) 8 | 9 | [为 JavaScript 程序员准备的 Flutter 指南 (lsvih 翻译)](https://juejin.im/post/5ac43c536fb9a028da7cbd59) 10 | 11 | [Flutter — 五个你会爱上它的原因 (rockzhai 翻译)](https://juejin.im/post/5a9e7e89f265da2381552542) 12 | 13 | [如何在中国使用 Flutter (mysterytony 翻译)](https://juejin.im/post/5a9f730c6fb9a028d2077ad4) 14 | 15 | [[译]Flutter for Android Developers - Intents](https://juejin.im/post/5a96cd1f5188257a780de9a0) 16 | 17 | [[译]Flutter for Android Developers - Async UI](https://juejin.im/post/5a9a21f8518825558b3d5d35) 18 | 19 | [[译]Flutter for Android Developers - Gesture Detection](https://juejin.im/post/5a9c106151882555872300f2) -------------------------------------------------------------------------------- /pics/Dart的模板设置.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/Dart的模板设置.png -------------------------------------------------------------------------------- /pics/Dart编辑模板字段.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/Dart编辑模板字段.png -------------------------------------------------------------------------------- /pics/Dart语言.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/Dart语言.png -------------------------------------------------------------------------------- /pics/Dart语言在Flutter里面报错.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/Dart语言在Flutter里面报错.png -------------------------------------------------------------------------------- /pics/Flutter Inspector1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/Flutter Inspector1.png -------------------------------------------------------------------------------- /pics/Flutter Inspector2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/Flutter Inspector2.png -------------------------------------------------------------------------------- /pics/Flutter和react native的对比.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/Flutter和react native的对比.png -------------------------------------------------------------------------------- /pics/Run Console1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/Run Console1.png -------------------------------------------------------------------------------- /pics/Run Console2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/Run Console2.png -------------------------------------------------------------------------------- /pics/app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/app.png -------------------------------------------------------------------------------- /pics/app2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/app2.png -------------------------------------------------------------------------------- /pics/app3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/app3.png -------------------------------------------------------------------------------- /pics/app4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/app4.png -------------------------------------------------------------------------------- /pics/app5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/app5.png -------------------------------------------------------------------------------- /pics/app6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/app6.png -------------------------------------------------------------------------------- /pics/donation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/donation.png -------------------------------------------------------------------------------- /pics/download-flutter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/download-flutter.png -------------------------------------------------------------------------------- /pics/flutter-dos1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/flutter-dos1.png -------------------------------------------------------------------------------- /pics/flutter-dos2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/flutter-dos2.png -------------------------------------------------------------------------------- /pics/flutter-dos3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/flutter-dos3.png -------------------------------------------------------------------------------- /pics/flutter-pits1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/flutter-pits1.png -------------------------------------------------------------------------------- /pics/flutter-pits10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/flutter-pits10.png -------------------------------------------------------------------------------- /pics/flutter-pits11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/flutter-pits11.png -------------------------------------------------------------------------------- /pics/flutter-pits12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/flutter-pits12.png -------------------------------------------------------------------------------- /pics/flutter-pits13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/flutter-pits13.png -------------------------------------------------------------------------------- /pics/flutter-pits14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/flutter-pits14.png -------------------------------------------------------------------------------- /pics/flutter-pits15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/flutter-pits15.png -------------------------------------------------------------------------------- /pics/flutter-pits2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/flutter-pits2.png -------------------------------------------------------------------------------- /pics/flutter-pits3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/flutter-pits3.png -------------------------------------------------------------------------------- /pics/flutter-pits4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/flutter-pits4.png -------------------------------------------------------------------------------- /pics/flutter-pits5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/flutter-pits5.png -------------------------------------------------------------------------------- /pics/flutter-pits6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/flutter-pits6.png -------------------------------------------------------------------------------- /pics/flutter-pits7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/flutter-pits7.png -------------------------------------------------------------------------------- /pics/flutter-pits8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/flutter-pits8.png -------------------------------------------------------------------------------- /pics/flutter-pits9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/flutter-pits9.png -------------------------------------------------------------------------------- /pics/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/logo.png -------------------------------------------------------------------------------- /pics/path1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/path1.png -------------------------------------------------------------------------------- /pics/path2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/path2.png -------------------------------------------------------------------------------- /pics/plugin-dart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/plugin-dart.png -------------------------------------------------------------------------------- /pics/plugin-flutter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/plugin-flutter.png -------------------------------------------------------------------------------- /pics/公众号二维码.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/公众号二维码.jpg -------------------------------------------------------------------------------- /pics/线性渐变封装图示.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/pics/线性渐变封装图示.png -------------------------------------------------------------------------------- /projects/dart_demo/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .dart_tool/ 3 | 4 | .packages 5 | .pub/ 6 | 7 | build/ 8 | 9 | .flutter-plugins 10 | -------------------------------------------------------------------------------- /projects/dart_demo/.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: f9bb4289e9fd861d70ae78bcc3a042ef1b35cc9d 8 | channel: beta 9 | -------------------------------------------------------------------------------- /projects/dart_demo/README.md: -------------------------------------------------------------------------------- 1 | # dart_demo 2 | 3 | #### [变量和常量](test/3-variable_and_constant) 4 | #### [特殊数据类型](test/4-datas-type) 5 | #### [运算符](test/5-opertors) 6 | #### [控制流程语句](test/6-control_flow_statements) 7 | #### [异常](test/7-exception) 8 | #### [类与函数](test/8-class) 9 | #### [库和可见性](test/9-library) 10 | #### [异步支持](test/10-async_demo) 11 | #### [生成器(Generators)](test/11-generator) 12 | #### [Isolates](test/12-isolate) -------------------------------------------------------------------------------- /projects/dart_demo/android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | *.class 3 | .gradle 4 | /local.properties 5 | /.idea/workspace.xml 6 | /.idea/libraries 7 | .DS_Store 8 | /build 9 | /captures 10 | GeneratedPluginRegistrant.java 11 | -------------------------------------------------------------------------------- /projects/dart_demo/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 | apply plugin: 'com.android.application' 15 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 16 | 17 | android { 18 | compileSdkVersion 27 19 | 20 | lintOptions { 21 | disable 'InvalidPackage' 22 | } 23 | 24 | defaultConfig { 25 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 26 | applicationId "com.lzw.dartdemo" 27 | minSdkVersion 16 28 | targetSdkVersion 27 29 | versionCode 1 30 | versionName "1.0" 31 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 32 | } 33 | 34 | buildTypes { 35 | release { 36 | // TODO: Add your own signing config for the release build. 37 | // Signing with the debug keys for now, so `flutter run --release` works. 38 | signingConfig signingConfigs.debug 39 | } 40 | } 41 | } 42 | 43 | flutter { 44 | source '../..' 45 | } 46 | 47 | dependencies { 48 | testImplementation 'junit:junit:4.12' 49 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 50 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 51 | } 52 | -------------------------------------------------------------------------------- /projects/dart_demo/android/app/src/main/java/com/lzw/dartdemo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.lzw.dartdemo; 2 | 3 | import android.os.Bundle; 4 | 5 | import io.flutter.app.FlutterActivity; 6 | import io.flutter.plugins.GeneratedPluginRegistrant; 7 | 8 | public class MainActivity extends FlutterActivity { 9 | @Override 10 | protected void onCreate(Bundle savedInstanceState) { 11 | super.onCreate(savedInstanceState); 12 | GeneratedPluginRegistrant.registerWith(this); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /projects/dart_demo/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /projects/dart_demo/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/dart_demo/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /projects/dart_demo/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/dart_demo/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /projects/dart_demo/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/dart_demo/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /projects/dart_demo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/dart_demo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /projects/dart_demo/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/dart_demo/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /projects/dart_demo/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /projects/dart_demo/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | google() 4 | jcenter() 5 | } 6 | 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:3.0.1' 9 | } 10 | } 11 | 12 | allprojects { 13 | repositories { 14 | google() 15 | jcenter() 16 | } 17 | } 18 | 19 | rootProject.buildDir = '../build' 20 | subprojects { 21 | project.buildDir = "${rootProject.buildDir}/${project.name}" 22 | } 23 | subprojects { 24 | project.evaluationDependsOn(':app') 25 | } 26 | 27 | task clean(type: Delete) { 28 | delete rootProject.buildDir 29 | } 30 | -------------------------------------------------------------------------------- /projects/dart_demo/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | -------------------------------------------------------------------------------- /projects/dart_demo/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 | -------------------------------------------------------------------------------- /projects/dart_demo/ios/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vagrant/ 3 | .sconsign.dblite 4 | .svn/ 5 | 6 | .DS_Store 7 | *.swp 8 | profile 9 | 10 | DerivedData/ 11 | build/ 12 | GeneratedPluginRegistrant.h 13 | GeneratedPluginRegistrant.m 14 | 15 | .generated/ 16 | 17 | *.pbxuser 18 | *.mode1v3 19 | *.mode2v3 20 | *.perspectivev3 21 | 22 | !default.pbxuser 23 | !default.mode1v3 24 | !default.mode2v3 25 | !default.perspectivev3 26 | 27 | xcuserdata 28 | 29 | *.moved-aside 30 | 31 | *.pyc 32 | *sync/ 33 | Icon? 34 | .tags* 35 | 36 | /Flutter/app.flx 37 | /Flutter/app.zip 38 | /Flutter/flutter_assets/ 39 | /Flutter/App.framework 40 | /Flutter/Flutter.framework 41 | /Flutter/Generated.xcconfig 42 | /ServiceDefinitions.json 43 | 44 | Pods/ 45 | .symlinks/ 46 | -------------------------------------------------------------------------------- /projects/dart_demo/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /projects/dart_demo/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /projects/dart_demo/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /projects/dart_demo/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /projects/dart_demo/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /projects/dart_demo/ios/Runner/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : FlutterAppDelegate 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /projects/dart_demo/ios/Runner/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #include "AppDelegate.h" 2 | #include "GeneratedPluginRegistrant.h" 3 | 4 | @implementation AppDelegate 5 | 6 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 7 | [GeneratedPluginRegistrant registerWithRegistry:self]; 8 | // Override point for customization after application launch. 9 | return [super application:application didFinishLaunchingWithOptions:launchOptions]; 10 | } 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/dart_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /projects/dart_demo/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 | -------------------------------------------------------------------------------- /projects/dart_demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/dart_demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /projects/dart_demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/dart_demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /projects/dart_demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/dart_demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /projects/dart_demo/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. -------------------------------------------------------------------------------- /projects/dart_demo/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 | -------------------------------------------------------------------------------- /projects/dart_demo/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | dart_demo 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /projects/dart_demo/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 | -------------------------------------------------------------------------------- /projects/dart_demo/test/10-async_demo/11-2-async&await/async_demo0.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | // async延迟功能 4 | main() { 5 | foo(499).then(print); 6 | print("after foo call"); 7 | } 8 | 9 | 10 | Future foo(x) async { 11 | print(x); 12 | return x + 1; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /projects/dart_demo/test/10-async_demo/11-2-async&await/async_demo01.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | void main(){ 4 | checkVersion(); 5 | } 6 | 7 | Future checkVersion() async { 8 | var version = await lookUpVersion(); 9 | // 其他操作 10 | } 11 | 12 | void lookUpVersion(){ 13 | // 逻辑... 14 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/10-async_demo/11-2-async&await/async_demo02.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | void main() { 4 | checkVersion(); 5 | } 6 | 7 | Future checkVersion() async { 8 | try { 9 | var version = await lookUpVersion(); 10 | } catch (e) { 11 | // 这里可以看到是什么错误。 12 | } finally { 13 | // 正确的解决方式写在这里 14 | } 15 | } 16 | 17 | void lookUpVersion() { 18 | // 逻辑... 19 | } 20 | -------------------------------------------------------------------------------- /projects/dart_demo/test/10-async_demo/11-2-async&await/async_demo03.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | void main() { 4 | checkVersion(); 5 | } 6 | 7 | Future checkVersion() async { 8 | var entrypoint = await findEntrypoint(); 9 | var exitCode = await runExecutable(entrypoint, 10); 10 | await flushThenExit(exitCode); 11 | } 12 | 13 | String findEntrypoint() { 14 | // 逻辑... 15 | return 'entrypoint'; 16 | } 17 | 18 | String runExecutable(String entrypoint, int args) { 19 | // 逻辑... 20 | return 'executable'; 21 | } 22 | 23 | String flushThenExit(String executable) { 24 | // 逻辑... 25 | return 'exit'; 26 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/10-async_demo/11-2-async&await/async_demo04.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | // 要在应用程序的main()函数中使用await,main()方法必须标记为async 4 | 5 | // 结果: 6 | // checkVersion() 7 | // lookUpVersion() 8 | // lookUpVersion() 9 | // In main: version is 版本号:v1.0 10 | Future main() async { 11 | checkVersion(); 12 | print('In main: version is ${await lookUpVersion()}'); 13 | } 14 | 15 | Future checkVersion() async { 16 | print('checkVersion()'); 17 | var version = await lookUpVersion(); 18 | } 19 | 20 | Future lookUpVersion() async{ 21 | print('lookUpVersion()'); 22 | return '版本号:v1.0'; 23 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/10-async_demo/11-3-define_asynchronous_function/define_demo.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | void main(){ 4 | lookUpVersion(); // 输出结果:lookUpVersion()同步方法 返回值是:1.0.0 5 | lookUpVersion2(); // 输出结果:lookUpVersion2()异步方法 返回值是:1.0.0 6 | lookUpVersion3(); // 输出结果:lookUpVersion3()异步方法 没有返回值 7 | } 8 | 9 | 10 | String lookUpVersion() { 11 | print('lookUpVersion()同步方法 返回值是:1.0.0'); 12 | return '1.0.0'; 13 | } 14 | 15 | // 返回值Future 16 | Future lookUpVersion2() async { 17 | print('lookUpVersion2()异步方法 返回值是:1.0.0'); 18 | return '1.0.0'; 19 | } 20 | 21 | // 返回值Future 22 | Future lookUpVersion3() async { 23 | print('lookUpVersion3()异步方法 没有返回值'); 24 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/10-async_demo/11-4-stream/stream_demo.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | import 'dart:convert'; 3 | 4 | void main() { 5 | test(); 6 | } 7 | 8 | // await for循环的使用示例 9 | // 这里是读取本地文件的内容 10 | Future test() async { 11 | var config = File('d:\\test.txt'); 12 | // 打开io流进行文件读取 13 | Stream> inputStream = config.openRead(); 14 | var lines = inputStream 15 | // 设置编码格式为utf-8 16 | .transform(utf8.decoder) 17 | .transform(LineSplitter()); 18 | try { 19 | await for (var line in lines) { 20 | print('从Stream中获取到的内容是: ${line} \r文本内容长度为:'+ 21 | '${line.length}\r======='); 22 | } 23 | print('文件现在没有关闭。。。'); 24 | } catch (e) { 25 | print(e); 26 | } 27 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/10-async_demo/test.txt: -------------------------------------------------------------------------------- 1 | 这是测试内容: 2 | 123456 3 | 文字 4 | abcdefg 5 | ABCDEFG -------------------------------------------------------------------------------- /projects/dart_demo/test/11-generator/generate_demo.dart: -------------------------------------------------------------------------------- 1 | void main() { 2 | // 返回一个Iterable对象 3 | Iterable naturalsTo(int n) sync* { 4 | int k = 0; 5 | while (k < n) yield k++; 6 | } 7 | 8 | // 生成器是递归的,您可以使用yield*提高性能 9 | Iterable naturalsDownFrom(int n) sync* { 10 | if (n > 0) { 11 | yield n; 12 | yield* naturalsDownFrom(n - 1); 13 | } 14 | } 15 | 16 | // 返回一个Stream对象 17 | Stream asynchronousNaturalsTo(int n) async* { 18 | int k = 0; 19 | while (k < n) yield k++; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /projects/dart_demo/test/12-isolate/isolates_demo.dart: -------------------------------------------------------------------------------- 1 | import 'dart:isolate'; 2 | import 'dart:io'; 3 | import 'dart:convert'; 4 | 5 | // 在另一个隔离区()中同步读取“D://file.json” 6 | // 结果是{msg: [{title: 你好1, contents: yes}, {title: 你好2, contents: NO}]} 7 | main() async { 8 | // 在其他隔离(isolate)中同步读取文件,然后对其进行解码。 9 | print(await readIsolate()); 10 | } 11 | 12 | // 同步读取'D//file.json'(在同一个线程中) 13 | Map readSync() { 14 | JsonCodec().decode(new File('D://file.json').readAsStringSync()); 15 | } 16 | 17 | // 在另一个隔离区()中同步读取“D://file.json” 18 | Future readIsolate() async { 19 | final response = new ReceivePort(); 20 | await Isolate.spawn(_isolate, response.sendPort); 21 | return response.first; 22 | } 23 | 24 | /// 期望通过[Isolate.spawn]创建 25 | void _isolate(SendPort sendPort) { 26 | sendPort.send(readSync()); 27 | } 28 | 29 | // 下面是file.json文件的内容: 30 | // { 31 | // "msg": [ 32 | // { 33 | // "title": "你好1", 34 | // "contents": "yes" 35 | // }, 36 | // { 37 | // "title": "你好2", 38 | // "contents": "NO" 39 | // } 40 | // ] 41 | // } 42 | -------------------------------------------------------------------------------- /projects/dart_demo/test/3-variable_and_constant/3-1-variable_and_constant1.dart: -------------------------------------------------------------------------------- 1 | void main() { 2 | // 1.变量的声明3种方式: 3 | var names1 = '张三'; 4 | Object names2 = '张三'; 5 | dynamic name3 = '李四'; 6 | } 7 | -------------------------------------------------------------------------------- /projects/dart_demo/test/3-variable_and_constant/3-2-variable_and_constant2.dart: -------------------------------------------------------------------------------- 1 | void main() { 2 | // 2.变量的默认值: 3 | int intDefaultValue; 4 | assert(intDefaultValue == null); 5 | print(intDefaultValue); // null 6 | } 7 | -------------------------------------------------------------------------------- /projects/dart_demo/test/4-datas-type/4-1-num_demo.dart: -------------------------------------------------------------------------------- 1 | void main() { 2 | test1(); 3 | test2(); 4 | } 5 | 6 | // int 示例 7 | void test1() { 8 | int intNum1 = 10; 9 | print(intNum1); //结果是10 10 | int intNum2 = 0xDEADBEEF; 11 | print(intNum2); //结果是3735928559 12 | 13 | // bitLength 返回存储此int整数所需的最小位数 14 | int a1 = 1; // 占了1个bit 相当于二进制数字 00000000 00000001 15 | int a2 = 12; // 占了4个bit 相当于二进制数字 00000000 00001100 16 | int a3 = 123; // 占了7个bit 相当于二进制数字 00000000 01111011 17 | int a4 = 1234; // 占了11个bit 相当于二进制数字 00000100 11010010 18 | print('${a1.bitLength}'); // 1 19 | print('${a2.bitLength}'); // 4 20 | print('${a3.bitLength}'); // 7 21 | print('${a4.bitLength}'); // 11 22 | } 23 | 24 | // double示例 25 | void test2() { 26 | double doubleNum1 = 1.1; 27 | print(doubleNum1); //结果是1.1 28 | double doubleNum2 = 1.42e5; 29 | print(doubleNum2); //结果是142000.0 30 | 31 | // int自动转double 32 | double test = 12; //打印结果是12.0 33 | print(test); //打印结果是12.0 34 | 35 | // 使用int的api转double 36 | int test2 = 10; 37 | print(test2.toDouble()); // 结果是: 10.0 38 | 39 | // double转int 40 | double test3 = 15.1; 41 | double test4 = 15.1234; 42 | print(test3.toInt()); // 结果是15 43 | print(test4.toInt()); // 结果是15 44 | } 45 | -------------------------------------------------------------------------------- /projects/dart_demo/test/4-datas-type/4-3-bool_demo.dart: -------------------------------------------------------------------------------- 1 | // bool示例 2 | void main() { 3 | test(); 4 | } 5 | 6 | void test() { 7 | 8 | // 检查是否为空字符串 9 | var emptyStr = ''; 10 | assert(emptyStr.isEmpty); 11 | 12 | // 检查是否为0 13 | var numberStr = 0; 14 | assert(numberStr <= 0); 15 | 16 | // 检查是否为null 17 | var nullStr; 18 | assert(nullStr == null); 19 | 20 | // 检查是否为NaN 21 | var value = 0 / 0; 22 | assert(value.isNaN); 23 | } 24 | -------------------------------------------------------------------------------- /projects/dart_demo/test/4-datas-type/4-4-list_demo.dart: -------------------------------------------------------------------------------- 1 | void main() { 2 | test(); 3 | test2(); 4 | } 5 | 6 | void test() { 7 | //创建一个int类型的list 8 | List list = [10, 7, 23]; 9 | print(list); // 输出结果 [10, 7, 23] 10 | 11 | // 要创建一个编译时常量const的list 12 | List constantList = const [10, 3, 15]; 13 | print(constantList); // 输出结果 [10, 3, 15] 14 | } 15 | 16 | void test2() { 17 | //把数字1添加到list中,默认是添加到末尾 18 | List list = [10, 7, 23]; 19 | list.add(1); 20 | print(list); // 输出结果 [10, 7, 23, 1] 21 | 22 | //移除数字1 23 | list.remove(1); 24 | print(list); // 输出结果 [10, 7, 23] 25 | 26 | //在索引为0的地方插入数字5 27 | list.insert(0, 5); 28 | print(list); // 输出结果 [5, 10, 7, 23] 29 | 30 | //查找10在list中的索引 31 | int value = list.indexOf(10); 32 | print(value); // 输出结果 1 33 | 34 | //查找list中是否包含数字5 35 | bool result = list.contains(5); 36 | print(result);// 输出结果 true 37 | 38 | } 39 | -------------------------------------------------------------------------------- /projects/dart_demo/test/4-datas-type/4-5-map_demo.dart: -------------------------------------------------------------------------------- 1 | void main() { 2 | test1(); 3 | test2(); 4 | } 5 | 6 | // 创建 7 | void test1() { 8 | // 直接声明 9 | Map companys = {'first': '阿里巴巴', 'second': '腾讯', 'fifth': '百度'}; 10 | print(companys); //打印结果 {first: 阿里巴巴, second: 腾讯, fifth: 百度} 11 | 12 | Map companys1 = new Map(); 13 | companys1['first'] = '阿里巴巴'; 14 | companys1['second'] = '腾讯'; 15 | companys1['fifth'] = '百度'; 16 | print(companys1); //打印结果 {first: 阿里巴巴, second: 腾讯, fifth: 百度} 17 | 18 | final fruitConstantMap = const {2: 'apple', 10: 'orange', 18: 'banana'}; 19 | print(fruitConstantMap); // {2: apple, 10: orange, 18: banana} 20 | } 21 | 22 | // 增删改查 23 | void test2() { 24 | Map companys = {'first': '阿里巴巴', 'second': '腾讯', 'fifth': '百度'}; 25 | 26 | //添加一个新的元素,key为“5”,value为“华为” 27 | companys[5] = '华为'; 28 | print(companys); //打印结果 {first: 阿里巴巴, second: 腾讯, fifth: 百度, 5: 华为} 29 | 30 | // 修改元素 31 | companys['first'] = 'alibaba'; 32 | print(companys); //打印结果 {first: alibaba, second: 腾讯, fifth: 百度, 5: 华为} 33 | 34 | // 查询元素 35 | bool mapKey = companys.containsKey('second'); 36 | bool mapValue = companys.containsValue('百度'); 37 | print(mapKey); //结果为:true 38 | print(mapValue); //结果为:true 39 | 40 | // 删除元素 41 | companys.remove('first'); // 移除key为“first”的元素。 42 | print(companys); // 打印结果{second: 腾讯, fifth: 百度, 5: 华为} 43 | 44 | companys.clear(); // 清空map集合的数据。 45 | print(companys); // 打印结果{} 46 | } 47 | -------------------------------------------------------------------------------- /projects/dart_demo/test/4-datas-type/4-6-runes_demo.dart: -------------------------------------------------------------------------------- 1 | // runes 字符(用于在字符串中表示Unicode字符) 2 | void main() { 3 | test(); 4 | } 5 | 6 | void test() { 7 | var clapping = '\u{1f44f}'; 8 | print(clapping); 9 | print(clapping.codeUnits); 10 | print(clapping.runes.toList()); 11 | 12 | //这里使用String.fromCharCodes方法显示字符图形 13 | Runes input = new Runes( 14 | '\u2665 \u{1f605} \u{1f60e} \u{1f47b} \u{1f596} \u{1f44d}'); 15 | print(new String.fromCharCodes(input)); 16 | } 17 | -------------------------------------------------------------------------------- /projects/dart_demo/test/6-control_flow_statements/6-1-if_else/if_else_demo.dart: -------------------------------------------------------------------------------- 1 | void main() { 2 | 3 | String text; 4 | int number = 50; 5 | String urlString = 'http://www.baidu.com/'; 6 | 7 | // 确保变量具有非空值 8 | assert(text != null); 9 | // 确保值小于100 10 | assert(number < 100); 11 | // 确保这是一个 https 网址 12 | assert(urlString.startsWith('https')); 13 | 14 | // 要将消息附加到断言,请添加一个字符串作为第二个参数。 15 | assert(urlString.startsWith('https'), 16 | 'URL ($urlString) should start with "https".'); 17 | } 18 | -------------------------------------------------------------------------------- /projects/dart_demo/test/6-control_flow_statements/6-2-for/for_demo1.dart: -------------------------------------------------------------------------------- 1 | void main() { 2 | for (int i = 0; i < 10; i++) { 3 | print(i); 4 | } 5 | 6 | // for循环内部的闭包获取索引的值。 7 | var array = []; 8 | for (var i = 0; i < 10; i++) { 9 | array.add(() => print(i)); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /projects/dart_demo/test/6-control_flow_statements/6-2-for/for_demo2.dart: -------------------------------------------------------------------------------- 1 | void main() { 2 | var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]; 3 | numbers.forEach((number)=> print(number)); 4 | } 5 | -------------------------------------------------------------------------------- /projects/dart_demo/test/6-control_flow_statements/6-2-for/for_demo3.dart: -------------------------------------------------------------------------------- 1 | void main() { 2 | var list = [1, 2, 3]; 3 | for (var data in list) { 4 | print(data); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /projects/dart_demo/test/6-control_flow_statements/6-3-while&do_while/while_demo.dart: -------------------------------------------------------------------------------- 1 | void main() { 2 | int a = 10; 3 | while (a > 5) { 4 | print(a); 5 | } 6 | 7 | do { 8 | print(a); 9 | } while (a > 5); 10 | } 11 | -------------------------------------------------------------------------------- /projects/dart_demo/test/6-control_flow_statements/6-4-break&continue/break&continue_demo.dart: -------------------------------------------------------------------------------- 1 | void main() { 2 | int a = 10; 3 | int b = 15; 4 | while (a > 5) { 5 | if (b > 5) { 6 | print(a); 7 | break; 8 | } 9 | } 10 | 11 | while (a > 5) { 12 | if (b < 10) { 13 | print(b); 14 | continue; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /projects/dart_demo/test/6-control_flow_statements/6-5-switch&case/switch_case_demo.dart: -------------------------------------------------------------------------------- 1 | void main() { 2 | var command = 'OPEN'; 3 | switch (command) { 4 | case 'CLOSED': 5 | executeClosed(); 6 | break; 7 | case 'PENDING': 8 | executePending(); 9 | break; 10 | case 'APPROVED': 11 | executeApproved(); 12 | break; 13 | case 'DENIED': 14 | executeDenied(); 15 | break; 16 | case 'OPEN': 17 | executeOpen(); 18 | break; 19 | default: 20 | executeUnknown(); 21 | } 22 | } 23 | 24 | executeClosed(){} 25 | executePending(){} 26 | executeApproved(){} 27 | executeDenied(){} 28 | executeOpen(){} 29 | executeUnknown(){} -------------------------------------------------------------------------------- /projects/dart_demo/test/6-control_flow_statements/6-6-assert/assert_demo.dart: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/dart_demo/test/6-control_flow_statements/6-6-assert/assert_demo.dart -------------------------------------------------------------------------------- /projects/dart_demo/test/7-exception/exception_demo.dart: -------------------------------------------------------------------------------- 1 | void main() { 2 | test1('a123'); 3 | test2(); 4 | test3(); 5 | misbehave(); 6 | test4(); 7 | 8 | try { 9 | misbehave(); 10 | } catch (e) { 11 | print('main() finished handling ${e.runtimeType}.'); 12 | } 13 | } 14 | 15 | void test1(String num) { 16 | if (num.startsWith('a')) { 17 | print(num); 18 | } else { 19 | throw FormatException('格式化错误'); 20 | } 21 | } 22 | 23 | void test2() => throw FormatException('格式化错误'); 24 | 25 | test3() { 26 | // try { 27 | // breedMoreLlamas(); 28 | // } on Exception { 29 | // buyMoreLlamas(); 30 | // } 31 | 32 | // 也可以两个参数的catch 33 | try { 34 | // ··· 35 | } on Exception catch (e) { 36 | print('Exception details:\n $e'); 37 | } catch (e, s) { 38 | print('Exception details:\n $e'); 39 | print('Stack trace:\n $s'); 40 | } 41 | } 42 | 43 | breedMoreLlamas() {} 44 | buyMoreLlamas() {} 45 | cleanLlamaStalls() {} 46 | 47 | void misbehave() { 48 | try { 49 | dynamic foo = true; 50 | print(foo++); // 运行时异常 51 | } catch (e) { 52 | print('misbehave() partially handled ${e.runtimeType}.'); 53 | rethrow; // 允许调用者查看exception. 54 | } 55 | } 56 | 57 | test4() { 58 | try { 59 | breedMoreLlamas(); 60 | } finally { 61 | // 即使抛出异常 也会执行这句代码. 62 | cleanLlamaStalls(); 63 | } 64 | // 该finally子句在任何匹配的catch子句之后运行: 65 | try { 66 | breedMoreLlamas(); 67 | } catch (e) { 68 | // 首先会处理异常 69 | print('Error: $e'); 70 | } finally { 71 | // 然后执行这句语句 72 | cleanLlamaStalls(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/1-class-type/1-common-class/1-common_class.dart: -------------------------------------------------------------------------------- 1 | // 普通类 2 | void main(){ 3 | new Test().tests(); 4 | } 5 | class Test{ 6 | void tests(){} 7 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/1-class-type/1-common-class/2-object_type.dart: -------------------------------------------------------------------------------- 1 | // 对象类型 2 | void main(){ 3 | var a = 10; 4 | var b = 10.0; 5 | var c = '10'; 6 | var d = true; 7 | var e = [12.5,13.1]; 8 | var f = {3:'5',5:'11'}; 9 | var t = new Test(); 10 | print('a 的类型是: ${a.runtimeType}'); // a 的类型是: int 11 | print('b 的类型是: ${b.runtimeType}'); // b 的类型是: double 12 | print('c 的类型是: ${c.runtimeType}'); // c 的类型是: String 13 | print('d 的类型是: ${d.runtimeType}'); // d 的类型是: bool 14 | print('e 的类型是: ${e.runtimeType}'); // e 的类型是: List 15 | print('f 的类型是: ${f.runtimeType}'); // f 的类型是: _InternalLinkedHashMap 16 | print('t 的类型是: ${t.runtimeType}'); // t 的类型是: Test 17 | 18 | } 19 | class Test{ 20 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/1-class-type/1-common-class/3-exdtend_a_class/3-extends_demo.dart: -------------------------------------------------------------------------------- 1 | // 继承一个类 示例代码 2 | class Test { 3 | void test() { 4 | print('Test ==> test()'); 5 | } 6 | // ··· 7 | } 8 | 9 | class TestChild extends Test { 10 | // @override标注在test()函数上面 表示test()函数是重写父类的 11 | @override 12 | void test() { 13 | super.test(); 14 | print('TestChild ==> test()'); 15 | } 16 | // ··· 17 | } 18 | 19 | // @deprecated的使用 表示过时方法 20 | class Television { 21 | @deprecated 22 | void activate() { 23 | turnOn(); 24 | } 25 | 26 | void turnOn() { 27 | //... 28 | } 29 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/1-class-type/1-common-class/3-exdtend_a_class/4-annotation_demo.dart: -------------------------------------------------------------------------------- 1 | // 定义元数据 2 | library todo; 3 | 4 | class Todo { 5 | final String who; 6 | final String what; 7 | const Todo(this.who, this.what); 8 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/1-class-type/1-common-class/3-exdtend_a_class/5-annotation_use.dart: -------------------------------------------------------------------------------- 1 | import '4-annotation_demo.dart'; 2 | 3 | void main(){ 4 | doSomething(); 5 | } 6 | 7 | // 以下是使用@todo注释的示例: 8 | @Todo('seth', 'make this do something') 9 | void doSomething() { 10 | print('do something'); 11 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/1-class-type/1-common-class/4-static_variable.dart: -------------------------------------------------------------------------------- 1 | 2 | // 静态变量和方法 3 | void main() { 4 | assert(Test. a == 16); 5 | print(Point.area(5, 4)); 6 | } 7 | 8 | // 静态变量 9 | class Test { 10 | static const num a = 16; 11 | // ··· 12 | } 13 | 14 | 15 | // 静态方法 16 | class Point { 17 | static num area(num x, num y) { 18 | return (x * y)/2; 19 | } 20 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/1-class-type/1-common-class/5-operator_demo.dart: -------------------------------------------------------------------------------- 1 | ////// 重写运算符 /////// 2 | 3 | void main() { 4 | final a = Testoperator(2, 3); 5 | final b = Testoperator(2, 2); 6 | var num1 = Testoperator(4, 5); 7 | var num2= Testoperator(0,1); 8 | print(a + b == num1); // true 9 | print(a - b == num2); // true 10 | 11 | } 12 | 13 | ////// 重写+ 和 - 运算符 /////// 14 | class Testoperator { 15 | final int x, y; 16 | 17 | Testoperator(this.x, this.y); 18 | 19 | Testoperator operator +(Testoperator o) => Testoperator(x + o.x, y + o.y); 20 | Testoperator operator -(Testoperator o) => Testoperator(x - o.x, y - o.y); 21 | 22 | // Operator == and hashCode not shown. For details, see note below. 23 | // ··· 24 | 25 | // Override hashCode using strategy from Effective Java, Chapter 11. 26 | @override 27 | int get hashCode { 28 | int result = 17; 29 | result = 37 * result + x.hashCode; 30 | result = 37 * result + y.hashCode; 31 | return result; 32 | } 33 | 34 | // You should generally implement operator == if you override hashCode. 35 | @override 36 | bool operator ==(dynamic other) { 37 | if (other is! Testoperator) return false; 38 | Testoperator person = other; 39 | return (person.x == x && person.y == y); 40 | } 41 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/1-class-type/1-common-class/6-nosuchmethod_demo.dart: -------------------------------------------------------------------------------- 1 | /////////// 重写 noSuchMethod //////////////// 2 | 3 | void main() { 4 | TestMethod test = new TestMethod(); 5 | dynamic f = test.foo; 6 | // Invokes `Object.noSuchMethod`, not `TestMethod.noSuchMethod`, so it throws. 7 | f(42); 8 | } 9 | 10 | 11 | class TestMethod { 12 | // 除非你重写noSuchMethod,否则使用不存在的成员会导致NoSuchMethodError 13 | @override 14 | dynamic noSuchMethod(Invocation i) { 15 | print('You tried to use a non-existent member: ' + 16 | '${i.memberName}'); 17 | } 18 | 19 | dynamic foo(); 20 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/1-class-type/2-abstract_class/1-abstract_demo.dart: -------------------------------------------------------------------------------- 1 | // 此类声明为abstract,因此无法实例化 2 | abstract class Test { 3 | //定义构造函数,字段,方法... 4 | 5 | // 抽象方法 6 | void test(); 7 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/1-class-type/2-abstract_class/2-abstract_demo.dart: -------------------------------------------------------------------------------- 1 | // 隐式接口 2 | void main() { 3 | print(sayHello(Person('李四'))); // 你好 张三. 我是 李四. 4 | print(sayHello(PersonImpl())); // 你好 张三 你知道我是谁吗? 5 | } 6 | 7 | // Person类 隐式接口包含hello() 8 | class Person { 9 | // 在接口中,但是仅在此库中可见。 10 | final _name; 11 | 12 | // 不在接口中,因为这是一个构造函数 13 | Person(this._name); 14 | 15 | // 在接口中 16 | String hello(String who) => '你好 $who. 我是 $_name.'; 17 | } 18 | 19 | // Person接口的实现 20 | class PersonImpl implements Person { 21 | get _name => ''; 22 | 23 | String hello(String name) => '你好 $name 你知道我是谁吗?'; 24 | } 25 | 26 | String sayHello(Person person) => person.hello('张三'); 27 | 28 | // 一个类也可以实现多个接口,例如: 29 | class ZhangSan implements Run,Life { 30 | //... 31 | } 32 | class Run {} 33 | class Life {} -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/1-class-type/3-callable_class/callable_class_demo.dart: -------------------------------------------------------------------------------- 1 | // 可调用的类(Callable Class) 2 | void main() { 3 | var test = new Test(); 4 | var result = test(166.6665,"Flutter真好玩",672); 5 | print("$result");// 666.666 Flutter真好玩 666 6 | } 7 | class Test { 8 | // 必须是call函数 9 | call(double a, String b, int c) => '${a*4} ${b} ${c-6}'; 10 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/1-class-type/4-enum/enum_demo.dart: -------------------------------------------------------------------------------- 1 | //枚举示例 2 | 3 | void main() { 4 | // 判断枚举的索引值是多少 5 | assert(Color.red.index == 0); 6 | print(Color.green.index == 1); 7 | print(Color.blue.index == 2); 8 | 9 | // 获取枚举中所有值的列表 10 | List colors = Color.values; 11 | print(colors[2] == Color.blue); 12 | 13 | // switch中使用枚举 14 | var aColor = Color.blue; 15 | switch (aColor) { 16 | case Color.red: 17 | print('Red'); 18 | break; 19 | case Color.green: 20 | print('Green'); 21 | break; 22 | default: // 你没有这个 你会看到一个警告 23 | print(aColor); // 'Color.blue' 24 | } 25 | } 26 | 27 | // 声明枚举类型 28 | enum Color { red, green, blue } 29 | -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/1-class-type/5-mixin/1-create_mixin.dart: -------------------------------------------------------------------------------- 1 | // mixin 2 | 3 | 4 | // 声明mixin 5 | 6 | // 专家 7 | mixin Expert { 8 | // 发现和解决难题 9 | bool solveProblems = false; 10 | 11 | // 精通数据结构和算法 12 | bool dataStructureAndAlgorithms = false; 13 | 14 | // 会架构设计 15 | bool architectureDesign = false; 16 | 17 | // 性能优化 18 | bool performanceOptimization = false; 19 | 20 | // 熟练掌握计算机系统 21 | bool computerSystem = false; 22 | 23 | void develop() { 24 | // 娱乐节目 25 | if (solveProblems) { 26 | print('发现和解决难题'); 27 | } 28 | if (dataStructureAndAlgorithms) { 29 | print('精通数据结构和算法'); 30 | } 31 | if (architectureDesign) { 32 | print('会架构设计'); 33 | } 34 | if (performanceOptimization) { 35 | print('熟练掌握性能优化'); 36 | } 37 | if (computerSystem) { 38 | print('熟练掌握计算机系统'); 39 | } 40 | } 41 | } 42 | 43 | // 特性 44 | 45 | // 有效率的 46 | mixin Efficient { 47 | void getEfficientAttrs() { 48 | print('有效率的'); 49 | } 50 | } 51 | 52 | // 和蔼的 53 | mixin Kind { 54 | void getKindAttrs() { 55 | print('和蔼的'); 56 | } 57 | } 58 | 59 | // 软件架构师 60 | class SoftwareArchitect { 61 | SoftwareArchitect() { 62 | print('软件架构师'); 63 | } 64 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/1-class-type/5-mixin/2-use_mixin.dart: -------------------------------------------------------------------------------- 1 | import '1-create_mixin.dart'; 2 | 3 | // 使用mixin 4 | 5 | void main() { 6 | // 姓名:张三 7 | // 发现和解决难题 8 | // 精通数据结构和算法 9 | // 会架构设计 10 | ACompanySoftwareArchitect architect1 = new ACompanySoftwareArchitect('张三'); 11 | architect1.develop(); 12 | print('===='); 13 | // 姓名:李四 14 | // 发现和解决难题 15 | // 精通数据结构和算法 16 | // 会架构设计 17 | // 熟练掌握性能优化 18 | // 熟练掌握计算机系统 19 | // 有效率的 20 | // 和蔼的 21 | BCompanySoftwareArchitect architect2 = new BCompanySoftwareArchitect('李四'); 22 | architect2.develop(); 23 | architect2.getEfficientAttrs(); 24 | architect2.getKindAttrs(); 25 | } 26 | 27 | 28 | // 使用mixin 29 | 30 | // A公司的软件架构师,继承自软件架构师,拥有专家的特性。 31 | class ACompanySoftwareArchitect extends SoftwareArchitect with Expert { 32 | String name; 33 | ACompanySoftwareArchitect(String name) { 34 | this.name = name; 35 | print('姓名:' + name); 36 | solveProblems = true; 37 | dataStructureAndAlgorithms = true; 38 | architectureDesign = true; 39 | } 40 | 41 | @override 42 | void develop() { 43 | super.develop(); 44 | } 45 | } 46 | 47 | // B公司的软件架构师,继承自软件架构师, 48 | class BCompanySoftwareArchitect extends SoftwareArchitect 49 | with Expert, Efficient, Kind { 50 | String name; 51 | 52 | BCompanySoftwareArchitect(String name) { 53 | this.name = name; 54 | print('姓名:' + name); 55 | solveProblems = true; 56 | dataStructureAndAlgorithms = true; 57 | architectureDesign = true; 58 | performanceOptimization = true; 59 | computerSystem = true; 60 | } 61 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/1-class-type/5-mixin/3-use_mixin2.dart: -------------------------------------------------------------------------------- 1 | import '2-use_mixin.dart'; 2 | 3 | // 要指定只有某些类型可以使用mixin 4 | mixin SoftwareDeveloper on ACompanySoftwareArchitect{} -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/2-generics/1-why_use_enerics.dart: -------------------------------------------------------------------------------- 1 | // 泛型 demo 2 | void main() { 3 | var names = List(); 4 | names.addAll(['Seth', 'Kathy', 'Lars']); 5 | // 报错 The argument type 'int' can't be assigned to the parameter type 'String'. 6 | // names.add(42); 7 | 8 | // 使用泛型以前的调用方式 9 | print(new Test1().getByKey('123')); 10 | print(new Test2().getByKey('456')); 11 | // 使用泛型之后的调用方式 12 | } 13 | 14 | // 使用泛型以前 15 | abstract class ObjectCache { 16 | Object getByKey(String key); 17 | void setByKey(String key, Object value); 18 | } 19 | 20 | abstract class StringCache { 21 | String getByKey(String key); 22 | void setByKey(String key, String value); 23 | } 24 | 25 | class Test1 extends ObjectCache { 26 | @override 27 | Object getByKey(String key) { 28 | return 'object cache'; 29 | } 30 | 31 | @override 32 | void setByKey(String key, Object value) { 33 | return null; 34 | } 35 | } 36 | 37 | class Test2 extends StringCache { 38 | @override 39 | String getByKey(String key) { 40 | return 'String cache'; 41 | } 42 | 43 | @override 44 | void setByKey(String key, String value) { 45 | return null; 46 | } 47 | } 48 | 49 | // 使用泛型来减少代码重复 50 | abstract class Cache { 51 | T getByKey(T key); 52 | } 53 | 54 | class Test3 extends Cache { 55 | @override 56 | String getByKey(String key) { 57 | // TODO: implement getByKey 58 | return null; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/2-generics/2-use_list.dart: -------------------------------------------------------------------------------- 1 | // 泛型 demo 2 | // list或map中使用泛型 3 | void main() { 4 | var numbers = ['11', '22', '33']; 5 | var pages = { 6 | 'index.html': 'Homepage', 7 | 'store.html': 'Store', 8 | 'mine.html': 'Mine' 9 | }; 10 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/2-generics/3-with-constructor_params.dart: -------------------------------------------------------------------------------- 1 | // 泛型 demo 2 | // 使用带有构造函数的参数化类型 3 | void main() { 4 | var names = List(); 5 | names.addAll(['Seth', 'Kathy', 'Lars']); 6 | 7 | // Set类带有一个泛型 from是一个工厂函数 8 | // abstract class Set extends EfficientLengthIterable 9 | // factory Set.from(Iterable elements) = LinkedHashSet.from; 10 | var nameSet = Set.from(names); 11 | } 12 | -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/2-generics/4-generis_list.dart: -------------------------------------------------------------------------------- 1 | // 泛型 demo 2 | // 泛型集合及其包含的类型 3 | void main() { 4 | var names = List(); 5 | names.addAll(['Seth', 'Kathy', 'Lars']); 6 | print(names is List);// true 7 | print(names.runtimeType);// List 8 | } 9 | -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/2-generics/5-limit_params_type.dart: -------------------------------------------------------------------------------- 1 | // 泛型 demo 2 | // 限制参数类型 3 | void main() { 4 | var someBaseClassFoo = Foo(); 5 | var extenderFoo = Foo(); 6 | 7 | print(someBaseClassFoo.toString());// Instance of Foo 8 | print(extenderFoo.toString());// Instance of Foo 9 | 10 | // 不指定泛型参数也可以使用。 11 | var foo = Foo(); 12 | print(foo); // Instance of 'Foo' 13 | //等同于print(foo.toString()); 14 | print(foo.toString()); // Instance of 'Foo' 15 | 16 | // 如果指定任何非SomeBaseClass类型会导致错误。 17 | // var foo2 = Foo; 18 | 19 | 20 | } 21 | 22 | abstract class SomeBaseClass { 23 | // 其他操作 24 | } 25 | 26 | class Foo { 27 | String toString() { 28 | return "Instance of Foo<$T>"; 29 | } 30 | } 31 | 32 | class Extender extends SomeBaseClass { 33 | //其他操作 34 | } 35 | -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/2-generics/6-generis_methods.dart: -------------------------------------------------------------------------------- 1 | // 泛型 demo 2 | // 泛型方法:使用在类和方法上 3 | void main() { 4 | List data = ["张三","李四","王五"]; 5 | var result = first(data); 6 | print(result); 7 | } 8 | 9 | // 在以下几个地方使用类型参数T: 10 | // 返回类型T, 参数类型List, 局部变量的类型T tmp 11 | T first(List data) { 12 | // 做一些初始工作或错误检查... 13 | T tmp = data[0]; 14 | // 做一些额外的检查或处理... 15 | return tmp; 16 | } 17 | 18 | class Test { 19 | static int first(int x) => 3; 20 | int second(int y) => 5; 21 | } 22 | 23 | void functionTypedParameter(T callback){} 24 | 25 | void localFunction(){ 26 | T itself(T thing) => thing; 27 | } 28 | 29 | void functionExpression(){ 30 | var lambda = (T thing) => thing; 31 | } 32 | -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/1-common_functions/1-method_write.dart: -------------------------------------------------------------------------------- 1 | // 函数的简写 2 | 3 | // 1.对于只有一个表达式的函数,可以简写 4 | // 操作前: 5 | // void main(){ 6 | // runApp(new MyApp()); 7 | // } 8 | // 操作后:(main.dart文件里面默认使用的是==>箭头符号) 9 | // 箭头符号 10 | // void main() => runApp(new MyApp()); 11 | 12 | // 2. 返回值为void时,可以省略void关键字 13 | void main() { 14 | 15 | // 函数属于Funtion类型 16 | assert(_incrementCounter() is Function); 17 | } 18 | 19 | // 省略前 20 | // void _incrementCounter() { 21 | //TODO:... 22 | // } 23 | 24 | // 省略后 25 | _incrementCounter() { 26 | //TODO:... 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/1-common_functions/10-method_abstract.dart: -------------------------------------------------------------------------------- 1 | // 抽象方法示例 2 | 3 | abstract class Test { 4 | //定义实例变量和方法... 5 | 6 | //定义一个抽象方法 7 | void doSomething(); 8 | } 9 | 10 | class TestImpl extends Test { 11 | // 抽象方法的实现 12 | void doSomething(){ 13 | // 具体的实现... 14 | } 15 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/1-common_functions/11-method_static.dart: -------------------------------------------------------------------------------- 1 | // 静态方法 2 | void main() { 3 | print(Point.area(5, 4)); // 10 4 | } 5 | 6 | class Point { 7 | static num area(num x, num y) { 8 | return (x * y) / 2; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/1-common_functions/2-choosable_functuons/method_choosable.dart: -------------------------------------------------------------------------------- 1 | 2 | // 可选参数使用: 3 | void main() { 4 | 5 | 6 | // 普通参数使用: 7 | 8 | //你随意使用其中的参数都是可以的,例如我使用了其中的参数1,参数4和参数5 9 | work2(address:'hangzhou', workTime:'9:00-5:00', workerNumbers:500); 10 | 11 | // 可选参数使用: 12 | 13 | // 缺一个参数都会报错 14 | work('hangzhou','XXCompany',1000000.00,'9:00-5:00',500); 15 | } 16 | 17 | 18 | 19 | // 工作:地址、公司名、工资、工作时长、公司人数 20 | void work(String address, String cpompany, double money, String workTime, 21 | int workerNumbers) { 22 | //TODO:... 23 | } 24 | 25 | // 设置了可选参数 26 | void work2({String address, String cpompany, double money, String workTime, 27 | int workerNumbers}) { 28 | //TODO:... 29 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/1-common_functions/2-choosable_functuons/method_choosable2.dart: -------------------------------------------------------------------------------- 1 | // 可选参数的默认值 2 | void work3( 3 | {String address = 'hangzhou', 4 | String cpompany = ' XXCompany ', 5 | double money, 6 | String workTime, 7 | int workerNumbers}) { 8 | //TODO:... 9 | } 10 | -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/1-common_functions/2-choosable_functuons/method_choosable3.dart: -------------------------------------------------------------------------------- 1 | // 普通函数的参数是一个匿名List集合,使用 = 设置默认值,比如address默认值为'hangzhou' 2 | void work4(String address, 3 | [String cpompany = ' XXCompany ', 4 | double money, 5 | String workTime, 6 | int workerNumbers]) { 7 | //TODO:... 8 | } 9 | -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/1-common_functions/2-choosable_functuons/method_choosable4.dart: -------------------------------------------------------------------------------- 1 | // 可变参数可以是显示声明的List集合或者map 2 | void work5( 3 | {List list = const [10, 20, 30], 4 | Map gifts = const { 5 | 'cpompany': 'XXCompany', 6 | 'money': '50000', 7 | 'workTime': '9:00-5:00', 8 | }}) { 9 | //TODO:... 10 | } 11 | -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/1-common_functions/3-method_params.dart: -------------------------------------------------------------------------------- 1 | // 函数作为参数穿个另一个函数 2 | void main() { 3 | // 例如main.dart里面FloatingActionButton的onPressed参数引入了一个_incrementCounter()函数 4 | // floatingActionButton: new FloatingActionButton(onPressed: _incrementCounter,), 5 | } 6 | 7 | 8 | void _incrementCounter() { 9 | // setState(() { 10 | // _counter++; 11 | // }); 12 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/1-common_functions/4-method_noname.dart: -------------------------------------------------------------------------------- 1 | // 匿名函数 2 | void main() { 3 | void _incrementCounter() { 4 | //setState函数就用到了匿名函数 5 | // setState(() { 6 | // _counter++; 7 | // }); 8 | } 9 | 10 | // 11 | List list = [10, 7, 23]; 12 | list.forEach((item) { 13 | print('$item'); 14 | }); 15 | 16 | list.forEach((item) => print('$item')); 17 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/1-common_functions/5-method_resolution.dart: -------------------------------------------------------------------------------- 1 | // 语法作用域 2 | 3 | bool topLevel = true; 4 | 5 | void main() { 6 | var insideMain = true; 7 | 8 | void myFunction() { 9 | var insideFunction = true; 10 | 11 | void nestedFunction() { 12 | var insideNestedFunction = true; 13 | 14 | print('topLevel\r'); 15 | print(topLevel); 16 | print('insideMain\r'); 17 | print(insideMain); 18 | print('insideFunction\r'); 19 | print(insideFunction); 20 | print('insideNestedFunction\r'); 21 | print(insideNestedFunction); 22 | } 23 | 24 | // print('topLevel\r'); 25 | // print(topLevel); 26 | // print('insideMain\r'); 27 | // print(insideMain); 28 | // print('insideFunction\r'); 29 | // print(insideFunction); 30 | 31 | // 调用函数nestedFunction 32 | nestedFunction(); 33 | 34 | } 35 | 36 | // 调用函数myFunction 37 | myFunction(); 38 | 39 | // print('topLevel\r'); 40 | // print(topLevel); 41 | // print('insideMain\r'); 42 | // print(insideMain); 43 | } 44 | 45 | //函数只能打印它的外层以及它里面的变量,前提是要被调用 46 | // main函数里面可以输出topLevel和insideMain的值。 47 | // myFunction函数里面可以输出topLevel、insideMain和insideFunction的值。 48 | // nestedFunction函数里面可以输出topLevel、insideMain、insideFunction和insideNestedFunction的值。 -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/1-common_functions/6-method_closure.dart: -------------------------------------------------------------------------------- 1 | // 借鉴js的闭包的5种方式 来聊聊闭包在Dart中的使用 2 | void main() { 3 | var result = test(); 4 | print(result(2.0)); 5 | // 变量作用域为函数内部,外部无法访问 6 | // print(result.PI); 7 | 8 | //外部要访问方法内部的变量,可以使用闭包 9 | var result2 = test2(); 10 | print(result2()); 11 | } 12 | 13 | //js闭包写法 14 | // var Circle = new Function( 15 | // "this.PI = 3.14; 16 | // this.area = function( r ) { 17 | // return r*r*this.PI; 18 | // }" 19 | // ); 20 | 21 | // 转换成Dart语言就是这样的: 22 | // 内部函数为有参数的匿名函数示例: 23 | Function test() { 24 | const PI = 3.14; 25 | return (double r) => r * r * PI; 26 | } 27 | 28 | // 内部函数为无参数的匿名函数示例: 29 | Function test2() { 30 | const PI = 3.14; 31 | return () => PI; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/1-common_functions/7-method_equals.dart: -------------------------------------------------------------------------------- 1 | //函数也是对象 2 | 3 | void topMethod() {} // 一个顶级函数 4 | 5 | class Demo { 6 | static void staticMethod() {} //一个静态方法 7 | void caseMethod() {} //实例方法 8 | } 9 | 10 | void main() { 11 | var compareVar; 12 | 13 | // 比较顶级的函数 14 | compareVar = topMethod; 15 | print(topMethod == compareVar); 16 | 17 | // 比较静态方法 18 | compareVar = Demo.staticMethod; 19 | print(Demo.staticMethod == compareVar); 20 | 21 | // 比较实例方法 22 | var demo1 = Demo(); // Demo类的实例1 23 | var demo2 = Demo(); // Demo类的实例2 24 | var y = demo2; 25 | compareVar = demo2.caseMethod; 26 | 27 | //这些闭包指向同一个实例demo2,所以它们相等。 28 | print(y.caseMethod == compareVar); 29 | 30 | //这些闭包是指不同的实例,所以他们不平等。 31 | print(demo1.caseMethod != demo2.caseMethod); 32 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/1-common_functions/8-method_alias.dart: -------------------------------------------------------------------------------- 1 | // 当看到用typedef定义函数别名的时候,不自觉的想到了函数指针 2 | 3 | void main(){ 4 | 5 | // 3. main函数里面使用Demo类,给mFunction参数传入一个函数 6 | 7 | int test(Object a, Object b) => 0; 8 | 9 | Demo demo = Demo(test); 10 | print(demo.funs is Function); // true 11 | print(demo.funs is Demo); // false 12 | 13 | } 14 | 15 | 16 | // 1.给Function取一个别名叫做TypedefFuns 17 | typedef TypedefFuns = int Function(Object a, Object b); 18 | 19 | 20 | // 2. Demo类里的构造方法使用这个别名 21 | class Demo { 22 | TypedefFuns funs; 23 | Demo(this.funs); 24 | } 25 | 26 | 27 | 28 | 29 | // Flutter源码FloatingActionButton里面的typedef使用 30 | // final VoidCallback onPressed; 31 | 32 | // class FloatingActionButton{ 33 | // const FloatingActionButton({this.onPressed,String name}); 34 | // } 35 | 36 | // get set可以不要 37 | // VoidCallback get onMetricsChanged => _onMetricsChanged; 38 | // VoidCallback _onMetricsChanged; 39 | 40 | // set onMetricsChanged(VoidCallback callback) { 41 | // _onMetricsChanged = callback; 42 | // } 43 | -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/1-common_functions/9-get_and_set/get_set_demo1.dart: -------------------------------------------------------------------------------- 1 | // getter setter 测试代码 2 | void main() { 3 | var rect = Rectangle(3, 4, 20, 15); 4 | print(rect.left == 3); 5 | rect.right = 12; 6 | print(rect.left == -8); 7 | } 8 | 9 | class Rectangle { 10 | num left, top, width, height; 11 | 12 | Rectangle(this.left, this.top, this.width, this.height); 13 | 14 | num get right => left + width; 15 | set right(num value) => left = value - width; 16 | num get bottom => top + height; 17 | set bottom(num value) => top = value - height; 18 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/1-common_functions/9-get_and_set/get_set_demo2.dart: -------------------------------------------------------------------------------- 1 | 2 | // 所有实例变量都生成一个隐式getter方法 3 | // 非final实例变量也会生成隐式setter方法 4 | void main() { 5 | var point = Point(); 6 | point.x = 4; // Use the setter method for x. 7 | assert(point.x == 4); // Use the getter method for x. 8 | assert(point.y == null); // Values default to null. 9 | 10 | var point2 = Point2(); 11 | point2.x = 4; // 12 | } 13 | 14 | 15 | class Point { 16 | num x; 17 | num y; 18 | } 19 | 20 | class Point2 { 21 | num x = 10; 22 | num y = 5; 23 | Point2 p = new Point2();//p在构造函数之前执行 24 | Point2(){} 25 | } 26 | -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/2-constructor_functions/1-constructor_common.dart: -------------------------------------------------------------------------------- 1 | 2 | // 最常见的构造函数形式 3 | void main(){ 4 | new Test(3, 4); // x:3, y:4 5 | } 6 | 7 | class Test { 8 | num x, y; 9 | 10 | Test(num x, num y) { 11 | this.x = x;//this.x指向的是当前Test类里面的变量num x 12 | this.y = y; 13 | print('x:$x, y:$y'); 14 | } 15 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/2-constructor_functions/2-constructor_params.dart: -------------------------------------------------------------------------------- 1 | // Dart具有语法糖,可以将构造函数参数赋值给实例变量 2 | void main() { 3 | new Test1(3, 4); // x:3, y:4 4 | } 5 | 6 | class Test1 { 7 | num x, y; 8 | 9 | // 构造函数运行之前设置x和y 10 | Test1(this.x, this.y) { 11 | print('x:$x, y:$y'); 12 | } 13 | 14 | // 没有内容体 可以简写 15 | // Test1(num x, num y); 16 | } 17 | 18 | class Test2 { 19 | num x, y; 20 | 21 | // 没有内容体 可以简写 22 | Test2(num x, num y); 23 | } 24 | -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/2-constructor_functions/3-constructor_default.dart: -------------------------------------------------------------------------------- 1 | // 空参构造 2 | void main() { 3 | new Test(); 4 | } 5 | 6 | class Test { 7 | 8 | // 如果不写 默认就是空参构造 9 | Test() { 10 | print('默认构造函数'); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/2-constructor_functions/4-constructor_named.dart: -------------------------------------------------------------------------------- 1 | // 命名构造 2 | void main() { 3 | new Test.help(); 4 | } 5 | 6 | class Test{ 7 | var x, y; 8 | Test(){ 9 | print('这是 Test 类的空参构造');//Test.help() 命名函数 x=5, y = 10 10 | } 11 | // 命名构造 12 | Test.help(){ 13 | x = 5; 14 | y = 10; 15 | print('Test.help() 命名函数 x=${x}, y = ${y}'); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/2-constructor_functions/5-constructor_not_extends.dart: -------------------------------------------------------------------------------- 1 | // 构造不能被继承 2 | void main() { 3 | // 先执行Test类的空参构造, 再执行TestChild类的空参构造。 4 | // 这是 Test 类的空参构造 5 | // 这是 TestChild 类的空参构造 6 | new TestChild(); 7 | 8 | // 调用时会报错 9 | // new TestChild.help(); 10 | } 11 | 12 | class Test{ 13 | var x, y; 14 | Test(){ 15 | print('这是 Test 类的空参构造'); 16 | } 17 | // 命名构造不能被继承 18 | Test.help(){ 19 | x = 5; 20 | y = 10; 21 | print('Test.help() 命名函数 x=${x}, y = ${y}'); 22 | } 23 | } 24 | 25 | class TestChild extends Test{ 26 | var x, y; 27 | TestChild(){ 28 | print('这是 TestChild 类的空参构造'); 29 | } 30 | // 加上与父类相同的命名构造就不会错 注释了就会报错 31 | // TestChild.help(){ 32 | // x = 3; 33 | // y = 2; 34 | // print('TestChild.help() 命名函数 x=${x}, y = ${y}'); 35 | // } 36 | } 37 | -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/2-constructor_functions/6-calling-process/calling-process1.dart: -------------------------------------------------------------------------------- 1 | // 构造函数调用流程 2 | void main() { 3 | // Test 空参构造 4 | // TestChild 有参构造 5 | // 面积为:6.0 6 | var result = new TestChild.area(3, 4); 7 | print('面积为:${result.area}'); 8 | } 9 | 10 | class Test { 11 | num width; 12 | num height; 13 | num area; 14 | 15 | // 必须加上空参构造,如果注释掉 它的子类会报错 16 | Test() { 17 | print('Test 空参构造'); 18 | } 19 | 20 | Test.area(width, height) 21 | : width = width, 22 | height = height, 23 | area = width * height { 24 | print('Test 有参构造'); 25 | } 26 | } 27 | 28 | class TestChild extends Test { 29 | 30 | num width; 31 | num height; 32 | num area; 33 | 34 | TestChild() { 35 | print('TestChild 空参构造'); 36 | } 37 | 38 | TestChild.area(num width, num height) 39 | : area = (width * height)/2 { 40 | print('TestChild 有参构造'); 41 | } 42 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/2-constructor_functions/6-calling-process/calling-process2.dart: -------------------------------------------------------------------------------- 1 | void main(){ 2 | // Test.area 命名函数,data: TestChild的数据 getDefaultData 3 | // TestChild 空参函数 调用父类的命名构造 4 | new TestChild(); 5 | } 6 | 7 | class Test{ 8 | static String data; 9 | Test() { 10 | print('Test 空参构造,data: $data'); 11 | } 12 | 13 | Test.area(String datas) { 14 | print('Test.area 命名函数,data: $datas'); 15 | } 16 | } 17 | 18 | class TestChild extends Test { 19 | // 参数可以是一个表达式 20 | TestChild() : super.area(getDefaultData()) { 21 | print('TestChild 空参函数 调用父类的命名构造'); 22 | } 23 | 24 | static String getDefaultData(){ 25 | return 'TestChild的数据 getDefaultData'; 26 | } 27 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/2-constructor_functions/6-calling-process/calling-process3.dart: -------------------------------------------------------------------------------- 1 | // 超类构造参数不能使用this关键字 2 | class Test { 3 | num width; 4 | num height; 5 | num area; 6 | 7 | // 必须加上空参构造,如果注释掉 它的子类会报错 8 | Test() { 9 | print('Test 空参构造'); 10 | } 11 | 12 | Test.area(width, height) 13 | : width = width, 14 | height = height, 15 | area = width * height { 16 | print('Test 有参构造'); 17 | } 18 | 19 | // 超类构造参数不能使用this关键字 20 | // Test.area(this.width, this.height) 21 | // : width = width, 22 | // height = height, 23 | // area = width * height { 24 | // print('Test 命名构造'); 25 | // } 26 | 27 | } 28 | 29 | class TestChild extends Test { 30 | 31 | num width; 32 | num height; 33 | num area; 34 | 35 | TestChild() { 36 | print('TestChild 空参构造'); 37 | } 38 | 39 | TestChild.area(num width, num height) 40 | : area = (width * height)/2 { 41 | print('TestChild 有参构造'); 42 | } 43 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/2-constructor_functions/7-constructor_redirect.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | // 重定向构造函数 4 | void main() { 5 | var result = new Test(4, true, '数字', 10); 6 | // abcd分别是:4,true,数字,10 7 | print('abcd分别是:${result.a},${result.b},${result.c},${result.d}'); 8 | } 9 | 10 | class Test { 11 | num a; 12 | bool b; 13 | String c; 14 | num d; 15 | // 主构造函数 16 | Test(this.a, this.b, this.c, this.d); 17 | 18 | // 委托给主构造函数 19 | Test.test1(num x,bool y) : this(x, y,'', 0); 20 | Test.test2(num a,bool b, String c) : this(a, b, c, 0); 21 | Test.test3(num a,bool b, String c,num d) : this(a, b, c, d); 22 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/2-constructor_functions/8-constructor_constant/constructor_constant1.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | // 常量构造函数 4 | void main() { 5 | var result = new Test(4, 10); 6 | print('x:${result.x}, y: ${result.y}'); 7 | } 8 | 9 | class Test { 10 | static final Test origin = const Test(0, 0); 11 | final num x, y; 12 | const Test(this.x, this.y); 13 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/2-constructor_functions/8-constructor_constant/constructor_constant2.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | // 常量上下文中的const构造函数 4 | void main() { 5 | // 这里有很多const关键字 6 | const pointAndLine = const { 7 | 'point': const [const ImmutablePoint(0, 0)], 8 | 'line': const [const ImmutablePoint(1, 10), const ImmutablePoint(-2, 11)], 9 | }; 10 | 11 | // 只有一个const, 它建立了常量上下文 12 | const pointAndLine2 = { 13 | 'point': [ImmutablePoint(0, 0)], 14 | 'line': [ImmutablePoint(1, 10), ImmutablePoint(-2, 11)], 15 | }; 16 | 17 | var a = const ImmutablePoint(1, 1); //创建一个常量 18 | var b = ImmutablePoint(1, 1); // 不创建常量 19 | assert(!identical(a, b)); // 不是同一个实例 20 | } 21 | 22 | class ImmutablePoint{ 23 | const ImmutablePoint(int a, int b); 24 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/2-constructor_functions/9-constructor_factory.dart: -------------------------------------------------------------------------------- 1 | // 工厂构造函数 2 | void main() { 3 | //Test('abc').test(); 4 | 5 | var a = new Test('abc'); 6 | var b = new Test('abc'); 7 | 8 | // 检查两个是否引用的相同的对象 9 | print(identical(a, b)); // true 10 | 11 | new Test('abc').test(); 12 | 13 | print(new Singleton() == new Singleton()); 14 | print(identical(new Singleton(), new Singleton())); 15 | 16 | // Cat cat = new Animal('cat'); 17 | // Dog dog = new Animal('dog'); 18 | // Animal animal = new Animal('haha'); 19 | } 20 | 21 | class Test { 22 | final String name; 23 | static Map _cache = new Map(); 24 | 25 | factory Test(String name) { 26 | if (_cache.containsKey(name)) { 27 | return _cache[name]; 28 | } else { 29 | final symbol = new Test._internal(name); 30 | _cache[name] = symbol; 31 | return symbol; 32 | } 33 | } 34 | 35 | Test._internal(this.name); 36 | 37 | void test(){ 38 | print('调用了test()'); 39 | } 40 | } 41 | 42 | 43 | ///////////// factory实现的单例 ///////////// 44 | class Singleton { 45 | factory Singleton() => const Singleton._internal_(); 46 | const Singleton._internal_(); 47 | } 48 | 49 | 50 | ///////////// 实际开发可能这么使用 ///////////////////////// 51 | 52 | abstract class Animal { 53 | factory Animal(String type) { 54 | switch (type) { 55 | case "cat": 56 | return new Cat(); 57 | case "dog": 58 | return new Dog(); 59 | default: 60 | throw Exception("输入的类型: '$type' 不是动物"); 61 | } 62 | } 63 | } 64 | 65 | class Cat implements Animal { 66 | Cat() { 67 | print('猫'); 68 | } 69 | } 70 | 71 | class Dog implements Animal { 72 | Dog() { 73 | print('狗'); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/3-init_list/1-init_list_demo1.dart: -------------------------------------------------------------------------------- 1 | void main() { 2 | new Test1(4, 3); 3 | Map json = { 4 | 'a': 1, 5 | 'b': 5, 6 | 'c': 12, 7 | }; 8 | 9 | new Test2.from(json); 10 | } 11 | 12 | 13 | // 有参构造初始化 14 | class Test1 { 15 | var x, y; 16 | Test1(var x, var y) 17 | : x = x, 18 | y = y { 19 | print('Test1 有参构造初始化'); 20 | } 21 | } 22 | 23 | // 命名构造的初始化 24 | class Test2 { 25 | var x, y; 26 | 27 | Test2.from(Map json) 28 | : x = json['x'], 29 | y = json['y'] { 30 | print('Test2.from(): ($x, $y)'); 31 | } 32 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/3-init_list/2-init_list_demo2.dart: -------------------------------------------------------------------------------- 1 | // 使用assert在初始化列表用来校验输入参数 2 | void main() { 3 | new Test1(4, 3); 4 | 5 | new Test2.withAssert(5, 10); 6 | } 7 | 8 | // 有参构造使用assert校验参数: 9 | 10 | class Test1 { 11 | var x, y; 12 | 13 | Test1(var x, var y) : assert(x >= 0) { 14 | print('Test5(): ($x, $y)'); 15 | } 16 | } 17 | 18 | // 命名构造使用assert校验参数: 19 | 20 | class Test2 { 21 | var x, y; 22 | Test2.withAssert(this.x, this.y) : assert(x >= 0) { 23 | print('Test2.withAssert(): ($x, $y)'); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/3-init_list/3-init_list_demo3.dart: -------------------------------------------------------------------------------- 1 | // 如果没有更多实际操作内容,可以简写。 2 | void main() { 3 | new Test1(4, 3); 4 | 5 | new Test2.withAssert(5, 10); 6 | } 7 | 8 | // 有参构造使用assert校验参数: 9 | 10 | class Test1 { 11 | var x, y; 12 | 13 | //如果没有更多实际操作内容 可以这样简写: 14 | Test1(var x, var y) : assert(x >= 0); 15 | 16 | } 17 | 18 | // 命名构造使用assert校验参数: 19 | 20 | class Test2 { 21 | var x, y; 22 | Test2.withAssert(this.x, this.y) : assert(x >= 0); 23 | } -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/3-init_list/4-init_list_demo4.dart: -------------------------------------------------------------------------------- 1 | // 把构造的初始化和assert校验同时使用 2 | void main() { 3 | new Test1(5, 10); 4 | } 5 | 6 | class Test1 { 7 | var x, y; 8 | Test1(var x, var y) : assert(x > 0) { 9 | this.x = x; 10 | this.y = y; 11 | print('Test1 有参构造初始化'); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /projects/dart_demo/test/8-class/3-functions/3-init_list/5-init_list_demo5.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | // 设置final字段,初始化程序时更方便 4 | 5 | void main() { 6 | var p = new Test1(4, 3); 7 | print('长方形的对角线长度:${p.hypotenuse}'); 8 | } 9 | 10 | class Test1 { 11 | final num width; 12 | final num height; 13 | final num hypotenuse; 14 | 15 | Test1(width, height) 16 | : width = width, 17 | height = height, 18 | hypotenuse = sqrt(width * width + height * height); 19 | } 20 | -------------------------------------------------------------------------------- /projects/dart_demo/test/9-library/libs/mylib.dart: -------------------------------------------------------------------------------- 1 | // 这是一个库 命名为mylib 2 | library mylib; 3 | 4 | // 希望使用mylib的时候 自动使用otherlib.dart 可以使用export关键字引入其他库 5 | export 'otherlib.dart'; 6 | // 导入otherlib2.dart 7 | export 'otherlib2.dart'; 8 | 9 | class MyLib { 10 | void test() { 11 | print('mylib.dart: MyLib : test()函数'); 12 | } 13 | } 14 | 15 | void test2() { 16 | print('mylib.dart: test2()函数'); 17 | } 18 | -------------------------------------------------------------------------------- /projects/dart_demo/test/9-library/libs/otherlib.dart: -------------------------------------------------------------------------------- 1 | // 其它的库 2 | library otherlib; 3 | 4 | class otherLib {} 5 | 6 | void test() { 7 | print('otherLib库 : test()函数'); 8 | } 9 | -------------------------------------------------------------------------------- /projects/dart_demo/test/9-library/libs/otherlib2.dart: -------------------------------------------------------------------------------- 1 | // 其它的库 2 | library otherlib2; 3 | 4 | class otherLib2 {} 5 | 6 | void test2() { 7 | print('otherLib2库 : test2()函数'); 8 | } 9 | -------------------------------------------------------------------------------- /projects/dart_demo/test/9-library/libs/testlib1.dart: -------------------------------------------------------------------------------- 1 | // 关于part 和 part of 2 | // 1. 不能同时使用library和part of,它们用于指定属于库的内容。 3 | // 1. B库是A库的一部分表示:part of A库名称 4 | // 2. 如果B库声明A库的一部分,同时A库也想声明它的一部分是B库,正确写法: 5 | // 必须是A库写了part 'B库的路径' 同时B库声明part of A库名称。 6 | // 这种情况下,某一边没有声明的话,就会报错。 7 | 8 | 9 | // 第1个库: 10 | library testlib1; 11 | 12 | // 可以不写 13 | part 'testlib2.dart'; 14 | 15 | 16 | void run() { 17 | print('testlib1库 : run()函数'); 18 | } 19 | -------------------------------------------------------------------------------- /projects/dart_demo/test/9-library/libs/testlib2.dart: -------------------------------------------------------------------------------- 1 | // 第2个库 2 | // 不能同时声明library 和 part of 冲突了。 3 | // library testlib2; 4 | 5 | // part of 表示这个库是testlib库的一部分 6 | part of testlib1; 7 | 8 | 9 | class testLib2 { 10 | 11 | } 12 | 13 | void start() { 14 | print('testlib2库 : start()函数'); 15 | } 16 | -------------------------------------------------------------------------------- /projects/dart_demo/test/9-library/test1.dart: -------------------------------------------------------------------------------- 1 | // 普通导入库 2 | // import 'libs/mylib.dart'; 3 | 4 | ///////////////////////////////////////// 5 | 6 | // test2.dart 和 test3.dart都有相同的hello()函数,这样写会报错 7 | // import 'test2.dart'; 8 | // import 'test3.dart'; 9 | // 解决方案:给导入的库指定一个前缀 方便识别 10 | // import 'test2.dart'; 11 | // import 'test3.dart' as test3; 12 | 13 | ///////////////////////////////////////// 14 | 15 | // 仅导入mylib.dart里面的test2函数 16 | // import 'libs/mylib.dart' show test2; 17 | 18 | // 刚好和show相反 除了test2函数之外 其它的都导入 19 | // import 'libs/mylib.dart' hide test2; 20 | //我们想导入mylib库,但是不想用里面的otherLib这个库 可以这样写 21 | // import 'libs/mylib.dart' hide otherLib; 22 | 23 | ///////////////////////////////////////// 24 | 25 | // 延迟导入的前缀 26 | // 当我们import一个库的时候,如果使用了as 不能同时使用deferred as 27 | import 'libs/mylib.dart' deferred as tests; 28 | import 'dart:async'; 29 | 30 | void main() { 31 | // hello(); 32 | // test3.hello(); 33 | 34 | hello(); 35 | 36 | } 37 | 38 | // 延迟导入的函数 需要使用loadLibrary 39 | Future hello() async { 40 | await tests.loadLibrary(); 41 | tests.test2(); 42 | } 43 | -------------------------------------------------------------------------------- /projects/dart_demo/test/9-library/test2.dart: -------------------------------------------------------------------------------- 1 | void hello() { 2 | print('test2.dart : hello()函数'); 3 | } 4 | -------------------------------------------------------------------------------- /projects/dart_demo/test/9-library/test3.dart: -------------------------------------------------------------------------------- 1 | void hello(){ 2 | print('test3.dart : hello()函数'); 3 | } -------------------------------------------------------------------------------- /projects/flutter-demo/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .dart_tool/ 3 | 4 | .packages 5 | .pub/ 6 | 7 | build/ 8 | 9 | .flutter-plugins 10 | -------------------------------------------------------------------------------- /projects/flutter-demo/.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /projects/flutter-demo/.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 36 | -------------------------------------------------------------------------------- /projects/flutter-demo/.idea/libraries/Dart_SDK.xml: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /projects/flutter-demo/.idea/libraries/Flutter_Plugins.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /projects/flutter-demo/.idea/markdown-navigator/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /projects/flutter-demo/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 22 | 32 | 33 | -------------------------------------------------------------------------------- /projects/flutter-demo/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /projects/flutter-demo/.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: f9bb4289e9fd861d70ae78bcc3a042ef1b35cc9d 8 | channel: beta 9 | -------------------------------------------------------------------------------- /projects/flutter-demo/README.md: -------------------------------------------------------------------------------- 1 | # 目录结构说明 2 | 3 | > **【说明】** lib目录是代码,请打开`lib`目录去看。 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /projects/flutter-demo/android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | *.class 3 | .gradle 4 | /local.properties 5 | /.idea/workspace.xml 6 | /.idea/libraries 7 | .DS_Store 8 | /build 9 | /captures 10 | GeneratedPluginRegistrant.java 11 | -------------------------------------------------------------------------------- /projects/flutter-demo/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 | apply plugin: 'com.android.application' 15 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 16 | 17 | android { 18 | compileSdkVersion 26 19 | 20 | lintOptions { 21 | disable 'InvalidPackage' 22 | } 23 | 24 | defaultConfig { 25 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 26 | applicationId "com.lzw.flutterdemo" 27 | minSdkVersion 21 28 | targetSdkVersion 26 29 | versionCode 1 30 | versionName "1.0" 31 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 32 | } 33 | 34 | buildTypes { 35 | release { 36 | // TODO: Add your own signing config for the release build. 37 | // Signing with the debug keys for now, so `flutter run --release` works. 38 | signingConfig signingConfigs.debug 39 | } 40 | } 41 | } 42 | 43 | flutter { 44 | source '../..' 45 | } 46 | 47 | dependencies { 48 | testImplementation 'junit:junit:4.12' 49 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 50 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 51 | } 52 | -------------------------------------------------------------------------------- /projects/flutter-demo/android/app/src/main/java/com/lzw/flutterdemo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.lzw.flutterdemo; 2 | 3 | import android.os.Bundle; 4 | 5 | import io.flutter.app.FlutterActivity; 6 | import io.flutter.plugins.GeneratedPluginRegistrant; 7 | 8 | public class MainActivity extends FlutterActivity { 9 | @Override 10 | protected void onCreate(Bundle savedInstanceState) { 11 | super.onCreate(savedInstanceState); 12 | GeneratedPluginRegistrant.registerWith(this); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /projects/flutter-demo/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /projects/flutter-demo/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /projects/flutter-demo/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /projects/flutter-demo/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /projects/flutter-demo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /projects/flutter-demo/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /projects/flutter-demo/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /projects/flutter-demo/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | google() 4 | jcenter() 5 | } 6 | 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:3.1.2' 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 | -------------------------------------------------------------------------------- /projects/flutter-demo/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | -------------------------------------------------------------------------------- /projects/flutter-demo/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /projects/flutter-demo/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip 7 | -------------------------------------------------------------------------------- /projects/flutter-demo/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 | -------------------------------------------------------------------------------- /projects/flutter-demo/images/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/images/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /projects/flutter-demo/images/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/images/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /projects/flutter-demo/images/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/images/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /projects/flutter-demo/images/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/images/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /projects/flutter-demo/images/mipmap-xhdpi/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/images/mipmap-xhdpi/demo.png -------------------------------------------------------------------------------- /projects/flutter-demo/images/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/images/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /projects/flutter-demo/images/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/images/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /projects/flutter-demo/images/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/images/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /projects/flutter-demo/images/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/images/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /projects/flutter-demo/images/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/images/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /projects/flutter-demo/images/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/images/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /projects/flutter-demo/ios/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vagrant/ 3 | .sconsign.dblite 4 | .svn/ 5 | 6 | .DS_Store 7 | *.swp 8 | profile 9 | 10 | DerivedData/ 11 | build/ 12 | GeneratedPluginRegistrant.h 13 | GeneratedPluginRegistrant.m 14 | 15 | .generated/ 16 | 17 | *.pbxuser 18 | *.mode1v3 19 | *.mode2v3 20 | *.perspectivev3 21 | 22 | !default.pbxuser 23 | !default.mode1v3 24 | !default.mode2v3 25 | !default.perspectivev3 26 | 27 | xcuserdata 28 | 29 | *.moved-aside 30 | 31 | *.pyc 32 | *sync/ 33 | Icon? 34 | .tags* 35 | 36 | /Flutter/app.flx 37 | /Flutter/app.zip 38 | /Flutter/flutter_assets/ 39 | /Flutter/App.framework 40 | /Flutter/Flutter.framework 41 | /Flutter/Generated.xcconfig 42 | /ServiceDefinitions.json 43 | 44 | Pods/ 45 | .symlinks/ 46 | -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Runner/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : FlutterAppDelegate 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Runner/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #include "AppDelegate.h" 2 | #include "GeneratedPluginRegistrant.h" 3 | 4 | @implementation AppDelegate 5 | 6 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 7 | [GeneratedPluginRegistrant registerWithRegistry:self]; 8 | // Override point for customization after application launch. 9 | return [super application:application didFinishLaunchingWithOptions:launchOptions]; 10 | } 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /projects/flutter-demo/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 | -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /projects/flutter-demo/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. -------------------------------------------------------------------------------- /projects/flutter-demo/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 | -------------------------------------------------------------------------------- /projects/flutter-demo/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | flutter_demo 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /projects/flutter-demo/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 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/all_samples/list/listview_horizontal.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | void main() { 4 | runApp( 5 | new MaterialApp( 6 | title: '横向ListView', 7 | theme: new ThemeData( 8 | primarySwatch: Colors.blue, //设置全局主题 9 | ), 10 | home: new ListViewHorizontalDemo(), 11 | ), 12 | ); 13 | } 14 | 15 | class ListViewHorizontalDemo extends StatelessWidget { 16 | @override 17 | Widget build(BuildContext context) { 18 | return new Scaffold( 19 | appBar: new AppBar( 20 | leading: new IconButton( 21 | icon: new Icon(Icons.keyboard_arrow_left), 22 | onPressed: () { 23 | // 返回上一个页面 24 | Navigator.of(context).pop(); 25 | }), 26 | title: new Text( 27 | '横向ListView', 28 | style: new TextStyle(fontSize: 17.0), 29 | ), 30 | ), 31 | body: new GestureDetector( 32 | onTap: () { 33 | print('点击了item!'); 34 | }, 35 | child: buildListItem()), 36 | ); 37 | } 38 | 39 | // 横向的ListView 40 | Widget buildListItem() { 41 | return new ListView( 42 | // 水平方向排列 43 | scrollDirection: Axis.horizontal, 44 | children: [ 45 | // 如果每一个item的宽度为屏幕的宽,就可以做出类似于Gallery的效果 46 | // 但是要控制好滑动的速度 47 | new Container( 48 | width: 480.0, 49 | color: Colors.red, 50 | ), 51 | new Container( 52 | width: 480.0, 53 | color: Colors.blue, 54 | ), 55 | new Container( 56 | width: 480.0, 57 | color: Colors.green, 58 | ), 59 | new Container( 60 | width: 480.0, 61 | color: Colors.yellow, 62 | ), 63 | new Container( 64 | width: 480.0, 65 | color: Colors.orange, 66 | ), 67 | ], 68 | ); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/all_samples/list/listview_longlist.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | void main() { 4 | runApp( 5 | new MaterialApp( 6 | title: 'ListView.builder构建长列表', 7 | theme: new ThemeData( 8 | primarySwatch: Colors.blue, //设置全局主题 9 | ), 10 | home: new ListViewLongListDemo(), 11 | ), 12 | ); 13 | } 14 | 15 | class ListViewLongListDemo extends StatelessWidget { 16 | @override 17 | Widget build(BuildContext context) { 18 | return new Scaffold( 19 | appBar: new AppBar( 20 | leading: new IconButton( 21 | icon: new Icon(Icons.keyboard_arrow_left), 22 | onPressed: () { 23 | // 返回上一个页面 24 | Navigator.of(context).pop(); 25 | }), 26 | title: new Text( 27 | 'ListView.builder构建长列表', 28 | style: new TextStyle(fontSize: 17.0), 29 | ), 30 | ), 31 | body: new GestureDetector( 32 | onTap: () { 33 | print('点击了item!'); 34 | }, 35 | child: buildListItem()), 36 | ); 37 | } 38 | 39 | // 长文本 40 | final items = new List.generate(10000, (i) => "Item $i"); 41 | 42 | // 通过ListView.builder 构建一个长列表 43 | Widget buildListItem() { 44 | return new ListView.builder( 45 | // padding: new EdgeInsets.all(8.0), 46 | itemCount: items.length, 47 | itemBuilder: (BuildContext context, int index) { 48 | return new ListTile( 49 | // title: new Text('${items[index]}'),//不加分割线 50 | title: buildItems(context, index), //添加分割线 51 | ); 52 | }, 53 | ); 54 | } 55 | 56 | Widget buildItems(BuildContext context, int index) { 57 | return new Column( 58 | children: [ 59 | new Container( 60 | child: Text('${items[index]}'), 61 | ), 62 | new Divider( 63 | height: 1.0, indent: 0.0, color: Theme.of(context).accentColor), 64 | ], 65 | ); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/all_samples/list/listview_radio_listtitle.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | void main() { 4 | runApp( 5 | new MaterialApp( 6 | title: 'ListView的RadioListTile的切换', 7 | theme: new ThemeData( 8 | primarySwatch: Colors.blue, //设置全局主题 9 | ), 10 | //动态演示RadioListTile的切换 11 | home: new RadioListTileDemo(), 12 | ), 13 | ); 14 | } 15 | 16 | // RadioListTile的示范代码 17 | class RadioListTileDemo extends StatefulWidget { 18 | @override 19 | _RadioListTileDemoState createState() => new _RadioListTileDemoState(); 20 | } 21 | 22 | class _RadioListTileDemoState extends State { 23 | @override 24 | Widget build(BuildContext context) { 25 | return new Scaffold( 26 | appBar: new AppBar( 27 | title: new Text( 28 | 'ListView的RadioListTile的切换', 29 | style: new TextStyle(fontSize: 17.0), 30 | ), 31 | ), 32 | body: items(), 33 | ); 34 | } 35 | 36 | // 示例来源于源码 37 | Widget items() { 38 | return new Column( 39 | // In the build function of that State 40 | children: [ 41 | new RadioListTile( 42 | title: const Text('item title1'), 43 | value: SingingCharacter.title1, 44 | groupValue: _character, 45 | onChanged: (SingingCharacter value) { 46 | setState(() { 47 | _character = value; 48 | }); 49 | }, 50 | ), 51 | new RadioListTile( 52 | title: const Text('item title2'), 53 | value: SingingCharacter.title2, 54 | groupValue: _character, 55 | onChanged: (SingingCharacter value) { 56 | setState(() { 57 | _character = value; 58 | }); 59 | }, 60 | ), 61 | ], 62 | ); 63 | } 64 | } 65 | 66 | // In the State of a stateful widget: 67 | SingingCharacter _character = SingingCharacter.title1; 68 | 69 | enum SingingCharacter { title1, title2 } 70 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/all_samples/list/listview_simple.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | void main() { 4 | runApp(new MaterialApp( 5 | title: '简单ListViewDemo', 6 | theme: new ThemeData( 7 | primarySwatch: Colors.blue, //设置全局主题 8 | ), 9 | home: new ListViewSimpleDemo(), 10 | )); 11 | } 12 | 13 | class ListViewSimpleDemo extends StatelessWidget { 14 | @override 15 | Widget build(BuildContext context) { 16 | return new Scaffold( 17 | appBar: new AppBar( 18 | title: new Text( 19 | '简单ListViewDemo', 20 | style: new TextStyle(fontSize: 17.0), 21 | ), 22 | ), 23 | body: new ListView( 24 | children: [ 25 | new Center( 26 | child: new Text( 27 | '\nListView Introduction', 28 | style: new TextStyle( 29 | fontFamily: 'serif', 30 | fontSize: 26.0, 31 | ), 32 | ), 33 | ), 34 | new Center( 35 | child: new Text( 36 | '这是文字内容,看看效果如何?\n ListView is the most commonly used scrolling widget.It displays its children one after another in the scroll direction.In the cross axis, the children are required to fill the ListView.If non-null, the itemExtent forces the children to have the given extent in the scroll direction. Specifying an itemExtent is more efficient than letting the children determine their own extent because the scrolling machinery can make use of the foreknowledge of the children\'s extent to save work, for example when the scroll position changes drastically.', 37 | style: new TextStyle( 38 | fontFamily: 'Monospace', 39 | fontSize: 23.0, 40 | ), 41 | )), 42 | ], 43 | ), 44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/all_samples/list/说明.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/lib/all_samples/list/说明.txt -------------------------------------------------------------------------------- /projects/flutter-demo/lib/all_samples/router/navigator_encapsulation/navigator_util.dart: -------------------------------------------------------------------------------- 1 | import 'dart:collection'; 2 | 3 | import 'package:flutter/material.dart'; 4 | 5 | 6 | 7 | class RouteManager{ 8 | 9 | BuildContext context; 10 | 11 | // 管理路由的map 12 | Map routeManagerMap = {}; 13 | 14 | Map routeMap = {}; 15 | 16 | // 构造函数 17 | RouteManager(this.context); 18 | 19 | void pushNamed(String routeName){ 20 | Navigator.of(context).pushNamed(routeName); 21 | } 22 | 23 | // key是 发送路由的标记 Value是要跳转的页面 24 | putRoutesMap(Map map){ 25 | routeMap = map; 26 | } 27 | 28 | _putRoutes(){ 29 | routeMap.forEach((routeName, targetPage){ 30 | routeManagerMap[routeName] = (BuildContext context) => targetPage; 31 | }); 32 | } 33 | 34 | 35 | Map getRoutes(){ 36 | return routeManagerMap; 37 | } 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/all_samples/router/readme.md: -------------------------------------------------------------------------------- 1 | # 路由使用Demo 2 | 3 | 4 | 5 | > **router_easy_sample** 这个是路由的简单实用。只需要运行`router_demo.dart`即可打开其他4个页面。 6 | 7 | 8 | 9 | > **router_all_sample** 这个是路由的完整使用示例。这个是**公众号Flutter那些事**文章的完整示例。建议看这个。每一个dart文件都是可以单独运行的。 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/all_samples/router/router_all_sample/router_sample1.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | // 这是路由的完整使用示例 4 | // 使用Navigator.push实现发送路由,Navigator.pop返回上一个页面。 5 | void main() { 6 | runApp( 7 | new MaterialApp( 8 | title: 'Flutter 路由Demo', 9 | theme: new ThemeData(primarySwatch: Colors.blue), 10 | home: new MyHomePage(), 11 | ), 12 | ); 13 | } 14 | 15 | class MyHomePage extends StatelessWidget { 16 | @override 17 | Widget build(BuildContext context) { 18 | return new Scaffold( 19 | appBar: new AppBar(title: new Text('Flutter 路由Demo')), 20 | body: new RaisedButton( 21 | color: Colors.teal, 22 | onPressed: () { 23 | Navigator.push( 24 | context, 25 | new MaterialPageRoute( 26 | builder: (context) => new MyApp(), 27 | ), 28 | ); 29 | }, 30 | child: new Text( 31 | '跳转到下一个页面', 32 | ), 33 | ), 34 | ); 35 | } 36 | } 37 | 38 | class MyApp extends StatelessWidget { 39 | @override 40 | Widget build(BuildContext context) { 41 | return new Scaffold( 42 | appBar: new AppBar( 43 | title: new Text('Flutter 路由Demo'), 44 | ), 45 | body: new RaisedButton( 46 | onPressed: () { 47 | Navigator.pop(context); 48 | }, 49 | child: new Text('返回上一个页面'), 50 | ), 51 | ); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/all_samples/router/router_all_sample/router_sample2.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | // 使用命名路由进行导航 4 | void main() { 5 | runApp( 6 | new MaterialApp( 7 | title: 'Flutter 路由Demo', 8 | theme: new ThemeData(primarySwatch: Colors.blue), 9 | home: new MyHomePage(), 10 | initialRoute: '/page_one', 11 | routes: { 12 | '/page_one': (context) => new MyHomePage(), 13 | '/jump_page_two': (context) => new MyApp(), 14 | }, 15 | ), 16 | ); 17 | } 18 | 19 | class MyHomePage extends StatelessWidget { 20 | @override 21 | Widget build(BuildContext context) { 22 | return new Scaffold( 23 | appBar: new AppBar(title: new Text('Flutter 路由Demo')), 24 | body: new RaisedButton( 25 | color: Colors.teal, 26 | onPressed: () { 27 | Navigator.pushNamed(context, '/jump_page_two'); 28 | }, 29 | child: new Text( 30 | '跳转到下一个页面', 31 | ), 32 | ), 33 | ); 34 | } 35 | } 36 | 37 | class MyApp extends StatelessWidget { 38 | @override 39 | Widget build(BuildContext context) { 40 | return new Scaffold( 41 | appBar: new AppBar( 42 | title: new Text('Flutter 路由Demo'), 43 | ), 44 | body: new RaisedButton( 45 | onPressed: () { 46 | Navigator.pop(context); 47 | }, 48 | child: new Text('返回上一个页面'), 49 | ), 50 | ); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/all_samples/router/router_all_sample/router_sample3.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | // 通过路由将数据传递给另一个页面 4 | void main() { 5 | runApp( 6 | new MaterialApp( 7 | title: 'Flutter 路由Demo', 8 | theme: new ThemeData(primarySwatch: Colors.blue), 9 | home: new MyHomePage(), 10 | ), 11 | ); 12 | } 13 | 14 | class MyHomePage extends StatelessWidget { 15 | final List datas = ["橘子", "苹果", "香蕉", "柚子"]; 16 | 17 | @override 18 | Widget build(BuildContext context) { 19 | return new Scaffold( 20 | appBar: new AppBar(title: new Text('Flutter 路由Demo')), 21 | body: new RaisedButton( 22 | color: Colors.teal, 23 | onPressed: () { 24 | Navigator.push( 25 | context, 26 | MaterialPageRoute( 27 | // 路由跳转 并向新页面传递数组 28 | builder: (context) => MyApp(data: datas), 29 | ), 30 | ); 31 | }, 32 | child: new Text( 33 | '跳转到下一个页面', 34 | ), 35 | ), 36 | ); 37 | } 38 | } 39 | 40 | class MyApp extends StatelessWidget { 41 | final List data; 42 | 43 | MyApp({Key key, @required this.data}) : super(key: key); 44 | 45 | @override 46 | Widget build(BuildContext context) { 47 | String tempData = ""; 48 | 49 | data.forEach((String data) { 50 | tempData += data; 51 | }); 52 | 53 | return new Scaffold( 54 | appBar: new AppBar( 55 | title: new Text(tempData), 56 | ), 57 | body: new RaisedButton( 58 | onPressed: () { 59 | Navigator.pop(context); 60 | }, 61 | child: new Text('返回上一个页面'), 62 | ), 63 | ); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/all_samples/router/router_all_sample/router_sample4.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | // 发送路由,并接收从其他页面返回数据 4 | void main() { 5 | runApp( 6 | MaterialApp( 7 | title: 'Flutter发送路由并返回数据Demo', 8 | home: HomePage(), 9 | ), 10 | ); 11 | } 12 | 13 | // 页面A 14 | class HomePage extends StatelessWidget { 15 | @override 16 | Widget build(BuildContext context) { 17 | return Scaffold( 18 | appBar: AppBar( 19 | title: Text( 20 | 'Flutter发送路由并返回数据Demo', 21 | style: new TextStyle(fontSize: 15), 22 | ), 23 | ), 24 | body: new MyHomePage(), 25 | ); 26 | } 27 | } 28 | 29 | class MyHomePage extends StatelessWidget { 30 | @override 31 | Widget build(BuildContext context) { 32 | return RaisedButton( 33 | color: Colors.teal, 34 | onPressed: () { 35 | _navigateAndDisplaySelection(context); 36 | }, 37 | child: Text('跳转到下一个页面'), 38 | ); 39 | } 40 | 41 | // 封装函数用来发送路由和接收路由返回的数据 42 | _navigateAndDisplaySelection(BuildContext context) async { 43 | // 获取路由返回的数据 44 | final result = await Navigator.push( 45 | context, 46 | // 通过路由把数据发给另一个页面 47 | MaterialPageRoute(builder: (context) => MyApp()), 48 | ); 49 | 50 | // 把收到的数据用SnackBar显示出来 51 | Scaffold.of(context).showSnackBar(SnackBar(content: Text("$result"))); 52 | } 53 | } 54 | 55 | // 页面B 56 | class MyApp extends StatelessWidget { 57 | @override 58 | Widget build(BuildContext context) { 59 | return Scaffold( 60 | appBar: AppBar( 61 | title: Text( 62 | "页面2", 63 | style: new TextStyle(fontSize: 15), 64 | ), 65 | ), 66 | body: new RaisedButton( 67 | onPressed: () { 68 | Navigator.pop(context, '这是页面B给页面A发的数据'); 69 | }, 70 | child: Text('点击返回到页面A'), 71 | ), 72 | ); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/all_samples/router/router_easy_sample/demo1.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | void main() { 4 | runApp( 5 | new MaterialApp( 6 | title: 'Demo1', 7 | theme: new ThemeData( 8 | primarySwatch: Colors.teal, 9 | ), 10 | home: new Demo1(), 11 | ), 12 | ); 13 | } 14 | 15 | class Demo1 extends StatelessWidget { 16 | @override 17 | Widget build(BuildContext context) { 18 | return new Scaffold( 19 | appBar: new AppBar( 20 | //背景色 21 | backgroundColor: Colors.red, 22 | // icon的主题色 23 | iconTheme: new IconThemeData(color: Colors.tealAccent), 24 | leading: new IconButton( 25 | icon: new Icon(Icons.keyboard_arrow_left), 26 | onPressed: () { 27 | print('返回首页'); 28 | // 返回上一个页面 29 | Navigator.of(context).pop(); 30 | }), 31 | title: new Text( 32 | 'Demo1', 33 | style: new TextStyle(color: Colors.tealAccent), 34 | ), 35 | ), 36 | body: new Center( 37 | child: new Text('hello world'), 38 | ), 39 | ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/all_samples/router/router_easy_sample/demo2.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | void main() { 4 | runApp( 5 | new MaterialApp( 6 | title: 'Demo2', 7 | theme: new ThemeData( 8 | primarySwatch: Colors.deepPurple, 9 | ), 10 | home: new Demo2(), 11 | ), 12 | ); 13 | } 14 | 15 | class Demo2 extends StatelessWidget { 16 | @override 17 | Widget build(BuildContext context) { 18 | return new Scaffold( 19 | appBar: new AppBar( 20 | backgroundColor: Colors.orangeAccent, 21 | leading: new IconButton( 22 | icon: new Icon(Icons.keyboard_arrow_left), 23 | onPressed: () { 24 | print('返回首页'); 25 | Navigator.of(context).pop(); 26 | }), 27 | title: new Text('Demo2'), 28 | ), 29 | body: new Center( 30 | child: new Text('hello world 2'), 31 | ), 32 | ); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/all_samples/router/router_easy_sample/demo3.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | void main() { 4 | runApp( 5 | new MaterialApp( 6 | title: 'Demo3', 7 | theme: new ThemeData( 8 | primarySwatch: Colors.deepOrange, 9 | ), 10 | home: new Demo3(), 11 | ), 12 | ); 13 | } 14 | 15 | class Demo3 extends StatelessWidget { 16 | @override 17 | Widget build(BuildContext context) { 18 | return new Scaffold( 19 | appBar: new AppBar( 20 | backgroundColor: Colors.greenAccent, 21 | leading: new IconButton( 22 | icon: new Icon(Icons.keyboard_arrow_left), 23 | onPressed: () { 24 | print('返回首页'); 25 | Navigator.of(context).pop(); 26 | }), 27 | title: new Text('Demo3'), 28 | ), 29 | body: new Center( 30 | child: new Text('hello world 3'), 31 | ), 32 | ); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/all_samples/router/router_easy_sample/demo4.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | void main() { 4 | runApp( 5 | new MaterialApp( 6 | title: 'Demo4', 7 | theme: new ThemeData( 8 | primarySwatch: Colors.lightGreen, 9 | ), 10 | home: new Demo4(), 11 | ), 12 | ); 13 | } 14 | 15 | class Demo4 extends StatelessWidget { 16 | @override 17 | Widget build(BuildContext context) { 18 | return new Scaffold( 19 | appBar: new AppBar( 20 | backgroundColor: Colors.deepPurple, 21 | leading: new IconButton( 22 | icon: new Icon(Icons.keyboard_arrow_left), 23 | onPressed: () { 24 | print('返回首页'); 25 | Navigator.of(context).pop(); 26 | }), 27 | title: new Text('Demo4'), 28 | ), 29 | body: new Center( 30 | child: new Text('hello world 4'), 31 | ), 32 | ); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/main2.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | void main() => runApp(new MyApp()); 4 | 5 | class MyApp extends StatelessWidget { 6 | // This widget is the root of your application. 7 | @override 8 | Widget build(BuildContext context) { 9 | return new MaterialApp( 10 | title: 'Flutter Demo', 11 | theme: new ThemeData( 12 | primarySwatch: Colors.blue, 13 | ), 14 | home: new MyHomePage(title: 'Flutter Demo Home Page'), 15 | ); 16 | } 17 | } 18 | 19 | class MyHomePage extends StatefulWidget { 20 | final String title; 21 | MyHomePage({Key key, this.title}) : super(key: key); 22 | 23 | @override 24 | _MyHomePageState createState() => new _MyHomePageState(); 25 | } 26 | 27 | class _MyHomePageState extends State { 28 | int _counter = 0; 29 | 30 | void _incrementCounter() { 31 | setState(() { 32 | _counter++; 33 | }); 34 | } 35 | 36 | @override 37 | Widget build(BuildContext context) { 38 | return new Scaffold( 39 | appBar: new AppBar( 40 | title: new Text(widget.title), 41 | ), 42 | body: new Center( 43 | child: new Column( 44 | mainAxisAlignment: MainAxisAlignment.center, 45 | children: [ 46 | new Text( 47 | 'You have pushed the button this many times:', 48 | ), 49 | new Text( 50 | '$_counter', 51 | style: Theme.of(context).textTheme.display1, 52 | ), 53 | ], 54 | ), 55 | ), 56 | floatingActionButton: new FloatingActionButton( 57 | onPressed: _incrementCounter, 58 | tooltip: 'Increment', 59 | child: new Icon(Icons.add), 60 | ), 61 | ); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/page1.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | void main() { 4 | runApp(new MaterialApp( 5 | title: 'flutter learning', 6 | home: new MyHome(), 7 | )); 8 | } 9 | 10 | class MyHome extends StatelessWidget { 11 | @override 12 | Widget build(BuildContext context) { 13 | return new Material( 14 | child: new Column( 15 | children: [ 16 | new MyAppBar( 17 | title: new Text('AppBar标题 flutter learning', 18 | style: Theme.of(context).primaryTextTheme.title), 19 | ), 20 | new Expanded( 21 | child: new Center( 22 | child: new Text('你好 世界!'), 23 | )), 24 | ], 25 | ), 26 | ); 27 | } 28 | } 29 | 30 | class MyAppBar extends StatelessWidget { 31 | MyAppBar({this.title}); 32 | 33 | final Widget title; 34 | 35 | @override 36 | Widget build(BuildContext context) { 37 | return new Container( 38 | height: 56.0, 39 | // padding: const EdgeInsets.symmetric(horizontal: 8.0), 40 | decoration: new BoxDecoration(color: Colors.blue), 41 | child: new Row( 42 | children: [ 43 | new IconButton( 44 | icon: new Icon(Icons.menu), tooltip: '导航菜单', onPressed: null), 45 | new Expanded(child: title), 46 | new IconButton( 47 | icon: new Icon(Icons.search), 48 | tooltip: '搜索', 49 | onPressed: null, 50 | ) 51 | ], 52 | ), 53 | ); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/page2.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | /// 实现一个MD风格的简单界面,包括有:AppBar + FloatingActionButton + Drawer 4 | /// Drawer只是简单的写了一个Text,并没有写具体内容,后续会详细介绍 5 | void main() { 6 | runApp(new MaterialApp( 7 | title: 'MaterialApp', 8 | theme: new ThemeData( 9 | primaryColor: Colors.red, //设置appbar主题 10 | primarySwatch: Colors.deepOrange, //设置全局主题 11 | ), 12 | home: new MyHome(), 13 | )); 14 | } 15 | 16 | class MyHome extends StatelessWidget { 17 | @override 18 | Widget build(BuildContext context) { 19 | return new Scaffold( 20 | appBar: new AppBar( 21 | leading: new IconButton( 22 | icon: new Icon(Icons.menu), tooltip: '导航菜单', onPressed: null), 23 | title: new Text('这是标题'), 24 | actions: [ 25 | new IconButton( 26 | icon: new Icon(Icons.search), tooltip: '搜索', onPressed: null), 27 | new IconButton( 28 | icon: new Icon(Icons.add), tooltip: '添加', onPressed: null), 29 | new IconButton( 30 | icon: new Icon(Icons.edit), tooltip: '编辑', onPressed: null), 31 | ], 32 | ), 33 | body: new Center( 34 | child: new Text('这是内容区域。。'), 35 | ), 36 | floatingActionButton: new FloatingActionButton( 37 | child: new Icon(Icons.add), 38 | tooltip: 'FloatingActionButton', 39 | onPressed: null, 40 | ), 41 | drawer: new Drawer( 42 | child: new Text('Drawer'), 43 | semanticLabel: '这是 Drawer', 44 | ), 45 | ); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/page3.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:fluttertoast/fluttertoast.dart'; 3 | 4 | /// 本demo 来源于: https://blog.csdn.net/column/details/13593.html?&page=4 5 | /// 事件的操作,另外这里引入了toast库 6 | void main() { 7 | runApp(new MaterialApp( 8 | title: 'MaterialApp', 9 | theme: new ThemeData( 10 | primaryColor: Colors.red, //设置appbar主题 11 | primarySwatch: Colors.deepOrange, //设置全局主题 12 | ), 13 | home: new MyGestureDetector(), 14 | )); 15 | } 16 | 17 | /// 手势操作 18 | class MyGestureDetector extends StatelessWidget { 19 | @override 20 | Widget build(BuildContext context) { 21 | return new GestureDetector( 22 | onTap: () { 23 | print('MyButton被监听了!'); 24 | Fluttertoast.showToast( 25 | msg: "MyButton被监听了! short toast", 26 | toastLength: Toast.LENGTH_LONG, 27 | gravity: ToastGravity.BOTTOM, 28 | ); 29 | }, 30 | child: new Container( 31 | height: 36.0, 32 | padding: const EdgeInsets.all(8.0), 33 | margin: const EdgeInsets.symmetric(horizontal: 8.0), 34 | decoration: new BoxDecoration( 35 | borderRadius: new BorderRadius.circular(5.0), 36 | color: Colors.deepOrange, 37 | ), 38 | child: new Center( 39 | child: new Text('点击监听'), 40 | ), 41 | ), 42 | ); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/readme.md: -------------------------------------------------------------------------------- 1 | # 目录说明 2 | 3 | ### 1、`all_samples`是一个小项目,选中`main_page`,只要右键选择`run`,就可以运行这个小项目了。 4 | 5 | 6 | 7 | 打开`all_samples/main_page` 是首页,点击它里面的3个按钮,分别跳到`normal_page`页面,`router`目录,`list`目录: 8 | 9 | `normal_page.dart` 是创建Flutter工程时自动创建的页面,我只是改了一个名字。 10 | `all_samples/list` 这个文件夹 表示ListView的各种用法的demo。 11 | `all_samples/router` 这个文件夹是 路由的使用demo,主要演示页面如何跳转和返回。 12 | 13 | 14 | ### 2、其他的Dart文件基本都是一些控件的使用,想看哪个效果,右键`run`就可以运行了,后期会逐渐整理到`all_samples`目录里面。 15 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/view_demo/action/OpacityAnimDemo.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | /// 不透明度动画demo 4 | void main() { 5 | runApp(new MaterialApp( 6 | title: 'AnimDemo', 7 | theme: new ThemeData( 8 | primarySwatch: Colors.blue, //设置全局主题 9 | ), 10 | home: new AnimDemo(), 11 | )); 12 | } 13 | 14 | class AnimDemo extends StatefulWidget { 15 | @override 16 | _AnimDemoState createState() => new _AnimDemoState(); 17 | } 18 | 19 | // State类主要负责两件事:保存数据;使用数据更新和构建UI 20 | class _AnimDemoState extends State { 21 | // 控件是可见还是不可见的。 22 | bool _visible = true; 23 | Alignment alignment = new Alignment(0.0, 0.0); 24 | 25 | @override 26 | Widget build(BuildContext context) { 27 | return new Scaffold( 28 | appBar: new AppBar( 29 | title: new Text('AnimDemo'), 30 | ), 31 | body: new Center( 32 | child: buildOpacityAnim(), 33 | ), 34 | floatingActionButton: new FloatingActionButton( 35 | onPressed: () { 36 | // 一定要调用setState,这会告诉Flutter使用我们的更改重新构建UI 37 | setState(() { 38 | // _visible = !_visible; 39 | alignment = Alignment.center; 40 | }); 41 | }, 42 | tooltip: '切换不透明度', 43 | child: Icon(Icons.flip), 44 | ), 45 | ); 46 | } 47 | 48 | /// 不透明度动画 49 | Widget buildOpacityAnim() { 50 | //使用Flutter提供的不透明度动画类 51 | return new AnimatedOpacity( 52 | //如果控件是可见的,动画到1.0(完全可见)。如果小部件是隐藏的,那么将其动画为0.0(不可见)。 53 | opacity: _visible ? 1.0 : 0.0, 54 | duration: new Duration(milliseconds: 500), 55 | child: new Container( 56 | width: 200.0, 57 | height: 200.0, 58 | color: Colors.teal, 59 | ), 60 | ); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/view_demo/action/page4.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | /// 交互 4 | void main() { 5 | runApp(new MaterialApp( 6 | title: '交互', 7 | home: new Counter(), 8 | )); 9 | } 10 | 11 | class Counter extends StatefulWidget { 12 | @override 13 | _CounterState createState() => new _CounterState(); 14 | } 15 | 16 | class _CounterState extends State { 17 | int _count = 0; //计数 18 | 19 | void _increment() { 20 | setState(() { 21 | _count += 1; 22 | }); 23 | } 24 | 25 | @override 26 | Widget build(BuildContext context) { 27 | return new Scaffold( 28 | appBar: new AppBar( 29 | title: new Text('交互'), 30 | ), 31 | body: new Center( 32 | child: new Text('按钮点击 $_count 次}'), 33 | ), 34 | floatingActionButton: new FloatingActionButton( 35 | onPressed: _increment, 36 | tooltip: '增加', 37 | child: new Icon(Icons.add), 38 | ), 39 | ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/view_demo/action/page4_review.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | void main() { 4 | runApp(new MaterialApp( 5 | title: '交互', 6 | home: new Counter(), 7 | )); 8 | } 9 | 10 | class Counter extends StatefulWidget { 11 | @override 12 | _CounterState createState() => new _CounterState(); 13 | } 14 | 15 | class _CounterState extends State { 16 | int _count = 0; //计数 17 | 18 | void _increment() { 19 | setState(() { 20 | _count += 1; 21 | }); 22 | } 23 | 24 | @override 25 | Widget build(BuildContext context) { 26 | return new Scaffold( 27 | appBar: new AppBar( 28 | title: new Text('交互'), 29 | ), 30 | body: new CounterDiaplay(count: _count), 31 | floatingActionButton: new CounterIncrementer( 32 | onPressed: _increment, 33 | ), 34 | ); 35 | } 36 | } 37 | 38 | // 简单的封装 计数显示 39 | class CounterDiaplay extends StatelessWidget { 40 | CounterDiaplay({this.count}); 41 | 42 | final int count; 43 | 44 | @override 45 | Widget build(BuildContext context) { 46 | return new Center( 47 | child: new Text('按钮点击 $count 次}'), 48 | ); 49 | } 50 | } 51 | 52 | // 简单的封装 计数改变 53 | class CounterIncrementer extends StatelessWidget { 54 | CounterIncrementer({this.onPressed}); 55 | 56 | final VoidCallback onPressed; 57 | 58 | @override 59 | Widget build(BuildContext context) { 60 | return new FloatingActionButton( 61 | onPressed: onPressed, 62 | tooltip: '增加', 63 | child: new Icon(Icons.add), 64 | ); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/view_demo/view/ContainerDemo.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | /// Container 容器的基本使用 4 | void main() { 5 | runApp(new MaterialApp( 6 | title: 'MaterialApp', 7 | theme: new ThemeData( 8 | primarySwatch: Colors.blue, //设置全局主题 9 | ), 10 | home: new ContainerDemo(), 11 | )); 12 | } 13 | 14 | class ContainerDemo extends StatelessWidget { 15 | @override 16 | Widget build(BuildContext context) { 17 | return new Center( 18 | //使子控件在其内部水平和垂直居中 19 | child: new Container( 20 | alignment: Alignment.center, 21 | padding: const EdgeInsets.all(8.0), 22 | margin: const EdgeInsets.all(8.0), 23 | constraints: new BoxConstraints.expand( 24 | height: Theme.of(context).textTheme.display1.fontSize * 1.1 + 200.0, 25 | ), 26 | width: 300.0, 27 | height: 200.0, 28 | decoration: buildBoxDecoration(), 29 | foregroundDecoration: buildBoxDecoration(), 30 | child: new Text('容器演示'), 31 | transform: new Matrix4.rotationZ(0.1), 32 | ), 33 | ); 34 | } 35 | 36 | // 注意:BoxDecoration返回的是Decoration对象 37 | Decoration buildBoxDecoration() { 38 | return new BoxDecoration( 39 | color: const Color(0xfffce5cd), 40 | //设置Border属性给容器添加边框 41 | border: new Border.all( 42 | //为边框添加颜色 43 | color: const Color(0xff6d9eeb), 44 | //边框宽度 45 | width: 8.0, 46 | ), 47 | ); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/view_demo/view/ImageDemo.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | /// TODO 4 | void main() { 5 | runApp(new MaterialApp( 6 | title: 'image使用', 7 | theme: new ThemeData( 8 | primarySwatch: Colors.blue, //设置全局主题 9 | ), 10 | home: new ImageDemo(), 11 | )); 12 | } 13 | 14 | class ImageDemo extends StatelessWidget { 15 | @override 16 | Widget build(BuildContext context) { 17 | return new Scaffold( 18 | appBar: new AppBar( 19 | title: new Text('从URL地址获取图片'), 20 | ), 21 | // body: new Center( 22 | // child: new Image.network(//从网络加载图片 23 | // 'http://pic.baike.soso.com/p/20130828/20130828161137-1346445960.jpg', 24 | // scale: 2.0, 25 | // ), 26 | body: new Center( 27 | child: new Container( 28 | decoration: new BoxDecoration( 29 | //从本地加载图片 30 | image: 31 | new DecorationImage(image: new AssetImage('images/demo.png')), 32 | ), 33 | ), 34 | ), 35 | ); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/view_demo/view/ListViewDemo.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | /// TODO 4 | void main() { 5 | runApp(new MaterialApp( 6 | title: 'ListViewDemo', 7 | theme: new ThemeData( 8 | primarySwatch: Colors.blue, //设置全局主题 9 | ), 10 | home: new ListViewDemo(), 11 | )); 12 | } 13 | 14 | class ListViewDemo extends StatelessWidget { 15 | @override 16 | Widget build(BuildContext context) { 17 | return new Scaffold( 18 | appBar: new AppBar( 19 | title: new Text('ListViewDemo'), 20 | ), 21 | body: new ListView( 22 | children: [ 23 | new Center( 24 | child: new Text( 25 | '\nListView Introduction', 26 | style: new TextStyle( 27 | fontFamily: 'serif', 28 | fontSize: 26.0, 29 | ), 30 | ), 31 | ), 32 | new Center( 33 | child: new Text( 34 | '这是文字内容,看看效果如何?\n ListView is the most commonly used scrolling widget.It displays its children one after another in the scroll direction.In the cross axis, the children are required to fill the ListView.If non-null, the itemExtent forces the children to have the given extent in the scroll direction. Specifying an itemExtent is more efficient than letting the children determine their own extent because the scrolling machinery can make use of the foreknowledge of the children\'s extent to save work, for example when the scroll position changes drastically.', 35 | style: new TextStyle( 36 | fontFamily: 'Monospace', 37 | fontSize: 20.0, 38 | ), 39 | )), 40 | ], 41 | ), 42 | ); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/view_demo/view/OpacityDemo.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | /// Opacity控件能调整子控件的不透明度,使子控件部分透明, 4 | /// 不透明度的量从0.0到1.1之间,0.0表示完全透明,1.1表示完全不透明。 5 | /// 即使子控件颜色带有透明度,例如:0xFF990D47A1,也会在这个颜色基础上再去设置透明度。 6 | void main() { 7 | runApp(new MaterialApp( 8 | title: 'OpacityDemo', 9 | theme: new ThemeData( 10 | primarySwatch: Colors.blue, //设置全局主题 11 | ), 12 | home: new OpacityDemo(), 13 | )); 14 | } 15 | 16 | class OpacityDemo extends StatelessWidget { 17 | @override 18 | Widget build(BuildContext context) { 19 | return new Scaffold( 20 | appBar: new AppBar( 21 | title: new Text('OpacityDemo'), 22 | ), 23 | body: new Center( 24 | child: new Opacity( 25 | opacity: 0.0, 26 | child: new Container( 27 | width: 250.0, 28 | height: 100.0, 29 | decoration: new BoxDecoration( 30 | color: const Color(0xFF990D47A1), 31 | ), 32 | ), 33 | )), 34 | ); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/view_demo/view/RaisedButtonDemo.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | /// RaisedButton 的基本使用 4 | void main() { 5 | runApp(new MaterialApp( 6 | title: 'RaisedButton', 7 | theme: new ThemeData( 8 | primarySwatch: Colors.blue, //设置全局主题 9 | ), 10 | home: new RaisedButtonDemo(), 11 | )); 12 | } 13 | 14 | class RaisedButtonDemo extends StatelessWidget { 15 | @override 16 | Widget build(BuildContext context) { 17 | return new Scaffold( 18 | appBar: new AppBar( 19 | title: new Text('RaisedButton'), 20 | ), 21 | body: new Center( 22 | //使子控件在其内部水平和垂直居中 23 | child: new Container( 24 | width: 300.0, 25 | height: 200.0, 26 | decoration: new BoxDecoration( 27 | color: Colors.pink, 28 | border: new Border.all( 29 | //设置Border属性给容器添加边框 30 | color: const Color(0xff6d9eeb), //为边框添加颜色 31 | width: 8.0, //边框宽度 32 | ), 33 | ), 34 | child: new RaisedButton( 35 | onPressed: null, 36 | ), 37 | ), 38 | ), 39 | ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /projects/flutter-demo/lib/view_demo/view/StackDemo.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | /// 堆叠视图 4 | void main() { 5 | runApp(new MaterialApp( 6 | title: '', 7 | theme: new ThemeData( 8 | primarySwatch: Colors.blue, //设置全局主题 9 | ), 10 | home: new StackDemo(), 11 | )); 12 | } 13 | 14 | class StackDemo extends StatelessWidget { 15 | @override 16 | Widget build(BuildContext context) { 17 | return new Scaffold( 18 | appBar: new AppBar( 19 | title: new Text(''), 20 | ), 21 | body: new Center( 22 | child: new Stack( 23 | children: [ 24 | new Image.network( 25 | 'http://pic.baike.soso.com/p/20130828/20130828161137-1346445960.jpg', 26 | scale: 2.0, 27 | ), 28 | new Positioned( 29 | left: 10.0, 30 | right: 10.0, 31 | top: 10.0, 32 | child: new Text( 33 | '这是上层的布局', 34 | style: new TextStyle( 35 | fontSize: 35.0, 36 | color: Colors.deepOrange, 37 | fontFamily: 'serif', 38 | ), 39 | ), 40 | ), 41 | ], 42 | ), 43 | ), 44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /projects/flutter-demo/pics/list_demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/pics/list_demo.png -------------------------------------------------------------------------------- /projects/flutter-demo/pics/main_page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/pics/main_page.png -------------------------------------------------------------------------------- /projects/flutter-demo/pics/normal_page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/pics/normal_page.png -------------------------------------------------------------------------------- /projects/flutter-demo/pics/router_demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/pics/router_demo.png -------------------------------------------------------------------------------- /projects/flutter-demo/pics/可折叠的appbar+listview.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/pics/可折叠的appbar+listview.gif -------------------------------------------------------------------------------- /projects/flutter-demo/pics/多级列表demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter-demo/pics/多级列表demo.png -------------------------------------------------------------------------------- /projects/flutter-demo/test/async.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async' show Future; 2 | import 'dart:convert'; 3 | 4 | import 'package:flutter/services.dart' show rootBundle; 5 | import 'package:flutter_logger/flutter_logger.dart'; 6 | import 'package:http/http.dart' as http; 7 | //import 'package:log/log.dart'; 8 | 9 | /// 加载网络json和本地json 10 | void main() { 11 | // _networkLoading(); 12 | _loadJson(); 13 | } 14 | 15 | /// 通过网络加载json并解析层对象 16 | void _networkLoading() { 17 | /// 访问快递接口 18 | /// 将给定标头的HTTP GET请求发送到给定的URL,并注册回调,参数为HTTP响应 19 | http 20 | .get('http://www.kuaidi100.com/query?type=yuantong&postid=11111111111') 21 | .then((http.Response response) { 22 | // 响应的主体作为字符串返回 23 | String netdata = response.body; 24 | // JsonDecoder类解析JSON字符串并构建相应的对象 25 | JsonDecoder decoder = new JsonDecoder(); 26 | // 将给定的JSON字符串输入转换为其对应的对象 27 | Map json = decoder.convert(netdata); 28 | // 输出给定的JSON数据 29 | new Log('networkLoading').d(json.toString()); 30 | }); 31 | } 32 | 33 | /// 以下是异步加载本地json资源 34 | Future loadAsset() async { 35 | return await rootBundle.loadString('assets/result.json'); 36 | } 37 | 38 | void _loadJson() { 39 | loadAsset().then((value) { 40 | JsonDecoder decoder = new JsonDecoder(); 41 | Map json = decoder.convert(value); 42 | new Log('_loadJson').d(json.toString()); 43 | }); 44 | } 45 | -------------------------------------------------------------------------------- /projects/flutter-demo/test/dart1.dart: -------------------------------------------------------------------------------- 1 | /// 创建一个简单的Dart类 2 | void main() { 3 | // 创建Bicycle对象 在Dart2中 new关键字可以省略 4 | /// 如果一个变量的值不会改变,你可以使用final而不是var 5 | var bike = new Bicycle(2, 100, 1); 6 | print(bike); //打印结果 Bicycle: 100 km/h 7 | } 8 | 9 | /// 在Dart中,您可以在类之外定义代码。变量,函数,getter和setter都可以写在类之外 10 | /// Java使用private标记声明私有实例变量,Dart不需要 11 | /// Dart所有的标识符默认都是公开的,Dart没有为关键字public,private或protected 12 | /// Dart使用2个字符的缩进,而不是4个 13 | class Bicycle { 14 | // 定义成员变量 15 | int cadence; 16 | int speed; 17 | int gear; 18 | 19 | // 构造方法 20 | /// 这个构造函数没有方法体的,它在Dart中是有效的 21 | /// 在构造函数中的参数列表使用this能够更方便便捷的对实例变量赋值 22 | Bicycle(this.cadence, this.speed, this.gear); 23 | 24 | /// 这个构造方法是有方法体的,等同于上面那个构造方法 25 | // Bicycle(int cadence, int speed, int gear) { 26 | // this.cadence = cadence; 27 | // this.speed = speed; 28 | // this.gear = gear; 29 | // } 30 | 31 | /// Dart在指定字符串时支持单引号或双引号 32 | /// 使用字符串插值将表达式的值放入字符串文字中:${expression} 33 | /// 如果表达式是标识符,则可以跳过大括号:$variableName 34 | /// 使用胖箭头 => 符号缩短单行函数或方法 35 | @override 36 | String toString() => 'Bicycle speed: $speed km/h'; 37 | } 38 | -------------------------------------------------------------------------------- /projects/flutter-demo/test/dart2.dart: -------------------------------------------------------------------------------- 1 | void main() { 2 | var bike = new Bicycle(2, 1); 3 | bike.cadence = 10; // 给公有的成员变量赋值 4 | bike.gear = 20; 5 | bike.speedUp(50); // 调用公有的方法 6 | print(bike); 7 | } 8 | 9 | /// 默认情况下,Dart为所有公共实例变量提供隐式getter和setter。 10 | /// 除非要强制执行只读或只写变量,计算或验证值或在其他位置更新值, 11 | /// 否则不需要定义自己的getter / setter 12 | class Bicycle { 13 | int cadence; 14 | 15 | /// Dart里面所有的私有属性 变量 方法等都是在前面加下划线 16 | int _speed = 50; 17 | int gear; 18 | 19 | Bicycle(this.cadence, this.gear); 20 | 21 | void applyBrake(int decrement) { 22 | _speed -= decrement; 23 | } 24 | 25 | void speedUp(int increment) { 26 | _speed += increment; 27 | } 28 | 29 | @override 30 | String toString() => 'Bicycle: $_speed km/h'; 31 | } 32 | -------------------------------------------------------------------------------- /projects/flutter-demo/test/dart3.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | main() { 4 | print(new Rectangle(origin: const Point(10, 20), width: 100, height: 200)); 5 | print(new Rectangle(origin: const Point(10, 10))); 6 | print(new Rectangle(width: 200)); 7 | print(new Rectangle()); 8 | 9 | /// 输出结果: 10 | /// Origin: (10, 20), width: 100, height: 200 11 | /// Origin: (10, 10), width: 0, height: 0 12 | /// Origin: (0, 0), width: 200, height: 0 13 | /// Origin: (0, 0), width: 0, height: 0 14 | } 15 | 16 | /// Java支持重载构造函数,但是Dart不支持重载函数,Dart只有可选参数 17 | 18 | class Rectangle { 19 | int width; 20 | int height; 21 | Point origin; 22 | 23 | /// 被const修饰的 是编译时常量 24 | /// this.origin,this.width并且this.height是可选的命名参数。命名参数用大括号{}括起来 25 | Rectangle({this.origin = const Point(0, 0), this.width = 0, this.height = 0}); 26 | 27 | @override 28 | String toString() => 29 | 'Origin: (${origin.x}, ${origin.y}), width: $width, height: $height'; 30 | } 31 | -------------------------------------------------------------------------------- /projects/flutter-demo/test/dart4.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | /// 如何在Dart中创建工厂类 4 | 5 | main() { 6 | /// 方式1: 7 | final circle = shapeFactory('circle'); 8 | final square = shapeFactory('square'); 9 | 10 | /// 方式2: 11 | // final circle = new Shape('circle'); 12 | // final square = new Shape('square'); 13 | print(circle.area); 14 | print(square.area); 15 | } 16 | 17 | /// Dart可以在一个文件中定义多个类 18 | abstract class Shape { 19 | /// 方式2:使用Dart的factory关键字来创建工厂构造函数。 20 | factory Shape(String type) { 21 | if (type == 'circle') return new Circle(2); 22 | if (type == 'square') return new Square(2); 23 | throw 'Can\'t create $type.'; 24 | } 25 | num get area; 26 | } 27 | 28 | /// dart.math是Dart的核心图书馆之一。 29 | /// 其他核心库包括dart:core,dart:async,dart:convert和dart:collection。 30 | /// 在Dart2 中,核心库常量是小写字母 31 | class Circle implements Shape { 32 | final num radius; 33 | Circle(this.radius); 34 | num get area => pi * pow(radius, 2); 35 | } 36 | 37 | class Square implements Shape { 38 | final num side; 39 | Square(this.side); 40 | num get area => pow(side, 2); 41 | } 42 | 43 | /// 方式1:工厂类 44 | Shape shapeFactory(String type) { 45 | if (type == 'circle') return new Circle(10); 46 | if (type == 'square') return new Square(5); 47 | throw 'Can\'t create $type.'; // 抛异常 48 | } 49 | -------------------------------------------------------------------------------- /projects/flutter-demo/test/dart5.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | /// 实现一个接口 4 | 5 | main() { 6 | final circle = new Shape('circle'); 7 | final square = new Shape('square'); 8 | print(circle.area); 9 | print(square.area); 10 | } 11 | 12 | abstract class Shape { 13 | factory Shape(String type) { 14 | if (type == 'circle') return new Circle(2); 15 | if (type == 'square') return new Square(2); 16 | throw 'Can\'t create $type.'; 17 | } 18 | num get area; 19 | } 20 | 21 | class Circle implements Shape { 22 | final num radius; 23 | Circle(this.radius); 24 | num get area => pi * pow(radius, 2); 25 | } 26 | 27 | /// 添加一个扩展Circle类的CircleMock类. 28 | /// 必须定义area和radius实例变量,如果不定义,会报“缺少具体实现”错误 29 | class CircleMock implements Circle { 30 | num area; 31 | num radius; 32 | } 33 | 34 | class Square implements Shape { 35 | final num side; 36 | Square(this.side); 37 | num get area => pow(side, 2); 38 | } 39 | -------------------------------------------------------------------------------- /projects/flutter-demo/test/dart6.dart: -------------------------------------------------------------------------------- 1 | /// Dart支持函数式编程中,可以执行以下操作: 2 | /// 传递函数作为参数。 3 | /// 为变量分配一个函数。 4 | /// 解构一个函数,该函数将多个参数放入一系列函数中,每个函数采用一个参数(也称为currying)。 5 | /// 创建一个可以用作常量值的无名函数(也称为lambda表达式)。 6 | /// 在Dart中,甚至函数都是对象并且有一个类型Function。即:函数可以分配给变量或作为参数传递给其他函数。 7 | main() { 8 | final values = [1, 2, 3, 5, 10, 50]; 9 | for (var length in values) { 10 | print(scream(length)); 11 | } 12 | 13 | /// for循环 14 | values.map(scream).forEach(print); 15 | 16 | /// 来自于dart:collection包里面的 List and Iterable, 有fold, where, join, skip等函数。 17 | /// Dart 同样也有 Map 和 Set 18 | // skip(1)跳过values列表文字中的第一个值1 19 | // take(3)获取values列表文字中的下3个值(2,3和5)。 20 | // 剩余的值被跳过 21 | values.skip(1).take(3).map(scream).forEach(print); 22 | } 23 | 24 | String scream(int length) => "A${'a' * length}h!"; 25 | -------------------------------------------------------------------------------- /projects/flutter-demo/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // To perform an interaction with a widget in your test, use the WidgetTester utility that Flutter 3 | // provides. For example, you can send tap and scroll gestures. You can also use WidgetTester to 4 | // find child widgets in the widget tree, read text, and verify that the values of widget properties 5 | // are correct. 6 | 7 | import 'package:flutter/material.dart'; 8 | import 'package:flutter_test/flutter_test.dart'; 9 | 10 | import 'package:flutter_demo/main.dart'; 11 | 12 | void main() { 13 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 14 | // Build our app and trigger a frame. 15 | await tester.pumpWidget(new MyApp()); 16 | 17 | // Verify that our counter starts at 0. 18 | expect(find.text('0'), findsOneWidget); 19 | expect(find.text('1'), findsNothing); 20 | 21 | // Tap the '+' icon and trigger a frame. 22 | await tester.tap(find.byIcon(Icons.add)); 23 | await tester.pump(); 24 | 25 | // Verify that our counter has incremented. 26 | expect(find.text('0'), findsNothing); 27 | expect(find.text('1'), findsOneWidget); 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /projects/flutter_adobe_logo/sample.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter_adobe_logo/sample.gif -------------------------------------------------------------------------------- /projects/flutter_white_screen/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.lock 4 | *.log 5 | *.pyc 6 | *.swp 7 | .DS_Store 8 | .atom/ 9 | .buildlog/ 10 | .history 11 | .svn/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # Visual Studio Code related 20 | .vscode/ 21 | 22 | # Flutter/Dart/Pub related 23 | **/doc/api/ 24 | .dart_tool/ 25 | .flutter-plugins 26 | .packages 27 | .pub-cache/ 28 | .pub/ 29 | build/ 30 | 31 | # Android related 32 | **/android/**/gradle-wrapper.jar 33 | **/android/.gradle 34 | **/android/captures/ 35 | **/android/gradlew 36 | **/android/gradlew.bat 37 | **/android/local.properties 38 | **/android/**/GeneratedPluginRegistrant.java 39 | 40 | # iOS/XCode related 41 | **/ios/**/*.mode1v3 42 | **/ios/**/*.mode2v3 43 | **/ios/**/*.moved-aside 44 | **/ios/**/*.pbxuser 45 | **/ios/**/*.perspectivev3 46 | **/ios/**/*sync/ 47 | **/ios/**/.sconsign.dblite 48 | **/ios/**/.tags* 49 | **/ios/**/.vagrant/ 50 | **/ios/**/DerivedData/ 51 | **/ios/**/Icon? 52 | **/ios/**/Pods/ 53 | **/ios/**/.symlinks/ 54 | **/ios/**/profile 55 | **/ios/**/xcuserdata 56 | **/ios/.generated/ 57 | **/ios/Flutter/App.framework 58 | **/ios/Flutter/Flutter.framework 59 | **/ios/Flutter/Generated.xcconfig 60 | **/ios/Flutter/app.flx 61 | **/ios/Flutter/app.zip 62 | **/ios/Flutter/flutter_assets/ 63 | **/ios/ServiceDefinitions.json 64 | **/ios/Runner/GeneratedPluginRegistrant.* 65 | 66 | # Exceptions to above rules. 67 | !**/ios/**/default.mode1v3 68 | !**/ios/**/default.mode2v3 69 | !**/ios/**/default.pbxuser 70 | !**/ios/**/default.perspectivev3 71 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 72 | -------------------------------------------------------------------------------- /projects/flutter_white_screen/.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: d74b1c205103ed2132fc5ae536a94217ec965fb3 8 | channel: master 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /projects/flutter_white_screen/README.md: -------------------------------------------------------------------------------- 1 | # flutter_white_screen 2 | 3 | ## 介绍 4 | 5 | A new Flutter application for solve flutter white screen problem. 6 | 7 | ## 截图 8 | 9 | ![运行截图](screenshots/screenshots.gif) -------------------------------------------------------------------------------- /projects/flutter_white_screen/android/app/src/main/java/com/awei/flutterwhitescreen/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.awei.flutterwhitescreen; 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 | -------------------------------------------------------------------------------- /projects/flutter_white_screen/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | 14 | 15 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /projects/flutter_white_screen/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter_white_screen/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /projects/flutter_white_screen/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter_white_screen/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /projects/flutter_white_screen/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter_white_screen/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /projects/flutter_white_screen/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter_white_screen/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /projects/flutter_white_screen/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter_white_screen/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /projects/flutter_white_screen/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /projects/flutter_white_screen/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | google() 4 | jcenter() 5 | } 6 | 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:3.1.3' 9 | } 10 | } 11 | 12 | allprojects { 13 | repositories { 14 | google() 15 | jcenter() 16 | } 17 | } 18 | 19 | rootProject.buildDir = '../build' 20 | subprojects { 21 | project.buildDir = "${rootProject.buildDir}/${project.name}" 22 | } 23 | subprojects { 24 | project.evaluationDependsOn(':app') 25 | } 26 | 27 | task clean(type: Delete) { 28 | delete rootProject.buildDir 29 | } 30 | -------------------------------------------------------------------------------- /projects/flutter_white_screen/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | -------------------------------------------------------------------------------- /projects/flutter_white_screen/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip 7 | -------------------------------------------------------------------------------- /projects/flutter_white_screen/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 | -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Runner/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : FlutterAppDelegate 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Runner/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #include "AppDelegate.h" 2 | #include "GeneratedPluginRegistrant.h" 3 | 4 | @implementation AppDelegate 5 | 6 | - (BOOL)application:(UIApplication *)application 7 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 8 | [GeneratedPluginRegistrant registerWithRegistry:self]; 9 | // Override point for customization after application launch. 10 | return [super application:application didFinishLaunchingWithOptions:launchOptions]; 11 | } 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter_white_screen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /projects/flutter_white_screen/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 | -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter_white_screen/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter_white_screen/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter_white_screen/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /projects/flutter_white_screen/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. -------------------------------------------------------------------------------- /projects/flutter_white_screen/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 | -------------------------------------------------------------------------------- /projects/flutter_white_screen/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | flutter_white_screen 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /projects/flutter_white_screen/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 | -------------------------------------------------------------------------------- /projects/flutter_white_screen/screenshots/screenshots.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/flutter_white_screen/screenshots/screenshots.gif -------------------------------------------------------------------------------- /projects/flutter_white_screen/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:flutter_white_screen/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(MyApp()); 17 | 18 | // Verify that our counter starts at 0. 19 | expect(find.text('0'), findsOneWidget); 20 | expect(find.text('1'), findsNothing); 21 | 22 | // Tap the '+' icon and trigger a frame. 23 | await tester.tap(find.byIcon(Icons.add)); 24 | await tester.pump(); 25 | 26 | // Verify that our counter has incremented. 27 | expect(find.text('0'), findsNothing); 28 | expect(find.text('1'), findsOneWidget); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /projects/hub_demo/sample.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/hub_demo/sample.gif -------------------------------------------------------------------------------- /projects/hub_demo/sample2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AweiLoveAndroid/Flutter-learning/0130cb7e22d090a367d2feacbc50ceb1200adde2/projects/hub_demo/sample2.gif -------------------------------------------------------------------------------- /projects/readme.md: -------------------------------------------------------------------------------- 1 | # 文件夹说明 2 | 3 | 4 | 5 | #### `flutter_demo` 是flutter使用的相关Demo 6 | 7 | #### `dart_demo` 是 Dart使用的相关Demo 8 | 9 | #### `flutter_white_screen` 是解决Flutter白屏的方案的示例项目,遇到应用启动白屏问题可以参考一下。 10 | 11 | #### `hub_demo`: Flutter仅用100行轻松实现自定义P站和油管的Logo及自由切换Logo功能。 12 | 13 | > `hub_demo`自由切换Logo功能效果图: 14 | 15 | ![](hub_demo/sample.gif) 16 | 17 | > `hub_demo`自定义各种风格的Logo效果图: 18 | 19 | ![](hub_demo/sample2.gif) 20 | 21 | > 代码戳这里:[hub_demo/hub_demo.dart](hub_demo/hub_demo.dart) 22 | 23 | > 配套视频请戳这里:[Flutter仅用100行轻松实现自定义P站和油管的Logo及自由切换Logo功能](https://www.bilibili.com/video/av75564707/) 24 | 25 | 26 | 27 | #### `flutter_adobe_logo`: Flutter轻松实现Adobe全家桶Logo列表功能。 28 | 29 | > `flutter_adobe_logo`效果图: 30 | 31 | ![](flutter_adobe_logo/sample.gif) 32 | 33 | > 代码戳这里:[flutter_adobe_logo/flutter_adobe_logo.dart](flutter_adobe_logo/flutter_adobe_logo.dart) 34 | 35 | > 配套视频请戳这里:[Flutter轻松实现Adobe全家桶Logo列表功能](https://www.bilibili.com/video/av75750858/) 36 | -------------------------------------------------------------------------------- /readme/Flutter和react native的对比.md: -------------------------------------------------------------------------------- 1 | ![Flutter和react native的对比](https://github.com/AweiLoveAndroid/Flutter-learning/blob/master/pics/Flutter%E5%92%8Creact%20native%E7%9A%84%E5%AF%B9%E6%AF%94.png?raw=true) -------------------------------------------------------------------------------- /readme/Flutter和原生Android控件对比.md: -------------------------------------------------------------------------------- 1 | Flutter和原生Android控件对比: 2 | 3 | Flutter控件|Android控件 4 | -|- 5 | AppBar|ActionBar/ToolBar 6 | ListView|ListView/RecyclerView 7 | Text|TextView 8 | Center|ViewGroup 9 | FloatingActionButton|FloatingActionButton(design库里面的) 10 | BottomNavigationBar|BottomNavigation(design库里面的) 11 | RaisedButton/Button|Button 12 | Column|LinearLayout的android:orientation="vertical" 13 | Row|android:orientation="horizontal" 14 | DecorationImage|ImageView 15 | Image|ImageView 16 | Stack|FrameLayout/RelativeLayout 17 | Container|RelativeLayout 18 | CustomMultiChildLayout|RelativeLayout 19 | Algin|alginParentXXX属性 20 | resizeToAvoidBottomPadding|android:windowSoftInputMode=”adjustResize属性 21 | SingleChildScrollView|ScrollView 22 | CustomScrollerView|Recyclerview 23 | 24 | 25 | ---- 26 | 27 | 28 | Image里面的BoxFit参数介绍:(相当于Android的ImageView的scaleType参数) 29 | 30 | // fill 通过篡改原始宽高比来填充目标box 31 | 32 | ![](https://flutter.github.io/assets-for-api-docs/assets/painting/box_fit_fill.png) 33 | 34 | 35 | /// contain 在尽可能大的情况下,仍然将源完全包含在目标框中。 36 | 37 | ![](https://flutter.github.io/assets-for-api-docs/assets/painting/box_fit_contain.png) 38 | 39 | /// cover 尽可能小,同时仍然覆盖整个目标框。 40 | 41 | ![](https://flutter.github.io/assets-for-api-docs/assets/painting/box_fit_cover.png) 42 | 43 | /// fitWidth 确保显示源的全部宽度,而不管这是否意味着源垂直溢出目标框。 44 | 45 | ![](https://flutter.github.io/assets-for-api-docs/assets/painting/box_fit_fitWidth.png) 46 | 47 | /// fitHeight 确保显示源的全部高度,而不管这是否意味着源水平地溢出目标框。 48 | 49 | ![](https://flutter.github.io/assets-for-api-docs/assets/painting/box_fit_fitHeight.png) 50 | 51 | /// none 在目标框中对齐源(默认为居中),并放弃位于框外的源的任何部分。源图像未调整大小。 52 | 53 | ![](https://flutter.github.io/assets-for-api-docs/assets/painting/box_fit_none.png) 54 | 55 | /// scaleDown 在目标框中对齐源(默认为居中),如果需要,将源缩小以确保源适合该框。这与contain的内容相同,如果该内容会收缩图像,那么它就是none。 56 | 57 | ![](https://flutter.github.io/assets-for-api-docs/assets/painting/box_fit_scaleDown.png) 58 | 59 | --------------------------------------------------------------------------------