Skip to content

Commit 86f6525

Browse files
committed
keep tab
1 parent e7da0c4 commit 86f6525

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

‎lib/page/DynamicPage.dart‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ class DynamicPage extends StatefulWidget {
1717
_DynamicPageState createState() => _DynamicPageState();
1818
}
1919

20-
class _DynamicPageState extends State<DynamicPage> {
20+
// ignore: mixin_inherits_from_not_object
21+
class _DynamicPageState extends State<DynamicPage> with AutomaticKeepAliveClientMixin {
2122

2223
bool isLoading = false;
2324

@@ -63,6 +64,9 @@ class _DynamicPageState extends State<DynamicPage> {
6364
return StoreProvider.of(context);
6465
}
6566

67+
@override
68+
bool get wantKeepAlive => true;
69+
6670
@override
6771
void initState() {
6872
super.initState();

‎lib/page/TrendPage.dart‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ class TrendPage extends StatefulWidget {
1010
_TrendPageState createState() => _TrendPageState();
1111
}
1212

13-
class _TrendPageState extends State<TrendPage> {
13+
// ignore: mixin_inherits_from_not_object
14+
class _TrendPageState extends State<TrendPage> with AutomaticKeepAliveClientMixin {
1415
bool isLoading = false;
1516

1617
int page = 1;
@@ -46,6 +47,9 @@ class _TrendPageState extends State<TrendPage> {
4647
return new ReposItem(e);
4748
}
4849

50+
@override
51+
bool get wantKeepAlive => true;
52+
4953
@override
5054
void initState() {
5155
super.initState();

‎lib/widget/GSYTabBarWidget.dart‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
22

33
///支持顶部和顶部的TabBar控件
4+
///配合AutomaticKeepAliveClientMixin可以keep住
45
class GSYTabBarWidget extends StatefulWidget {
56
///底部模式type
67
static const int BOTTOM_TAB = 1;

0 commit comments

Comments
 (0)