SundayMaterialTextField class

A customizable Material-style text field for the Sunday UI framework.

This widget provides a text input field with Material design styling. It allows for customization of various properties such as label text, hint text, and input decoration.

Parameters

  • labelText: The text to display as the label for the text field.
  • hintText: The text to display as a hint when the text field is empty.
  • controller: A controller for managing the text being edited.
  • onChanged: A callback that is called when the text field's value changes.
  • keyboardType: The type of keyboard to use for editing the text.
  • obscureText: Whether to hide the text being edited (e.g., for passwords).
  • decoration: Additional decoration to add to the text field.
  • style: The style to use for this text field (Material, Cupertino, etc.).
  • enabled: Whether the text field is interactive.
  • readOnly: Whether the text field is read-only.
  • maxLines: The maximum number of lines for the text field.
  • minLines: The minimum number of lines for the text field.
  • maxLength: The maximum number of characters allowed.
  • textAlign: The alignment of the text within the field.
  • textDirection: The directionality of the text.
  • autocorrect: Whether to enable autocorrect.
  • autofocus: Whether the text field should be focused initially.
  • autofillHints: A list of strings that helps the autofill service identify the type of this text input.
  • buildCounter: Callback that generates a custom InputDecoration.counter widget.
  • canRequestFocus: Determine whether this text field can request the primary focus.
  • clipBehavior: The content will be clipped (or not) according to this option.
  • contentInsertionConfiguration: Configuration of handler for media content inserted via the system input method.
  • contextMenuBuilder: Builds the text selection toolbar when requested by the user.
  • cursorColor: The color of the cursor.
  • cursorErrorColor: The color of the cursor when the InputDecorator is showing an error.
  • cursorHeight: How tall the cursor will be.
  • cursorOpacityAnimates: Whether the cursor will animate from fully transparent to fully opaque during each cursor blink.
  • cursorRadius: How rounded the corners of the cursor should be.
  • cursorWidth: How thick the cursor will be.
  • dragStartBehavior: Determines the way that drag start behavior is handled.
  • enableIMEPersonalizedLearning: Whether to enable that the IME update personalized data such as typing history and user dictionary data.
  • enableInteractiveSelection: Whether to enable user interface affordances for changing the text selection.
  • enableSuggestions: Whether to show input suggestions as the user types.
  • expands: Whether this widget's height will be sized to fill its parent.
  • focusNode: Defines the keyboard focus for this widget.
  • groupId: The group identifier for the TextFieldTapRegion of this text field.
  • ignorePointers: Determines whether this widget ignores pointer events.
  • inputFormatters: Optional input validation and formatting overrides.
  • keyboardAppearance: The appearance of the keyboard.
  • magnifierConfiguration: The configuration for the magnifier of this text field.
  • maxLengthEnforcement: Determines how the maxLength limit should be enforced.
  • mouseCursor: The cursor for a mouse pointer when it enters or is hovering over the widget.
  • obscuringCharacter: Character used for obscuring text if obscureText is true.
  • onAppPrivateCommand: This is used to receive a private command from the input method.
  • onEditingComplete: Called when the user submits editable content (e.g., user presses the "done" button on the keyboard).
  • onTapAlwaysCalled: Whether onTap should be called for every tap.
  • onTapOutside: Called for each tap that occurs outside of theTextFieldTapRegion group when the text field is focused.
  • restorationId: Restoration ID to save and restore the state of the text field.
  • scribbleEnabled: Whether iOS 14 Scribble features are enabled for this widget.
  • scrollController: The ScrollController to use when vertically scrolling the input.
  • scrollPadding: Configures padding to edges surrounding a Scrollable when the Textfield scrolls into view.
  • scrollPhysics: The ScrollPhysics to use when vertically scrolling the input.
  • selectionControls: Optional delegate for building the text selection handles.
  • selectionHeightStyle: Controls how tall the selection highlight boxes are computed to be.
  • selectionWidthStyle: Controls how wide the selection highlight boxes are computed to be.
  • showCursor: Whether to show cursor.
  • smartDashesType: Whether to allow the platform to automatically format dashes.
  • smartQuotesType: Whether to allow the platform to automatically format quotes.
  • spellCheckConfiguration: Configuration that details how spell check should be performed.
  • statesController: Represents the interactive "state" of this widget in terms of a set of MaterialStates, including MaterialState.disabled, MaterialState.hovered, MaterialState.error, and MaterialState.focused.
  • strutStyle: The strut style used for the vertical layout.
  • textAlignVertical: How the text should be aligned vertically.
  • toolbarOptions: Configuration of toolbar options.
  • undoController: Controls the undo state.

