'When I rebuild the app it's all good, but when I´m inside the app, the app bar gets all weird, and it disappears when i change screens

So i'm building an app that has a login (i'm knew to flutter so i'm just getting code on youtube and try to add it) and it's supposed to have a bottom bar that leeds to de home page and the profile. In the profile screen he can log out.

The problem is, the app was all good, but I tried to add the bottom bar, (i had to add a AuthWrapper()

import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:pap_test/tabs_screen.dart';
import 'login_signup/screens/login_screen.dart';

class AuthWrapper extends StatelessWidget {
  const AuthWrapper({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final FirebaseAuth _auth = FirebaseAuth.instance;
    return StreamBuilder(
      stream: _auth.authStateChanges(),
      builder: (context, user) {
        User? _user = user.data as User?;
        if (_user != null) {
          return const TabsScreen();
        } else {
          return const LoginScreen();
        }
      },
    );
  }
}

That takes to the home page and the profile page.

// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables

import 'package:flutter/material.dart';
import 'disciplinas/disciplinas_screen.dart';
import 'login_signup/screens/home_screen.dart';

class TabsScreen extends StatefulWidget {
  const TabsScreen({Key? key}) : super(key: key);

  @override
  _TabsScreenState createState() => _TabsScreenState();
}

class _TabsScreenState extends State<TabsScreen> {
  final List<Widget> _pages = [
    DisciplinasScreen(),
    HomeScreen(),
  ];

  int _selectedPageIndex = 0;

  void _selectPage(int index) {
    setState(() {
      _selectedPageIndex = index;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          '',
        ), //seja qual for a opção do bottom bar selecionada ele irá dar o titulo que indicamos e mesmo para a outra página
      ),
      body: _pages[_selectedPageIndex],
      bottomNavigationBar: BottomNavigationBar(
        onTap: _selectPage,
        backgroundColor: Colors.black,
        items: [
          BottomNavigationBarItem(
            icon: Icon(Icons.home),
            label: 'Home',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.account_circle_outlined),
            label: 'Profile',
          ),
        ],
      ),
    );
  }
}

the problem is that when i'm in the app, when i rebuild it, the bottom bar is there, but the app bar gets all weird, and when i go to the profile screen, log out and then sign in the app bar gets back to normal but the bottom bar isn't there.

the rotes in the main

routes: {
        '/': (ctx) => AuthWrapper(),
        DisciplinaModuloScreen.routeName: (ctx) => DisciplinaModuloScreen(),
        DownloadScreen.routeName: (ctx) => DownloadScreen(),
        UploadResumoScreen.routeName: (ctx) => UploadResumoScreen(),
      },

all the code is here https://drive.google.com/drive/folders/1TlFibzTPXph_mAzyeS3CADTYxsWF3YIv?usp=sharing



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source