diff --git a/CHANGELOG.md b/CHANGELOG.md index 292ec27..901e8ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ SPDX-FileCopyrightText: 2022 Iconica SPDX-License-Identifier: GPL-3.0-or-later --> +# 1.2.0 + +- feat: Added the ability to have an async register function so you can call it asynchronous. + # 1.1.0 - feat: Added the ability to go to specific page on error diff --git a/lib/src/auth_screen.dart b/lib/src/auth_screen.dart index 984e558..d007268 100644 --- a/lib/src/auth_screen.dart +++ b/lib/src/auth_screen.dart @@ -2,6 +2,7 @@ // // SPDX-License-Identifier: BSD-3-Clause +import 'dart:async'; import 'dart:collection'; import 'package:flutter/material.dart'; import 'package:flutter_registration/flutter_registration.dart'; @@ -22,7 +23,7 @@ class AuthScreen extends StatefulWidget { }) : assert(steps.length > 0, 'At least one step is required'); final String title; - final Function({ + final Future Function({ required HashMap values, required void Function(int? pageToReturn) onError, }) onFinish; @@ -32,7 +33,7 @@ class AuthScreen extends StatefulWidget { final String previousBtnTitle; final AppBar? customAppBar; final Color? customBackgroundColor; - final Widget Function(VoidCallback, String)? nextButtonBuilder; + final Widget Function(Future Function(), String)? nextButtonBuilder; final Widget Function(VoidCallback, String)? previousButtonBuilder; @override @@ -58,7 +59,7 @@ class _AuthScreenState extends State { ); } - void onNext(AuthStep step) { + Future onNext(AuthStep step) async { if (!_formKey.currentState!.validate()) { return; } @@ -77,7 +78,7 @@ class _AuthScreenState extends State { } } - widget.onFinish( + await widget.onFinish( values: values, onError: (int? pageToReturn) => _pageController.animateToPage( pageToReturn ?? 0, @@ -169,14 +170,16 @@ class _AuthScreenState extends State { ), ), widget.nextButtonBuilder?.call( - () => onNext(step), + () async { + await onNext(step); + }, widget.steps.last == step ? widget.submitBtnTitle : widget.nextBtnTitle, ) ?? ElevatedButton( - onPressed: () { - onNext(step); + onPressed: () async { + await onNext(step); }, child: Row( children: [ diff --git a/lib/src/config/registration_options.dart b/lib/src/config/registration_options.dart index a1862c5..8ed741b 100644 --- a/lib/src/config/registration_options.dart +++ b/lib/src/config/registration_options.dart @@ -2,6 +2,8 @@ // // SPDX-License-Identifier: BSD-3-Clause +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:flutter_registration/flutter_registration.dart'; @@ -24,7 +26,7 @@ class RegistrationOptions { final VoidCallback afterRegistration; final RegistrationRepository registrationRepository; final AppBar Function(String title)? customAppbarBuilder; - final Widget Function(VoidCallback onPressed, String label)? + final Widget Function(Future Function() onPressed, String label)? nextButtonBuilder; final Widget Function(VoidCallback onPressed, String label)? previousButtonBuilder; diff --git a/pubspec.yaml b/pubspec.yaml index 03f5923..d318f16 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ name: flutter_registration description: A Flutter Registration package -version: 1.1.0 +version: 1.2.0 repository: https://github.com/Iconica-Development/flutter_registration environment: