Skip to content
This repository was archived by the owner on Dec 10, 2023. It is now read-only.

Commit c33b9c5

Browse files
Email Verification
1 parent ef6262d commit c33b9c5

7 files changed

+236
-13
lines changed

lib/Registration.dart

+9-10
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class Registpage extends StatefulWidget {
1717
}
1818

1919
class _RegistpageState extends State<Registpage> {
20-
late String _text="";
21-
late String _password="";
20+
late String _text = "";
21+
late String _password = "";
2222

2323
@override
2424
Widget build(BuildContext context) {
@@ -229,11 +229,11 @@ class BottomButton extends StatelessWidget {
229229
// ignore: non_constant_identifier_names
230230
BottomButton(
231231
{required this.txt,
232-
required this.path,
233-
required this.h,
234-
required this.w,
235-
required this.text,
236-
required this.password});
232+
required this.path,
233+
required this.h,
234+
required this.w,
235+
required this.text,
236+
required this.password});
237237
double h, w;
238238
String txt, text, password;
239239
Widget path;
@@ -254,14 +254,14 @@ class BottomButton extends StatelessWidget {
254254
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
255255
content: Text("Please enter password"),
256256
));
257-
258257
} else
259258
Navigator.push(
260259
context, MaterialPageRoute(builder: (context) => path));
261260
} catch (e) {
262261
print(e);
263262
ScaffoldMessenger.of(context).showSnackBar(
264-
SnackBar(content: Text(e.toString()),
263+
SnackBar(
264+
content: Text(e.toString()),
265265
backgroundColor: Colors.red,
266266
),
267267
);
@@ -275,7 +275,6 @@ class BottomButton extends StatelessWidget {
275275
width: w / 1.18,
276276
decoration: BoxDecoration(
277277
gradient: const LinearGradient(
278-
279278
colors: [Color(0xffFFDA94), Color(0xffFF942F)],
280279
begin: Alignment.topCenter,
281280
end: Alignment.bottomCenter),

lib/logIn.dart

-1
Original file line numberDiff line numberDiff line change
@@ -284,4 +284,3 @@ List<BoxShadow> shadow = [
284284
List<BoxShadow> Shadow = [
285285
BoxShadow(color: Colors.grey[300]!, blurRadius: 10, offset: Offset(0, 10))
286286
];
287-

lib/main.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import 'package:animated_splash_screen/animated_splash_screen.dart'
22
show AnimatedSplashScreen, SplashTransition;
33
import 'package:flutter/material.dart';
44
import 'package:firebase_core/firebase_core.dart';
5+
import 'package:handsforhunger/cpy.dart';
56
import 'package:handsforhunger/donor.dart';
7+
import 'package:handsforhunger/verifyEmail.dart';
68
import 'welcomeScreen.dart';
79

810
void main() async {
@@ -34,7 +36,7 @@ class MyApp extends StatelessWidget {
3436
),
3537
),
3638
duration: 2000,
37-
nextScreen: WelcomeScreen()),
39+
nextScreen: Verify()),
3840
);
3941
}
4042
}

lib/verifyEmail.dart

