Flutter - Error: The language version override has to be the same in the library and its part(s)

Flutter - Error: The language version override has to be the same in the library and its part(s)

我正在将我的 Flutter SDK 版本从开发通道 (1.14.5) 更新到稳定通道 (2.0.1)。我的代码运行良好,但现在出现此错误。我认为问题出在 slide_countdown_clock 但我不确定。

    lib/Screens/sets4_widget/Countdown.dart:7:6: Error: The language version override has to be the same in the library and its part(s).
part 'package:slide_countdown_clock/clip_digit.dart';
     ^
lib/Screens/sets4_widget/Countdown.dart:8:6: Error: The language version override has to be the same in the library and its part(s).
part 'package:slide_countdown_clock/digit.dart';
     ^
lib/Screens/sets4_widget/Countdown.dart:9:6: Error: The language version override has to be the same in the library and its part(s).
part 'package:slide_countdown_clock/slide_direction.dart';
     ^


FAILURE: Build failed with an exception.

* Where:
Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 13s
Exception: Gradle task assembleDebug failed with exit code 1
     ^

我还在下面分享错误指向我的代码行。

part 'package:slide_countdown_clock/clip_digit.dart';
part 'package:slide_countdown_clock/digit.dart';
part 'package:slide_countdown_clock/slide_direction.dart';

那些部分给我错误。我尝试了 flutter clean > flutter upgrade > flutter pub upgrade 但仍然没有结果。有人可以帮忙吗?

slide_countdown_clock,本包不支持Null Safety,Flutter 2.0.1是带null safety的版本

因此,您不能在 Flutter 2.0.1 版本上使用它。尝试使用另一个支持 Null Safety 的 pub 包。

在现有项目的依赖项不支持 Null Safety 之前,您不应升级到 Flutter 版本 2.0.1。