在AndroidStudio中搭建Flutter开发环境

文章目录

    • 安装 Flutter 和 Dart 插件
    • 获取Flutter SDK
    • 创建Flutter App
    • Flutter 学习参考资料


安装 Flutter 和 Dart 插件

安装步骤:

  1. 打开Android Studio
  2. 选择Android Studio,选择Preferences,选择Plugins
  3. 选择Browse repositories,搜索Flutter,选择安装
  4. 弹出安装Dart 插件对话框时,选择安装
  5. 重启Android Studio

获取Flutter SDK

1.可以去flutter官网下载其最新可用的安装包 。
在AndroidStudio中搭建Flutter开发环境_第1张图片
也可以去Flutter GitHub项目下去下载安装包。
在AndroidStudio中搭建Flutter开发环境_第2张图片
2. 解压下载的flutter_macos_v1.2.1-stable.zip文件,然后配置环境变量:

1.open ~/.bash_profile
2.添加:export PATH={你存储的路径}/flutter/bin:$PATH,例如:export PATH=/Users/admin/project/flutter/flutter/bin:$PATH
3.source ~/.bash_profile

3.查看是否安装成功

运行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

2.选择New Flutter Application,点击Next
在AndroidStudio中搭建Flutter开发环境_第3张图片
Flutter SDK path选择之前解压下载的flutter_macos_v1.2.1-stable.zip文件的路径

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

在AndroidStudio中搭建Flutter开发环境_第4张图片
初次run时间稍微长。

在手机上的运行效果:

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

Flutter 学习参考资料

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

2.Flutter 项目GitHub地址:Flutter。

3.Flutter 中文网

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

你可能感兴趣的:(Flutter,Flutter,Android,Studio)