Home > OS >  The method 'UserUid' isn't defined for the type '_HomeState'
The method 'UserUid' isn't defined for the type '_HomeState'

Time:01-11

I'm developing a Flutter mobile app. I'm doing the authentication using Firebase, but I have a problem. I want to add a button to log out, but I'm facing this error, how can I solve it? I need help. UserUid(), OutButton(), I am getting error in these two places.With the help of Firebase, I wanted to take the current user and log out with the signOut method, but I wanted to add it to a button in the method and add it as a widget, but I could not solve the error.

Errors: The method 'UserUid' isn't defined for the type '_HomeState'. Errors: The method 'OutButton' isn't defined for the type '_HomeState'.

I think it is because I use statefull widget but I have to use statefull and I definitely need to add a exit button to this page.

class Home extends StatefulWidget {
 static String routeName="/home";
 Home({Key? key}) : super(key: key);
 final User? user = Auth().currentUser;

 Future<void> signOut() async {
   await Auth().signOut();
 }

 Widget Title_() {
   return const Text('Firebase Auth');
 }

 Widget UserUid() {
   return Text(user?.email ?? 'User email');
 }

 Widget OutButton() {
   return ElevatedButton(
     onPressed: signOut,
     child: const Text('Sign Out'),
   );
 }


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

class _HomeState extends State<Home> {
 String getEmoji(String text) {
   if (text == "anger") {
     return '           
  • Related