While working with firebase authentication weird error without any notes happen to me.
This time application stops after I press set name button. Instantly in VScode I am redirected to this page:
As I said there is no error in debug console, no notes. No expections to see.
I guess there is something wrong with setting displayName but not clearly what.
This is full code of the class:
class Verified extends StatefulWidget {
@override
_VerifiedState createState() => _VerifiedState();
}
class _VerifiedState extends State<Verified> {
final formKey = GlobalKey<FormState>();
final nameController = TextEditingController();
final _auth = FirebaseAuth.instance;
validate(displayName) {
if (formKey.currentState.validate()) {
setName(displayName);
}
}
setName(displayName) async {
try {
await _auth.currentUser.updateProfile(displayName: displayName);
} catch (e) {
log(e.code.toString());
}
log(_auth.currentUser.displayName.toString());
}
@override
Widget build(BuildContext context) {
return Material(
child: Padding(
padding: const EdgeInsets.all(100.0),
child: Column(
children: [
Text('choose your username'),
Form(
key: formKey,
child: TextFormField(
controller: nameController,
decoration: InputDecoration(hintText: 'name'),
),
),
RaisedButton(
child: Text('set name'),
onPressed: () => validate(nameController))
],
),
),
);
}
}
Thank you in advance
question from:
https://stackoverflow.com/questions/65940245/redirecting-without-any-error-displayname 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…