我正在尝试在我的应用程序上使用 freezed,所以我添加了
environment:
sdk: ">=2.7.0<3.0.0"
freezed: ^0.14.0
freezed_annotation: ^0.14.0
对我的依赖。
dev_dependencies:
freezed_annotation: ^0.12.0
build_runner: ^2.0.1
retrofit_generator:
flutter_localizations:
sdk: flutter
flutter_test:
sdk: flutter
之后,我创建了简单的冻结类:
import 'package:freezed_annotation/freezed_annotation.dart';
part 'chart_daily_expanded_detailes_model.freezed.dart';
@freezed
abstract class ChartDailyExpandedDetailesModel
with _$ChartDailyExpandedDetailesModel {
const factory ChartDailyExpandedDetailesModel({
String title,
String testNumber,
String testPercentage,
String icon,
}) = _ChartDailyExpandedDetailesModel;
}
但我得到了这个错误:
[SEVERE] freezed:freezed on lib/new_develop/model/test/chart_daily_expanded_detailes_model.dart:
The parameter `title` of `ChartDailyExpandedDetailesModel` is non-nullable but is neither required nor marked with @Default
package:app/new_develop/model/test/chart_daily_expanded_detailes_model.dart:9:12
╷
9 │ String title,
这是颤振医生:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.3, on Linux, locale en_US.UTF-8)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/linux#android-setup for more details.
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.2)
[✓] Android Studio
[✓] VS Code (version 1.60.0)
[✓] Connected device (2 available)
! Doctor found issues in 1 category.
我的项目不是空安全的,我想在非空安全状态下使用冻结。