title: How to keep disappearing Flutter Bottom Navigation and AppBar after navigating from subpages
body: <p>I have a bottom Tab bar in my app for navigation and appbar, from the menu page after adding products in Cart screen there is Continue button when i pressed it take me to Login screen, there a normal login with and otp verification, now when i try to navigate back to menu screen after successfull otp verification, i see Tab bar disappeared and the App bar.</p>
  <p>How i can fix this problem</p>
  <p>Cart Screen</p>
  <pre><code>return Scaffold
    ....
    row
      ...
  
     Container showOrderConfirmationBtn(BuildContext context) {
      return Container(
        height: 50.0,
        decoration: BoxDecoration(
          border: Border.all(
              color: Colors.transparent, style: BorderStyle.solid, width: 1.0),
          color: Theme.of(context).primaryColor,
          borderRadius: BorderRadius.circular(10.0),
        ),
        child: FlatButton(
          onPressed: () {
            isLoggedIn == false
                ? Navigator.push(
                    context, MaterialPageRoute(builder: (context) =&gt; LoginPage()))
                : Navigator.of(context).push(MaterialPageRoute(
                    builder: (context) =&gt; CarConfirmationCompletePage()));
          },
          child: Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: &lt;Widget&gt;[
              Center(
                child: Wrap(
                  crossAxisAlignment: WrapCrossAlignment.center,
                  children: [
                    Text(
                      'Continue',
                      style: TextStyle(
                          color: Colors.white,
                          fontFamily: 'BuffetRegular',
                          fontSize: 13,
                          letterSpacing: 0.5),
                    ),
                  ],
                ),
              )
            ],
          ),
        ),
      );
    }
  }
  </code></pre>
  <p>Login Screen</p>
  <p>return Scafold
  ....</p>
  <pre><code>GestureDetector(
                                onTap: () async {
                                  final prefs =
                                      await SharedPreferences.getInstance();
  
                                  final customerData = LoginModel(
                                      mobile: maskFormatter.getUnmaskedText());
  
                                  final result = await loginServices
                                      .loginCustomer(customerData);
  
                                  final customerId = result['id'];
  
                                  if (result['existsFlag'] == '1') {
  
                                    Navigator.of(context).push(MaterialPageRoute(
                                        builder: (context) =&gt; OtpVerification(
                                            customerId: customerId)));
                                  } else {
                                    // Registering customer
                                    // Registering customer device info
                                    
                                    // and navigating the user to otpverification page
  
                                    Navigator.of(context).push(MaterialPageRoute(
                                        builder: (context) =&gt; OtpVerification(
                                            customerId: customerId)));
                                  }
                                },
                                child: Container(
                                  margin: const EdgeInsets.only(right: 20.0),
                                  width: 40,
                                  height: 40.0,
                                  decoration: BoxDecoration(
                                    color: Colors.green.shade300,
                                    borderRadius: BorderRadius.circular(10.0),
                                  ),
                                  child: Icon(Icons.arrow_forward_ios),
                                ),
                              ),
  </code></pre>
  <p>Otp Screen</p>
  <pre><code>return Scaffold
   ....
  PinEntryTextField(
                  fieldWidth: 60.0,
                  showFieldAsBox: true,
                  onSubmit: (String pin) async {
                    final prefs = await SharedPreferences.getInstance();
                    
                    // redirected to menu page
  
                    final optData =
                        OtpModel(customerId: widget.customerId, otp: pin);
  
                    final result = await loginServices.otpVerify(optData);
                    if (result['existsFlag'] == '1') {
                      // setting customer prefs
                      prefs.setBool('isLoggedIn', true);
  
                      Navigator.push(context,
                          MaterialPageRoute(builder: (context) =&gt; MenuPage()));
                  
                    } else {
                      showDialog(
                        context: context,
                        builder: (context) {
                          return AlertDialog(
                            title: null,
                            content: Text('неверный код подтверждения '),
                          );
                        },
                      ); //end showDialog()
                    }
                    // ...............................
                    // showDialog(
                    //   context: context,
                    //   builder: (context) {
                    //     return AlertDialog(
                    //       title: Text(&quot;Pin&quot;),
                    //       content: Text('Pin entered is $pin'),
                    //     );
                    //   },
                    // ); //end showDialog()
                    // ...............................
                  }, // end onSubmit
                ),
  </code></pre>
  <p>Menu Page</p>
  <pre><code>import 'package:flutter/material.dart';
  import 'package:provider/provider.dart';
  import 'package:get_it/get_it.dart';
  import 'package:cached_network_image/cached_network_image.dart';
  import 'package:font_awesome_flutter/font_awesome_flutter.dart';
  
  // ... Constants
  import '../constants.dart';
  
  // ... Providers
  import '../providers/order_notify.dart';
  
  // ... Models
  import '../models/cart_order.dart';
  import '../models/menu_model.dart';
  
  // ... API'S
  import '../apis/api_response.dart';
  import '../apis/menu-api.dart';
  
  // ... Pages
  import '../pages/menu_detail.dart';
  
  class MenuPage extends StatefulWidget {
    final Products pro;
  
    MenuPage({Key key, this.pro}) : super(key: key);
  
    @override
    _MenuPageState createState() =&gt; _MenuPageState();
  }
  
  class _MenuPageState extends State&lt;MenuPage&gt; {
    ProductApi get productsServices =&gt; GetIt.I&lt;ProductApi&gt;();
  
    APIResponse&lt;List&lt;Products&gt;&gt; _apiResponse;
  
    bool _isLoading = false;
  
    void _fetchProducts() async {
      setState(() {
        _isLoading = true;
      });
  
      _apiResponse = await productsServices.getProductsList();
  
      setState(() {
        _isLoading = false;
      });
    }
  
    hasDiscount(product) {
      return product.hasDiscount == '1'
          ? product.priceAfter
          : product.hasDiscount == '0'
              ? product.priceBefore
              : product.priceAfter;
    }
  
    @override
    void initState() {
      _fetchProducts();
      super.initState();
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        body: Container(
          child: ListView(
            physics: PageScrollPhysics(),
            children: [
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Padding(
                    padding: const EdgeInsets.symmetric(
                        horizontal: kDefaultPadding, vertical: kDefaultPadding),
                    child: Text('Меню', style: kStyleHeaders),
                  ),
                  SizedBox(
                    height: 10.0,
                  ),
                  Builder(builder: (_) {
                    if (_isLoading) {
                      return Padding(
                        padding: EdgeInsets.symmetric(vertical: 200.0),
                        child: Center(child: null),
                      );
                    }
                    if (_apiResponse.error) {
                      return Center(child: Text(_apiResponse.errorMessage));
                    }
                    if (_apiResponse.data.length == 0) {
                      return Padding(
                        padding: EdgeInsets.symmetric(vertical: 200.0),
                        child: Center(
                          child: Text(
                            'No products has been found..!',
                            style: TextStyle(
                              fontSize: 16.0,
                              fontWeight: FontWeight.bold,
                              fontFamily: 'BuffetBold',
                              color: Colors.black,
                            ),
                          ),
                        ),
                      );
                    }
                    return GridView.builder(
                      shrinkWrap: true,
                      physics: ClampingScrollPhysics(),
                      itemCount: _apiResponse.data.length,
                      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                        crossAxisCount: 2,
                        childAspectRatio: 0.72,
                        mainAxisSpacing: 1.0,
                        crossAxisSpacing: 1.0,
                      ),
                      itemBuilder: (context, index) {
                        var product = _apiResponse.data[index];
                        return CachedNetworkImage(
                          imageUrl: product.imageMedium,
                          imageBuilder: (context, imageProvider) =&gt; Column(
                            children: [
                              GestureDetector(
                                onTap: () =&gt; Navigator.push(
                                  context,
                                  MaterialPageRoute(
                                    builder: (context) =&gt; ProductDetail(
                                        id: product.id,
                                        title: product.title,
                                        description: product.description,
                                        structure: product.structure,
                                        imageLarge: product.imageLarge,
                                        weight: product.weight,
                                        hasDiscount: product.hasDiscount,
                                        priceBefore:
                                            double.parse(product.priceBefore),
                                        priceAfter:
                                            double.parse(product.priceAfter),
                                        isHit: product.isHit,
                                        isNew: product.isNew,
                                        isSpicy: product.isSpicy,
                                        isRecommended: product.isRecommended,
                                        isVegetarian: product.isVegetarian,
                                        attributes: product.attributes),
                                  ),
                                ),
                                child: Container(
                                  alignment: Alignment(-1, 0.9),
                                  child: (product.isNew == '1')
                                      ? Image.asset(
                                          'assets/images/new.png',
                                          width: 60.0,
                                        )
                                      : null,
                                  height: 165.0,
                                  width: 165.0,
                                  decoration: BoxDecoration(
                                    borderRadius: BorderRadius.circular(10.0),
                                    image: DecorationImage(
                                      image: imageProvider,
                                      fit: BoxFit.cover,
                                    ),
                                    boxShadow: [
                                      BoxShadow(
                                          color: Colors.grey,
                                          blurRadius: 2.0,
                                          spreadRadius: 0,
                                          offset: Offset(0, 2))
                                    ],
                                  ),
                                ),
                              ),
                              Padding(
                                padding: EdgeInsets.symmetric(
                                    vertical: 10.0, horizontal: 10.0),
                                child: Row(
                                  children: [
                                    Flexible(
                                        child: Text(product.title,
                                            style: kStyleTitle))
                                  ],
                                ),
                              ),
                              Container(
                                margin: EdgeInsets.symmetric(horizontal: 10.0),
                                child: Row(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceBetween,
                                  children: [
                                    Text(
                                        product.weight != null
                                            ? product.weight
                                            : '',
                                        style: kStyleWeight),
                                    Text(
                                        product.hasDiscount != '0'
                                            ? product.priceBefore
                                            : '',
                                        style: kStyleDiscount),
                                    Container(
                                      margin: EdgeInsets.symmetric(
                                          horizontal: 3, vertical: 0),
                                      height: 30.0,
                                      width: 70.0,
                                      child: FlatButton(
                                        shape: RoundedRectangleBorder(
                                          borderRadius:
                                              BorderRadius.circular(20.0),
                                        ),
                                        color: kPrimaryColor,
                                        textColor: Colors.white,
                                        padding:
                                            EdgeInsets.symmetric(horizontal: 5.0),
                                        onPressed: () {
                                          // ... Todo
                                          context.read&lt;OrderNotify&gt;().addOrder(
                                                CartOrder(
                                                    product: product,
                                                    qty: 1,
                                                    price: hasDiscount(product)),
                                              );
                                        },
                                        child: Row(
                                          mainAxisAlignment:
                                              MainAxisAlignment.center,
                                          children: [
                                            Text(hasDiscount(product),
                                                style: kStylePrice),
                                            Icon(
                                              FontAwesomeIcons.rubleSign,
                                              size: 13.0,
                                              color: Colors.white,
                                            )
                                          ],
                                        ),
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                            ],
                          ),
                          placeholder: (context, url) =&gt; Center(
                            child: CircularProgressIndicator(
                              valueColor:
                                  AlwaysStoppedAnimation(Color(0xffB81F33)),
                            ),
                          ),
                          errorWidget: (context, url, error) =&gt; Icon(
                            Icons.error,
                            size: 40.0,
                            color: Theme.of(context).primaryColor,
                          ),
                        );
                      },
                    );
                  }),
                ],
              ),
            ],
          ),
        ),
      );
    }
  }
  </code></pre>
  <p>Main.dart</p>
  <pre><code>import 'package:flutter/material.dart';
  import 'dart:async';
  import 'package:get_it/get_it.dart';
  import 'package:provider/provider.dart';
  import 'package:shared_preferences/shared_preferences.dart';
  
  // ... API'S
  import './apis/category-api.dart';
  import './apis/menu-api.dart';
  import './apis/promotion-api.dart';
  import './apis/login-api.dart';
  import './apis/ipaddress-api.dart';
  import './apis/deviceinfo-api.dart';
  import './apis/customer_deviceinfo-api.dart';
  
  // Providers
  import './providers/order_notify.dart';
  
  import 'app.dart';
  
  void setupLocator() {
    GetIt.I.registerLazySingleton(() =&gt; PromotionApi());
    GetIt.I.registerLazySingleton(() =&gt; CategoriesApi());
    GetIt.I.registerLazySingleton(() =&gt; ProductApi());
    GetIt.I.registerLazySingleton(() =&gt; LoginApi());
    GetIt.I.registerLazySingleton(() =&gt; IPAddressInfo());
    GetIt.I.registerLazySingleton(() =&gt; DeviceInfo());
    GetIt.I.registerLazySingleton(() =&gt; CustomerDeviceInfoApi());
  }
  
  void setDeviceInfo() async {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    DeviceInfo deviceServices = GetIt.I&lt;DeviceInfo&gt;();
    IPAddressInfo ipServices = GetIt.I&lt;IPAddressInfo&gt;();
  
    prefs.setString('ipAddress', await ipServices.getIPAddress());
    prefs.setString('manufacturerModel', await deviceServices.getPhoneInfo());
    prefs.setString('deviceVersion', await deviceServices.getPhoneVersion());
    prefs.setString('os', await deviceServices.getOperatingSystem());
    prefs.setString(
        'screenResolution', await deviceServices.getScreenResolution());
    prefs.setString('packageOrBundle', await deviceServices.getPackageName());
    prefs.setString('appVersion', await deviceServices.getAppVersion());
    prefs.setString('isPhysical',
        await deviceServices.isPhysicalDevice() == true ? '1' : '0');
    prefs.setBool('isLoggedIn', false);
  }
  
  void main() {
    // ... setup shared prefrences
    // ... todo
    // ... get device informaton set shared prefrences
    // ... todo
  
    // ... Setuploacator
    setupLocator();
  
    runApp(
      MultiProvider(
        providers: [
          ChangeNotifierProvider(
            create: (ctx) =&gt; OrderNotify(),
          ),
        ],
        child: MaterialApp(
          debugShowCheckedModeBanner: false,
          home: MyApp(),
        ),
      ),
    );
  
    setDeviceInfo();
  }
  
  class MyApp extends StatefulWidget {
    @override
    _MyAppState createState() =&gt; _MyAppState();
  }
  
  class _MyAppState extends State&lt;MyApp&gt; {
    bool isStartHomePage = false;
  
    @override
    void initState() {
      super.initState();
  
      Future.delayed(Duration(seconds: 3), () {
        // If the page has not jump over the jump page
        if (!isStartHomePage) {
          // Go Home and destroy the current page
          Navigator.of(context).pushAndRemoveUntil(
              MaterialPageRoute(
                builder: (context) =&gt; App(),
              ),
              (Route&lt;dynamic&gt; rout) =&gt; false);
          isStartHomePage = true;
        }
      });
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        body: Stack(
          children: [
            Container(
              width: MediaQuery.of(context).size.width,
              height: MediaQuery.of(context).size.height,
              decoration: BoxDecoration(
                image: DecorationImage(
                  fit: BoxFit.cover,
                  image: AssetImage(
                    'assets/images/stripes_min.jpg',
                  ),
                ),
              ),
            ),
            Positioned(
              width: MediaQuery.of(context).size.width,
              height: MediaQuery.of(context).size.height,
              child: Container(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Image.asset(
                      'assets/images/Buffet_Logo_Trans_min.png',
                      width: 200.0,
                      height: 200.0,
                    ),
                  ],
                ),
              ),
            ),
          ],
        ),
      );
    }
  }
  </code></pre>
  <p>main.screen</p>
  <pre><code>import 'package:flutter/material.dart';
  import 'package:provider/provider.dart';
  
  // ... APP Helpers
  import '../helpers/app_helper.dart';
  
  // ... Pages
  import '../pages/home_page.dart';
  import '../pages/promotions_page.dart';
  import '../pages/menu_page.dart';
  import '../pages/more_page.dart';
  import '../pages/orders_page.dart';
  import '../pages/cart.dart';
  
  // ... Providers
  import '../providers/order_notify.dart';
  
  // ... Widgets
  import '../widgets/badge.dart';
  
  class MainScreen extends StatefulWidget {
    @override
    _MainScreenState createState() =&gt; _MainScreenState();
  }
  
  class _MainScreenState extends State&lt;MainScreen&gt; {
    // Current Index set to 0
    int currentTabIndex = 0;
  
    final List&lt;Widget&gt; pages = [
      HomePage(
        key: PageStorageKey('HomePage'),
      ),
      PromotionsPage(
        key: PageStorageKey('PromoPage'),
      ),
      MenuPage(
        key: PageStorageKey('MenuOage'),
      ),
      OrdersPage(
        key: PageStorageKey('Orderpage'),
      ),
      MorePage(
        key: PageStorageKey('Morepage'),
      ),
      Cart(
        key: PageStorageKey('CartPage'),
      )
    ];
  
    final PageStorageBucket bucket = PageStorageBucket();
  
    // Current page
    Widget currentPage;
  
    void setTabIndex(index) {
      setState(() {
        currentTabIndex = index;
        currentPage = pages[index];
      });
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          backgroundColor: Theme.of(context).primaryColor,
          elevation: 0.0,
          leading: InkWell(
            onTap: () {
              Helper.launchUrl('tel:88007073566');
            },
            child: Icon(
              Icons.call,
              color: Colors.black,
              size: 25.0,
            ),
          ),
          title: Text(
            'BUFFET',
            style: TextStyle(fontSize: 30.0, fontFamily: 'BuffetBold'),
          ),
          centerTitle: true,
          actions: [
            Container(
              margin: EdgeInsets.symmetric(horizontal: 0),
              width: 60,
              child: Badge(
                color: Colors.green,
                child: IconButton(
                  icon: Icon(Icons.shopping_cart),
                  onPressed: () {
                    Navigator.push(
                        context, MaterialPageRoute(builder: (context) =&gt; Cart()));
                  },
                ),
                value: context.watch&lt;OrderNotify&gt;().items.length.toString(),
              ),
            )
          ],
        ),
        body: PageStorage(
          child: pages[currentTabIndex],
          bucket: bucket,
        ),
        bottomNavigationBar: BottomNavigationBar(
          onTap: (int index) {
            setTabIndex(index);
          },
          currentIndex: currentTabIndex,
          type: BottomNavigationBarType.fixed,
          selectedItemColor: Theme.of(context).primaryColor,
          selectedFontSize: 0,
          unselectedFontSize: 0,
          iconSize: 30,
          elevation: 0,
          backgroundColor: Colors.white,
          selectedIconTheme: IconThemeData(size: 28),
          unselectedItemColor: Theme.of(context).focusColor.withOpacity(1),
          selectedLabelStyle:
              Theme.of(context).textTheme.bodyText1.merge(TextStyle(
                    fontSize: 12,
                    fontFamily: 'BuffetBold',
                  )),
          unselectedLabelStyle:
              Theme.of(context).textTheme.button.merge(TextStyle(
                    fontSize: 12,
                    fontFamily: 'BuffetBold',
                  )),
          showUnselectedLabels: true,
          items: &lt;BottomNavigationBarItem&gt;[
            BottomNavigationBarItem(
              icon: Icon(
                Icons.home_outlined,
              ),
              label: 'Главная',
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.card_giftcard_outlined),
              label: 'Акции',
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.restaurant),
              label: 'Меню',
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.av_timer),
              label: 'Заказы',
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.menu),
              label: 'Еще',
            )
          ],
        ),
      );
    }
  }
  </code></pre>
  <p>App.dart</p>
  <pre><code>import 'package:flutter/material.dart';
  
  // ... Constants
  import 'constants.dart';
  
  // ... Screens
  import './screens/main_screen.dart';
  
  class App extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        debugShowCheckedModeBanner: false,
        title: 'Buffet',
        theme: ThemeData(
          primaryColor: kPrimaryColor,
          fontFamily: 'Buffet',
        ),
        home: MainScreen(),
      );
    }
  }
  </code></pre>