title: New tab showing previous tab List Data flutter Dart in Tab bar function
body: <p>I had created a single function for different tabs. Categories List are loading in all the tabs but the problem is when changing tabs, previous tab category list data is loading on the top of the next tab. How to overcome this problem. First tab data is loading when changing to the second tab on the top and In third tab First tab and Second tab data is loading on the top.</p>
  <pre><code>class _CategoryTabState extends State&lt;CategoryTab&gt; {
    final scaffoldKey = GlobalKey&lt;ScaffoldState&gt;();
  
    @override
    void initState() {
      super.initState();
      if (mounted) {
        context.read&lt;CategoryTabBloc&gt;().categoryList.contains(widget.category)
            ? print('data already loaded')
            : context.read&lt;CategoryTabBloc&gt;().getData(mounted, widget.category);
      }
      // print(widget.category);
    }
  
    @override
    Widget build(BuildContext context) {
      final cb = context.read&lt;CategoryTabBloc&gt;();
  
      return RefreshIndicator(
        onRefresh: () async {
          context.read&lt;CategoryTabBloc&gt;().onRefresh(mounted, widget.category);
        },
        child: cb.categoryCListMap[widget.category]['checkHasData'] == false
            ? ListView(
                children: [
                  SizedBox(
                    height: MediaQuery.of(context).size.height * 0.20,
                  ),
                  const EmptyPage(
                      icon: Feather.clipboard,
                      message: 'No data found',
                      message1: ''),
                ],
              )
            : ListView.separated(
                key: PageStorageKey(widget.category),
                addAutomaticKeepAlives : false,
                padding: const EdgeInsets.all(15),
                physics: const NeverScrollableScrollPhysics(),
                itemCount: cb
                        .categoryCListMap[widget.category]['checkData'].isNotEmpty
                    ? cb.categoryCListMap[widget.category]['checkData'].length + 1
                    : 4,
                separatorBuilder: (BuildContext context, int index) =&gt;
                    const SizedBox(
                  height: 15,
                ),
                shrinkWrap: true,
                itemBuilder: (_, int index) {
                  if (index &lt;
                      cb.categoryCListMap[widget.category]['checkData'].length) {
                    if (index % 2 == 0 &amp;&amp; index != 0) {
                      return Card1(
                          d: cb.categoryCListMap[widget.category]['checkData']
                              [index],
                          heroTag: widget.category + '$index');
                    }
                    return Card2(
                        d: cb.categoryCListMap[widget.category]['checkData']
                            [index],
                        heroTag: widget.category + '$index');
                  }
                  return Opacity(
                    opacity: cb.categoryCListMap[widget.category]['checkLoading']
                        ? 1.0
                        : 0.0,
                    child: cb.categoryCListMap[widget.category]
                                ['checkLastVisible'] ==
                            null
                        ? const LoadingCard(height: 250)
                        : const Center(
                            child: SizedBox(
                                width: 32.0,
                                height: 32.0,
                                child: CupertinoActivityIndicator()),
                          ),
                  );
                },
              ),
      );
    }
  }
  </code></pre>