2022-09-29 17:22:26 +02:00
|
|
|
// ignore_for_file: avoid_print
|
|
|
|
|
2022-09-20 16:32:46 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2022-09-27 16:38:12 +02:00
|
|
|
import 'package:flutter_login/flutter_login.dart';
|
2022-09-20 16:32:46 +02:00
|
|
|
|
2022-09-29 17:22:26 +02:00
|
|
|
final loginOptions = LoginOptions(
|
|
|
|
decoration: const InputDecoration(
|
|
|
|
border: OutlineInputBorder(),
|
|
|
|
),
|
|
|
|
emailInputPrefix: const Icon(Icons.email),
|
|
|
|
passwordInputPrefix: const Icon(Icons.password),
|
|
|
|
title: const Text('Login'),
|
|
|
|
image: const FlutterLogo(),
|
|
|
|
requestForgotPasswordButtonBuilder: (context, onPressed, isDisabled) {
|
|
|
|
return Opacity(
|
|
|
|
opacity: isDisabled ? 0.5 : 1.0,
|
|
|
|
child: ElevatedButton(
|
|
|
|
onPressed: onPressed,
|
|
|
|
child: const Text('Send request'),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
2022-09-20 16:32:46 +02:00
|
|
|
void main() {
|
2022-09-27 16:38:12 +02:00
|
|
|
runApp(const LoginExample());
|
2022-09-20 16:32:46 +02:00
|
|
|
}
|
|
|
|
|
2022-09-27 16:38:12 +02:00
|
|
|
class LoginExample extends StatelessWidget {
|
|
|
|
const LoginExample({super.key});
|
2022-09-20 16:32:46 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-09-27 16:38:12 +02:00
|
|
|
return MaterialApp(
|
|
|
|
theme: ThemeData.dark(),
|
2022-09-29 17:22:26 +02:00
|
|
|
home: LoginScreen(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class LoginScreen extends StatelessWidget {
|
|
|
|
const LoginScreen({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
body: EmailPasswordLoginForm(
|
|
|
|
options: loginOptions,
|
|
|
|
onLogin: (email, password) => print('$email:$password'),
|
|
|
|
onRegister: (email, password) => print('Register!'),
|
|
|
|
onForgotPassword: (email) {
|
|
|
|
Navigator.of(context).push(
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) {
|
|
|
|
return const ForgotPasswordScreen();
|
|
|
|
},
|
2022-09-27 16:38:12 +02:00
|
|
|
),
|
2022-09-29 17:22:26 +02:00
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ForgotPasswordScreen extends StatelessWidget {
|
|
|
|
const ForgotPasswordScreen({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(),
|
|
|
|
body: ForgotPasswordForm(
|
|
|
|
options: loginOptions,
|
|
|
|
title: Text('Forgot password'),
|
|
|
|
description: Text('Hello world'),
|
|
|
|
onRequestForgotPassword: (email) {
|
|
|
|
print('Forgot password email sent to $email');
|
|
|
|
},
|
2022-09-27 16:38:12 +02:00
|
|
|
),
|
|
|
|
);
|
2022-09-20 16:32:46 +02:00
|
|
|
}
|
|
|
|
}
|