Add the AutomaticKeepAliveClientMixin
mixin to your State
of your StatefulWidget
(Item widget), override the wantKeepAlive
method and return true
.
class _MarkWidgetState extends State<MarkWidget> with AutomaticKeepAliveClientMixin{
...
@override
Widget build(BuildContext context) {
// call this method.
super.build(context);
...
}
@override
bool get wantKeepAlive => true;
}
More info here: https://docs.flutter.io/flutter/widgets/AutomaticKeepAliveClientMixin-mixin.html