flutter - 从 2.8.1 升级到 Flutter 3.0,得到 : Warning: Op

从 2.8.1 升级到 Flutter 3.0,得到:Warning: Operand of null-aware operation '?.'具有排除空错误的“PaintingBinding”类型

它在 binding.dart 上——一个我根本不碰的文件。

() => PaintingBinding.instance?.imageCache?.evict(key),
                            ^

你们有没有机会知道我该如何解决它?

不知道是否相关,但也经常看到:

Class 'kotlin.Unit' was compiled with an incompatible version

使用此处的指南进行迁移:https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects

这是我的发布规范:

environment:
  sdk: '>=2.12.0 <3.0.0'

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter

  google_maps_flutter: ^2.0.6
  rxdart:
  shimmer:
  cupertino_icons: ^1.0.3

  dependencies:
  flutter_svg: ^1.0.0

  http: ^0.13.3
  flutter_spinkit: ^5.0.0
  url_launcher: ^6.0.9
  html: ^0.15.0
  cached_network_image: ^3.1.0
  collection: ^1.15.0
  share_plus: ^3.0.4
  flutter_native_splash: ^1.3.2


dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_launcher_icons: ^0.9.2

flutter_icons:
  android: true
  ios: true
  image_path: "assets/app/launch/ic_launcher.png"
  adaptive_icon_padding: true

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  # assets:
  #  - images/a_dot_burr.jpeg
  #  - images/a_dot_ham.jpeg

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

最佳答案

所以,一些对我有帮助的事情:

  1. 删除下一个文件夹/Users/your-user/.pub-cache/hosted/pub.dartlang.org
  2. 点击 flutter pub upgrade

然后尝试运行你的项目 ?

关于flutter - 从 2.8.1 升级到 Flutter 3.0,得到 : Warning: Operand of null-aware operation '?.' has type 'PaintingBinding' which excludes null error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72222750/

相关文章:

visual-studio - 如何一次查找和替换多个不同的键值对?

angular - 如何重置表单中的特定字段?

hibernate - 我在 grails 中遇到完整性违规异常。如何级联删除到grails中的相关

azure - 我正在将 AddMicrosoftIdentityWebApi .net core

node.js - 如何在工作区中使用 npm-shrinkwrap?

google-cloud-platform - 为什么 Airflow PubSubPullOper

python - 最大方程长度

mysql - 运行 mysql_secure_installation 时出现错误

amazon-web-services - 如何找出弹性 beantalk 部署失败的原因?

rust - 为什么 cargo build 在 git 更改锁时忽略锁文件?