2022-11-01 09:19:20 +01:00
|
|
|
// SPDX-FileCopyrightText: 2022 Iconica
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
|
2024-02-05 13:00:21 +01:00
|
|
|
import 'package:flutter/gestures.dart';
|
2022-09-20 15:51:22 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_registration/flutter_registration.dart';
|
|
|
|
import 'example_registration_repository.dart';
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
runApp(
|
2024-02-05 13:00:21 +01:00
|
|
|
MaterialApp(
|
|
|
|
theme: ThemeData(
|
|
|
|
inputDecorationTheme: const InputDecorationTheme(
|
|
|
|
errorStyle: TextStyle(color: Colors.red),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
home: const FlutterRegistrationDemo(),
|
2022-09-20 15:51:22 +02:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-02-05 13:00:21 +01:00
|
|
|
class FlutterRegistrationDemo extends StatefulWidget {
|
2022-09-20 15:51:22 +02:00
|
|
|
const FlutterRegistrationDemo({Key? key}) : super(key: key);
|
|
|
|
|
2024-02-05 13:00:21 +01:00
|
|
|
@override
|
|
|
|
State<FlutterRegistrationDemo> createState() =>
|
|
|
|
_FlutterRegistrationDemoState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _FlutterRegistrationDemoState extends State<FlutterRegistrationDemo> {
|
|
|
|
late List<AuthStep> steps;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
steps = RegistrationOptions.getDefaultSteps();
|
|
|
|
|
|
|
|
steps[1].fields.add(
|
|
|
|
AuthBoolField(
|
|
|
|
name: 'termsConditions',
|
|
|
|
widgetType: BoolWidgetType.checkbox,
|
|
|
|
validators: [
|
|
|
|
(value) {
|
|
|
|
if (value == null || !value) {
|
|
|
|
return 'Required';
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
],
|
|
|
|
rightWidget: Text.rich(
|
|
|
|
TextSpan(
|
|
|
|
text: 'I agree with the ',
|
|
|
|
children: <TextSpan>[
|
|
|
|
TextSpan(
|
|
|
|
text: 'terms & conditions',
|
|
|
|
style: const TextStyle(
|
|
|
|
decoration: TextDecoration.underline,
|
|
|
|
),
|
|
|
|
recognizer: TapGestureRecognizer()
|
|
|
|
..onTap = () {
|
|
|
|
debugPrint('Open terms and conditions');
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-09-20 15:51:22 +02:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return RegistrationScreen(
|
2022-09-26 10:35:53 +02:00
|
|
|
registrationOptions: RegistrationOptions(
|
2024-02-05 13:00:21 +01:00
|
|
|
previousButtonBuilder: (onPressed, label) => null,
|
2022-09-26 10:35:53 +02:00
|
|
|
registrationRepository: ExampleRegistrationRepository(),
|
2024-02-05 13:00:21 +01:00
|
|
|
registrationSteps: steps,
|
2022-09-26 10:35:53 +02:00
|
|
|
afterRegistration: () {
|
|
|
|
debugPrint('Registered!');
|
|
|
|
},
|
|
|
|
),
|
2022-09-20 15:51:22 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ProtectedScreen extends StatelessWidget {
|
|
|
|
const ProtectedScreen({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return const Scaffold(
|
|
|
|
body: Center(
|
|
|
|
child: Text('FlutterRegistrationDemo'),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|