1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-10 23:08:59 +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

@@ -12,10 +12,10 @@ import 'package:veggieseasons/styles.dart';
class FrostedBox extends StatelessWidget {
const FrostedBox({
this.child,
Key key,
Key? key,
}) : super(key: key);
final Widget child;
final Widget? child;
@override
Widget build(BuildContext context) {
@@ -37,18 +37,15 @@ class ColorChangingIcon extends ImplicitlyAnimatedWidget {
this.icon, {
this.color = CupertinoColors.black,
this.size,
@required Duration duration,
Key key,
}) : assert(icon != null),
assert(color != null),
assert(duration != null),
super(key: key, duration: duration);
required Duration duration,
Key? key,
}) : super(key: key, duration: duration);
final Color color;
final IconData icon;
final double size;
final double? size;
@override
_ColorChangingIconState createState() => _ColorChangingIconState();
@@ -56,7 +53,7 @@ class ColorChangingIcon extends ImplicitlyAnimatedWidget {
class _ColorChangingIconState
extends AnimatedWidgetBaseState<ColorChangingIcon> {
ColorTween _colorTween;
ColorTween? _colorTween;
@override
Widget build(BuildContext context) {
@@ -73,14 +70,14 @@ class _ColorChangingIconState
_colorTween = visitor(
_colorTween,
widget.color,
(dynamic value) => ColorTween(begin: value as Color),
) as ColorTween;
(dynamic value) => ColorTween(begin: value as Color?),
) as ColorTween?;
}
}
/// A simple "close this modal" button that invokes a callback when pressed.
class CloseButton extends StatefulWidget {
const CloseButton(this.onPressed, {Key key}) : super(key: key);
const CloseButton(this.onPressed, {Key? key}) : super(key: key);
final VoidCallback onPressed;