mirror of
https://github.com/Iconica-Development/flutter_registration.git
synced 2025-05-18 21:23:43 +02:00
feat: register function can now return a nullable string
Works like a validator
This commit is contained in:
parent
caf68b6d8f
commit
e715b1192b
4 changed files with 7 additions and 6 deletions
|
@ -9,8 +9,8 @@ import 'package:flutter_registration/flutter_registration.dart';
|
|||
|
||||
class ExampleRegistrationRepository with RegistrationRepository {
|
||||
@override
|
||||
Future<bool> register(HashMap values) {
|
||||
Future<String?> register(HashMap values) {
|
||||
debugPrint('register: $values');
|
||||
return Future.value(true);
|
||||
return Future.value(null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class RegistrationOptions {
|
|||
|
||||
final RegistrationTranslations registrationTranslations;
|
||||
final List<AuthStep> registrationSteps;
|
||||
final VoidCallback? onError;
|
||||
final void Function(String error)? onError;
|
||||
final VoidCallback afterRegistration;
|
||||
final RegistrationRepository registrationRepository;
|
||||
final AppBar Function(String title)? customAppbarBuilder;
|
||||
|
|
|
@ -23,10 +23,11 @@ class RegistrationScreen extends StatelessWidget {
|
|||
try {
|
||||
var registered =
|
||||
await registrationOptions.registrationRepository.register(values);
|
||||
if (registered) {
|
||||
|
||||
if (registered == null) {
|
||||
registrationOptions.afterRegistration();
|
||||
} else {
|
||||
registrationOptions.onError?.call();
|
||||
registrationOptions.onError?.call(registered);
|
||||
onError();
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
|
@ -5,5 +5,5 @@
|
|||
import 'dart:collection';
|
||||
|
||||
mixin RegistrationRepository {
|
||||
Future<bool> register(HashMap values);
|
||||
Future<String?> register(HashMap values);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue