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 ## 5.1.3
* Added title spacer * Added title spacer

View file

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

View file

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

View file

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