1
0
mirror of https://github.com/flutter/samples.git synced 2026-05-14 02:47:42 +00:00

veggieseasons: Migrate to null safety (#922)

This commit is contained in:
Brett Morgan
2021-10-12 10:27:54 +11:00
committed by GitHub
parent 994cdb4afa
commit ac2bef7d83
21 changed files with 134 additions and 148 deletions

View File

@@ -16,7 +16,7 @@ import 'package:veggieseasons/styles.dart';
typedef SettingsItemCallback = FutureOr<void> Function();
class SettingsNavigationIndicator extends StatelessWidget {
const SettingsNavigationIndicator({Key key}) : super(key: key);
const SettingsNavigationIndicator({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
@@ -30,12 +30,11 @@ class SettingsNavigationIndicator extends StatelessWidget {
class SettingsIcon extends StatelessWidget {
const SettingsIcon({
@required this.icon,
required this.icon,
this.foregroundColor = CupertinoColors.white,
this.backgroundColor = CupertinoColors.black,
Key key,
}) : assert(icon != null),
super(key: key);
Key? key,
}) : super(key: key);
final Color backgroundColor;
final Color foregroundColor;
@@ -61,20 +60,19 @@ class SettingsIcon extends StatelessWidget {
class SettingsItem extends StatefulWidget {
const SettingsItem({
@required this.label,
required this.label,
this.icon,
this.content,
this.subtitle,
this.onPress,
Key key,
}) : assert(label != null),
super(key: key);
Key? key,
}) : super(key: key);
final String label;
final Widget icon;
final Widget content;
final String subtitle;
final SettingsItemCallback onPress;
final Widget? icon;
final Widget? content;
final String? subtitle;
final SettingsItemCallback? onPress;
@override
State<StatefulWidget> createState() => SettingsItemState();
@@ -97,7 +95,7 @@ class SettingsItemState extends State<SettingsItem> {
setState(() {
pressed = true;
});
await widget.onPress();
await widget.onPress!();
Future.delayed(
const Duration(milliseconds: 150),
() {
@@ -138,7 +136,7 @@ class SettingsItemState extends State<SettingsItem> {
style: themeData.textTheme.textStyle),
const SizedBox(height: 4),
Text(
widget.subtitle,
widget.subtitle!,
style: Styles.settingsItemSubtitleText(themeData),
),
],