From 23440c316dcb4e887e4b97c255c50982b1260991 Mon Sep 17 00:00:00 2001 From: Bhavya L Narayanan Date: Fri, 30 Jul 2021 16:58:26 +0530 Subject: [PATCH] Toast --- lib/pages/item_page.dart | 11 +++++++++ lib/pages/signin_page.dart | 50 +++++++++++++++++++++++++++++++++++++- lib/pages/signup_page.dart | 32 +++++++++++++++++++++++- pubspec.lock | 7 ++++++ pubspec.yaml | 1 + 5 files changed, 99 insertions(+), 2 deletions(-) diff --git a/lib/pages/item_page.dart b/lib/pages/item_page.dart index 6f6f6b3..3eb17c6 100644 --- a/lib/pages/item_page.dart +++ b/lib/pages/item_page.dart @@ -5,6 +5,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutterlogindesign/pages/donor_dashboard.dart'; import 'package:flutterlogindesign/pages/qr.dart'; +import 'package:fluttertoast/fluttertoast.dart'; String generatedID; @@ -95,6 +96,16 @@ class _State extends State { generatedID = querySnapshot.id.toString() + uidDonor.toString(); // Here we call the ID of the document + Fluttertoast.showToast( + msg: "Item added.", + toastLength: Toast.LENGTH_LONG, + gravity: ToastGravity.BOTTOM, + timeInSecForIosWeb: 1, + backgroundColor: Colors.red, + textColor: Colors.white, + fontSize: 16.0 + ); + }); diff --git a/lib/pages/signin_page.dart b/lib/pages/signin_page.dart index 7cb6d20..fab40c7 100644 --- a/lib/pages/signin_page.dart +++ b/lib/pages/signin_page.dart @@ -8,6 +8,7 @@ import 'package:flutterlogindesign/widgets/btn_widget.dart'; import 'package:flutterlogindesign/widgets/Headdersignup.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:fluttertoast/fluttertoast.dart'; import 'donor_dashboard.dart'; @@ -142,6 +143,15 @@ class _LoginPageState extends State { check == "(2)" || check == "(0)") { FirebaseAuth.instance.signOut(); + Fluttertoast.showToast( + msg: "No account found", + toastLength: Toast.LENGTH_LONG, + gravity: ToastGravity.BOTTOM, + timeInSecForIosWeb: 1, + backgroundColor: Colors.red, + textColor: Colors.white, + fontSize: 16.0 + ); print("No account found"); } else { Navigator.push( @@ -165,6 +175,15 @@ class _LoginPageState extends State { check == "(1)" || check == "(0)") { FirebaseAuth.instance.signOut(); + Fluttertoast.showToast( + msg: "No account found", + toastLength: Toast.LENGTH_LONG, + gravity: ToastGravity.BOTTOM, + timeInSecForIosWeb: 1, + backgroundColor: Colors.red, + textColor: Colors.white, + fontSize: 16.0 + ); print("No account found"); } else { Navigator.push( @@ -188,6 +207,15 @@ class _LoginPageState extends State { check == "(1)" || check == "(0)") { FirebaseAuth.instance.signOut(); + Fluttertoast.showToast( + msg: "No account found", + toastLength: Toast.LENGTH_LONG, + gravity: ToastGravity.BOTTOM, + timeInSecForIosWeb: 1, + backgroundColor: Colors.red, + textColor: Colors.white, + fontSize: 16.0 + ); print("No account found"); } else { Navigator.push( @@ -198,8 +226,26 @@ class _LoginPageState extends State { } } on FirebaseAuthException catch (e) { if (e.code == 'user-not-found') { + Fluttertoast.showToast( + msg: "No user found for that email.", + toastLength: Toast.LENGTH_LONG, + gravity: ToastGravity.BOTTOM, + timeInSecForIosWeb: 1, + backgroundColor: Colors.red, + textColor: Colors.white, + fontSize: 16.0 + ); print('No user found for that email.'); } else if (e.code == 'wrong-password') { + Fluttertoast.showToast( + msg: "Wrong password provided for that user.", + toastLength: Toast.LENGTH_LONG, + gravity: ToastGravity.BOTTOM, + timeInSecForIosWeb: 1, + backgroundColor: Colors.red, + textColor: Colors.white, + fontSize: 16.0 + ); print('Wrong password provided for that user.'); } } @@ -231,6 +277,7 @@ class _LoginPageState extends State { color: Colors.black54, decoration: TextDecoration.underline, )), + ]), ) ], @@ -240,9 +287,10 @@ class _LoginPageState extends State { ), ), ), + ); } - + Widget _textInput({hint, icon, myController, obscure}) { return Container( margin: EdgeInsets.only(top: 10), diff --git a/lib/pages/signup_page.dart b/lib/pages/signup_page.dart index 3df8967..9da2f8f 100644 --- a/lib/pages/signup_page.dart +++ b/lib/pages/signup_page.dart @@ -7,6 +7,7 @@ import 'package:flutterlogindesign/pages/volunteer_page.dart'; import 'package:flutterlogindesign/widgets/btn_widget.dart'; import 'package:flutterlogindesign/widgets/Headdersignup.dart'; import 'package:firebase_auth/firebase_auth.dart'; +import 'package:fluttertoast/fluttertoast.dart'; import 'donor_dashboard.dart'; @@ -127,12 +128,41 @@ class _RegPageState extends State { } } on FirebaseAuthException catch (e) { if (e.code == 'weak-password') { + Fluttertoast.showToast( + msg: "The password provided is too weak.", + toastLength: Toast.LENGTH_LONG, + gravity: ToastGravity.BOTTOM, + timeInSecForIosWeb: 1, + backgroundColor: Colors.red, + textColor: Colors.white, + fontSize: 16.0 + ); print('The password provided is too weak.'); - } else if (e.code == 'email-already-in-use') { + } else if (e.code == 'email-already-in-use') { + Fluttertoast.showToast( + msg: "The account already exists for that email.", + toastLength: Toast.LENGTH_LONG, + gravity: ToastGravity.BOTTOM, + timeInSecForIosWeb: 1, + backgroundColor: Colors.red, + textColor: Colors.white, + fontSize: 16.0 + ); + print( 'The account already exists for that email.'); } } catch (e) { + Fluttertoast.showToast( + msg: "$e", + toastLength: Toast.LENGTH_LONG, + gravity: ToastGravity.BOTTOM, + timeInSecForIosWeb: 1, + backgroundColor: Colors.red, + textColor: Colors.white, + fontSize: 16.0 + ); + print(e); } }, diff --git a/pubspec.lock b/pubspec.lock index 249d759..08f9a16 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -198,6 +198,13 @@ packages: description: flutter source: sdk version: "0.0.0" + fluttertoast: + dependency: "direct main" + description: + name: fluttertoast + url: "https://pub.dartlang.org" + source: hosted + version: "8.0.7" http_parser: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 4e101de..f094d55 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -26,6 +26,7 @@ dependencies: flutter: sdk: flutter firebase_core: "0.7.0" + fluttertoast: ^8.0.7