From c05c9f77c04143efb912ffb7e7aad6d313c9d63d Mon Sep 17 00:00:00 2001 From: chunhtai <47866232+chunhtai@users.noreply.github.com> Date: Wed, 6 Apr 2022 09:51:35 -0700 Subject: [PATCH] Makes AutomaticKeepAlive.child non null (#101376) --- .../flutter/lib/src/widgets/automatic_keep_alive.dart | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/flutter/lib/src/widgets/automatic_keep_alive.dart b/packages/flutter/lib/src/widgets/automatic_keep_alive.dart index 19c7b84730..2fa5a55eeb 100644 --- a/packages/flutter/lib/src/widgets/automatic_keep_alive.dart +++ b/packages/flutter/lib/src/widgets/automatic_keep_alive.dart @@ -28,13 +28,13 @@ class AutomaticKeepAlive extends StatefulWidget { /// [KeepAlive] widget appropriately. const AutomaticKeepAlive({ Key? key, - this.child, + required this.child, }) : super(key: key); /// The widget below this widget in the tree. /// /// {@macro flutter.widgets.ProxyWidget.child} - final Widget? child; + final Widget child; @override State createState() => _AutomaticKeepAliveState(); @@ -42,7 +42,7 @@ class AutomaticKeepAlive extends StatefulWidget { class _AutomaticKeepAliveState extends State { Map? _handles; - Widget? _child; + late Widget _child; bool _keepingAlive = false; @override @@ -60,7 +60,7 @@ class _AutomaticKeepAliveState extends State { void _updateChild() { _child = NotificationListener( onNotification: _addClient, - child: widget.child!, + child: widget.child, ); } @@ -228,10 +228,9 @@ class _AutomaticKeepAliveState extends State { @override Widget build(BuildContext context) { - assert(_child != null); return KeepAlive( keepAlive: _keepingAlive, - child: _child!, + child: _child, ); }