mirror of
https://github.com/Iconica-Development/flutter_registration.git
synced 2025-05-18 21:23:43 +02:00
feat: Now returning page
This commit is contained in:
parent
fffafdffd5
commit
059ba3c754
4 changed files with 9 additions and 11 deletions
|
@ -5,7 +5,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||
-->
|
||||
# 1.1.0
|
||||
|
||||
- feat: Added the ability to not go back to the first page on error
|
||||
- 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 bool? 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,14 +27,12 @@ class RegistrationScreen extends StatelessWidget {
|
|||
if (registered == null) {
|
||||
registrationOptions.afterRegistration();
|
||||
} else {
|
||||
var returnToFirstPage = registrationOptions.onError?.call(registered);
|
||||
var pageToReturn = registrationOptions.onError?.call(registered);
|
||||
|
||||
if (returnToFirstPage ?? true) {
|
||||
onError();
|
||||
}
|
||||
onError(pageToReturn);
|
||||
}
|
||||
} catch (e) {
|
||||
onError();
|
||||
onError(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue