step-6
This commit is contained in:
parent
9353037c77
commit
9257d1b79d
|
@ -0,0 +1,24 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
Future<void> showErrorDialog(
|
||||
BuildContext context,
|
||||
String text,
|
||||
) {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text('An error occurred'),
|
||||
content: Text(text),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: const Text('OK'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'dart:developer' as devtools show log;
|
||||
|
||||
import 'package:mynotes/constants/routes.dart';
|
||||
import 'package:mynotes/utilities/show_error_dialog.dart';
|
||||
|
||||
class LoginView extends StatefulWidget {
|
||||
const LoginView({Key? key}) : super(key: key);
|
||||
|
@ -70,10 +69,26 @@ class _LoginViewState extends State<LoginView> {
|
|||
);
|
||||
} on FirebaseAuthException catch (e) {
|
||||
if (e.code == 'user-not-found') {
|
||||
devtools.log('User not found');
|
||||
await showErrorDialog(
|
||||
context,
|
||||
'User not found',
|
||||
);
|
||||
} else if (e.code == 'wrong-password') {
|
||||
devtools.log('Wrong password');
|
||||
await showErrorDialog(
|
||||
context,
|
||||
'Wrong credentials',
|
||||
);
|
||||
} else {
|
||||
await showErrorDialog(
|
||||
context,
|
||||
'Error: ${e.code}',
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
await showErrorDialog(
|
||||
context,
|
||||
e.toString(),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: const Text('Login'),
|
||||
|
|
Loading…
Reference in New Issue