【发布时间】:2021-02-16 22:52:10
【问题描述】:
有时,当我尝试使用 firebase 登录时,我会收到以下错误:
W/DynamiteModule(8142):找不到 com.google.firebase.auth 的本地模块描述符类。
I/FirebaseAuth(8142):[FirebaseAuth:] 正在准备创建与 gms 实施的服务连接
D/FirebaseAuth(8142):通知 id 令牌侦听器有关用户 (skEEmC0dDBW9z73MsfShWX8M1iu1)。
I/flutter (8142):错误:NoSuchMethodError:方法“调用”在 null 上被调用。
I/flutter (8142):接收者:null
I/flutter (8142):尝试调用:call()
特别是如果我单击注册按钮返回登录。有人可以解释为什么我会收到此错误以及如何解决它: 代码如下:
class LoginPage extends StatefulWidget{
static const routeName = '/login';
LoginPage({this.onSignedIn});
final VoidCallback onSignedIn;
@override
State<StatefulWidget> createState() => new _LoginPageState();
}
enum FormType {
login,
}
class _LoginPageState extends State <LoginPage> {
final formKey = new GlobalKey<FormState>();
String _email,_password;
bool validateAndSave(){
final form = formKey.currentState;
if(form.validate()){
form.save();
return true;
}
return false;
}
void validateAndSubmit() async{
if(validateAndSave()){
try{
await FirebaseAuth.instance.signInWithEmailAndPassword(email: _email, password: _password);
widget.onSignedIn();
}catch (e){
print('Error:$e');
}
}
}
void moveToRegister() {
Navigator.of(context).pushReplacementNamed(RegisterPage.routeName);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: new AppBar(
title:new Text ('',
style: new TextStyle(color:Colors.white, fontWeight:FontWeight.bold)
),
backgroundColor: Color(0xff04346c),
),
body: Stack (
children:<Widget>[
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0xff04a3b3),
Color(0xff04a3b3),
Color(0xff04a3b3),
Color(0xff04a3b3),
]
)
),
),
Center(
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0)
),
child: Container(
height:350,
width:350,
padding: EdgeInsets.all(16.0),
child: Form(
key:formKey,
child: new Column(
children:
buildInputs() + buildSubmitButtons(),
)
)
)
)
)
],
),
);
}
List<Widget> buildInputs(){
return [
Image.asset('imageapp/myimage.png',height:50,width: 250,),
new TextFormField(
decoration: new InputDecoration(labelText: 'Email',
icon: new Icon (Icons.email)
),
onSaved: (value) => _email = value,
),
new TextFormField(
decoration: new InputDecoration (labelText: 'Password',
icon: new Icon (Icons.lock)
),
obscureText: true,
onSaved: (value) => _password = value,
),
];
}
List<Widget> buildSubmitButtons(){
return [
Padding(padding: EdgeInsets.all(3.0)),
new RaisedButton(
child: new Text('Login',style: new TextStyle(fontSize:18.0,color: Colors.white),
),
color: Color(0xff04346c),
shape: RoundedRectangleBorder(
borderRadius : new BorderRadius.circular(30.0)
),
onPressed: validateAndSubmit
),
new FlatButton(
onPressed: moveToRegister,
child: new Text('Create an account',style: new TextStyle(fontSize:13.0),)
)
];
}
}
【问题讨论】:
标签: android firebase flutter mobile