mirror of
https://github.com/Iconica-Development/flutter_registration.git
synced 2025-05-18 21:23:43 +02:00
Merge pull request #10 from Iconica-Development/feature/return_page_on_error
Feature/return page on error
This commit is contained in:
commit
e2b73bdb7b
5 changed files with 13 additions and 9 deletions
|
@ -3,6 +3,9 @@ SPDX-FileCopyrightText: 2022 Iconica
|
|||
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
-->
|
||||
# 1.1.0
|
||||
|
||||
- feat: Added the ability to go to specific page on error
|
||||
|
||||
# 1.0.0
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ class AuthScreen extends StatefulWidget {
|
|||
final String title;
|
||||
final Function({
|
||||
required HashMap<String, String> values,
|
||||
required VoidCallback onError,
|
||||
required void Function(int? pageToReturn) onError,
|
||||
}) onFinish;
|
||||
final List<AuthStep> steps;
|
||||
final String submitBtnTitle;
|
||||
|
@ -79,8 +79,8 @@ class _AuthScreenState extends State<AuthScreen> {
|
|||
|
||||
widget.onFinish(
|
||||
values: values,
|
||||
onError: () => _pageController.animateToPage(
|
||||
0,
|
||||
onError: (int? pageToReturn) => _pageController.animateToPage(
|
||||
pageToReturn ?? 0,
|
||||
duration: _animationDuration,
|
||||
curve: _animationCurve,
|
||||
),
|
||||
|
|
|
@ -20,7 +20,7 @@ class RegistrationOptions {
|
|||
|
||||
final RegistrationTranslations registrationTranslations;
|
||||
final List<AuthStep> registrationSteps;
|
||||
final void Function(String error)? onError;
|
||||
final int? Function(String error)? onError;
|
||||
final VoidCallback afterRegistration;
|
||||
final RegistrationRepository registrationRepository;
|
||||
final AppBar Function(String title)? customAppbarBuilder;
|
||||
|
|
|
@ -18,7 +18,7 @@ class RegistrationScreen extends StatelessWidget {
|
|||
|
||||
Future<void> register({
|
||||
required HashMap<String, String> values,
|
||||
required VoidCallback onError,
|
||||
required void Function(int? pageToReturn) onError,
|
||||
}) async {
|
||||
try {
|
||||
var registered =
|
||||
|
@ -27,11 +27,12 @@ class RegistrationScreen extends StatelessWidget {
|
|||
if (registered == null) {
|
||||
registrationOptions.afterRegistration();
|
||||
} else {
|
||||
registrationOptions.onError?.call(registered);
|
||||
onError();
|
||||
var pageToReturn = registrationOptions.onError?.call(registered);
|
||||
|
||||
onError(pageToReturn);
|
||||
}
|
||||
} catch (e) {
|
||||
onError();
|
||||
onError(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
name: flutter_registration
|
||||
description: A Flutter Registration package
|
||||
version: 1.0.0
|
||||
version: 1.1.0
|
||||
repository: https://github.com/Iconica-Development/flutter_registration
|
||||
|
||||
environment:
|
||||
|
|
Loading…
Reference in a new issue