mirror of
https://github.com/Iconica-Development/flutter_registration.git
synced 2025-05-18 21:23:43 +02:00
Merge pull request #11 from Iconica-Development/feature/async_on_next
Feature/async on next
This commit is contained in:
commit
5bc388677b
4 changed files with 18 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -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<void> Function({
|
||||
required HashMap<String, String> 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<void> Function(), String)? nextButtonBuilder;
|
||||
final Widget Function(VoidCallback, String)? previousButtonBuilder;
|
||||
|
||||
@override
|
||||
|
@ -58,7 +59,7 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||
);
|
||||
}
|
||||
|
||||
void onNext(AuthStep step) {
|
||||
Future<void> onNext(AuthStep step) async {
|
||||
if (!_formKey.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
|
@ -77,7 +78,7 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||
}
|
||||
}
|
||||
|
||||
widget.onFinish(
|
||||
await widget.onFinish(
|
||||
values: values,
|
||||
onError: (int? pageToReturn) => _pageController.animateToPage(
|
||||
pageToReturn ?? 0,
|
||||
|
@ -169,14 +170,16 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||
),
|
||||
),
|
||||
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: [
|
||||
|
|
|
@ -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<void> Function() onPressed, String label)?
|
||||
nextButtonBuilder;
|
||||
final Widget Function(VoidCallback onPressed, String label)?
|
||||
previousButtonBuilder;
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue