Merge pull request #27 from Iconica-Development/5.1.4

fix: added context to callbacks
This commit is contained in:
Freek van de Ven 2024-02-15 16:59:33 +01:00 committed by GitHub
commit 3ee3cc9461
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 16 additions and 6 deletions

View file

@ -1,3 +1,7 @@
## 5.1.4
* Added BuildContext to the `onForgotPassword` and `onRegister`.
## 5.1.3
* Added title spacer

View file

@ -58,8 +58,8 @@ class LoginScreen extends StatelessWidget {
body: EmailPasswordLoginForm(
options: loginOptions,
onLogin: (email, password) => print('$email:$password'),
onRegister: (email, password) => print('Register!'),
onForgotPassword: (email) {
onRegister: (email, password, ctx) => print('Register!'),
onForgotPassword: (email, ctx) {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) {

View file

@ -13,8 +13,12 @@ class EmailPasswordLoginForm extends StatefulWidget {
});
final LoginOptions options;
final void Function(String email)? onForgotPassword;
final FutureOr<void> Function(String email, String password)? onRegister;
final void Function(String email, BuildContext ctx)? onForgotPassword;
final FutureOr<void> Function(
String email,
String password,
BuildContext context,
)? onRegister;
final FutureOr<void> Function(String email, String password) onLogin;
@override
@ -181,7 +185,8 @@ class _EmailPasswordLoginFormState extends State<EmailPasswordLoginForm> {
child: options.forgotPasswordButtonBuilder(
context,
() {
widget.onForgotPassword?.call(_currentEmail);
widget.onForgotPassword
?.call(_currentEmail, context);
},
false,
() {},
@ -211,6 +216,7 @@ class _EmailPasswordLoginFormState extends State<EmailPasswordLoginForm> {
widget.onRegister?.call(
_currentEmail,
_currentPassword,
context,
);
},
false,

View file

@ -1,6 +1,6 @@
name: flutter_login
description: Flutter Login Component
version: 5.1.3
version: 5.1.4
environment:
sdk: ">=2.18.1 <3.0.0"