Unverified Commit c05c9f77 authored by chunhtai's avatar chunhtai Committed by GitHub

Makes AutomaticKeepAlive.child non null (#101376)

parent 7f64e2ae
...@@ -28,13 +28,13 @@ class AutomaticKeepAlive extends StatefulWidget { ...@@ -28,13 +28,13 @@ class AutomaticKeepAlive extends StatefulWidget {
/// [KeepAlive] widget appropriately. /// [KeepAlive] widget appropriately.
const AutomaticKeepAlive({ const AutomaticKeepAlive({
Key? key, Key? key,
this.child, required this.child,
}) : super(key: key); }) : super(key: key);
/// The widget below this widget in the tree. /// The widget below this widget in the tree.
/// ///
/// {@macro flutter.widgets.ProxyWidget.child} /// {@macro flutter.widgets.ProxyWidget.child}
final Widget? child; final Widget child;
@override @override
State<AutomaticKeepAlive> createState() => _AutomaticKeepAliveState(); State<AutomaticKeepAlive> createState() => _AutomaticKeepAliveState();
...@@ -42,7 +42,7 @@ class AutomaticKeepAlive extends StatefulWidget { ...@@ -42,7 +42,7 @@ class AutomaticKeepAlive extends StatefulWidget {
class _AutomaticKeepAliveState extends State<AutomaticKeepAlive> { class _AutomaticKeepAliveState extends State<AutomaticKeepAlive> {
Map<Listenable, VoidCallback>? _handles; Map<Listenable, VoidCallback>? _handles;
Widget? _child; late Widget _child;
bool _keepingAlive = false; bool _keepingAlive = false;
@override @override
...@@ -60,7 +60,7 @@ class _AutomaticKeepAliveState extends State<AutomaticKeepAlive> { ...@@ -60,7 +60,7 @@ class _AutomaticKeepAliveState extends State<AutomaticKeepAlive> {
void _updateChild() { void _updateChild() {
_child = NotificationListener<KeepAliveNotification>( _child = NotificationListener<KeepAliveNotification>(
onNotification: _addClient, onNotification: _addClient,
child: widget.child!, child: widget.child,
); );
} }
...@@ -228,10 +228,9 @@ class _AutomaticKeepAliveState extends State<AutomaticKeepAlive> { ...@@ -228,10 +228,9 @@ class _AutomaticKeepAliveState extends State<AutomaticKeepAlive> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
assert(_child != null);
return KeepAlive( return KeepAlive(
keepAlive: _keepingAlive, keepAlive: _keepingAlive,
child: _child!, child: _child,
); );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment