flutter-01-hello world入门

124 阅读1分钟

一、mac环境配置

环境要求

  • Operating Systems: macOS
  • Disk Space: 2.8 GB (does not include disk space for IDE/tools).
  • Tools: Flutter uses git for installation and upgrade. We recommend installing Xcode, which includes git, but you can also install git separately.

第一步 下载flutter

推荐去官网下载,速度并不慢,网址:

flutter.io/setup-macos…

也可以直接使用如下链接,直接下载: storage.googleapis.com/flutter_inf…

下载完后解压存在某目录 /Users/{user_name}/flutter

第二步 配置flutter环境变量

2.1 执行如下命令

vim ~/.bash_profile

注意:如果没有~/.bash_profile,用如下命令创建

touch ~/.bash_profile

2.2 添加如下指令

export PATH=/Users/{user_name}/flutter/flutter/bin:$PATH

2.3 保存环境变量

source ~/.bash_profile

第三步 检测flutter是否安装成功

flutter doctor

如果出现[!] ✗号说明这一行有问题,如下: Xnip2022-11-19_14-27-50.jpg 这里表示iOS、Android的环境有问题

Android解决方案

flutter doctor --android-licenses

iOS解决方案

brew install --HEAD libimobiledevice
brew install ideviceinstaller
brew install ios-deploy
brew install cocoapods
pod setup

注意如果出现以下错误 Xnip2022-11-19_14-31-00.jpg 请执行

brew link --overwrite cocoapods

python环境问题

Xnip2022-11-19_14-32-59.jpg 请执行如下执行

brew reinstall python@3
pip install six

第四步 IDE集成flutter插件

这里以vscode为例 Xnip2022-11-19_14-35-26.jpg

二、Hello world工程

book.flutterchina.club/chapter2/fi… 这里是flutter官方提供的demo可以作为入门课

到这里就讲完flutter入门了,下一节是flutter结构、以及运行原理