I'm getting this error while running my application
LateInitializationError: Field '_email@598051279' has already been initialized.
How can i fix this problem?
this my code divided in two parts:
class _LoginViewState extends State<LoginView> {
late final TextEditingController _email;
late final TextEditingController _password;
@override
void dispose() {
_email = TextEditingController();
_password = TextEditingController();
super.dispose();
}
@override
void initState() {
_email = TextEditingController();
_password = TextEditingController();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Login')),
body: Column(
children: [
TextField(
controller: _email,
),
TextField(
controller: _password,
),
this is the second part
Center(
child: TextButton(
onPressed: () async {
final email = _email.text;
final password = _password.text;
try {
final userCredintials =
await FirebaseAuth.instance.signInWithEmailAndPassword(
email: email,
password: password,
);
Navigator.of(context).pushNamedAndRemoveUntil(
notesRoute,
(route) => false,
);
}
],
),
);
}
}
here is depug-console
LateInitializationError: Field '_email@49051279' has already been initialized.
When the exception was thrown, this was the stack
#0 LateError._throwFieldAlreadyInitialized (dart:_internal-patch/internal_patch.dart:201:5)
#1 _LoginViewState._email=
package:learn_flutter_37_hours/views/login.dart:14
#2 _LoginViewState.dispose