Error message :
Missing concrete implementation of 'State.build'.
Try implementing the missing method, or make the class abstract.
I get the above error for class _ResetPasswordViewState which is located on Line 13 , in the code below. I get the error message in spite of writing the code for that override. I started getting the error on writing the code for Future passwordReset(), which starts on Line 22. Can someone tell me the mistake I did .
This is the code of my Password Reset file.
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:secure_pass/services/auth/auth_exceptions.dart';
import 'package:secure_pass/utilities/dialogs/error_dialog.dart';
class ResetPasswordView extends StatefulWidget {
const ResetPasswordView({Key? key}) : super(key: key);
@override
State<ResetPasswordView> createState() => _ResetPasswordViewState();
}
class _ResetPasswordViewState extends State<ResetPasswordView> {
final _email = TextEditingController();
@override
void dispose() {
_email.dispose();
super.dispose();
}
Future passwordReset() async{
try {
await FirebaseAuth.instance.sendPasswordResetEmail(email: _email.text);
showDialog(
context: context,
builder: (context) {
return const AlertDialog(
content : Text('Password reset link sent! Check your email'),
);
}
);
} on UserNotFoundAuthException {
await showErrorDialog(
context,
'User not found',
);
} on InvalidEmailAuthException {
await showErrorDialog(
context,
'This is an invalid email address',
);
} on GenericAuthException {
await showErrorDialog(
context,
'Please try again',
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.deepPurple[200],
elevation: 0,
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Padding(
padding: EdgeInsets.symmetric(horizontal: 23.0),
child: Text(
"Enter your Email and we will send you a password reset link",
textAlign: TextAlign.center,
),
),
const SizedBox(height: 10),
//email textfield
Padding(
padding: const EdgeInsets.symmetric(horizontal: 25.0),
child: Container(
decoration: BoxDecoration(
color: Colors.grey[200],
border: Border.all(color: Colors.white),
borderRadius: BorderRadius.circular(12),
),
child: Padding(
padding: const EdgeInsets.only(left: 20.0),
child: TextField(
controller: _email,
enableSuggestions: false,
autocorrect: false,
keyboardType: TextInputType.emailAddress,
decoration: const InputDecoration(
hintText: 'Enter your email here',
border: InputBorder.none
),
),
),
),
),
const SizedBox(height: 10),
MaterialButton(
onPressed: passwordReset,
child: Text('Reset Password'),
color: Colors.deepPurple[200],
),
],
),
);
}
}
}
CodePudding user response:
Because you have put you build Widget method inside another method which is the reset password and the stateful widget is looking for the build method in the first stage to run it . i know you did it by mistake and you forgot a } at the end of the fucntion of the reset password, just add it and you will be good to go !