There is a Back button in the appbar on the page that appears after successful login. In many similar questions, people used Navigator, but I didn't use Navigator. So I think the problem is the fact that the screen is stacked, not the navigator. I think it would be better to initState or SetState rather than build, but I don't know what to do.
To tell you about my app, the login screen doesn't come out as soon as I turn on the app. (log in screen is not 1st screen.) If you enter Page5 of the bottom navigation bar and press the login button, the signup screen appears, and after successful login, go back to Page1 of bottomnavigaitonbar on HomePage.
I easily implemented the login screen using the firebaseui package.
Thank you in advance for your reply.
the below is Page5.dart
class Page5 extends StatefulWidget {
const Page5({Key? key}) : super(key: key);
@override
State<Page5> createState() => _Page5State();
}
class _Page5State extends State<Page5> {
final providerConfigs = [EmailProviderConfiguration()];
@override
Widget build(BuildContext context) {
return
FirebaseAuth.instance.currentUser == null
? Page5_null()
: Page5_on();
}
}
the below is authentication.dart
class Authentication extends StatelessWidget {
const Authentication({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return StreamBuilder(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return SignInScreen(
providerConfigs: [EmailProviderConfiguration()],);
}
return HomePage();
);
}
}
the below is homepage.dart
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
var _index = 0;
final _pages = [
Ppage1(),
const Page2(),
const Page3(),
const Page4(),
const Page5(),
]; ...
CodePudding user response:
The firebaseui package makes your life more easy to implement, but you dont know how to proceed with some questions. But to solve your case, I think removing the leading Icon from the AppBar gonna solve.
CodePudding user response:
To remove the back button in the AppBar you just need to pass
automaticallyImplyLeading: false,
And remember to use Navigator.pushReplacement()
instead of Navigator.push()
to remove all stack and push, hope this work
CodePudding user response:
Always remove all previous screen when you navigate to home screen after login, I suggest you to use,
Navigator.of(context).pushAndRemoveUntil(MaterialPageRoute(builder: (context) =>LoginScreen()), (Route<dynamic> route) => false);