From eae6cda1500a93069d641a66f82a5ac29c2f87a7 Mon Sep 17 00:00:00 2001 From: Jacques Doeleman Date: Fri, 30 Sep 2022 09:19:15 +0200 Subject: [PATCH] Added docs to exported abstract classes --- lib/src/widgets/input/abstractions.dart | 34 +++++++++++++++++-- .../input/input_types/input_types.dart | 1 - 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/lib/src/widgets/input/abstractions.dart b/lib/src/widgets/input/abstractions.dart index 7cbf871..097b229 100644 --- a/lib/src/widgets/input/abstractions.dart +++ b/lib/src/widgets/input/abstractions.dart @@ -5,9 +5,11 @@ import '/src/utils/formstate.dart' as fs; /// Abstract class for the input widgets used in a [FlutterForm]. /// /// The controller [FlutterFormInputController] has to be given to the widget. -/// Whicht controller is used determines how to value will be handled. +/// Which controller is used determines how to value will be handled. /// /// label is a standard parameter to normally sets the label of the input. +/// +/// [registerController] should be called to register the given [controller] to the form page. abstract class FlutterFormInputWidget extends ConsumerWidget { const FlutterFormInputWidget({ Key? key, @@ -16,9 +18,13 @@ abstract class FlutterFormInputWidget extends ConsumerWidget { String? hintText, }) : super(key: key); + /// The [controller] which determines how the value is handled and how the value is shown on the checkpage. final FlutterFormInputController controller; + + /// [label] is a standard parameter to normally sets the label of the input. final Widget? label; + /// [registerController] should be called to register the given [controller] to the form page. registerController(BuildContext context) { FlutterFormInputController? localController = fs.FormState.of(context).formController.getController(controller.id!); @@ -33,7 +39,7 @@ abstract class FlutterFormInputWidget extends ConsumerWidget { /// /// The [id] determines the key in the [Map] returned by the [FlutterForm]. /// -/// [value] is a way to set a initial value. +/// [value] is a way to set a initial value and will be the value when change by the user. /// /// [mandatory] determines if the input is mandatory. /// @@ -49,15 +55,39 @@ abstract class FlutterFormInputWidget extends ConsumerWidget { /// /// [checkPageDescription] is the same as checkPageTitle but for the description. /// If null no description will be shown. +/// +/// [onSaved] goes of when the save function is called for the page if [onValidate] return null. +/// +/// [onValidate] is used to validate the given input by the user. abstract class FlutterFormInputController { + /// The [id] determines the key in the [Map] returned by the [FlutterForm]. String? id; + + /// [value] is a way to set a initial value and will be the value when change by the user. T? value; + + /// [mandatory] determines if the input is mandatory. bool mandatory = false; + + /// [checkPageTitle] is a function where you can transform the value from the input into something representable. + /// This value will be given when defining the check page widgets. + /// If this function is not set, the value will be used as is. + /// Example: + /// ``` dart + /// checkPageTitle: (dynamic amount) { + /// return "$amount persons"; + /// }, + /// ``` String Function(T value)? checkPageTitle; + + /// [checkPageDescription] is the same as checkPageTitle but for the description. + /// If null no description will be shown. String Function(T value)? checkPageDescription; + /// [onSaved] goes of when the save function is called for the page if [onValidate] return null. void onSaved(T value); + /// [onValidate] is used to validate the given input by the user. String? onValidate( T value, String Function(String, {List? params}) translator); } diff --git a/lib/src/widgets/input/input_types/input_types.dart b/lib/src/widgets/input/input_types/input_types.dart index 11bc2a3..8920d92 100644 --- a/lib/src/widgets/input/input_types/input_types.dart +++ b/lib/src/widgets/input/input_types/input_types.dart @@ -1,5 +1,4 @@ export 'input_carousel/input_carousel.dart'; -export 'input_carousel/input_carousel.dart'; export 'input_email.dart'; export 'input_number_picker/input_number_picker.dart'; export 'input_password/input_password.dart';