1.创建 Flutter 工程
flutter create <output directory>
D: otebookflutterprojectsui_tutoriallayout>flutter create layout_app Creating project layout_app... layout_app.gitignore (created) layout_app.idealibrariesDart_SDK.xml (created) layout_app.idealibrariesFlutter_for_Android.xml (created) layout_app.idealibrariesKotlinJavaRuntime.xml (created) layout_app.ideamodules.xml (created) layout_app.idea unConfigurationsmain_dart.xml (created) layout_app.ideaworkspace.xml (created) layout_app.metadata (created) layout_appandroidappuild.gradle (created) layout_appandroidappsrcmainjavacomexamplelayout_appMainActivity.java (created) layout_appandroiduild.gradle (created) layout_appandroidlayout_app_android.iml (created) layout_appandroidappsrcdebugAndroidManifest.xml (created) layout_appandroidappsrcmainAndroidManifest.xml (created) layout_appandroidappsrcmain esdrawablelaunch_background.xml (created) layout_appandroidappsrcmain esmipmap-hdpiic_launcher.png (created) layout_appandroidappsrcmain esmipmap-mdpiic_launcher.png (created) layout_appandroidappsrcmain esmipmap-xhdpiic_launcher.png (created) layout_appandroidappsrcmain esmipmap-xxhdpiic_launcher.png (created) layout_appandroidappsrcmain esmipmap-xxxhdpiic_launcher.png (created) layout_appandroidappsrcmain esvaluesstyles.xml (created) layout_appandroidappsrcprofileAndroidManifest.xml (created) layout_appandroidgradlewrappergradle-wrapper.properties (created) layout_appandroidgradle.properties (created) layout_appandroidsettings.gradle (created) layout_appiosRunnerAppDelegate.h (created) layout_appiosRunnerAppDelegate.m (created) layout_appiosRunnermain.m (created) layout_appiosRunner.xcodeprojproject.pbxproj (created) layout_appiosRunner.xcodeprojxcshareddataxcschemesRunner.xcscheme (created) layout_appiosFlutterAppFrameworkInfo.plist (created) layout_appiosFlutterDebug.xcconfig (created) layout_appiosFlutterRelease.xcconfig (created) layout_appiosRunnerAssets.xcassetsAppIcon.appiconsetContents.json (created) layout_appiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-1024x1024@1x .png (created) layout_appiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-20x20@1x.png (created) layout_appiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-20x20@2x.png (created) layout_appiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-20x20@3x.png (created) layout_appiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-29x29@1x.png (created) layout_appiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-29x29@2x.png (created) layout_appiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-29x29@3x.png (created) layout_appiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-40x40@1x.png (created) layout_appiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-40x40@2x.png (created) layout_appiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-40x40@3x.png (created) layout_appiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-60x60@2x.png (created) layout_appiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-60x60@3x.png (created) layout_appiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-76x76@1x.png (created) layout_appiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-76x76@2x.png (created) layout_appiosRunnerAssets.xcassetsAppIcon.appiconsetIcon-App-83.5x83.5@2x .png (created) layout_appiosRunnerAssets.xcassetsLaunchImage.imagesetContents.json (created) layout_appiosRunnerAssets.xcassetsLaunchImage.imagesetLaunchImage.png (created) layout_appiosRunnerAssets.xcassetsLaunchImage.imagesetLaunchImage@2x.png (created) layout_appiosRunnerAssets.xcassetsLaunchImage.imagesetLaunchImage@3x.png (created) layout_appiosRunnerAssets.xcassetsLaunchImage.imagesetREADME.md (created) layout_appiosRunnerBase.lprojLaunchScreen.storyboard (created) layout_appiosRunnerBase.lprojMain.storyboard (created) layout_appiosRunnerInfo.plist (created) layout_appiosRunner.xcodeprojproject.xcworkspacecontents.xcworkspacedata (created) layout_appiosRunner.xcworkspacecontents.xcworkspacedata (created) layout_applibmain.dart (created) layout_applayout_app.iml (created) layout_apppubspec.yaml (created) layout_appREADME.md (created) layout_app estwidget_test.dart (created) Running "flutter packages get" in layout_app... 8.1s Wrote 66 files. All done! [√] Flutter is fully installed. (Channel beta, v1.2.1, on Microsoft Windows [Version 6.1.7601], locale zh-CN) [√] Android toolchain - develop for Android devices is fully installed. (Android SDK version 28.0.3) [!] Android Studio is not available. (not installed) [!] Connected device is not available. Run "flutter doctor" for information about installing additional components. In order to run your application, type: $ cd layout_app $ flutter run Your application code is in layout_applibmain.dart. D: otebookflutterprojectsui_tutoriallayout>
2. Flutter 编译 apk
flutter build [apk]
D: otebookflutterprojectsui_tutoriallayout>cd layout_app D: otebookflutterprojectsui_tutoriallayoutlayout_app>flutter build Flutter build commands. Usage: flutter build <subcommand> [arguments] -h, --help Print this usage information. Available subcommands: aot Build an ahead-of-time compiled snapshot of your app's Dart code. apk Build an Android APK file from your app. appbundle Build an Android App Bundle file from your app. bundle Build the Flutter assets directory from your app. flx Deprecated ios Build an iOS application bundle (Mac OS X host only). Run "flutter help" to see global options. D: otebookflutterprojectsui_tutoriallayoutlayout_app>flutter build apk Initializing gradle... 5.3s Resolving dependencies... 47.5s Running Gradle task 'assembleRelease'... Calling mockable JAR artifact transform to create file: C:UsersAdministrator. gradlecaches ransforms-1files-1.1android.jar9af1ff324598fa2d595c0bf1564a0c1 5android.jar with input D:softsAndroidandroid-sdkplatformsandroid-28andro id.jar Running Gradle task 'assembleRelease'... 395.9s (!) Built buildappoutputsapk eleaseapp-release.apk (4.8MB). D: otebookflutterprojectsui_tutoriallayoutlayout_app>
Flutter 是站在巨人的肩膀上做出来的优秀作品。