Usage

To use the SundayMaterialTextField, you can create an instance of it in your widget tree. For example:

SundayMaterialTextField(
  labelText: 'Enter your name',
  hintText: 'John Doe',
  controller: myController,
  onChanged: (value) {
    // Handle the change
  },
  keyboardType: TextInputType.text,
  obscureText: false,
  style: Style.material,
)

Example

Here is a complete example of how to use the SundayMaterialTextField within a Flutter application:

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final TextEditingController myController = TextEditingController();

    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('Material Text Field Example')),
        body: Padding(
          padding: const EdgeInsets.all(16.0),
          child: SundayMaterialTextField(
            labelText: 'Enter your name',
            hintText: 'John Doe',
            controller: myController,
            onChanged: (value) {
              print('Current value: $value');
            },
            keyboardType: TextInputType.text,
            obscureText: false,
            style: Style.material,
          ),
        ),
      ),
    );
  }
}
Inheritance

Constructors

SundayMaterialTextField({Key? key, String? labelText, String? hintText, TextEditingController? controller, ValueChanged<String>? onChanged, TextInputType? keyboardType, bool obscureText = false, dynamic decoration, required Style style, bool? enabled, bool? readOnly, int? maxLines, int? minLines, int? maxLength, TextAlign? textAlign, TextDirection? textDirection, bool? autocorrect, bool? autofocus, Iterable<String>? autofillHints, InputCounterWidgetBuilder? buildCounter, bool? canRequestFocus, Clip? clipBehavior, ContentInsertionConfiguration? contentInsertionConfiguration, EditableTextContextMenuBuilder? contextMenuBuilder, Color? cursorColor, Color? cursorErrorColor, double? cursorHeight, bool? cursorOpacityAnimates, Radius? cursorRadius, double? cursorWidth, DragStartBehavior? dragStartBehavior, bool? enableIMEPersonalizedLearning, bool? enableInteractiveSelection, bool? enableSuggestions, bool? expands, FocusNode? focusNode, Object? groupId, bool? ignorePointers, List<TextInputFormatter>? inputFormatters, Brightness? keyboardAppearance, TextMagnifierConfiguration? magnifierConfiguration, MaxLengthEnforcement? maxLengthEnforcement, MouseCursor? mouseCursor, String? obscuringCharacter, AppPrivateCommandCallback? onAppPrivateCommand, VoidCallback? onEditingComplete, bool? onTapAlwaysCalled, TapRegionCallback? onTapOutside, String? restorationId, bool? scribbleEnabled, ScrollController? scrollController, EdgeInsets? scrollPadding, ScrollPhysics? scrollPhysics, TextSelectionControls? selectionControls, BoxHeightStyle? selectionHeightStyle, BoxWidthStyle? selectionWidthStyle, bool? showCursor, SmartDashesType? smartDashesType, SmartQuotesType? smartQuotesType, SpellCheckConfiguration? spellCheckConfiguration, StrutStyle? strutStyle, TextStyle? textStyle, TextAlignVertical? textAlignVertical, UndoHistoryController? undoController, EdgeInsets? padding, ValueChanged<String>? onSubmitted, ValueChanged<bool>? onFocusChange, bool showClearButton = false})
Constructs a SundayMaterialTextField with the given properties.
const

Properties

