缓存的网络映像在flutter中使用不可为null后引发错误



当前使用Non-Nullable进行flutter,除cached_network_image外,所有依赖项都可以正常工作。

我的出版物名称:

environment:
sdk: ">=2.10.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cached_network_image: ^2.3.3

在VS代码的launch.json中,我包含了args:

"--enable-experiment=non-nullable",
"--no-sound-null-safety",

我还添加了analysis_options.yaml:

analyzer:
enable-experiment:
- non-nullable

我得到的错误:

../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/src/compat.dart:1:1: Error: Null safe libraries are not allowed to export declarations from of opt-out libraries.
export 'package:sqflite_common/src/compat.dart';
^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/src/sqflite_import.dart:5:1: Error: Null safe libraries are not allowed to export declarations from of opt-out libraries.
export 'package:sqflite_common/src/compat.dart' show SqfliteOptions;
^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/src/constant.dart:1:1: Error: Null safe libraries are not allowed to export declarations from of opt-out libraries.
export 'package:sqflite_common/src/constant.dart';
^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/src/utils.dart:1:1: Error: Null safe libraries are not allowed to export declarations from of opt-out libraries.
export 'package:sqflite_common/src/utils.dart';
^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/utils/utils.dart:1:1: Error: Null safe libraries are not allowed to export declarations from of opt-out libraries.
export 'package:sqflite_common/utils/utils.dart';
^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/sqlite_api.dart:1:1: Error: Null safe libraries are not allowed to export declarations from of opt-out libraries.
export 'package:sqflite_common/sqlite_api.dart';
^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/src/sqflite_import.dart:18:1: Error: Null safe libraries are not allowed to export declarations from of opt-out libraries.
export 'package:sqflite_common/src/factory_mixin.dart'
^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/src/sqflite_import.dart:8:1: Error: Null safe libraries are not allowed to export declarations from of opt-out libraries.
export 'package:sqflite_common/src/database.dart' // ignore: implementation_imports
^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/src/sqflite_import.dart:12:1: Error: Null safe libraries are not allowed to export declarations from of opt-out libraries.
export 'package:sqflite_common/src/database_mixin.dart' // ignore: implementation_imports
^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/src/sqflite_import.dart:16:1: Error: Null safe libraries are not allowed to export declarations from of opt-out libraries.
export 'package:sqflite_common/src/exception.dart'
^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/src/sqflite_import.dart:20:1: Error: Null safe libraries are not allowed to export declarations from of opt-out libraries.
export 'package:sqflite_common/src/factory.dart' show SqfliteDatabaseFactory;
^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/src/sqflite_import.dart:21:1: Error: Null safe libraries are not allowed to export declarations from of opt-out libraries.
export 'package:sqflite_common/src/mixin/constant.dart'
^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/src/sqflite_import.dart:32:1: Error: Null safe libraries are not allowed to export declarations from of opt-out libraries.
export 'package:sqflite_common/src/mixin/factory.dart'
^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/src/sql_builder.dart:1:1: Error: Null safe libraries are not allowed to export declarations from of opt-out libraries.
export 'package:sqflite_common/src/sql_builder.dart';
^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/sqflite.dart:13:1: Error: Null safe libraries are not allowed to export declarations from of opt-out libraries.
export 'package:sqflite/src/compat.dart';
^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/sqflite.dart:16:1: Error: Null safe libraries are not allowed to export declarations from of opt-out libraries.
export 'sqlite_api.dart';
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/sql.dart:5:1: Error: Null safe libraries are not allowed to export declarations from of opt-out libraries.
export 'package:sqflite/src/sql_builder.dart'
^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/sqflite.dart:12:1: Error: Null safe libraries are not allowed to export declarations from of opt-out libraries.
export 'package:sqflite/sql.dart' show ConflictAlgorithm;
^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/sqflite.dart:70:17: Error: Optional parameter 'duration' should have a default value because its type 'Duration' doesn't allow null.
- 'Duration' is from 'dart:core'.
{Duration duration, void Function() callback}) {
^^^^^^^^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/sqflite.dart:70:43: Error: Optional parameter 'callback' should have a default value because its type 'void Function()' doesn't allow null.
{Duration duration, void Function() callback}) {
^^^^^^^^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/sqflite.dart:128:10: Error: Optional parameter 'version' should have a default value because its type 'int' doesn't allow null.
{int version,
^^^^^^^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/sqflite.dart:129:27: Error: Optional parameter 'onConfigure' should have a default value because its type 'FutureOr<void> Function(Database)' doesn't allow null.
- 'Database' is from 'package:sqflite_common/sqlite_api.dart' ('../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite_common-1.0.2+1/lib/sqlite_api.dart').
OnDatabaseConfigureFn onConfigure,
^^^^^^^^^^^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/sqflite.dart:130:24: Error: Optional parameter 'onCreate' should have a default value because its type 'FutureOr<void> Function(Database, int)' doesn't allow null.
- 'Database' is from 'package:sqflite_common/sqlite_api.dart' ('../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite_common-1.0.2+1/lib/sqlite_api.dart').
OnDatabaseCreateFn onCreate,
^^^^^^^^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/sqflite.dart:131:31: Error: Optional parameter 'onUpgrade' should have a default value because its type 'FutureOr<void> Function(Database, int, int)' doesn't allow null.
- 'Database' is from 'package:sqflite_common/sqlite_api.dart' ('../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite_common-1.0.2+1/lib/sqlite_api.dart').
OnDatabaseVersionChangeFn onUpgrade,
^^^^^^^^^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/sqflite.dart:132:31: Error: Optional parameter 'onDowngrade' should have a default value because its type 'FutureOr<void> Function(Database, int, int)' doesn't allow null.
- 'Database' is from 'package:sqflite_common/sqlite_api.dart' ('../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite_common-1.0.2+1/lib/sqlite_api.dart').
OnDatabaseVersionChangeFn onDowngrade,
^^^^^^^^^^^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/sqflite.dart:133:22: Error: Optional parameter 'onOpen' should have a default value because its type 'FutureOr<void> Function(Database)' doesn't allow null.
- 'Database' is from 'package:sqflite_common/sqlite_api.dart' ('../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite_common-1.0.2+1/lib/sqlite_api.dart').
OnDatabaseOpenFn onOpen,
^^^^^^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/src/factory_impl.dart:10:24: Error: Field '_databaseFactory' should be initialized because its type 'SqfliteDatabaseFactory' doesn't allow null.
- 'SqfliteDatabaseFactory' is from 'package:sqflite_common/src/factory.dart' ('../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite_common-1.0.2+1/lib/src/factory.dart').
SqfliteDatabaseFactory _databaseFactory;
^^^^^^^^^^^^^^^^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/src/factory_impl.dart:42:30: Error: The value 'null' can't be assigned to a variable of type 'SqfliteDatabaseFactory' because 'SqfliteDatabaseFactory' is not nullable.
- 'SqfliteDatabaseFactory' is from 'package:sqflite_common/src/factory.dart' ('../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite_common-1.0.2+1/lib/src/factory.dart').
sqfliteDatabaseFactory = null;
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/src/factory_impl.dart:53:5: Warning: Operand of null-aware operation '??=' has type 'SqfliteDatabaseFactory' which excludes null.
- 'SqfliteDatabaseFactory' is from 'package:sqflite_common/src/factory.dart' ('../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite_common-1.0.2+1/lib/src/factory.dart').
_databaseFactory ??= SqfliteDatabaseFactoryImpl();
^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/src/factory_impl.dart:67:5: Warning: Operand of null-aware operation '??=' has type 'SqfliteDatabaseFactory' which excludes null.
- 'SqfliteDatabaseFactory' is from 'package:sqflite_common/src/factory.dart' ('../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite_common-1.0.2+1/lib/src/factory.dart').
_databaseFactory ??= SqfliteDatabaseFactoryImpl();
^
../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/src/sqflite_impl.dart:17:13: Error: A value of type 'Future<T?>' can't be returned from a function with return type 'Future<T>' because 'T?' is nullable and 'T' isn't.
- 'Future' is from 'dart:async'.
channel.invokeMethod<T>(method, arguments);

FAILURE: Build failed with an exception.
* Where:
Script '/../flutter_tools/gradle/flutter.gradle' line: 900
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDevDebug'.
> Process 'command '/../flutter/bin/flutter'' finished with non-zero exit value 1

cached_network_image似乎没有空的安全版本。如果有人遇到过这种情况或有见解,请告诉我。非常感谢!

删除"args"的完整密钥:

"args": [
"--enable-experiment=non-nullable",
"--no-sound-null-safety",
]

最新更新