Created
March 2, 2021 05:57
-
-
Save IsmailAlamKhan/e0f2567dcc10a74c63b7bbf14fa75ace to your computer and use it in GitHub Desktop.
Copy this, wrap your widget widget KeepAlivePage and you will get the AutomaticKeepAliveClientMixin on that widget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class KeepAlivePage extends StatefulWidget { | |
const KeepAlivePage({ | |
Key key, | |
@required this.child, | |
}) : super(key: key); | |
final Widget child; | |
@override | |
_KeepAlivePageState createState() => _KeepAlivePageState(); | |
} | |
class _KeepAlivePageState extends State<KeepAlivePage> | |
with AutomaticKeepAliveClientMixin { | |
@override | |
void dispose() { | |
super.dispose(); | |
} | |
@override | |
Widget build(BuildContext context) { | |
super.build(context); | |
return widget.child; | |
} | |
@override | |
bool get wantKeepAlive => true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment