mirror of
https://github.com/Iconica-Development/flutter_registration.git
synced 2025-05-19 05: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
|
# 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
|
# 1.0.0
|
||||||
|
|
||||||
|
|
|
@ -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,
|
||||||
),
|
),
|
||||||
|
|
|
@ -20,7 +20,7 @@ class RegistrationOptions {
|
||||||
|
|
||||||
final RegistrationTranslations registrationTranslations;
|
final RegistrationTranslations registrationTranslations;
|
||||||
final List<AuthStep> registrationSteps;
|
final List<AuthStep> registrationSteps;
|
||||||
final bool? 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;
|
||||||
|
|
|
@ -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,14 +27,12 @@ class RegistrationScreen extends StatelessWidget {
|
||||||
if (registered == null) {
|
if (registered == null) {
|
||||||
registrationOptions.afterRegistration();
|
registrationOptions.afterRegistration();
|
||||||
} else {
|
} else {
|
||||||
var returnToFirstPage = registrationOptions.onError?.call(registered);
|
var pageToReturn = registrationOptions.onError?.call(registered);
|
||||||
|
|
||||||
if (returnToFirstPage ?? true) {
|
onError(pageToReturn);
|
||||||
onError();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
onError();
|
onError(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue