'I/flutter (16745): LateInitializationError: Field 'email' has not been initialized

class _RigestritState extends State<Rigestrit> {
  final _auth = FirebaseAuth.instance;

  late String email;
  late String password;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: backrond,
      body: SafeArea(
        child: Padding(
          padding: const EdgeInsets.symmetric(horizontal: 24),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: [
              Text('تسجيل' ,style: logo, textAlign: TextAlign.center,),
              SizedBox(height: 50,),
              ButtenHint(hint: 'الايميل  ', onpressed:(value){ email = value;}, obscureText: false, ),
              ButtenHint(hint: 'كلمة السر ', onpressed:(value){password = value;}, obscureText: true, ),



              Mybouttn(color: blueColor, titel: 'تسجيل', onpressed: () async  {//to send the data to firebase
                try{
                  final newUer = await  _auth.createUserWithEmailAndPassword(email: email, password: password);
                  Navigator.pushNamed(context, home.homePage);
                }catch(e){
                  print(e);

                }

              }),


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source