I have a form to create a firebase user using createUserWithEmailAndPassword() and a button who redirect to home page. after I click on the button, the user account is created successfully but without redirection to another page
the button's code in 'register.dart'
child: FlatButton(
onPressed: () {
FirebaseAuth.instance.createUserWithEmailAndPassword(
email: _emailController.text,
password: _passwordController.text
).then((signedUser){
UserToDatabase().addNewUser(signedUser, context);
**** Navigator.of(context).pushReplacementNamed('/home');
}).catchError((e){
print(e);
});
},
child: Center(
child: Text("S'inscrire"),
),
),
user_to_database.dart
import 'package:car_app/GUI/bottomNavBar.dart';
import 'package:firebase_database/firebase_database.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
class UserToDatabase{
addNewUser(user, context){
FirebaseDatabase.instance.reference().child('users').push().set({
'email' : user.email,
'uid' : user.uid
}).then((value){
Navigator.push(context, new MaterialPageRoute(builder: (context) => new BottomNavBar()));
}).catchError((e){
print(e);
});
}
}
I want to know what should I change so that I can redirect to home page. this is what I get as error messages:
Performing hot reload...
Syncing files to device Android SDK built for x86...
Reloaded 3 of 474 libraries in 1 272ms.
I/BiChannelGoogleApi(17924): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzao@711d32a
W/DynamiteModule(17924): Local module descriptor class for com.google.firebase.auth not found.
I/FirebaseAuth(17924): [FirebaseAuth:] Preparing to create service connection to gms implementation
I/art (17924): Background sticky concurrent mark sweep GC freed 20942(1058KB) AllocSpace objects, 0(0B) LOS objects, 31% free, 2MB/3MB, paused 29.893ms total 107.321ms
D/FirebaseAuth(17924): Notifying id token listeners about user ( YT5FSoTNCJdlUQb2msW0S01VZSf1 ).
D/FirebaseAuth(17924): Notifying auth state listeners about user ( YT5FSoTNCJdlUQb2msW0S01VZSf1 ).
I/flutter (17924): NoSuchMethodError: Class 'AuthResult' has no instance getter 'email'.
I/flutter (17924): Receiver: Instance of 'AuthResult'
I/flutter (17924): Tried calling: email
@IhssaneTAJ This does not look related to robotframework. Wrong issue tracker?
UserToDatabase().addNewUser(signedUser.user, context); //try to add 'user' on this line
If you find the solution, please let me know
UserToDatabase().addNewUser(signedUser.user,context); //try to add 'user' on this line
Thank you this worked for me
Most helpful comment
UserToDatabase().addNewUser(signedUser.user,context); //try to add 'user' on this line