美文网首页
2023-Flutter环境配置

2023-Flutter环境配置

作者: 洲洲哥 | 来源:发表于2023-02-08 17:26 被阅读0次

    官方开发文档地址

    官方开发文档地址

    Flutter下载包地址

    下载包git地址

    配置FlutterSDK

    1:解压压缩包,以我个人配置为例,放到文稿中,并且创建一个文件夹flutterSDK,且把解压后的文件放入该文件夹中。
    配置FlutterSDK.png
    2:配置环境变量

    zsh为例(iTerm2)

    以`zsh`为例.png

    配置环境变量代码如下


    配置环境变量代码.png
    #flutter 镜像地址
    export PUB_HOSTED_URL=https://pub.flutter-io.cn
    export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
    #flutter 环境变量
    export FLUTTER_PATH=/Users/zzg/Documents/flutterSDK
    export PATH=$PATH:$FLUTTER_PATH/bin
    export PATH=$PATH:$FLUTTER_PATH/bin/cache/dart-sdk/bin
    

    执行生效
    命令:

    source ~/.zshrc
    

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

    flutter -h
    

    执行完命令后出现如下日志

    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.
    
    

    检查环境

    flutter doctor
    

    出现日志如下

    ![环境检查如下](https://img.haomeiwen.com/i1416781/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

    到这里就可以创建flutter程序了

    相关文章

      网友评论

          本文标题:2023-Flutter环境配置

          本文链接:https://www.haomeiwen.com/subject/bgiqkdtx.html