mirror of
https://github.com/Iconica-Development/flutter_registration.git
synced 2025-05-19 05: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
|
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
|
# 1.1.0
|
||||||
|
|
||||||
- feat: Added the ability to go to specific page on error
|
- feat: Added the ability to go to specific page on error
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
import 'dart:async';
|
||||||
import 'dart:collection';
|
import 'dart:collection';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_registration/flutter_registration.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');
|
}) : assert(steps.length > 0, 'At least one step is required');
|
||||||
|
|
||||||
final String title;
|
final String title;
|
||||||
final Function({
|
final Future<void> Function({
|
||||||
required HashMap<String, String> values,
|
required HashMap<String, String> values,
|
||||||
required void Function(int? pageToReturn) onError,
|
required void Function(int? pageToReturn) onError,
|
||||||
}) onFinish;
|
}) onFinish;
|
||||||
|
@ -32,7 +33,7 @@ class AuthScreen extends StatefulWidget {
|
||||||
final String previousBtnTitle;
|
final String previousBtnTitle;
|
||||||
final AppBar? customAppBar;
|
final AppBar? customAppBar;
|
||||||
final Color? customBackgroundColor;
|
final Color? customBackgroundColor;
|
||||||
final Widget Function(VoidCallback, String)? nextButtonBuilder;
|
final Widget Function(Future<void> Function(), String)? nextButtonBuilder;
|
||||||
final Widget Function(VoidCallback, String)? previousButtonBuilder;
|
final Widget Function(VoidCallback, String)? previousButtonBuilder;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -58,7 +59,7 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onNext(AuthStep step) {
|
Future<void> onNext(AuthStep step) async {
|
||||||
if (!_formKey.currentState!.validate()) {
|
if (!_formKey.currentState!.validate()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +78,7 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.onFinish(
|
await widget.onFinish(
|
||||||
values: values,
|
values: values,
|
||||||
onError: (int? pageToReturn) => _pageController.animateToPage(
|
onError: (int? pageToReturn) => _pageController.animateToPage(
|
||||||
pageToReturn ?? 0,
|
pageToReturn ?? 0,
|
||||||
|
@ -169,14 +170,16 @@ class _AuthScreenState extends State<AuthScreen> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
widget.nextButtonBuilder?.call(
|
widget.nextButtonBuilder?.call(
|
||||||
() => onNext(step),
|
() async {
|
||||||
|
await onNext(step);
|
||||||
|
},
|
||||||
widget.steps.last == step
|
widget.steps.last == step
|
||||||
? widget.submitBtnTitle
|
? widget.submitBtnTitle
|
||||||
: widget.nextBtnTitle,
|
: widget.nextBtnTitle,
|
||||||
) ??
|
) ??
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () async {
|
||||||
onNext(step);
|
await onNext(step);
|
||||||
},
|
},
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_registration/flutter_registration.dart';
|
import 'package:flutter_registration/flutter_registration.dart';
|
||||||
|
|
||||||
|
@ -24,7 +26,7 @@ class RegistrationOptions {
|
||||||
final VoidCallback afterRegistration;
|
final VoidCallback afterRegistration;
|
||||||
final RegistrationRepository registrationRepository;
|
final RegistrationRepository registrationRepository;
|
||||||
final AppBar Function(String title)? customAppbarBuilder;
|
final AppBar Function(String title)? customAppbarBuilder;
|
||||||
final Widget Function(VoidCallback onPressed, String label)?
|
final Widget Function(Future<void> Function() onPressed, String label)?
|
||||||
nextButtonBuilder;
|
nextButtonBuilder;
|
||||||
final Widget Function(VoidCallback onPressed, String label)?
|
final Widget Function(VoidCallback onPressed, String label)?
|
||||||
previousButtonBuilder;
|
previousButtonBuilder;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
name: flutter_registration
|
name: flutter_registration
|
||||||
description: A Flutter Registration package
|
description: A Flutter Registration package
|
||||||
version: 1.1.0
|
version: 1.2.0
|
||||||
repository: https://github.com/Iconica-Development/flutter_registration
|
repository: https://github.com/Iconica-Development/flutter_registration
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
|
Loading…
Reference in a new issue