FormattedInput constructor

const FormattedInput({
  1. Key? key,
  2. FormattedValue? initialValue,
  3. ValueChanged<FormattedValue>? onChanged,
  4. TextStyle? style,
  5. Widget? leading,
  6. Widget? trailing,
  7. bool enabled = true,
  8. FormattedInputController? controller,
})

Creates a FormattedInput.

The input structure is defined by the initialValue or controller value, which contains the mix of static text and editable segments. Each editable segment can have its own length restrictions and formatting.

Parameters:

  • initialValue (FormattedValue?, optional): Initial structure and values
  • onChanged (ValueChanged<FormattedValue>?, optional): Callback for value changes
  • style (TextStyle?, optional): Text styling for all segments
  • leading (Widget?, optional): Widget displayed before the input
  • trailing (Widget?, optional): Widget displayed after the input
  • enabled (bool, default: true): Whether the input accepts user interaction
  • controller (FormattedInputController?, optional): External controller for programmatic control

Example:

FormattedInput(
  initialValue: FormattedValue([
    FormattedValuePart.static('$'),
    FormattedValuePart.editable('0.00', length: 8),
  ]),
  leading: Icon(Icons.attach_money),
  style: TextStyle(fontSize: 16),
);

Implementation

const FormattedInput({
  super.key,
  this.initialValue,
  this.onChanged,
  this.style,
  this.leading,
  this.trailing,
  this.enabled = true,
  this.controller,
});