问题:Logger.onLevelChanged
Failed to build json_model:json_model: ../../AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/build_runner_core-7.2.2/lib/src/logging/build_for_input_logger.dart:13:7: Error: The non-abstract class 'BuildForInputLogger' is missing implementations for th ese members:
- Logger.onLevelChanged Try to either
- provide an implementation,
- inherit an implementation from a superclass or mixin,
- mark the class as abstract, or
- provide a 'noSuchMethod' implementation.
class BuildForInputLogger implements Logger { ^^^^^^^^^^^^^^^^^^^ ../../AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/logging-1.2.0/lib/src/logger.dart:162:22: Context: 'Logger.onLevelChanged' is defined here. Stream<Level?> get onLevelChanged { ^^^^^^^^^^^^^^ ../../AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/build_runner-2.1.11/lib/src/build_script_generate/bootstrap.dart:76:40: Error: Method not found: 'NullThrownError'. final error = e[0] as Object? ?? NullThrownError();
dev_dependencies: flutter_lints: ^2.0.0 json_model: ^1.0.0 json_serializable: ^5.0.0
dev_dependencies: flutter_lints: ^2.0.0 json_model: ^1.0.0 json_serializable: ^5.0.0
I resolved the same error by following the below link: https://github.com/dart-lang/build/issues/3519#issuecomment-1722803465
Terminal Command: 1.dart pub upgrade 2.dart pub outdated 3.dart pub upgrade --major-versions 4.flutter packages pub run json_model or (dart run json_mode)
because the version of logging in your project is incompatible with the version used by json_model, you should specify the logging version.
just do it follow this:
-
delete pubspec.lock
-
add dependencies logging: ^1.0.1
-
flutter pub get