Merge pull request #10 from Iconica-Development/feature/return_page_on_error

Feature/return page on error
This commit is contained in:
Gorter-dev 2023-10-03 14:40:06 +02:00 committed by GitHub
commit e2b73bdb7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 9 deletions

View file

@ -3,6 +3,9 @@ SPDX-FileCopyrightText: 2022 Iconica
SPDX-License-Identifier: GPL-3.0-or-later 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 # 1.0.0

View file

@ -24,7 +24,7 @@ class AuthScreen extends StatefulWidget {
final String title; final String title;
final Function({ final Function({
required HashMap<String, String> values, required HashMap<String, String> values,
required VoidCallback onError, required void Function(int? pageToReturn) onError,
}) onFinish; }) onFinish;
final List<AuthStep> steps; final List<AuthStep> steps;
final String submitBtnTitle; final String submitBtnTitle;
@ -79,8 +79,8 @@ class _AuthScreenState extends State<AuthScreen> {
widget.onFinish( widget.onFinish(
values: values, values: values,
onError: () => _pageController.animateToPage( onError: (int? pageToReturn) => _pageController.animateToPage(
0, pageToReturn ?? 0,
duration: _animationDuration, duration: _animationDuration,
curve: _animationCurve, curve: _animationCurve,
), ),

View file

@ -20,7 +20,7 @@ class RegistrationOptions {
final RegistrationTranslations registrationTranslations; final RegistrationTranslations registrationTranslations;
final List<AuthStep> registrationSteps; final List<AuthStep> registrationSteps;
final void Function(String error)? onError; final int? Function(String error)? onError;
final VoidCallback afterRegistration; final VoidCallback afterRegistration;
final RegistrationRepository registrationRepository; final RegistrationRepository registrationRepository;
final AppBar Function(String title)? customAppbarBuilder; final AppBar Function(String title)? customAppbarBuilder;

View file

@ -18,7 +18,7 @@ class RegistrationScreen extends StatelessWidget {
Future<void> register({ Future<void> register({
required HashMap<String, String> values, required HashMap<String, String> values,
required VoidCallback onError, required void Function(int? pageToReturn) onError,
}) async { }) async {
try { try {
var registered = var registered =
@ -27,11 +27,12 @@ class RegistrationScreen extends StatelessWidget {
if (registered == null) { if (registered == null) {
registrationOptions.afterRegistration(); registrationOptions.afterRegistration();
} else { } else {
registrationOptions.onError?.call(registered); var pageToReturn = registrationOptions.onError?.call(registered);
onError();
onError(pageToReturn);
} }
} catch (e) { } catch (e) {
onError(); onError(0);
} }
} }

View file

@ -4,7 +4,7 @@
name: flutter_registration name: flutter_registration
description: A Flutter Registration package description: A Flutter Registration package
version: 1.0.0 version: 1.1.0
repository: https://github.com/Iconica-Development/flutter_registration repository: https://github.com/Iconica-Development/flutter_registration
environment: environment: