2023-Flutter環(huán)境配置

官方開發(fā)文檔地址

官方開發(fā)文檔地址

Flutter下載包地址

下載包git地址

配置FlutterSDK

1:解壓壓縮包,以我個人配置為例,放到文稿中,并且創(chuàng)建一個文件夾flutterSDK,且把解壓后的文件放入該文件夾中。
配置FlutterSDK.png
2:配置環(huán)境變量

zsh為例(iTerm2)

以`zsh`為例.png

配置環(huán)境變量代碼如下


配置環(huán)境變量代碼.png
#flutter 鏡像地址
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
#flutter 環(huán)境變量
export FLUTTER_PATH=/Users/zzg/Documents/flutterSDK
export PATH=$PATH:$FLUTTER_PATH/bin
export PATH=$PATH:$FLUTTER_PATH/bin/cache/dart-sdk/bin

執(zhí)行生效
命令:

source ~/.zshrc

這個時候應該能運行flutter命令了,我們運行命令行:

flutter -h

執(zhí)行完命令后出現(xiàn)如下日志

Manage your Flutter app development.

Common commands:

  flutter create <output directory>
    Create a new Flutter project in the specified directory.

  flutter run [options]
    Run your Flutter application on an attached device or in an emulator.

Usage: flutter <command> [arguments]

Global options:
-h, --help                  Print this usage information.
-v, --verbose               Noisy logging, including all shell commands
                            executed.
                            If used with --help, shows hidden options.

-d, --device-id             Target device id or name (prefixes allowed).
    --version               Reports the version of this tool.
    --suppress-analytics    Suppress analytics reporting when this command runs.
    --bug-report            Captures a bug report file to submit to the Flutter
                            team.
                            Contains local paths, device identifiers, and log
                            snippets.

    --packages              Path to your ".packages" file.
                            (required, since the current directory does not
                            contain a ".packages" file)

Available commands:
  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.
  help                     Display help information for flutter.
  install                  Install a Flutter app on an attached device.
  logs                     Show log output for running Flutter apps.
  make-host-app-editable   Moves host apps from generated directories to
                           non-generated directories so that they can be edited
                           by developers.
  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.

Run "flutter help <command>" for more information about a command.
Run "flutter help -v" for verbose help output, including less commonly used
options.

檢查環(huán)境

flutter doctor

出現(xiàn)日志如下

![環(huán)境檢查如下](https://upload-images.jianshu.io/upload_images/1416781-f1797dbb30e71ace.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

Doctor summary (to see all details, run flutter doctor -v):
[?] Flutter (Channel stable, v1.0.0, on Mac OS X 10.13.1 17B1003, locale
    zh-Hans-CN)
[?] Android toolchain - develop for Android devices
    ? Unable to locate Android SDK.
      Install Android Studio from:
      https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK
      components.
      (or visit https://flutter.io/setup/#android-setup for detailed
      instructions).
      If Android SDK has been installed to a custom location, set $ANDROID_HOME
      to that location.
      You may also want to add it to your PATH environment variable.

[!] iOS toolchain - develop for iOS devices (Xcode 9.2)
    ? 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 with Brew:
        brew install ios-deploy
[!] Android Studio (not installed)
[?] VS Code (version 1.31.1)
[?] Connected device (1 available)

! Doctor found issues in 3 categories.

3:配置VSCode

1:安裝flutter
安裝flutter.png
2:安裝dart
安裝dart.png

到這里就可以創(chuàng)建flutter程序了

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容