简体   繁体   English

如何在 null 安全后将您的 Flutter 项目(应用程序)升级到最新的 Flutter 版本?

[英]How to upgrade your flutter project (app) to the latest flutter version after null safety?

I want to upgrade my project which is on Flutter 2.0 to the latest version of flutter (2.5).我想将 Flutter 2.0 上的项目升级到最新版本的 flutter (2.5)。

I have already seen this question which is most relevant.我已经看到了这个最相关的问题。 How do I upgrade an existing Flutter app?如何升级现有的 Flutter 应用程序?

In my Mac, I have Flutter upgraded to 2.5.在我的 Mac 中,我已将 Flutter 升级到 2.5。 You can see the output of flutter doctor -v below:您可以在下面看到flutter doctor -v的输出:

[✓] Flutter (Channel stable, 2.5.0, on macOS 11.5.2 20G95 darwin-arm, locale
    en-PK)
    • Flutter version 2.5.0 at /Users/ahmad/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4cc385b4b8 (9 days ago), 2021-09-07 23:01:49 -0700
    • Engine revision f0826da7ef
    • Dart version 2.14.0

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/ahmad/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5.1, Build version 12E507
    • CocoaPods version 1.11.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] Connected device (2 available)
    • iPhone 12 Pro Max (mobile) • 57868E1C-4871-4185-A797-383121736AB8 • ios
      • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
    • Chrome (web)               • chrome                               •
      web-javascript • Google Chrome 93.0.4577.82

• No issues found!

I have searched over the internet about it.我已经在互联网上搜索过它。 Mostly, I see two things, either how to upgrade to null-safety (which means from earlier versions to 2.0) or how to upgrade Flutter sdk in your system.大多数情况下,我看到了两件事,要么如何升级到 null-safety(这意味着从早期版本到 2.0),要么如何升级系统中的 Flutter sdk。

I have tried running flutter upgrade command which says I'm up-to-date.我试过运行flutter upgrade命令,它说我是最新的。 I have also tried running flutter pub upgrade .我也试过运行flutter pub upgrade Both do not change the version of flutter in the pubspec.lock file inside my project which says at the end of file:两者都不会更改我项目中的pubspec.lock文件中的pubspec.lock版本,该文件在文件末尾显示:

sdks:
  dart: ">=2.14.0 <3.0.0"
  flutter: ">=2.0.0"

Please guide me how can I upgrade my project to the latest version.请指导我如何将我的项目升级到最新版本。 Thanks in advance :)提前致谢 :)

You're using flutter: >=2.0.0 which basically tells your app to use 2.0.0.您正在使用flutter: >=2.0.0基本上告诉您的应用程序使用 2.0.0。 Usually using the flutter sdk constraint is only used in plugins.通常使用 flutter sdk 约束只在插件中使用。 It's okay to leave this out, if you remove flutter: >=2.0.0 it will automatically use your SDK version可以忽略这一点,如果您删除flutter: >=2.0.0它将自动使用您的 SDK 版本

The Flutter project will have the same version as your system does. Flutter 项目将与您的系统具有相同的版本。 If you have the latest Flutter version on your system, then the app built from that system will have the latest version.如果您的系统上有最新的 Flutter 版本,那么从该系统构建的应用程序将具有最新版本。

For example, if your system has Flutter 2.8 (latest while answering) and you build an app through it, your app is based on 2.8.例如,如果您的系统有 Flutter 2.8(在回答时最新)并且您通过它构建了一个应用程序,那么您的应用程序是基于 2.8 的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM