Flutter iOS UITabBarController

  • children的State 重写 wantKeepAlive 为true

  • children的State build 方法必须调用super.build

 class _MyPageState extends State with AutomaticKeepAliveClientMixin{
  @override
  bool get wantKeepAlive => true;  //重点1

  @override
  Widget build(BuildContext context) {
    super.build(context); //重点2
    return Scaffold(
      appBar: AppBar(
        title: Text(
          '我的',
          style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600),
        ),
        centerTitle: true,
        backgroundColor: Color.fromRGBO(32, 32, 32, 1),
      ),
    );
  }
}

你可能感兴趣的:(Flutter iOS UITabBarController)