---
title: "Comment by Michael Mao on \"State Persistence Techniques for the Flutter Bottom Navigation Bar\" | Hashnode"
description: "there is still have a problem. if a page have FutureBuilder in a inner TabBarView, it will reload while change bottomNavigationBar even thouth did AutomaticKeep"
url: "https://hashnode.com/posts/state-persistence-techniques-for-the-flutter-bottom-navigation-bar/624be78b2b09bb392ea5c53a/comment/62b6a8bdb86f939ac81b4d01"
---

[Discussion](https://hashnode.com/posts/state-persistence-techniques-for-the-flutter-bottom-navigation-bar/624be78b2b09bb392ea5c53a)

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

[Michael Mao](https://hashnode.com/@krmao)

[Jun 25, 2022](https://hashnode.com/posts/state-persistence-techniques-for-the-flutter-bottom-navigation-bar/624be78b2b09bb392ea5c53a/comment/62b6a8bdb86f939ac81b4d01)

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.

[Michael Mao](https://hashnode.com/@krmao)

[Jun 25, 2022](https://hashnode.com/posts/state-persistence-techniques-for-the-flutter-bottom-navigation-bar/624be78b2b09bb392ea5c53a/comment/62b6a8bdb86f939ac81b4d01#reply-62b6b09bb86f939ac81b4e2d)

I fix this, also set FutureBuilder's parent widget is PageView.

stackoverflow futurebuilder-reloading-whenever-the-bottomnavigationbaritem-is-changed

[Nikki Goel](https://hashnode.com/@nicks101)

[Jun 25, 2022](https://hashnode.com/posts/state-persistence-techniques-for-the-flutter-bottom-navigation-bar/624be78b2b09bb392ea5c53a/comment/62b6a8bdb86f939ac81b4d01#reply-62b7307492447c9aed5b804c)

Hey Michael, Glad you found the solution for this. There's another one that might help. Here's the [link](https://youtu.be/sqE-J8YJnpg).

[Michael Mao](https://hashnode.com/@krmao)

[Jun 26, 2022](https://hashnode.com/posts/state-persistence-techniques-for-the-flutter-bottom-navigation-bar/624be78b2b09bb392ea5c53a/comment/62b6a8bdb86f939ac81b4d01#reply-62b7fb89b86f939ac81b6dd0)

[Nikki Goel](https://hashnode.com/@nicks101)

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) {
```

[Michael Mao](https://hashnode.com/@krmao)

[Jun 26, 2022](https://hashnode.com/posts/state-persistence-techniques-for-the-flutter-bottom-navigation-bar/624be78b2b09bb392ea5c53a/comment/62b6a8bdb86f939ac81b4d01#reply-62b80736b86f939ac81b6ed6)

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,
```
