mirror of
https://github.com/flutter/samples.git
synced 2025-11-11 07:18:15 +00:00
veggieseasons: Migrate to null safety (#922)
This commit is contained in:
@@ -8,10 +8,10 @@ import 'package:veggieseasons/styles.dart';
|
||||
/// Presents a series of trivia questions about a particular widget, and tracks
|
||||
/// the user's score.
|
||||
class TriviaView extends StatefulWidget {
|
||||
final int id;
|
||||
final String restorationId;
|
||||
final int? id;
|
||||
final String? restorationId;
|
||||
|
||||
const TriviaView({this.id, this.restorationId, Key key}) : super(key: key);
|
||||
const TriviaView({this.id, this.restorationId, Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_TriviaViewState createState() => _TriviaViewState();
|
||||
@@ -26,10 +26,10 @@ enum PlayerStatus {
|
||||
|
||||
class _TriviaViewState extends State<TriviaView> with RestorationMixin {
|
||||
/// Current app state. This is used to fetch veggie data.
|
||||
AppState appState;
|
||||
late AppState appState;
|
||||
|
||||
/// The veggie trivia about which to show.
|
||||
Veggie veggie;
|
||||
late Veggie veggie;
|
||||
|
||||
/// Index of the current trivia question.
|
||||
RestorableInt triviaIndex = RestorableInt(0);
|
||||
@@ -45,10 +45,10 @@ class _TriviaViewState extends State<TriviaView> with RestorationMixin {
|
||||
_RestorablePlayerStatus(PlayerStatus.readyToAnswer);
|
||||
|
||||
@override
|
||||
String get restorationId => widget.restorationId;
|
||||
String? get restorationId => widget.restorationId;
|
||||
|
||||
@override
|
||||
void restoreState(RestorationBucket oldBucket, bool initialRestore) {
|
||||
void restoreState(RestorationBucket? oldBucket, bool initialRestore) {
|
||||
registerForRestoration(triviaIndex, 'index');
|
||||
registerForRestoration(score, 'score');
|
||||
registerForRestoration(status, 'status');
|
||||
@@ -234,7 +234,7 @@ class _RestorablePlayerStatus extends RestorableValue<PlayerStatus> {
|
||||
}
|
||||
|
||||
@override
|
||||
PlayerStatus fromPrimitives(Object data) {
|
||||
PlayerStatus fromPrimitives(Object? data) {
|
||||
return PlayerStatus.values[data as int];
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ class _RestorablePlayerStatus extends RestorableValue<PlayerStatus> {
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateValue(PlayerStatus oldValue) {
|
||||
void didUpdateValue(PlayerStatus? oldValue) {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user