Makes AutomaticKeepAlive.child non null (#101376)
This commit is contained in:
parent
7f64e2ae02
commit
c05c9f77c0
@ -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 {
|
|||||||
|
|
||||||
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> {
|
|||||||
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> {
|
|||||||
|
|
||||||
@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,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user