97 lines
3.2 KiB
Dart
97 lines
3.2 KiB
Dart
// ignore_for_file: use_build_context_synchronously
|
|
|
|
import 'package:firebase_auth/firebase_auth.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:securify/Components/background.dart';
|
|
|
|
class ForgotPassword extends StatefulWidget {
|
|
const ForgotPassword({super.key});
|
|
|
|
@override
|
|
State<ForgotPassword> createState() => _ForgotPasswordState();
|
|
}
|
|
|
|
class _ForgotPasswordState extends State<ForgotPassword> {
|
|
TextEditingController email = TextEditingController();
|
|
|
|
reset() async {
|
|
await FirebaseAuth.instance.sendPasswordResetEmail(email: email.text);
|
|
// Tampilkan snackbar ketika email berhasil dikirim
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Text('Password reset email has been sent to ${email.text}'),
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Size size = MediaQuery.of(context).size;
|
|
|
|
return Scaffold(
|
|
body: Background(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: <Widget>[
|
|
Container(
|
|
alignment: Alignment.centerLeft,
|
|
padding: const EdgeInsets.symmetric(horizontal: 35),
|
|
child: const Text(
|
|
"Forgot Password",
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
color: Color(0xFF2661FA),
|
|
fontSize: 30,
|
|
),
|
|
textAlign: TextAlign.left,
|
|
),
|
|
),
|
|
SizedBox(height: size.height * 0.01),
|
|
Container(
|
|
alignment: Alignment.center,
|
|
margin: const EdgeInsets.symmetric(horizontal: 40),
|
|
child: TextField(
|
|
controller: email,
|
|
decoration:
|
|
const InputDecoration(labelText: "Enter your email"),
|
|
),
|
|
),
|
|
SizedBox(height: size.height * 0.03),
|
|
Container(
|
|
alignment: Alignment.centerRight,
|
|
margin: const EdgeInsets.symmetric(horizontal: 40, vertical: 10),
|
|
child: ElevatedButton(
|
|
onPressed: (() => reset()),
|
|
style: ElevatedButton.styleFrom(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(80.0),
|
|
),
|
|
padding: const EdgeInsets.all(0),
|
|
),
|
|
child: Container(
|
|
alignment: Alignment.center,
|
|
height: 50.0,
|
|
width: size.width * 0.5,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(80.0),
|
|
gradient: const LinearGradient(colors: [
|
|
Color.fromARGB(255, 255, 136, 34),
|
|
Color.fromARGB(255, 255, 177, 41),
|
|
]),
|
|
),
|
|
padding: const EdgeInsets.all(0),
|
|
child: const Text(
|
|
"Send",
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(fontWeight: FontWeight.bold),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|