Navigating from a TabBarView Child to another Route (full screen)

Issue

I have a TabBarView containg 4 tabs. They all have a button that can be used to navigate to another Route, but the navigation is done in the tabs itself i.e. The tabbed Appbar still exists, how to navigate to those routes without the tabbed appbar.

Edit:
At the home page there are some buttons which take the user to the Tabbed Page,
At that Page the TabBarView has Page 2 with different Strings passed, now Page 2 is used to call a widget which verifies user login, logout and stuff and returns the correct widget. When the user is logged in there’s a Fab which takes them to a new route, now that route is still navigating in the tabbed view which i want to change.

TabbedView

 home: DefaultTabController(
    length: 4,
    child: Scaffold(
      appBar: AppBar(
        bottom: TabBar(
          tabs: [
            Tab(text: ("Numbers")),
            Tab(text: ("Relationship")),
            Tab(text: ("Word")),
            Tab(text: ("Sentence"))
          ],
        ),
       ------
       ------

      ),
    ),
  ),

      ),
      body: TabBarView(
        children: [
          Page2("Number" ),
          Page2("Relationship"),
          Page2("Word"),
          Page2("Sentence"),
        ],
      ),
    ),
  ),
);

Page2

return new MaterialApp(
    theme: new ThemeData(
      primarySwatch: Colors.blue,
    ),
      home: new Scaffold(
       body: new RootPage(auth: new Auth()
    )
  )
);

OnloggedIn

return new HomePage(
        userId: _userId,
        auth: widget.auth,
        onSignedOut: _onSignedOut,
      );

Fab

return new Scaffold(
-----
-----
floatingActionButton: FloatingActionButton(
      onPressed: () {
        //_showDialog(context);
        Navigator.push(context, MaterialPageRoute(builder: (context)=>Levels(
          auth: widget.auth,
          userId: widget.userId,
          onSignedOut: widget.onSignedOut,
        )),);
      },

Solution

I solved it by removing the Page2 call in TabBarView and directly calling rootpage .

Answered By – Akshit Sharma

Answer Checked By – Senaida (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *