相关疑难解决方法(0)

flutter的AutomaticKeepAliveClientMixin在navigator.push后不保持页面状态

在测试AutomaticKeepAliveClientMixin并遇到问题,在navigator.push后页面丢失状态。有人知道此问题吗?任何解决方法?为任何信息而高兴,欢呼

我的目标是保持页面状态

重现步骤:打开应用程序,单击PageOne的按钮,然后向左和向右滑动,页面将丢失状态 图像

import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(home: MyApp()));

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: DefaultTabController(
        initialIndex: 0,
        length: 2,
        child: Scaffold(
          body: TabBarView(
            children: <Widget>[Page1(), Page2()],
          ),
          bottomNavigationBar: Material(
            child: TabBar(
              labelColor: Colors.black,
              tabs: <Widget>[
                Tab(
                  icon: Icon(Icons.check),
                ),
                Tab(
                  icon: Icon(Icons.check),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

class Page1 extends StatefulWidget {
  @override
  Page1State createState() {
    return new Page1State();
  }
}

class Page1State extends State<Page1> with …
Run Code Online (Sandbox Code Playgroud)

flutter

7
推荐指数
1
解决办法
1403
查看次数

标签 统计

flutter ×1