Commit 5f368f69 authored by skeyboy's avatar skeyboy

修复切换tabbar导致用户状态丢失的问题

parent 04afb450
...@@ -9,7 +9,7 @@ class AssistantPage extends GetView<AssistantController> { ...@@ -9,7 +9,7 @@ class AssistantPage extends GetView<AssistantController> {
// 主视图 // 主视图
Widget _buildView() { Widget _buildView() {
return GridWidget(); return _AssistantPage();
} }
@override @override
...@@ -29,3 +29,20 @@ class AssistantPage extends GetView<AssistantController> { ...@@ -29,3 +29,20 @@ class AssistantPage extends GetView<AssistantController> {
); );
} }
} }
class _AssistantPage extends StatefulWidget {
const _AssistantPage({Key? key}) : super(key: key);
@override
State<_AssistantPage> createState() => _AssistantPageState();
}
class _AssistantPageState extends State<_AssistantPage> with AutomaticKeepAliveClientMixin{
@override
// TODO: implement wantKeepAlive
bool get wantKeepAlive => true;
@override
Widget build(BuildContext context) {
return GridWidget();
}
}
...@@ -9,7 +9,7 @@ class CreationPage extends GetView<CreationController> { ...@@ -9,7 +9,7 @@ class CreationPage extends GetView<CreationController> {
// 主视图 // 主视图
Widget _buildView() { Widget _buildView() {
return GridWidget(); return const _InnerCreationPage();
// return Obx(() => Center( // return Obx(() => Center(
// child: InkWell( // child: InkWell(
// onTap: () => controller.increment(), // onTap: () => controller.increment(),
...@@ -40,3 +40,23 @@ class CreationPage extends GetView<CreationController> { ...@@ -40,3 +40,23 @@ class CreationPage extends GetView<CreationController> {
); );
} }
} }
class _InnerCreationPage extends StatefulWidget {
const _InnerCreationPage({Key? key}) : super(key: key);
@override
State<_InnerCreationPage> createState() => _InnerCreationPageState();
}
class _InnerCreationPageState extends State<_InnerCreationPage>
with AutomaticKeepAliveClientMixin {
/// 防止每次切换之后自动滑动到顶部
@override
bool get wantKeepAlive => true;
@override
Widget build(BuildContext context) {
return GridWidget();
}
}
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment