macos 在 AndroidStudio 中搭建 Flutter 开发环境

转自:https://blog.csdn.net/wangjiang_qianmo/article/details/88195238

在 AndroidStudio 中搭建 Flutter 开发环境

安装 Flutter 和 Dart 插件

安装步骤:

  • 打开 Android Studio

  • 选择 Android Studio,选择 Preferences,选择 Plugins

  • 选择 Browse repositories,搜索 Flutter,选择安装

  • 弹出安装 Dart 插件对话框时,选择安装

  • 重启 Android Studio

获取 Flutter SDK

  1. 可以去 flutter 官网1下载其最新可用的安装包 。

也可以去 Flutter GitHub2 项目下去下载安装包

  1. 解压下载的 flutter_macos_v1.2.1-stable.zip 文件,然后配置环境变量(macOS 环境):
1.open ~/.bash_profile
2.添加:export PATH={你存储的路径}/flutter/bin:$PATH,例如:export PATH=/Users/admin/project/flutter/flutter/bin:$PATH
3.source ~/.bash_profile
  1. 查看是否安装成功

运行 flutter doctor 命令:

admindeMacBook-Pro-88:~ admin$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[] Flutter (Channel stable, v1.2.1, on Mac OS X 10.14.1 18B75, locale zh-Hans-CN)
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[] iOS toolchain - develop for iOS devices
    ✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
      Download at: https://developer.apple.com/xcode/download/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
    ✗ libimobiledevice and ideviceinstaller are not installed. To install with Brew, run:
        brew update
        brew install --HEAD usbmuxd
        brew link usbmuxd
        brew install --HEAD libimobiledevice
        brew install ideviceinstaller
    ✗ ios-deploy not installed. To install:
        brew install ios-deploy
    ✗ CocoaPods not installed.
        CocoaPods is used to retrieve the iOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without resolving iOS dependencies with CocoaPods, plugins will not work on iOS.
        For more info, see https://flutter.io/platform-plugins
      To install:
        brew install cocoapods
        pod setup
[!] Android Studio (not installed)
[] Connected device (1 available)

创建 Flutter App

  1. 在 Android Studio 中,点击 File → New → New Flutter Project

  1. 选择 New Flutter Application,点击 Next

Flutter SDK path 选择之前解压下载的 flutter_macos_v1.2.1-stable.zip 文件的路径

  1. 创建项目成功后,直接 run main.dart

初次 run 时间稍微长。

在手机上的运行效果:

除了打开时间稍微有点长(大概有两秒)外,页面刷新还是挺流畅的。

Flutter 学习参考资料

  1. Flutter 官方网站:英文文档3,中文文档4

  2. Flutter 项目 GitHub 地址:Flutter。

  3. Flutter 中文网

  4. 阿里巴巴组织的 Flutter 学习项目 GitHub 地址:flutter-go5


  1. https://flutter.dev/docs/development/tools/sdk/releases?tab=windows ↩︎

  2. https://github.com/flutter/flutter/releases ↩︎

  3. https://flutter.dev/docs ↩︎

  4. https://flutter-io.cn/docs/development/ui/interactive ↩︎

  5. https://github.com/alibaba/flutter-go ↩︎

猜你喜欢

转载自blog.csdn.net/qq_37954086/article/details/88885472