I am a beginner in Flutter
and i am trying to integrate Firebase
with Flutter for the first time. I got several errors, cleared them one by one but this final one is where im stuck. I am actually trying for email/password authentication. Could you please help
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'dart:async';
final FirebaseAuth mAuth = FirebaseAuth.instance;
class login extends StatefulWidget{
@override
_loginState createState()=>_loginState();
}
class _loginState extends State<login>{
final _formKey= GlobalKey<FormState>();
TextEditingController emailController = new TextEditingController();
TextEditingController passwordController = new TextEditingController();
//String email='';
//String password='';
@override
Widget build(BuildContext context){
return Scaffold(
appBar: AppBar( // multiple properties separated by ,
title:Text('Login',
style:TextStyle(color:Colors.black )
),
actions:<Widget>[
FlatButton.icon(onPressed:(){
Navigator.pushNamed(context,'/signup');
}
, icon:Icon(Icons.people), label:Text('Register')),
],
backgroundColor: Colors.lightBlue[200],
centerTitle:true,
),
// actions used for multiple widgets
body:Center(
child: Padding(
padding: EdgeInsets.all(25),
child: Form(
key:_formKey,
child: Column(
children:<Widget>[
TextFormField(
controller: emailController,
validator:(val)=>val.isEmpty?'Enter Email' :null,
autocorrect: true,
autofocus: false,
cursorColor: Colors.blue,
decoration: new InputDecoration(
hintText: 'Email Address',
icon: new Icon(
Icons.people,
)
),
keyboardType: TextInputType.emailAddress,
onChanged:(val){
//email = val;
},
),
SizedBox(height:10.0),
TextFormField(
controller: passwordController,
validator:(val)=>val.length < 6 ?'Enter Password: Length greater than 6' :null,
autocorrect:true,
autofocus: false,
cursorColor: Colors.blue,
decoration: new InputDecoration(
hintText: 'Password',
icon: new Icon(
Icons.mail,
)
),
obscureText: true,
onChanged:(val){
// password=val;
},
),
SizedBox(height:10.0),
RaisedButton(onPressed:(){
if(_formKey.currentState.validate()){
Navigator.pushNamed(context,'/page1_menu');
}
else{return null;}
},
child: Text('Login'),
color: Colors.blueAccent[400],
)
]
)
),
)
),
);
}
void signUpWithEmailPassword()
async {
FirebaseUser user;
user = await mAuth.createUserWithEmailAndPassword(email: emailController.text, password: passwordController.text);
}
}
The error reads as follows : A value of type 'UserCredential' can't be assigned to a variable of type 'FirebaseUser'. Try changing the type of the variable, or casting the right-hand type to 'FirebaseUser'.dartinvalid_assignment