Skip to content

Instantly share code, notes, and snippets.

@IsmailAlamKhan
Created March 2, 2021 05:57
Show Gist options
  • Save IsmailAlamKhan/e0f2567dcc10a74c63b7bbf14fa75ace to your computer and use it in GitHub Desktop.
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
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