gpt4 book ai didi

Flutter build web 构建没有健全的 null 安全并且在错误时运行

转载 作者:行者123 更新时间:2023-12-02 02:18:15 31 4
gpt4 key购买 nike

运行 flutter build web 出现以下错误:

flutter build web
Changing current working directory to: /home/forest/projects/icell/i_cell_parking_manager

Building without sound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety

Target dart2js failed: Exception: ../../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-1.0.1/lib/src/interop/utils/utils.dart:15:41:
Error: The argument type 'Object? Function(Object)' can't be assigned to the parameter type 'Object? Function(Object?)?' because 'Object?' is nullable and 'Object' isn't.
- 'Object' is from 'dart:core'.
return core_interop.dartify(jsObject, (Object object) {
^
../../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore_web-1.0.1/lib/src/interop/utils/utils.dart:39:41:
Error: The argument type 'dynamic Function(Object)' can't be assigned to the parameter type 'Object? Function(Object?)?' because 'Object?' is nullable and 'Object' isn't.
- 'Object' is from 'dart:core'.
return core_interop.jsify(dartObject, (Object object) {
^
Error: Compilation failed.


Compiling lib/main.dart for the Web... 8.3s
Exception: Failed to compile application for the Web.

Android 构建工作没有任何错误(flutter build apk)。

flutter 医生

Flutter 2.0.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 4d7946a68d (10 days ago) • 2021-03-18 17:24:33 -0700
Engine • revision 3459eb2436
Tools • Dart 2.12.2

Running flutter doctor...
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.3, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Chrome - develop for the web
[!] Android Studio (not installed)
[✓] IntelliJ IDEA Ultimate Edition (version 2020.2)
[✓] Connected device (2 available)
! Doctor found issues in 1 category.

(未安装的 Androd studio 很奇怪,因为我正在从它运行项目,并且我使用来自 AVD 的虚拟设备没有问题...)

我的 index.html 导入了最新的库:

...

<script src="https://www.gstatic.com/firebasejs/7.8.0/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.20.0/firebase-app.js"></script>

相关pubspec.yaml部分:

dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
flutter_spinkit: "^4.1.2"
cloud_firestore: ^1.0.1
cloud_functions: "^1.0.2"
provider: ^5.0.0
google_sign_in: ^5.0.0
firebase_core: ^1.0.1
firebase_messaging: ^9.0.0
firebase_auth: ^1.0.1

最佳答案

要在没有空安全的情况下制作发布版本:

flutter build web --no-sound-null-safety

生成的文件会放在build/web下.

NOTE: The --no-sound-null-safety must be passed as a flag to the web subcommand, and not to build or flutter.


NOTE2: The build sets <base href="/"> therefore unless you serve your app from the webserver root you'll need to adjust the value to the correct path. There is a github issue to make the base href configurable via a command line parameter. The current docs recommend to set the base href by hand. UPDATE: the corresponding pull request is now merged to the master branch.

关于Flutter build web 构建没有健全的 null 安全并且在错误时运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66851542/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com