美文网首页
flutter channel通道切换与Config

flutter channel通道切换与Config

作者: YXWKY | 来源:发表于2020-09-27 11:04 被阅读0次

flutter channel 有四个版本,按稳定度递增排序分别是:

  • master 最初的版本,功能可能会在后面的版本中被删减
  • dev 由master过来的经过全面测试的,比master更稳定完善的版本
  • beta 由master分支过来的,比dev版本更稳定的版本
  • stable 由beta版本过来的,最终稳定的版本,生产环境建议使用此版本

有时候我们切换到某一个版本是为了使用stable暂不支持的功能,要了解某个功能在哪个版本受支持时,需要用到config命令,举例:我需要用flutter 开发windows客户端程序,这个时候我需要知道有哪些flutter版本目前是支持该功能的,所以我执行:

flutter config

得到如下数据:

Configure Flutter settings.

To remove a setting, configure it to an empty string.

The Flutter tool anonymously reports feature usage statistics and basic crash reports to help improve Flutter tools over time. See Google's privacy policy: https://www.google.com/intl/en/policies/privacy/

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.

Usage: flutter config [arguments]
-h, --help                                      Print this usage information.
    --[no-]analytics                            Enable or disable reporting anonymously tool usage statistics and crash reports.
    --clear-ios-signing-cert                    Clear the saved development certificate choice used to sign apps for iOS device deployment.
    --android-sdk                               The Android SDK directory.
    --android-studio-dir                        The Android Studio install directory.
    --build-dir=<out/>                          The relative path to override a projects build directory
    --[no-]enable-web                           Enable or disable Flutter for web. This setting will take effect on the master, dev, and beta channels.
    --[no-]enable-linux-desktop                 Enable or disable Flutter for desktop on Linux. This setting will take effect on the master and dev channels.
    --[no-]enable-macos-desktop                 Enable or disable Flutter for desktop on macOS. This setting will take effect on the master and dev channels.
    --[no-]enable-windows-desktop               Enable or disable Flutter for desktop on Windows. This setting will take effect on the master channel.
    --[no-]single-widget-reload-optimization    Enable or disable Hot reload optimization for changes to class body of a single widget. This setting will take effect on the master, dev, beta, and stable
                                                channels.
    --[no-]enable-android                       Enable or disable Flutter for Android. This setting will take effect on the master, dev, beta, and stable channels.
    --[no-]enable-ios                           Enable or disable Flutter for iOS. This setting will take effect on the master, dev, beta, and stable channels.
    --[no-]enable-fuchsia                       Enable or disable Flutter for Fuchsia. This setting will take effect on the master channel.
    --clear-features                            Remove all configured features and restore them to the default values.

Run "flutter help" to see global options.

Settings:
  enable-web: true
  enable-windows-desktop: true (Unavailable)

Analytics reporting is currently enabled.

使用该方法可以看到上面的enable-windows-desktop后面的描述信息,指明了启用该功能仅在master版本上产生作用。
所以我仅需执行下面的命令执行切换版本动作:

flutter channel master //flutter channel 可以看到所有的版本

注意:如果一直没有响应,可以尝试到flutter安装目录执行:git clean -xffd命令后再做切换。
切换成功后将会提示:

Switching to flutter channel 'master'...
git: Branch 'master' set up to track remote branch 'master' from 'origin'.
git: Switched to a new branch 'master'
Successfully switched to flutter channel 'master'.
To ensure that you're on the latest build from this channel, run 'flutter upgrade'

根据最后一行的信息我们知道,需要更新版本,所以跟着操作就可以了:

flutter upgrade

成功后得到下面的信息表示成功:

Checking Dart SDK version...
Downloading Dart SDK from Flutter engine 3a73d073c8bedb678d82ee78daf05037b3a7a85e...
Building flutter tool...
Running pub upgrade...
Flutter is already up to date on channel master
Flutter 1.22.0-10.0.pre.380 • channel master • https://github.com/flutter/flutter.git
Framework • revision ec40df9576 (22 hours ago) • 2020-09-25 21:27:22 -0700
Engine • revision 3a73d073c8
Tools • Dart 2.11.0 (build 2.11.0-161.0.dev)

最后,运行devices命令查看已经连接的客户端:

flutter devices

出现下面的结果表示一切准备就绪,可以开始编码了:

4 connected devices:

MX5 (mobile)      • 85GBBM82258V • android-arm64  • Android 5.1 (API 22)
Windows (desktop) • windows      • windows-x64    • Microsoft Windows [Version 10.0.18362.1016]
Web Server (web)  • web-server   • web-javascript • Flutter Tools
Chrome (web)      • chrome       • web-javascript • Google Chrome 79.0.3945.88

提示:

windows开发需要在visual studio里面下载安装c++桌面开发程序

  • Visual Studio 2019 (not to be confused with Visual Studio Code) with the “Desktop development with C++” workload installed, including all of its default components

相关文章

网友评论

      本文标题:flutter channel通道切换与Config

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