上手开发一个入门级别的应用。

创建 APP

  1. flutter create myapp

该命令会创建一个名为 myapp,里面包含一个简单的示例程序,里面用到了 Material 组件

输出如下信息,

  1. All done!
  2. You'll need to install additional components before you can run your Flutter
  3. app:
  4. [✓] Flutter (Channel stable, v1.9.1+hotfix.2, on Mac OS X 10.14.6 18G95, locale
  5. zh-Hans-CN)
  6. • Flutter version 1.9.1+hotfix.2 at
  7. /Users/taoshilei/Documents/develop/flutter
  8. • Framework revision 2d2a1ffec9 (11 days ago), 2019-09-06 18:39:49 -0700
  9. • Engine revision b863200c37
  10. • Dart version 2.5.0
  11. [✗] Android toolchain - develop for Android devices
  12. ✗ Unable to locate Android SDK.
  13. Install Android Studio from:
  14. https://developer.android.com/studio/index.html
  15. On first launch it will assist you in installing the Android SDK
  16. components.
  17. (or visit https://flutter.dev/setup/#android-setup for detailed
  18. instructions).
  19. If the Android SDK has been installed to a custom location, set
  20. ANDROID_HOME to that location.
  21. You may also want to add it to your PATH environment variable.
  22. [✗] Xcode - develop for iOS and macOS
  23. ✗ Xcode installation is incomplete; a full installation is necessary for iOS
  24. development.
  25. Download at: https://developer.apple.com/xcode/download/
  26. Or install Xcode via the App Store.
  27. Once installed, run:
  28. sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
  29. ✗ CocoaPods not installed.
  30. CocoaPods is used to retrieve the iOS and macOS platform side's plugin
  31. code that responds to your plugin usage on the Dart side.
  32. Without CocoaPods, plugins will not work on iOS or macOS.
  33. For more info, see https://flutter.dev/platform-plugins
  34. To install:
  35. sudo gem install cocoapods
  36. pod setup
  37. [!] Android Studio (not installed)
  38. Android Studio not found; download from
  39. https://developer.android.com/studio/index.html
  40. (or visit https://flutter.dev/setup/#android-setup for detailed
  41. instructions).
  42. [!] IntelliJ IDEA Ultimate Edition (version 2019.1.2)
  43. IntelliJ at /Applications/IntelliJ IDEA.app
  44. Flutter plugin not installed; this adds Flutter specific functionality.
  45. Dart plugin not installed; this adds Dart specific functionality.
  46. For information about installing plugins, see
  47. https://flutter.dev/intellij-setup/#installing-the-plugins
  48. [!] Connected device
  49. ! No devices available
  50. ! Doctor found issues in 5 categories.
  51. After installing components, run 'flutter doctor' in order to re-validate your
  52. setup.
  53. When complete, type 'flutter run' from the 'myapp' directory in order to launch
  54. your app.
  55. Your application code is in myapp/lib/main.dart

提示

应用程序所需的代码在 ‘lib/main.dart’,如果想要从更高层次了解每个代码块的讲解,请看代码中的注释。