Options constructor
Options({
- String placeholder = '_',
- Marker? optionalmarker,
- Marker? quantifiermarker,
- Marker? groupmarker,
- Marker? alternatormarker,
- String? escapeChar,
- String? mask,
- String? regex,
- void oncleared()?,
- void oncomplete()?,
- void onincomplete()?,
- int? repeat,
- bool greedy = false,
- bool autoUnmask = false,
- bool removeMaskOnSubmit = false,
- bool clearMaskOnLostFocus = true,
- bool insertMode = true,
- bool? clearIncomplete,
- String? alias,
- void onKeyDown(
- KeyboardEvent event,
- String buffer,
- int caretPos,
- dynamic opts,
- String onBeforeMask(
- String initialValue,
- dynamic opts
- String onBeforePaste(
- String initialValue,
- dynamic opts
- dynamic onBeforeWrite(
- KeyboardEvent event,
- String buffer,
- int caretPos,
- dynamic opts,
- String onUnMask()?,
- bool showMaskOnFocus = true,
- bool showMaskOnHover = false,
- void onKeyValidation(
- int key,
- dynamic result
- bool rightAlign = false,
- bool undoOnEscape = true,
- String? radixPoint,
- String? groupSeparator,
- bool? keepStatic,
- bool positionCaretOnTab = true,
- bool tabThrough = false,
- Definitions? definitions,
- bool? isComplete(
- String buffer,
- dynamic opts
- dynamic postValidation()?,
- dynamic preValidation(),
- String? staticDefinitionSymbol,
- bool nullable = true,
- bool noValuePatching = false,
- String positionCaretOnClick = 'lvp',
- dynamic casing,
- String inputmode = 'text',
- bool importDataAttributes = true,
- bool shiftPositions = true,
- bool usePrototypeDefinitions = true,
- int validationEventTimeOut = 3000,
- dynamic substitutes,
- String? prefix,
- int? digits,
- String disablePredictiveText = 'rtfm',
- bool numericInput = false,
Implementation
external factory Options({
/// Change the mask placeholder. Default: "_"
///
/// Instead of "_", you can change the unfilled characters mask as you like,
/// simply by adding the placeholder option.
/// For example, placeholder: " " will change the default
/// autofill with empty values
String placeholder = '_',
/// Definition of the symbols used to indicate an optional part in the mask.
///
/// optionalmarker: { start: "[", end: "]" }
Marker? optionalmarker,
/// Definition of the symbols used to indicate a quantifier in the mask.
////
// quantifiermarker: { start: "{", end: "}" }
Marker? quantifiermarker,
/// Definition of the symbols used to indicate a group in the mask.
///
/// groupmarker: { start: "(", end: ")" }
Marker? groupmarker,
/// Definition of the symbols used to indicate an alternator part in the mask.
///
/// alternatormarker: "|"
Marker? alternatormarker,
/// Definition of the symbols used to escape a part in the mask.
///
/// escapeChar: "\\"
///
/// See [escape special mask chars](https://github.com/RobinHerbots/Inputmask#escape-special-mask-chars)
String? escapeChar,
/// The mask to use.
///
/// ex: 9{*}
String? mask,
/// Use a regular expression as a mask
///
/// Inputmask( regex: "[0-9]*" ).mask(selector);
/// When using shorthands be aware that you need to double escape or use String.raw with a string literal.
///
/// Inputmask( regex: "\\d*" ).mask(selector);
/// ~
/// Inputmask{ regex: '\\d*').mask(selector);
String? regex,
/// Execute a function when the mask is cleared.
void Function(Object)? oncleared,
/// Execute a function when the mask is completed
void Function(Object)? oncomplete,
/// Execute a function when the mask is incomplete. Executes on blur.
void Function(Object)? onincomplete,
/// Mask repeat function. Repeat the mask definition x-times.
int? repeat,
/// Default: false Toggle to allocate as much possible or the opposite.
/// Non-greedy repeat function.
/// With the non-greedy option set to false, you can specify * as repeat.
/// This makes an endless repeat.
bool greedy = false,
/// Automatically unmask the value when retrieved.
///
/// When setting this option to true the plugin also expects the initial
/// value from the server to be unmasked.
bool autoUnmask = false,
/// Remove the mask before submitting the form.
bool removeMaskOnSubmit = false,
/// Remove the empty mask on blur or when not empty remove
/// the optional trailing part
bool clearMaskOnLostFocus = true,
/// Toggle to insert or overwrite input.
/// This option can be altered by pressing the Insert key.
bool insertMode = true,
// Clear the incomplete input on blur
bool? clearIncomplete,
/// With an alias, you can define a complex mask definition and call it by
/// using an alias name. So this is mainly to simplify the use of
/// your masks. Some aliases found in the extensions are email, currency,
/// decimal, integer, date, DateTime, dd/mm/yyyy, etc.
///
/// First, you have to create an alias definition. The alias definition
/// can contain options for the mask, custom definitions,
/// the mask to use, etc.
///
/// When you pass in an alias, the alias is first resolved and then the
/// other options are applied. So you can call an alias and pass another
/// mask to be applied over the alias. This also means that you can write
/// aliases that "inherit" from another alias.
String? alias,
/// Callback to implement autocomplete on certain keys for example
void Function(html.KeyboardEvent event, String buffer,
int caretPos, dynamic opts)? onKeyDown,
/// Executes before masking the initial value to allow preprocessing of the initial value.
String Function(String initialValue, dynamic opts)? onBeforeMask,
/// This callback allows for preprocessing the pasted value before actually
/// handling the value for masking. This can be useful for stripping away
/// some characters before processing.
///
/// You can also disable pasting a value by returning false in the
/// onBeforePaste call.
///
/// Default: Calls the onBeforeMask
String Function(String initialValue, dynamic opts)? onBeforePaste,
/// Executes before writing to the masked element
///
/// Use this to do some extra processing of the input.
/// This can be useful when implementing an alias, ex. decimal alias,
/// autofill the digits when leaving the inputfield.
///
/// Function return: command object (see [Define custom definitions](https://github.com/RobinHerbots/Inputmask#define-custom-definitions))
dynamic Function(html.KeyboardEvent event, String buffer,
int caretPos, dynamic opts)? onBeforeWrite,
/// Executes after unmasking to allow post-processing of the unmaskedvalue.
String Function(String maskedValue, String unmaskedValue)? onUnMask,
/// Shows the mask when the input gets focus.
///
/// To make sure no mask is visible on focus also set the showMaskOnHover
/// to false. Otherwise hovering with the mouse will set the mask and
/// will stay on focus.
bool showMaskOnFocus = true,
// Shows the mask when hovering the mouse. (default = true)
bool showMaskOnHover = false,
/// Callback function is executed on every keyvalidation
/// with the key, result as the parameter.
void Function(int key, dynamic result)? onKeyValidation,
/// Align the input to the right
///
/// By setting the rightAlign you can specify to right-align an inputmask.
/// This is only applied in combination op the numericInput option or the dir-attribute. The default is true.
bool rightAlign = false,
// Make escape behave like undo. (ctrl-Z)
// Pressing escape reverts the value to the value before focus.
bool undoOnEscape = true,
/// Define the radixpoint (decimal separator)
String? radixPoint,
// Define the groupseparator
String? groupSeparator,
/// Use in combination with the alternator syntax Try to keep the mask static while typing. Decisions to alter the mask will be postponed if possible.
///
/// typing 1212345123 => should result in +55-12-1234-5123 type extra 4 =>
/// switch to +55-12-12345-1234
///
/// When the option is not set, it will default to false, except for
/// multiple masks it will default to true!
bool? keepStatic,
/// When enabled the caret position is set after the latest
/// valid position on TAB
bool positionCaretOnTab = true,
/// Allows for tabbing through the different parts of the masked field.
bool tabThrough = false,
/// Pass custom definitions directly in the options.
Definitions? definitions,
/// With this call-in (hook) you can override the default implementation of the isComplete function.
// Args => buffer, opts Return => true|false
bool? Function(String buffer, dynamic opts)? isComplete,
/// Hook to postValidate the result from isValid.
/// Usefull for validating the entry as a whole.
/// Return => true|false|command object
dynamic Function(List buffer, int pos, dynamic c, dynamic currentResult,
dynamic opts, dynamic maskset, bool strict,
dynamic fromCheckval)? postValidation,
/// Hook to preValidate the input. Useful for validating
/// regardless of the definition.
/// Return true/false/command object When returning true,
/// the normal validation kicks in, otherwise, it is skipped.
///
/// When returning a command object the actions are executed and further
/// validation is stopped.
/// If you want to continue further validation, you need to add the
/// rewritePosition action.
dynamic Function(String buffer, int pos, String char,
bool isSelection, dynamic opts, dynamic maskset,
int caretPos, bool strict) preValidation,
/// The staticDefinitionSymbol option is used to indicate that the static
/// entries in the mask can match a certain definition.
/// Especially useful with alternators so that the static element in the
/// mask can match another alternation.
///
/// In the example below, we mark the spaces as a possible match for
/// the "i" definition. By doing so the mask can alternate to the second
/// mask even when we typed already "12 3".
String? staticDefinitionSymbol,
/// Return nothing when the user hasn't entered anything.
bool nullable = true,
/// Disable value property patching
bool noValuePatching = false,
/// Positioning of the caret on click.
///
/// Options:
///
/// none
/// lvp (based on the last valid position (default)
/// radixFocus (position caret to radixpoint on initial click)
/// select (select the whole input)
/// ignore (ignore the click and continue the mask)
String positionCaretOnClick = 'lvp',
/// Apply casing at the mask-level.
/// Options: null, "upper", "lower" or "title" or
/// callback args => elem, test, pos, validPositions return charValue
dynamic casing,
/// Default: "text"
/// The inputmode hints at the type of data that might be entered by the
/// user while editing the element or its contents.
///
/// https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode
String inputmode = 'text',
/// Specify to use the data-inputmask attributes or to ignore them.
///
/// If you don't use data attributes you can disable the import by
/// specifying importDataAttributes: false.
bool importDataAttributes = true,
/// Alter the behavior of the char shifting on entry or deletion.
///
/// In some cases shifting the mask entries or deletion should be more restrictive.
/// Ex. date masks. Shifting month to day makes no sense
///
/// true = shift on the "def" match
/// false = shift on the "nativeDef" match
bool shiftPositions = true,
/// Use the default defined definitions from the prototype.
bool usePrototypeDefinitions = true,
/// Time to show html5 validation error on form submit.
int validationEventTimeOut = 3000,
// Define character substitutes.
//
// substitutes: {
// ",": "."
// }
dynamic substitutes,
String? prefix,
int? digits,
String disablePredictiveText = 'rtfm',
/// Numeric input direction. Keeps the caret at the end.
bool numericInput = false
});