fix: remove alert dialog from module

This commit is contained in:
Stein Milder 2022-09-26 12:00:03 +02:00
parent 6f7ec0b0e6
commit 08532d368a
3 changed files with 9 additions and 31 deletions

View file

@ -5,8 +5,8 @@ import 'package:flutter_registration/flutter_registration.dart';
class ExampleRegistrationRepository with RegistrationRepository {
@override
Future<void> register(HashMap values) {
Future<bool> register(HashMap values) {
debugPrint('register: $values');
return Future.value(null);
return Future.value(true);
}
}

View file

@ -14,34 +14,12 @@ class RegistrationScreen extends StatelessWidget {
Widget build(BuildContext context) {
var translations = registrationOptions.registrationTranslations;
void showError(String error) => showDialog<String>(
context: context,
builder: (BuildContext context) => AlertDialog(
content: Text(error),
actions: <Widget>[
TextButton(
onPressed: () => Navigator.pop(
context,
translations.closeBtn,
),
child: Text(
translations.closeBtn,
),
),
],
),
);
void register(values) => registrationOptions.registrationRepository
.register(values)
.then(
(_) => registrationOptions.afterRegistration(),
)
.catchError(
(error) {
showError(
error.toString(),
);
void register(values) =>
registrationOptions.registrationRepository.register(values).then(
(response) {
if (response) {
registrationOptions.afterRegistration();
}
},
);

View file

@ -1,5 +1,5 @@
import 'dart:collection';
mixin RegistrationRepository {
Future<void> register(HashMap values);
Future<bool> register(HashMap values);
}