Commit 3fbe7e3e authored by Budi Prasetyo's avatar Budi Prasetyo

alertdialog

parent c07c7e6f
......@@ -4,7 +4,7 @@ import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:form_field_validator/form_field_validator.dart';
import 'package:http/http.dart' as http;
import 'package:medapp_eksad/firebase/showSnackbar.dart';
import 'package:medapp_eksad/firebase/showSnackbar_Alertdialog.dart';
import 'package:medapp_eksad/widget/button_color.dart';
class ForgotPassword extends StatefulWidget {
......
......@@ -3,7 +3,7 @@ import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:medapp_eksad/firebase/showOtpDialog.dart';
import 'package:medapp_eksad/firebase/showSnackbar.dart';
import 'package:medapp_eksad/firebase/showSnackbar_Alertdialog.dart';
class FirebaseAuthMethods {
final FirebaseAuth _auth;
......@@ -55,7 +55,7 @@ class FirebaseAuthMethods {
} else if (e.code == 'email-already-in-use') {
print('The account already exists for that email.');
}
showSnackBar(
showAlertError(
context, e.message!); // Displaying the usual firebase error message
}
}
......@@ -92,7 +92,7 @@ class FirebaseAuthMethods {
Navigator.pushNamed(context, '/demo');
}
} on FirebaseAuthException catch (e) {
showDialog(context: context, builder: (context) => AlertDialog(title: Text(e.message!,style: TextStyle(color: Colors.yellow),),backgroundColor: Colors.red,)); // Displaying the error message
showAlertError(context, e.message!); // Displaying the error message
}
}
......@@ -100,9 +100,9 @@ class FirebaseAuthMethods {
Future<void> sendEmailVerification(BuildContext context) async {
try {
_auth.currentUser!.sendEmailVerification();
showSnackBar(context, 'Email verification sent! , Check your Inbox or Spam Email');
showAlert(context, 'Email verification sent! , Check your Inbox or Spam Email');
} on FirebaseAuthException catch (e) {
showSnackBar(context, e.message!); // Display error message
showAlertError(context, e.message!); // Display error message
}
}
......
import 'package:flutter/material.dart';
void showSnackBar(BuildContext context, String text) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(text),
),
);
}
import 'package:flutter/material.dart';
void showSnackBar(BuildContext context, String text) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(text),
backgroundColor: Colors.green,
),
);
}
void showSnackBarError(BuildContext context, String text) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(text),
backgroundColor: Colors.red,
),
);
}
void showAlert(BuildContext context, String isiAlert) {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text(
isiAlert,
style: TextStyle(color: Colors.white),
),
backgroundColor: Colors.green,
));
}
void showAlertError(BuildContext context, String isiAlert) {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text(
isiAlert,
style: TextStyle(color: Colors.yellow),
),
backgroundColor: Colors.red,
));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment