【发布时间】:2019-10-15 04:43:19
【问题描述】:
此代码用于 FireBase 注册
onPressed: () async {
if (_emailController.text.isEmpty || _passwordController.text.isEmpty) {
throw _showDialog2(context);
}
FirebaseUser user;
if (user == null) {
try {
user = await _firebaseAuth.createUserWithEmailAndPassword(email: email, password: password);
_showDialog(context);
await user.sendEmailVerification();
} on PlatformException catch (e) {
switch (e.code) {
case "ERROR_EMAIL_AlREADY_IN_USE":
setState(() {
errorMsg = "This email is already in use.";
});
_showDialog1(context);
}
print(e.message);
}
}
},
Future<Void> _showDialog1(BuildContext context) {
return showDialog<void>(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text('Alert'),
content: const Text('User Already Exists'),
actions: <Widget>[
FlatButton(
child: Text('Ok'),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => LoginPage(),
),
);
},
),
],
);
},
);
}
对话框不工作,如果用户尝试注册并且不显示任何警报,则使用该对话框的用户将不知道发生了什么。
V/FA (23130): Recording user engagement, ms: 67474
V/FA (23130): Connecting to remote service
V/FA (23130): Activity paused, time: 479832386
D/FA (23130): Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=67474, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=8428444267785459928}]
V/FA (23130): Connection attempt already in progress
D/FA (23130): Connected to remote service
V/FA (23130): Processing queued up service tasks: 2
V/FA (23130): Inactivity, disconnecting from the service
V/FA (23130): Connecting to remote service
V/FA (23130): Activity resumed, time: 480570394
W/1.gpu (23130): type=1400 audit(0.0:73052): avc: denied { search } for name="ctx" dev="debugfs" ino=15090 scontext=u:r:untrusted_app:s0:c153,c257,c512,c768 tcontext=u:object_r:qti_debugfs:s0 tclass=dir permissive=0
D/FA (23130): Connected to remote service
V/FA (23130): Processing queued up service tasks: 1
W/BiChannelGoogleApi(23130): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzak@5aa370
W/DynamiteModule(23130): Local module descriptor class for com.google.firebase.auth not found.
I/FirebaseAuth(23130): [FirebaseAuth:] Loading module via FirebaseOptions.
I/FirebaseAuth(23130): [FirebaseAuth:] Preparing to create service connection to gms implementation
I/flutter (23130): The email address is already in use by another account.
V/FA (23130): Inactivity, disconnecting from the service
W/BiChannelGoogleApi(23130): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzak@5aa370
I/flutter (23130): The email address is already in use by another account
Flutter 中的 Catch 是否支持警报对话框,或者我必须为此尝试其他方法? V/FA (23130):记录用户参与度,毫秒:67474 V/FA (23130):连接到远程服务 V/FA (23130):活动暂停,时间:479832386 D/FA (23130): 记录事件 (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto,engagement_time_msec(_et)=67474, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=8428444267785459928}] V/FA (23130):连接尝试已在进行中 D/FA (23130):连接到远程服务 V/FA (23130):处理排队的服务任务:2 V/FA (23130):不活动,与服务断开连接 V/FA (23130):连接到远程服务 V/FA (23130):活动恢复,时间:48057039
【问题讨论】:
标签: flutter