在AndroidStudio中搭建Flutter开发环境

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wangjiang_qianmo/article/details/88195238

安装 Flutter 和 Dart 插件

安装步骤:

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

获取Flutter SDK

1.可以去flutter官网下载其最新可用的安装包 。
在这里插入图片描述
也可以去Flutter GitHub项目下去下载安装包
在这里插入图片描述
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
在这里插入图片描述
Flutter SDK path选择之前解压下载的flutter_macos_v1.2.1-stable.zip文件的路径

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

在这里插入图片描述
初次run时间稍微长。

在手机上的运行效果:

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

Flutter 学习参考资料

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

扫描二维码关注公众号,回复: 5609219 查看本文章

2.Flutter 项目GitHub地址:Flutter

3.Flutter 中文网

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

猜你喜欢

转载自blog.csdn.net/wangjiang_qianmo/article/details/88195238