autocorrect bool?
Whether to enable autocorrect.
final
autofillHints Iterable<String>?
A list of strings that helps the autofill service identify the type of this text input.
final
autofocus bool?
Whether the text field should be focused initially.
final
buildCounter InputCounterWidgetBuilder?
Callback that generates a custom InputDecoration.counter widget.
final
canRequestFocus bool?
Determine whether this text field can request the primary focus.
final
clipBehavior Clip?
The content will be clipped (or not) according to this option.
final
contentInsertionConfiguration ContentInsertionConfiguration?
Configuration of handler for media content inserted via the system input method.
final
contextMenuBuilder EditableTextContextMenuBuilder?
Builds the text selection toolbar when requested by the user.
final
controller TextEditingController?
A controller for managing the text being edited.
final
cursorColor Color?
The color of the cursor.
final
cursorErrorColor Color?
The color of the cursor when the InputDecorator is showing an error.
final
cursorHeight double?
How tall the cursor will be.
final
cursorOpacityAnimates bool?
Whether the cursor will animate from fully transparent to fully opaque during each cursor blink.
final
cursorRadius Radius?
How rounded the corners of the cursor should be.
final
cursorWidth double?
How thick the cursor will be.
final
decoration → dynamic
Additional decoration to add to the text field.
final
dragStartBehavior DragStartBehavior?
Determines the way that drag start behavior is handled.
final
enabled bool?
Whether the text field is interactive.
final
enableIMEPersonalizedLearning bool?
Whether to enable that the IME update personalized data such as typing history and user dictionary data.
final
enableInteractiveSelection bool?
Whether to enable user interface affordances for changing the text selection.
final
enableSuggestions bool?
Whether to show input suggestions as the user types.
final
expands bool?
Whether this widget's height will be sized to fill its parent.
final
focusNode FocusNode?
Defines the keyboard focus for this widget.
final
groupId Object?
The group identifier for the TextFieldTapRegion of this text field.
final
hashCode int
The hash code for this object.
no setterinherited
hintText String?
The text to display as a hint when the text field is empty.
final
ignorePointers bool?
Determines whether this widget ignores pointer events.
final
inputFormatters List<TextInputFormatter>?
Optional input validation and formatting overrides.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
keyboardAppearance Brightness?
The appearance of the keyboard.
final
keyboardType TextInputType?
The type of keyboard to use for editing the text.
final
labelText String?
The text to display as the label for the text field.
final
magnifierConfiguration TextMagnifierConfiguration?
The configuration for the magnifier of this text field.
final
maxLength int?
The maximum number of characters allowed.
final
maxLengthEnforcement MaxLengthEnforcement?
Determines how the maxLength limit should be enforced.
final
maxLines int?
The maximum number of lines for the text field.
final
minLines int?
The minimum number of lines for the text field.
final
mouseCursor MouseCursor?
The cursor for a mouse pointer when it enters or is hovering over the widget.
final
obscureText bool
Whether to hide the text being edited (e.g., for passwords).
final
obscuringCharacter String?
Character used for obscuring text if obscureText is true.
final
onAppPrivateCommand AppPrivateCommandCallback?
This is used to receive a private command from the input method.
final
onChanged ValueChanged<String>?
A callback that is called when the text field's value changes.
final
onEditingComplete VoidCallback?
Called when the user submits editable content (e.g., user presses the "done" button on the keyboard).
final
onFocusChange ValueChanged<bool>?
Called when the focus changes.
final
onSubmitted ValueChanged<String>?
Called when the user submits the text field.
final
onTapAlwaysCalled bool?
Whether onTap should be called for every tap.
final
onTapOutside TapRegionCallback?
Called for each tap that occurs outside of theTextFieldTapRegion group when the text field is focused.
final
padding EdgeInsets?
The padding around the text field.
final
readOnly bool?
Whether the text field is read-only.
final
restorationId String?
Restoration ID to save and restore the state of the text field.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scribbleEnabled bool?
Whether iOS 14 Scribble features are enabled for this widget.
final
scrollController ScrollController?
The ScrollController to use when vertically scrolling the input.
final
scrollPadding EdgeInsets?
Configures padding to edges surrounding a Scrollable when the Textfield scrolls into view.
final
scrollPhysics ScrollPhysics?
The ScrollPhysics to use when vertically scrolling the input.
final
selectionControls TextSelectionControls?
Optional delegate for building the text selection handles.
final
selectionHeightStyle BoxHeightStyle?
Controls how tall the selection highlight boxes are computed to be.
final
selectionWidthStyle BoxWidthStyle?
Controls how wide the selection highlight boxes are computed to be.
final
showClearButton bool
Whether to show a clear button.
final
showCursor bool?
Whether to show cursor.
final
smartDashesType SmartDashesType?
Whether to allow the platform to automatically format dashes.
final
smartQuotesType SmartQuotesType?
Whether to allow the platform to automatically format quotes.
final
spellCheckConfiguration SpellCheckConfiguration?
Configuration that details how spell check should be performed.
final
strutStyle StrutStyle?
The strut style used for the vertical layout.
final
style Style
The style to use for this text field (Material, Cupertino, etc.).
final
textAlign TextAlign?
The alignment of the text within the field.
final
textAlignVertical TextAlignVertical?
How the text should be aligned vertically.
final
textDirection TextDirection?
The directionality of the text.
final
textStyle TextStyle?
The style to use for the text being edited.
final
undoController UndoHistoryController?
Controls the undo state.
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
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.
inherited
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, int wrapWidth = 65}) 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