---
title: "Michael Mao (@krmao) | Hashnode"
description: "Michael Mao (@krmao) writes on Hashnode. Read their latest articles and follow their work."
url: "https://hashnode.com/@krmao"
---

@krmao

# Michael Mao

@krmao · Joined June 2022

## Comments

[I find a newer way to final fix this! change FutureBuilder code into a child StatefulWidget with AutomaticKeepAliveClientMixin, and wrap \_homeRequestGoodsByRecommendCategory(index) to a fix property \_requestFuture with a fix index. that is PageView nested PageView all themself's children need AutomaticKeepAliveClientMixin. and FutureBuilder's future need a origin property. children: List.generate(\_homeRecommendDefaultCategoryList.length, (index) { return HomeItemPage( index: index, homeRecommendDefaultCategoryList: \_homeRecommendDefaultCategoryList, homeTabBarThresholdNotifier: \_homeTabBarThresholdNotifier); })))) and the HomeItemPage should be class HomeItemPage extends StatefulWidget { final int index; final dynamic homeRecommendDefaultCategoryList; final ValueNotifier<double> homeTabBarThresholdNotifier; const HomeItemPage({Key? key, required this.index, required this.homeRecommendDefaultCategoryList, required this.homeTabBarThresholdNotifier}) : super(key: key); @override HomeItemPageState createState() => HomeItemPageState(); } class HomeItemPageState extends State<HomeItemPage> with AutomaticKeepAliveClientMixin { late Future \_requestFuture; @override void initState() { super.initState(); \_requestFuture = \_homeRequestGoodsByRecommendCategory(); print("--> homeItem initState"); } @override void dispose() { print("--> homeItem dispose"); super.dispose(); } @override Widget build(BuildContext context) { super.build(context); print("--> homeItem build"); return FutureBuilder<dynamic>( future: \_requestFuture,](https://hashnode.com/posts/state-persistence-techniques-for-the-flutter-bottom-navigation-bar/624be78b2b09bb392ea5c53a/comment/62b6a8bdb86f939ac81b4d01#reply-62b80736b86f939ac81b6ed6)

Reply · Article · Jun 26, 2022 · [State Persistence Techniques for the Flutter Bottom Navigation Bar](https://hashnode.com/posts/state-persistence-techniques-for-the-flutter-bottom-navigation-bar/624be78b2b09bb392ea5c53a)

[Nikki Goel sorry about that, my way found not work today! the youtobe video the future property is no argument, but I need multi FutureBuilder with List.generate, I can't use it. Expanded( child: Container( color: const Color(0xFFF0F0F0), child: \_homePageController == null ? Container() : PageView( onPageChanged: (pageIndex) { }, physics: const ClampingScrollPhysics(), controller: \_homePageController, children: List.generate(\_homeRecommendDefaultCategoryList.length, (index) { return FutureBuilder<dynamic>( future: \_homeRequestGoodsByRecommendCategory(index), builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {](https://hashnode.com/posts/state-persistence-techniques-for-the-flutter-bottom-navigation-bar/624be78b2b09bb392ea5c53a/comment/62b6a8bdb86f939ac81b4d01#reply-62b7fb89b86f939ac81b6dd0)

Reply · Article · Jun 26, 2022 · [State Persistence Techniques for the Flutter Bottom Navigation Bar](https://hashnode.com/posts/state-persistence-techniques-for-the-flutter-bottom-navigation-bar/624be78b2b09bb392ea5c53a)

[I fix this, also set FutureBuilder's parent widget is PageView. stackoverflow futurebuilder-reloading-whenever-the-bottomnavigationbaritem-is-changed](https://hashnode.com/posts/state-persistence-techniques-for-the-flutter-bottom-navigation-bar/624be78b2b09bb392ea5c53a/comment/62b6a8bdb86f939ac81b4d01#reply-62b6b09bb86f939ac81b4e2d)

Reply · Article · Jun 25, 2022 · [State Persistence Techniques for the Flutter Bottom Navigation Bar](https://hashnode.com/posts/state-persistence-techniques-for-the-flutter-bottom-navigation-bar/624be78b2b09bb392ea5c53a)

[there is still have a problem. if a page have FutureBuilder in a inner TabBarView, it will reload while change bottomNavigationBar even thouth did AutomaticKeepAliveClientMixin.](https://hashnode.com/posts/state-persistence-techniques-for-the-flutter-bottom-navigation-bar/624be78b2b09bb392ea5c53a/comment/62b6a8bdb86f939ac81b4d01)

Comment · Article · Jun 25, 2022 · [State Persistence Techniques for the Flutter Bottom Navigation Bar](https://hashnode.com/posts/state-persistence-techniques-for-the-flutter-bottom-navigation-bar/624be78b2b09bb392ea5c53a)
