【问题标题】:Flutter null safety issues, unable to compileFlutter null 安全问题,无法编译
【发布时间】:2021-06-21 12:26:28
【问题描述】:

我在构建 FLUTTER WEB 应用程序时遇到以下错误:

Error: Cannot run with sound null safety, because the following dependencies don't support null safety:

 - package:html2md
 - package:html
 - package:csslib

For solutions, see https://dart.dev/go/unsound-null-safety ../../../flutter/.pub-cache/hosted/pub.dartlang.org/easy_web_view-1.4.0-nullsafety/lib/src/web.dart:61:5: Warning: Operand of null-aware operation '?.' has type 'EasyWebView' which excludes null.
 - 'EasyWebView' is from 'package:easy_web_view/src/web.dart' ('../../../flutter/.pub-cache/hosted/pub.dartlang.org/easy_web_view-1.4.0-nullsafety/lib/src/web.dart').
    widget?.onLoaded();
    ^ ../../../flutter/.pub-cache/hosted/pub.dartlang.org/easy_web_view-1.4.0-nullsafety/lib/src/web.dart:66:15: Warning: Operand of null-aware operation '?.' has type 'EasyWebView' which excludes null.
 - 'EasyWebView' is from 'package:easy_web_view/src/web.dart' ('../../../flutter/.pub-cache/hosted/pub.dartlang.org/easy_web_view-1.4.0-nullsafety/lib/src/web.dart').
          if (widget?.onLoaded != null) {
              ^ ../../../flutter/.pub-cache/hosted/pub.dartlang.org/easy_web_view-1.4.0-nullsafety/lib/src/web.dart:95:14: Warning: Operand of null-aware operation '?.' has type 'EasyWebView' which excludes null.
 - 'EasyWebView' is from 'package:easy_web_view/src/web.dart' ('../../../flutter/.pub-cache/hosted/pub.dartlang.org/easy_web_view-1.4.0-nullsafety/lib/src/web.dart').
      width: widget?.width,
             ^ ../../../flutter/.pub-cache/hosted/pub.dartlang.org/easy_web_view-1.4.0-nullsafety/lib/src/web.dart:96:15: Warning: Operand of null-aware operation '?.' has type 'EasyWebView' which excludes null.
 - 'EasyWebView' is from 'package:easy_web_view/src/web.dart' ('../../../flutter/.pub-cache/hosted/pub.dartlang.org/easy_web_view-1.4.0-nullsafety/lib/src/web.dart').
      height: widget?.height,
              ^ ../../../flutter/.pub-cache/hosted/pub.dartlang.org/easy_web_view-1.4.0-nullsafety/lib/src/web.dart:124:20: Warning: Operand of null-aware operation '?.' has type 'EasyWebView' which excludes null.
 - 'EasyWebView' is from 'package:easy_web_view/src/web.dart' ('../../../flutter/.pub-cache/hosted/pub.dartlang.org/easy_web_view-1.4.0-nullsafety/lib/src/web.dart').
              key: widget?.key,
                   ^ Unhandled exception: Bad state: Unsupported Null Safety mode NonNullableByDefaultCompiledMode.Invalid, in null.
#0      ProgramCompiler.emitModule (package:dev_compiler/src/kernel/compiler.dart:435:9)
#1      JavaScriptBundler.compile (package:frontend_server/src/javascript_bundle.dart:144:33)
#2      FrontendCompiler.writeJavascriptBundle (package:frontend_server/frontend_server.dart:632:20) <asynchronous suspension>
#3      FrontendCompiler.compile (package:frontend_server/frontend_server.dart:545:9) <asynchronous suspension>
#4      listenAndCompile.<anonymous closure> (package:frontend_server/frontend_server.dart:1105:11) <asynchronous suspension> Finished with error: the Dart compiler exited unexpectedly. Failed to compile application.

以下是我的依赖项:

  cupertino_icons: ^1.0.2
  http: ^0.13.1
  json_annotation: ^4.0.1
  provider: ^5.0.0
  google_fonts: ^2.0.0
  vibration: ^1.7.4-nullsafety.0 #^1.7.4
  firebase_core: ^1.0.2
  cloud_firestore: ^1.0.2
  easy_web_view: ^1.4.0-nullsafety #easy_web_view: ^1.3.0
  intl: ^0.17.0
  uuid: ^3.0.2
  url_launcher: ^6.0.2
  shared_preferences: ^2.0.5

【问题讨论】:

    标签: flutter dart flutter-dependencies flutter-web


    【解决方案1】:

    easy_web_view: ^1.4.0-nullsafety 使用版本 0.5.1 中的包 html2md,它不完全支持 null 安全性。

    html2md 在支持空值安全的 1.0.0 版本中可用,但使用此新版本的 easy_web_view 没有更新。

    您将不得不等待easy_web_view 的维护者创建更新版本,或者您可以帮助并分支并自己做。

    【讨论】:

    猜你喜欢
    • 2021-06-03
    • 2021-11-09
    • 1970-01-01
    • 2021-04-04
    • 1970-01-01
    • 2020-08-13
    • 1970-01-01
    • 2021-09-02
    • 2022-11-09
    相关资源
    最近更新 更多