Flutter学习笔记(一)

安装flutter:https://flutter.io/setup-macos/

环境要求:

  • Operating Systems: macOS (64-bit)

  • Disk Space: 700 MB (does not include disk space for IDE/tools).

  • Tools: Flutter depends on these command-line tools being available in your environment.

  • bash, mkdir, rm, git, curl, unzip, which

配置国内镜像

export PUB_HOSTED_URL=https://pub.flutter-io.cn export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

下载代码到本地:

cd /usr/local git clone -b dev https://github.com/flutter/flutter.git

添加到path目录,可全局访问

export PATH="$PWD/flutter/bin:$PATH"

安装IDE插件

Android Studio: Flutter、Dart

VS Code: Flutter

运行flutter环境检查程序,检查本地环境安装情况 cd ./flutter flutter doctor

IOS环境配置:

  1. 安装Xcode 9.0及以上
  2. sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
  3. 接受xcode协议,打开Xcode工具接受协议,或执行命令: sudo xcodebuild -license
  4. 发布到真机需要安装的环境:

安装homebrew,如果已安装跳过

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

安装依赖的软件:

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

常用命令:

启动IOS模拟器:

open -a Simulator

运行flutter程序:

flutter run //运行程序
flutter test //运行测试用例

执行flutter安装环境检查

flutter doctor

常用命令

flutter packages get //下载依赖
flutter packages upgrade //更新依赖
flutter packages test //运行测试
flutter packages pub

flutter完整命令列表:

analyze Analyze the project's Dart code.
attach Attach to a running application.
bash-completion Output command line shell completion setup scripts.
build Flutter build commands.
channel List or switch flutter channels.
clean Delete the build/ directory.
config Configure Flutter settings.
create Create a new Flutter project.
devices List all connected devices.
doctor Show information about the installed tooling.
drive Runs Flutter Driver tests for the current project.
emulators List, launch and create emulators.
format Format one or more dart files.
fuchsia_reload Hot reload on Fuchsia.
help Display help information for flutter.
install Install a Flutter app on an attached device.
logs Show log output for running Flutter apps.
packages Commands for managing Flutter packages.
precache Populates the Flutter tool's cache of binary artifacts.
run Run your Flutter app on an attached device.
screenshot Take a screenshot from a connected device.
stop Stop your Flutter app on an attached device.
test Run Flutter unit tests for the current project.
trace Start and stop tracing for a running Flutter app.
upgrade Upgrade your copy of Flutter.

你可能感兴趣的:(Flutter学习笔记(一))