+206
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:google_fonts/google_fonts.dart';
3+
import 'package:email_otp/email_otp.dart';
4+
5+
import 'Registration.dart';
6+
import 'welcomeScreen.dart';
7+
8+
class Verify extends StatefulWidget {
9+
const Verify({super.key});
10+
11+
@override
12+
State<Verify> createState() => _VerifyState();
13+
}
14+
15+
late String _txt = "";
16+
late String _Password = "";
17+
18+
class _VerifyState extends State<Verify> {
19+
EmailOTP myauth = EmailOTP();
20+
21+
@override
22+
Widget build(BuildContext context) {
23+
double h = (MediaQuery.of(context).size.height),
24+
w = (MediaQuery.of(context).size.width);
25+
return Scaffold(
26+
body: SingleChildScrollView(
27+
child: Container(
28+
color: Color(0xffFAFAFC),
29+
padding: EdgeInsets.only(
30+
top: h / 9, bottom: h / 15, left: w / 16, right: w / 16),
31+
child: Column(
32+
children: [
33+
TopText(),
34+
SizedBox(
35+
height: h / 25,
36+
),
37+
Row(
38+
children: [
39+
SizedBox(
40+
width: w / 18,
41+
),
42+
Align(
43+
alignment: Alignment.centerLeft,
44+
child: Text(
45+
textAlign: TextAlign.left,
46+
'Verification',
47+
style: GoogleFonts.poppins(
48+
fontSize: w / 16,
49+
fontWeight: FontWeight.w600,
50+
color: Color(0xffFFBA25)),
51+
),
52+
),
53+
],
54+
),
55+
SizedBox(
56+
height: h / 30,
57+
),
58+
Container(
59+
margin: EdgeInsets.symmetric(horizontal: h / 80),
60+
padding: EdgeInsets.only(left: w / 80),
61+
height: h / 13,
62+
decoration: BoxDecoration(
63+
color: Colors.white,
64+
borderRadius: BorderRadius.circular(15),
65+
boxShadow: Shadow,
66+
),
67+
child: Center(
68+
child: TextFormField(
69+
onChanged: (value) {
70+
_txt = value;
71+
},
72+
decoration: InputDecoration(
73+
border: InputBorder.none,
74+
hintText: 'Email',
75+
hintStyle: GoogleFonts.poppins(
76+
fontSize: w / 25, color: Colors.grey[500]),
77+
prefixIcon: Icon(
78+
Icons.person,
79+
color: Colors.grey[500],
80+
)),
81+
),
82+
),
83+
),
84+
Align(
85+
alignment: Alignment.centerRight,
86+
child: GestureDetector(
87+
onTap: () async {
88+
myauth.setConfig(
89+
appEmail: "[email protected]",
90+
appName: "Email OTP",
91+
userEmail: _txt,
92+
otpLength: 6,
93+
otpType: OTPType.digitsOnly);
94+
if (await myauth.sendOTP() == true) {
95+
ScaffoldMessenger.of(context)
96+
.showSnackBar(const SnackBar(
97+
content: Text("OTP has been sent"),
98+
));
99+
} else {
100+
ScaffoldMessenger.of(context)
101+
.showSnackBar(const SnackBar(
102+
content: Text("Oops, OTP send failed"),
103+
));
104+
}
105+
},
106+
child: Container(
107+
padding: EdgeInsets.symmetric(
108+
horizontal: w / 15, vertical: h / 80),
109+
child: Text(
110+
'SendOtp',
111+
))),
112+
),
113+
SizedBox(
114+
height: h / 35,
115+
),
116+
Container(
117+
margin: EdgeInsets.symmetric(horizontal: h / 80),
118+
height: h / 13,
119+
decoration: BoxDecoration(
120+
color: Colors.white,
121+
borderRadius: BorderRadius.circular(15),
122+
boxShadow: Shadow,
123+
),
124+
child: Center(
125+
child: TextFormField(
126+
onChanged: (value) {
127+
_Password = value;
128+
},
129+
decoration: InputDecoration(
130+
border: InputBorder.none,
131+
hintText: 'OTP',
132+
hintStyle: GoogleFonts.poppins(
133+
fontSize: w / 25, color: Colors.grey[500]),
134+
prefixIcon: Icon(
135+
Icons.lock_outline_rounded,
136+
color: Colors.grey[500],
137+
),
138+
suffixIcon: IconButton(
139+
icon: Icn,
140+
color: Colors.grey[500],
141+
onPressed: () {
142+
setState(() {
143+
pressed = !pressed;
144+
});
145+
}),
146+
),
147+
),
148+
),
149+
),
150+
SizedBox(
151+
height: h / 15,
152+
),
153+
GestureDetector(
154+
onTap: () async {
155+
setState(() async {
156+
if (await myauth.verifyOTP(otp: _Password) == true) {
157+
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
158+
content: Text("OTP is verified"),
159+
));
160+
Navigator.push(
161+
context,
162+
MaterialPageRoute(
163+
builder: (context) => Registpage()));
164+
} else {
165+
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
166+
content: Text("Invalid OTP"),
167+
));
168+
}
169+
});
170+
},
171+
child: Padding(
172+
padding: const EdgeInsets.symmetric(horizontal: 30),
173+
child: Container(
174+
margin: EdgeInsets.only(top: 20),
175+
height: h / 14,
176+
width: w / 1.18,
177+
decoration: BoxDecoration(
178+
gradient: const LinearGradient(
179+
colors: [Color(0xffFFDA94), Color(0xffFF942F)],
180+
begin: Alignment.topCenter,
181+
end: Alignment.bottomCenter),
182+
borderRadius: BorderRadius.circular(12),
183+
color: Color(0xff4BB0FE)),
184+
child: Center(
185+
child: Text(
186+
'Verify',
187+
style: GoogleFonts.poppins(
188+
fontSize: w / 24.5,
189+
fontWeight: FontWeight.w600,
190+
color: Colors.white),
191+
),
192+
),
193+
),
194+
),
195+
),
196+
],
197+
),
198+
),
199+
),
200+
);
201+
}
202+
}
203+
204+
List<BoxShadow> Shadow = [
205+
BoxShadow(color: Colors.grey[300]!, blurRadius: 10, offset: Offset(0, 10))
206+
];

lib/welcomeScreen.dart

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
22
import 'package:google_fonts/google_fonts.dart';
33
import 'package:handsforhunger/Registration.dart';
4+
import 'package:handsforhunger/verifyEmail.dart';
45
import 'logIn.dart';
56

67
class WelcomeScreen extends StatefulWidget {
@@ -70,7 +71,7 @@ class _WelcomeScreenState extends State<WelcomeScreen> {
7071
),
7172
BottomButton(
7273
txt: 'Ngo',
73-
path: Registpage(),
74+
path: Verify(),
7475
h: h,
7576
w: w,
7677
),

pubspec.lock

+14
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,20 @@ packages:
9999
url: "https://pub.dartlang.org"
100100
source: hosted
101101
version: "1.0.5"
102+
email_otp:
103+
dependency: "direct main"
104+
description:
105+
name: email_otp
106+
url: "https://pub.dartlang.org"
107+
source: hosted
108+
version: "1.0.4"
109+
email_validator:
110+
dependency: "direct main"
111+
description:
112+
name: email_validator
113+
url: "https://pub.dartlang.org"
114+
source: hosted
115+
version: "2.1.17"
102116
fake_async:
103117
dependency: transitive
104118
description:

pubspec.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ dependencies:
4242
sizer: ^2.0.15
4343
lottie: ^2.1.0
4444
page_transition: ^2.0.9
45+
email_validator: ^2.1.17
46+
email_otp: ^1.0.4
4547

4648
dev_dependencies:
4749
flutter_test:

0 commit comments

Comments
 (0)