Flutter学习(1)-mac环境安装

Flutter开发系列学习

Flutter已经出来有一段时间了,目前很多大厂也在学习并初步融入了使用之中,去年学习了下kotlin,今年的目标是在工作之余学习Flutter,暂定希望可以打到使用Flutter熟练开发的程度。本人安卓开发,开发软件为AS。

1. Flutter学习(1)-mac环境安装

本篇文章就是系列文章的第一篇文章,flutter环境安装。
PS:建议在翻墙环境在准备flutter环境的搭建,要不会有一些墙的限制。

下载FlutterSDK并配置环境变量

https://flutter.dev/docs/development/tools/sdk/releases#macos
flutter官网下载就可以,600多兆目前。

下载的同时,建议去AS安装下flutter插件
Android Studio - preferences - plugins - 搜索flutter安装插件即可。安装完成后AS会帮助我们下载flutter和dart两个插件。这是必须安装的,否则在安装过程中会报错

Flutter plugin not installed; this adds Flutter specific functionality
Dart plugin not installed; this adds Dart specific functionality.

原因就是缺少这两个插件,这时候你应该下载好的你的sdk了,开始配置环境变量。

1.打开终端,输入命令,打开bash_profile文件。

vim ~/.bash_profile

如果没有此文件的话,使用命令创建bash_profile文件。

touch .bash_profile

输入i进入INSERT状态。

增加一行:(注意这里写你自己的flutter路径)

export PATH=/Users/zrb/Desktop/androidStudy/flutter/bin:$PATH

保存文件。先 按esc按键退出输入状态,然后输入保存。

:wq

保存完毕之后运行命令使文件生效:

source ~/.bash_profile

这个时候应该能运行flutter命令了,我们运行命令行:

flutter -h

这个时候应该能展示flutter的命令帮助。
运行以下命令查看是否需要安装其它依赖项来完成安装

  flutter doctor 

我的报错:

[✓] Flutter (Channel stable, v1.5.4-hotfix.2, on Mac OS X 10.14.4 18E226, 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.dev/platform-plugins
      To install:
        brew install cocoapods
        pod setup
[✓] Android Studio (version 3.4)
[✓] Connected device (1 available)

一、第一个打钩说明我的Flutter安装没问题
二、第二个说明我的Android SDK有问题,有一些android方面不被许可,执行提示命令,一路Y就可以。
三、第三个是说xcode和iOS工具没安装好,开发IOs,要装一下xcode。其他工具具体就是需要安装他提供的两个库,按照他的说法终端执行如下操作,如果你没有安装homebrew的话,建议去安装一下,要不一下命令你用不了。
brew install --HEAD libimobiledevice
brew install ideviceinstaller
brew install --HEAD libimobiledevice
brew install ideviceinstaller
brew install ios-deploy
brew install cocoapods
pod setup
四五、Flutter插件没问题,一开始我们装插件就解决这个问题哈哈。

全部安装完成以后就会在终端看到这样的提示

[✓] Flutter (Channel stable, v1.5.4-hotfix.2, on Mac OS X 10.14.4 18E226, locale
    zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.2.1)
[✓] Android Studio (version 3.4)
[!] Connected device

创建项目

打开AS,你就会发现你可以创建一个flutter项目:
在这里插入图片描述

运行成功,咱的flutter环境就算配置好了,下周在开始学习flutter的语法。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值