ZdsInputDialog class
A dialog with a textfield and built-in validation.
This dialog can be used to retrieve 1 String value through a Future. Validation is built-in, so the Future will only return a valid value.
final filterName = await showDialog<String?>(
context: context,
builder: (context) => ZdsInputDialog(
title: 'Save Filter',
hint: 'Enter filter name',
primaryAction: 'Save',
secondaryAction: 'Cancel',
onValidate: (value) async {
if (value.isEmpty) {
return 'This field is mandatory';
} else if (state.filters.contains(value) {
return 'This filter already exists';
} else {
return null;
}
},
),
);
See also:
- ZdsModal, to create a general purpose dialog.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- ZdsInputDialog
- Available Extensions
Constructors
-
ZdsInputDialog({required String primaryAction, Key? key, String? title, String? labelText, String? hint, String? initialText, String? secondaryAction, TextInputAction inputAction = TextInputAction.done, bool autoFocus = true, List<
TextInputFormatter> ? inputFormatters, Future<String?> onValidate(String text)?, int? characterCount}) -
A dialog used to retrieve 1 String value with built-in validation.
const
Properties
- autoFocus → bool
-
Whether to autofocus on this dialog.
final
- characterCount → int?
-
How many characters can be input in the textField.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hint → String?
-
The hint of the textField.
final
- initialText → String?
-
Optional initial text that will pre-populate the textField.
final
- inputAction → TextInputAction
-
The TextInputAction that will be shown in the keyboard when the user types on the textField.
final
-
inputFormatters
→ List<
TextInputFormatter> ? -
An optional input formatter to provide validation as the user types.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- labelText → String?
-
The label of the textField. Recommended to use title instead.
final
-
onValidate
→ (Future<
String?> Function(String text)?) -
The function to be called when the user taps on the primaryAction button to return the value.
final
- primaryAction → String
-
The text for primary action of this dialog, which will validate the input and then close the dialog and return
the Future with the value.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- secondaryAction → String?
-
The text for the button that will close this dialog and cancel any value retrieval.
final
- title → String?
-
The title of this dialog, shown at the top.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → ZdsInputDialogState -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of
DiagnosticsNode
objects describing this node's children.inherited -
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited