MutableText constructor
const
MutableText(
- String value, {
- Key? key,
- MainAxisSize mainAxisSize = MainAxisSize.min,
- ValueChanged<
String> ? onChanged, - bool autoCorrect = true,
- int? minLines,
- TextStyle? style,
- int? maxLines,
- Locale? locale,
- Color? selectionColor,
- TextOverflow? overflow,
- String? semanticsLabel,
- List<
TextInputFormatter> ? inputFormatters, - bool? softWrap,
- StrutStyle? strutStyle,
- TextAlign? textAlign,
- TextDirection? textDirection,
- TextHeightBehavior? textHeightBehavior,
- TextScaler? textScaler,
- TextWidthBasis? textWidthBasis,
- int? maxLength,
- Widget? placeholder,
- Widget? overrideButtonContent,
- double buttonGapWidth = 4,
- VoidCallback? onEditingComplete,
- VoidCallback? onEditingStarted,
- EditButtonType buttonType = EditButtonType.pencil,
- String labelBuilder()?,
- bool border = false,
Constructs a MutableText widget with the specified initial text value and optional editing configurations.
Parameters and Initialization:
- The required
valuesets the initial display text, which becomes the starting point for editing. onChanged(optional) is invoked with the new text value when editing completes via submission or escape.onEditingComplete(optional) is called after editing ends, useful for form validation or state updates in ArcaneField.onEditingStarted(optional) triggers on edit initiation, allowing pre-edit logic like focus management.- Styling options like
style,textAlign,maxLines,minLines,overflow, andselectionColorcustomize appearance and behavior, defaulting to Flutter's Text standards. - Input controls include
autoCorrect(defaults to true),inputFormattersfor validation (e.g., numeric only), andmaxLengthwith enforcement. - Edit UI:
buttonTypedefaults to EditButtonType.pencil using IconButton; set toghostfor GhostButton.buttonGapWidth(default 4) spaces the button, andoverrideButtonContentallows custom icons. - Layout:
mainAxisSizecontrols row sizing (min or max), affecting text flexibility in containers. - Advanced:
placeholdershows hint text during editing,labelBuildertransformsvaluefor display (e.g., formatting numbers),borderenables default TextField border, and accessibility viasemanticsLabel,locale,softWrap,strutStyle,textDirection,textHeightBehavior,textScaler,textWidthBasis.
Usage Example:
MutableText(
'Initial Text',
onChanged: (newValue) => setState(() => myText = newValue),
style: ArcaneTheme.of(context).bodyLarge,
maxLines: 3,
buttonType: EditButtonType.ghost,
)
This creates an editable text block that updates state on change and uses ghost button styling, integrating with ArcaneTheme for consistent theming.
If onChanged is null, no edit button is shown, rendering as a static Text. For form integration, wrap in FieldWrapper or use with ArcaneFieldProvider for reactive updates.
Implementation
const MutableText(this.value,
{super.key,
this.mainAxisSize = MainAxisSize.min,
this.onChanged,
this.autoCorrect = true,
this.minLines,
this.style,
this.maxLines,
this.locale,
this.selectionColor,
this.overflow,
this.semanticsLabel,
this.inputFormatters,
this.softWrap,
this.strutStyle,
this.textAlign,
this.textDirection,
this.textHeightBehavior,
this.textScaler,
this.textWidthBasis,
this.maxLength,
this.placeholder,
this.overrideButtonContent,
this.buttonGapWidth = 4,
this.onEditingComplete,
this.onEditingStarted,
this.buttonType = EditButtonType.pencil,
this.labelBuilder,
this.border = false});