mirror of
https://github.com/Iconica-Development/flutter_form_wizard.git
synced 2025-05-19 10:53:49 +02:00
Merge pull request #43 from Iconica-Development/doc/improve-documentation
doc: create documentation for files
This commit is contained in:
commit
1b9844c5d0
9 changed files with 102 additions and 1 deletions
|
@ -4,20 +4,26 @@
|
||||||
|
|
||||||
import 'package:flutter_form_wizard/flutter_form.dart';
|
import 'package:flutter_form_wizard/flutter_form.dart';
|
||||||
|
|
||||||
|
/// Controller class for managing input controllers in a Flutter form.
|
||||||
class FlutterFormPageController {
|
class FlutterFormPageController {
|
||||||
|
/// List of input controllers.
|
||||||
List<FlutterFormInputController> _controllers = [];
|
List<FlutterFormInputController> _controllers = [];
|
||||||
|
|
||||||
|
/// Registers an input controller.
|
||||||
void register(FlutterFormInputController inputController) {
|
void register(FlutterFormInputController inputController) {
|
||||||
_controllers.add(inputController);
|
_controllers.add(inputController);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Clears all registered input controllers.
|
||||||
void clearControllers() {
|
void clearControllers() {
|
||||||
_controllers = [];
|
_controllers = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Checks if an input controller is registered with a given ID.
|
||||||
bool _isRegisteredById(String id) =>
|
bool _isRegisteredById(String id) =>
|
||||||
_controllers.any((element) => element.id == id);
|
_controllers.any((element) => element.id == id);
|
||||||
|
|
||||||
|
/// Retrieves the input controller associated with the provided ID.
|
||||||
FlutterFormInputController? getController(String key) {
|
FlutterFormInputController? getController(String key) {
|
||||||
if (_isRegisteredById(key)) {
|
if (_isRegisteredById(key)) {
|
||||||
return _controllers.firstWhere((element) => element.id == key);
|
return _controllers.firstWhere((element) => element.id == key);
|
||||||
|
@ -25,6 +31,7 @@ class FlutterFormPageController {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Retrieves all values from registered input controllers.
|
||||||
Map<String, dynamic> getAllValues() {
|
Map<String, dynamic> getAllValues() {
|
||||||
var values = <String, dynamic>{};
|
var values = <String, dynamic>{};
|
||||||
|
|
||||||
|
|
|
@ -5,15 +5,19 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_form_wizard/src/utils/form_page_controller.dart';
|
import 'package:flutter_form_wizard/src/utils/form_page_controller.dart';
|
||||||
|
|
||||||
|
/// Widget for managing form state and providing access to form controller.
|
||||||
class FormState extends InheritedWidget {
|
class FormState extends InheritedWidget {
|
||||||
|
/// Constructor for FormState.
|
||||||
const FormState({
|
const FormState({
|
||||||
required super.child,
|
required super.child,
|
||||||
required this.formController,
|
required this.formController,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// The form controller associated with this FormState.
|
||||||
final FlutterFormPageController formController;
|
final FlutterFormPageController formController;
|
||||||
|
|
||||||
|
/// Retrieves the nearest ancestor FormState from the given context.
|
||||||
static FormState of(BuildContext context) {
|
static FormState of(BuildContext context) {
|
||||||
var result = context.dependOnInheritedWidgetOfExactType<FormState>();
|
var result = context.dependOnInheritedWidgetOfExactType<FormState>();
|
||||||
assert(result != null, 'No FormStat found in context');
|
assert(result != null, 'No FormStat found in context');
|
||||||
|
|
|
@ -13,6 +13,22 @@ import 'package:intl/intl.dart';
|
||||||
///
|
///
|
||||||
/// Standard controller is [FlutterFormInputDateController].
|
/// Standard controller is [FlutterFormInputDateController].
|
||||||
class FlutterFormInputDateTime extends FlutterFormInputWidget<String> {
|
class FlutterFormInputDateTime extends FlutterFormInputWidget<String> {
|
||||||
|
/// Creates a [FlutterFormInputDateTime].
|
||||||
|
///
|
||||||
|
/// The [controller], [inputType], [dateFormat] are required parameters.
|
||||||
|
/// The [label] parameter specifies the label of the input field.
|
||||||
|
/// The [showIcon] parameter determines whether to show an icon
|
||||||
|
/// with the input field.
|
||||||
|
/// The [firstDate] and [lastDate] parameters specify the range
|
||||||
|
/// of selectable dates.
|
||||||
|
/// The [initialDate] parameter specifies the initial date for
|
||||||
|
/// the input field.
|
||||||
|
/// The [initialDateTimeRange] parameter specifies the initial
|
||||||
|
/// date time range for the input field.
|
||||||
|
/// The [icon] parameter specifies the icon to show with the input field.
|
||||||
|
/// The [enabled] parameter specifies whether the input field is enabled.
|
||||||
|
/// The [onTapEnabled] parameter specifies whether tapping on
|
||||||
|
/// the input field is enabled.
|
||||||
const FlutterFormInputDateTime({
|
const FlutterFormInputDateTime({
|
||||||
required super.controller,
|
required super.controller,
|
||||||
required this.inputType,
|
required this.inputType,
|
||||||
|
@ -70,6 +86,12 @@ class FlutterFormInputDateTime extends FlutterFormInputWidget<String> {
|
||||||
/// Mainly used by [FlutterFormInputDateTime].
|
/// Mainly used by [FlutterFormInputDateTime].
|
||||||
class FlutterFormInputDateTimeController
|
class FlutterFormInputDateTimeController
|
||||||
implements FlutterFormInputController<String> {
|
implements FlutterFormInputController<String> {
|
||||||
|
/// Creates a [FlutterFormInputDateTimeController].
|
||||||
|
///
|
||||||
|
/// The [id], [dateTimeType], and [dateFormat] are required parameters.
|
||||||
|
/// The [mandatory] parameter specifies whether the input is mandatory.
|
||||||
|
/// The [value], [initialDate], [initialDateTimeRange], [checkPageTitle],
|
||||||
|
/// [checkPageDescription], and [onChanged] parameters are optional.
|
||||||
FlutterFormInputDateTimeController({
|
FlutterFormInputDateTimeController({
|
||||||
required this.id,
|
required this.id,
|
||||||
required this.dateTimeType,
|
required this.dateTimeType,
|
||||||
|
|
|
@ -10,6 +10,10 @@ import 'package:flutter_input_library/flutter_input_library.dart' as input;
|
||||||
///
|
///
|
||||||
/// Standard controller is [FlutterFormInputEmailController].
|
/// Standard controller is [FlutterFormInputEmailController].
|
||||||
class FlutterFormInputEmail extends FlutterFormInputWidget<String> {
|
class FlutterFormInputEmail extends FlutterFormInputWidget<String> {
|
||||||
|
/// Creates a [FlutterFormInputEmail].
|
||||||
|
///
|
||||||
|
/// The [controller] parameter is required.
|
||||||
|
/// The [key], [focusNode], [label], and [enabled] parameters are optional.
|
||||||
const FlutterFormInputEmail({
|
const FlutterFormInputEmail({
|
||||||
required super.controller,
|
required super.controller,
|
||||||
super.key,
|
super.key,
|
||||||
|
@ -49,6 +53,12 @@ class FlutterFormInputEmail extends FlutterFormInputWidget<String> {
|
||||||
/// Mainly used by [FlutterFormInputEmail].
|
/// Mainly used by [FlutterFormInputEmail].
|
||||||
class FlutterFormInputEmailController
|
class FlutterFormInputEmailController
|
||||||
implements FlutterFormInputController<String> {
|
implements FlutterFormInputController<String> {
|
||||||
|
/// Creates a [FlutterFormInputEmailController].
|
||||||
|
///
|
||||||
|
/// The [id] parameter specifies the unique identifier for the controller.
|
||||||
|
/// The [mandatory] parameter specifies whether the input is mandatory.
|
||||||
|
/// The [value], [checkPageTitle], [checkPageDescription], [onChanged],
|
||||||
|
/// and [onSubmit] parameters are optional.
|
||||||
FlutterFormInputEmailController({
|
FlutterFormInputEmailController({
|
||||||
required this.id,
|
required this.id,
|
||||||
this.mandatory = true,
|
this.mandatory = true,
|
||||||
|
|
|
@ -41,8 +41,18 @@ class FlutterFormInputNumberPicker extends FlutterFormInputWidget<int> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Controller for numbers used by a [FlutterFormInputWidget] used in a
|
||||||
|
/// [FlutterForm].
|
||||||
|
///
|
||||||
|
/// Mainly used by [FlutterFormInputNumberPicker].
|
||||||
class FlutterFormInputNumberPickerController
|
class FlutterFormInputNumberPickerController
|
||||||
implements FlutterFormInputController<int> {
|
implements FlutterFormInputController<int> {
|
||||||
|
/// Creates a [FlutterFormInputNumberPickerController].
|
||||||
|
///
|
||||||
|
/// The [id] parameter specifies the unique identifier for the controller.
|
||||||
|
/// The [mandatory] parameter specifies whether the input is mandatory.
|
||||||
|
/// The [value], [checkPageTitle], [checkPageDescription],
|
||||||
|
/// and [onChanged] parameters are optional.
|
||||||
FlutterFormInputNumberPickerController({
|
FlutterFormInputNumberPickerController({
|
||||||
required this.id,
|
required this.id,
|
||||||
this.mandatory = true,
|
this.mandatory = true,
|
||||||
|
|
|
@ -48,6 +48,12 @@ class FlutterFormInputPassword extends FlutterFormInputWidget<String> {
|
||||||
/// Mainly used by [FlutterFormInputPassword].
|
/// Mainly used by [FlutterFormInputPassword].
|
||||||
class FlutterFormInputPasswordController
|
class FlutterFormInputPasswordController
|
||||||
implements FlutterFormInputController<String> {
|
implements FlutterFormInputController<String> {
|
||||||
|
/// Creates a [FlutterFormInputPasswordController].
|
||||||
|
///
|
||||||
|
/// The [id] parameter specifies the unique identifier for the controller.
|
||||||
|
/// The [mandatory] parameter specifies whether the input is mandatory.
|
||||||
|
/// The [value], [checkPageTitle], [checkPageDescription], [onChanged],
|
||||||
|
/// and [onSubmit] parameters are optional.
|
||||||
FlutterFormInputPasswordController({
|
FlutterFormInputPasswordController({
|
||||||
required this.id,
|
required this.id,
|
||||||
this.mandatory = true,
|
this.mandatory = true,
|
||||||
|
@ -95,7 +101,7 @@ class FlutterFormInputPasswordController
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value.length < 6) {
|
if (value.length < 6) {
|
||||||
return translator('Field should be atleast 6 characters long');
|
return translator('Field should be at least 6 characters long');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,12 @@ import 'package:flutter_input_library/flutter_input_library.dart' as input;
|
||||||
///
|
///
|
||||||
/// Standard controller is [FlutterFormInputPlainTextController].
|
/// Standard controller is [FlutterFormInputPlainTextController].
|
||||||
class FlutterFormInputPlainText extends FlutterFormInputWidget<String> {
|
class FlutterFormInputPlainText extends FlutterFormInputWidget<String> {
|
||||||
|
/// Creates a [FlutterFormInputPlainText].
|
||||||
|
///
|
||||||
|
/// The [controller] parameter is required.
|
||||||
|
/// The [key], [focusNode], [label], [decoration], [textAlignVertical],
|
||||||
|
/// [expands], [maxLines], [scrollPadding], [maxLength], [keyboardType],
|
||||||
|
/// [enabled], [style], and [textCapitalization] parameters are optional.
|
||||||
const FlutterFormInputPlainText({
|
const FlutterFormInputPlainText({
|
||||||
required super.controller,
|
required super.controller,
|
||||||
super.key,
|
super.key,
|
||||||
|
@ -92,13 +98,25 @@ class FlutterFormInputMultiLine extends StatelessWidget {
|
||||||
this.textCapitalization = TextCapitalization.sentences,
|
this.textCapitalization = TextCapitalization.sentences,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// The controller for the multi-line input.
|
||||||
final FlutterFormInputController<String> controller;
|
final FlutterFormInputController<String> controller;
|
||||||
|
|
||||||
|
/// The optional label widget for the input.
|
||||||
final Widget? label;
|
final Widget? label;
|
||||||
|
|
||||||
|
/// The optional focus node for the input.
|
||||||
final FocusNode? focusNode;
|
final FocusNode? focusNode;
|
||||||
|
|
||||||
|
/// The optional hint text displayed inside the input field.
|
||||||
final String? hint;
|
final String? hint;
|
||||||
|
|
||||||
|
/// The optional maximum number of characters allowed in the input field.
|
||||||
final int? maxCharacters;
|
final int? maxCharacters;
|
||||||
|
|
||||||
|
/// A flag indicating whether the input field is enabled.
|
||||||
final bool enabled;
|
final bool enabled;
|
||||||
|
|
||||||
|
/// The capitalization behavior for the input field.
|
||||||
final TextCapitalization textCapitalization;
|
final TextCapitalization textCapitalization;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -126,6 +144,12 @@ class FlutterFormInputMultiLine extends StatelessWidget {
|
||||||
/// Mainly used by [FlutterFormInputPlainText].
|
/// Mainly used by [FlutterFormInputPlainText].
|
||||||
class FlutterFormInputPlainTextController
|
class FlutterFormInputPlainTextController
|
||||||
implements FlutterFormInputController<String> {
|
implements FlutterFormInputController<String> {
|
||||||
|
/// Creates a [FlutterFormInputPlainTextController].
|
||||||
|
///
|
||||||
|
/// The [id] parameter specifies the unique identifier for the controller.
|
||||||
|
/// The [mandatory] parameter specifies whether the input is mandatory.
|
||||||
|
/// The [value], [checkPageTitle], [checkPageDescription], [onChanged],
|
||||||
|
/// and [onSubmit] parameters are optional.
|
||||||
FlutterFormInputPlainTextController({
|
FlutterFormInputPlainTextController({
|
||||||
required this.id,
|
required this.id,
|
||||||
this.mandatory = false,
|
this.mandatory = false,
|
||||||
|
|
|
@ -11,6 +11,12 @@ import 'package:flutter_input_library/flutter_input_library.dart' as input;
|
||||||
///
|
///
|
||||||
/// Standard controller is [FlutterFormInputSliderController].
|
/// Standard controller is [FlutterFormInputSliderController].
|
||||||
class FlutterFormInputSlider extends FlutterFormInputWidget<double> {
|
class FlutterFormInputSlider extends FlutterFormInputWidget<double> {
|
||||||
|
/// Creates a [FlutterFormInputPassword].
|
||||||
|
///
|
||||||
|
/// The [controller] parameter is required.
|
||||||
|
/// The [focusNode] parameter specifies the focus node of the input field.
|
||||||
|
/// The [label] parameter specifies the label of the input field.
|
||||||
|
/// The [enabled] parameter specifies whether the input field is enabled.
|
||||||
const FlutterFormInputSlider({
|
const FlutterFormInputSlider({
|
||||||
required super.controller,
|
required super.controller,
|
||||||
super.key,
|
super.key,
|
||||||
|
@ -43,6 +49,12 @@ class FlutterFormInputSlider extends FlutterFormInputWidget<double> {
|
||||||
/// Mainly used by [FlutterFormInputSlider].
|
/// Mainly used by [FlutterFormInputSlider].
|
||||||
class FlutterFormInputSliderController
|
class FlutterFormInputSliderController
|
||||||
implements FlutterFormInputController<double> {
|
implements FlutterFormInputController<double> {
|
||||||
|
/// Creates a [FlutterFormInputPasswordController].
|
||||||
|
///
|
||||||
|
/// The [id] parameter specifies the unique identifier for the controller.
|
||||||
|
/// The [mandatory] parameter specifies whether the input is mandatory.
|
||||||
|
/// The [value], [checkPageTitle], [checkPageDescription], [onChanged],
|
||||||
|
/// and [onSubmit] parameters are optional.
|
||||||
FlutterFormInputSliderController({
|
FlutterFormInputSliderController({
|
||||||
required this.id,
|
required this.id,
|
||||||
this.mandatory = true,
|
this.mandatory = true,
|
||||||
|
|
|
@ -42,6 +42,12 @@ class FlutterFormInputSwitch extends FlutterFormInputWidget<bool> {
|
||||||
/// Mainly used by [FlutterFormInputSwitch].
|
/// Mainly used by [FlutterFormInputSwitch].
|
||||||
class FlutterFormInputSwitchController
|
class FlutterFormInputSwitchController
|
||||||
implements FlutterFormInputController<bool> {
|
implements FlutterFormInputController<bool> {
|
||||||
|
/// Creates a [FlutterFormInputSwitchController].
|
||||||
|
///
|
||||||
|
/// The [id] parameter specifies the unique identifier for the controller.
|
||||||
|
/// The [mandatory] parameter specifies whether the input is mandatory.
|
||||||
|
/// The [value], [checkPageTitle], [checkPageDescription],
|
||||||
|
/// and [onChanged] parameters are optional.
|
||||||
FlutterFormInputSwitchController({
|
FlutterFormInputSwitchController({
|
||||||
required this.id,
|
required this.id,
|
||||||
this.mandatory = true,
|
this.mandatory = true,
|
||||||
|
|
Loading…
Reference in a new issue