title: How do I switch to the another Tab Screen?
body: <p>I want to switch to a another Screen, when i tap to the other icon on the tab bar but it does not work. I am always in HomeScreen() and I can´t switch to the HomeScreenMapView(). I think i have an issue at the return by the <code>ListView.builder</code> but i don´t know how i continue.</p>
  
  <p>My Code:</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:flutter/rendering.dart';
  import '../screens/home_screen.dart';
  import '../screens/home_screen_map_view.dart';
  
  class TabBarTop extends StatefulWidget {
    @override
    _TabBarTopState createState() =&gt; _TabBarTopState();
  }
  
  class _TabBarTopState extends State&lt;TabBarTop&gt; with SingleTickerProviderStateMixin {
    bool _isAppbar = true;
        ScrollController _scrollController = new ScrollController();
  
        @override
        void initState() {
          super.initState();
          _scrollController.addListener(() {
            if (_scrollController.position.userScrollDirection ==
                ScrollDirection.reverse) {
              appBarStatus(false);
            }
            if (_scrollController.position.userScrollDirection ==
                ScrollDirection.forward) {
              appBarStatus(true);
            }
          });
        }
  
        void appBarStatus(bool status) {
          setState(() {
            _isAppbar = status;
          });
        }
  
        @override
        Widget build(BuildContext context) {
          return SafeArea(
            child: Scaffold(
              appBar: PreferredSize(
                preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.12),
                child: AnimatedContainer(
                  height: _isAppbar ? MediaQuery.of(context).size.height * 1 : 0.0,
                  duration: Duration(milliseconds: 200),
                  child: CustomAppBar(),
                ),
              ),
              body: ListView.builder(
                controller: _scrollController,
                itemCount: 100,
                itemBuilder: (BuildContext context, int index) {
                  return HomeScreen();
                },
              ),
            ),
          );
        }
      }
  
      class CustomAppBar extends StatefulWidget {
        @override
        AppBarView createState() =&gt; new AppBarView();
      }
  
      class AppBarView extends State&lt;CustomAppBar&gt; {
        @override
        Widget build(BuildContext context) {
          return DefaultTabController(
        length: 2,
        child: NestedScrollView(
          headerSliverBuilder: (context, value) {
            return [
              SliverAppBar(
                title: Center(
                  heightFactor: 0,
                  child: Padding(
                    padding: const EdgeInsets.only(top: 7),
                    child: Image.asset(
                      'assets/images/***.png',
                      fit: BoxFit.cover,
                      scale: MediaQuery.of(context).size.width * 0.007,
                      alignment: Alignment.bottomCenter,
                    ),
                  ),
                ),
                expandedHeight: MediaQuery.of(context).size.height * 0.12,
                primary: true,
                floating: true,
                pinned: true,
                bottom: TabBar(
                  indicatorColor: Color.fromRGBO(253, 166, 41, 1.0),
                  tabs: &lt;Widget&gt;[
                    Tab(
                      icon: Icon(Icons.list),
                    ),
                    Tab(
                      icon: Icon(Icons.location_on),
                    ),
                  ],
                ),
                forceElevated: false,
                flexibleSpace: Container(
                  decoration: BoxDecoration(
                    gradient: LinearGradient(
                      begin: Alignment.topCenter,
                      end: Alignment.bottomCenter,
                      colors: &lt;Color&gt;[
                        Color.fromRGBO(107, 176, 62, 1.0),
                        Color.fromRGBO(153, 199, 58, 1.0),
                      ],
                    ),
                  ),
                ),
              )
            ];
          },
          body: TabBarView(
            children: &lt;Widget&gt;[
              HomeScreen(),
              HomeScreenMapView(),
            ],
          ),
        ),
      );
        }
      }
  </code></pre>
  
  <p>Thanks :)</p>