I add sign out button but when I press that button it show me this errors: enter image description here
maybe because I add routeName in login page!!
can any one explain the error for me??
this is my code:
ListTile(
title: const Text('Logout'),
trailing: const Icon(
Icons.logout_rounded,
color: Colors.blueGrey,
),
onTap: () async {
await FirebaseAuth.instance.signOut();
Navigator.of(context)
.pushReplacementNamed(LoginScreen.routeName);
}),
this is my loginscreen:
import 'package:test/page/loginForm.dart';
import 'package:flutter/material.dart';
class LoginScreen extends StatelessWidget {
static const routeName = '/login';
const LoginScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Scaffold(
body: Stack(
children: [
SizedBox(
width: double.infinity,
height: double.infinity,
child: Image.asset(
"assets/images/Login.jpeg",
fit: BoxFit.cover,
),
),
Padding(
padding: const EdgeInsets.only(
top: 400,
right: 60,
left: 60,
),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
SizedBox(height: 50),
LoginForm(),
Most times it's because you did something wrong in main, or you defined a route incorrectly. if nothing helps, try these steps:
Ensure both initial route and onGenerate routes are correct.
This class is a magic string for routes. it allows you to not type strings when calling images or route etc. these will be used when navigating to a page etc.
Ensure you're calling the right page in your routes.
Lastly, we navigate just as you'd do from login page to homepage or vice versa.
Hope this helps you in anyway.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.