示例#1
0
 public TextInputConfiguration(
     TextInputType inputType               = null,
     bool obscureText                      = false,
     bool autocorrect                      = true,
     SmartDashesType?smartDashesType       = null,
     SmartQuotesType?smartQuotesType       = null,
     bool enableSuggestions                = true,
     string actionLabel                    = null,
     TextInputAction inputAction           = TextInputAction.done,
     ui.Brightness keyboardAppearance      = ui.Brightness.light,
     TextCapitalization textCapitalization = TextCapitalization.none,
     bool unityTouchKeyboard               = false
     )
 {
     D.assert(inputType != null);
     this.smartDashesType =
         smartDashesType ?? (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled);
     this.smartQuotesType =
         smartQuotesType ?? (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled);
     this.inputType          = inputType ?? TextInputType.text;
     this.obscureText        = obscureText;
     this.autocorrect        = autocorrect;
     this.enableSuggestions  = enableSuggestions;
     this.actionLabel        = actionLabel ?? "";
     this.inputAction        = inputAction;
     this.textCapitalization = textCapitalization;
     this.keyboardAppearance = keyboardAppearance;
     this.unityTouchKeyboard = unityTouchKeyboard;
 }
示例#2
0
        public EditableText(TextEditingController controller, FocusNode focusNode, TextStyle style,
                            Color cursorColor, bool obscureText = false, bool autocorrect                           = false,
                            TextAlign textAlign                       = TextAlign.left, TextDirection?textDirection = null,
                            float?textScaleFactor                     = null, int?maxLines          = 1,
                            bool autofocus                            = false, Color selectionColor = null, TextSelectionControls selectionControls = null,
                            TextInputType keyboardType                = null, TextInputAction?textInputAction = null,
                            TextCapitalization textCapitalization     = TextCapitalization.none,
                            ValueChanged <string> onChanged           = null, VoidCallback onEditingComplete = null,
                            ValueChanged <string> onSubmitted         = null, SelectionChangedCallback onSelectionChanged = null,
                            List <TextInputFormatter> inputFormatters = null, bool rendererIgnoresPointer                 = false,
                            EdgeInsets scrollPadding                  = null, bool unityTouchKeyboard = false,
                            Key key = null) : base(key)
        {
            D.assert(controller != null);
            D.assert(focusNode != null);
            D.assert(style != null);
            D.assert(cursorColor != null);
            D.assert(maxLines == null || maxLines > 0);
            this.keyboardType = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline);

            this.scrollPadding          = scrollPadding ?? EdgeInsets.all(20.0f);
            this.controller             = controller;
            this.focusNode              = focusNode;
            this.obscureText            = obscureText;
            this.autocorrect            = autocorrect;
            this.style                  = style;
            this.textAlign              = textAlign;
            this.textDirection          = textDirection;
            this.textScaleFactor        = textScaleFactor;
            this.textInputAction        = textInputAction;
            this.textCapitalization     = textCapitalization;
            this.cursorColor            = cursorColor;
            this.maxLines               = maxLines;
            this.autofocus              = autofocus;
            this.selectionColor         = selectionColor;
            this.onChanged              = onChanged;
            this.onSubmitted            = onSubmitted;
            this.onSelectionChanged     = onSelectionChanged;
            this.onEditingComplete      = onEditingComplete;
            this.rendererIgnoresPointer = rendererIgnoresPointer;
            this.selectionControls      = selectionControls;
            this.unityTouchKeyboard     = unityTouchKeyboard;
            if (maxLines == 1)
            {
                this.inputFormatters = new List <TextInputFormatter>();
                this.inputFormatters.Add(BlacklistingTextInputFormatter.singleLineFormatter);
                if (inputFormatters != null)
                {
                    this.inputFormatters.AddRange(inputFormatters);
                }
            }
            else
            {
                this.inputFormatters = inputFormatters;
            }
        }
示例#3
0
        public TextField(Key key = null, TextEditingController controller                = null, FocusNode focusNode         = null,
                         InputDecoration decoration            = null, bool noDecoration = false, TextInputType keyboardType = null,
                         TextInputAction?textInputAction       = null,
                         TextCapitalization textCapitalization = TextCapitalization.none, TextStyle style = null,
                         TextAlign textAlign               = TextAlign.left, TextDirection textDirection = TextDirection.ltr,
                         bool autofocus                    = false, bool obscureText      = false, bool autocorrect = false, int?maxLines = 1,
                         int?maxLength                     = null, bool maxLengthEnforced = true, ValueChanged <string> onChanged = null,
                         VoidCallback onEditingComplete    = null,
                         ValueChanged <string> onSubmitted = null, List <TextInputFormatter> inputFormatters = null,
                         bool?enabled = null, float?cursorWidth = 2.0f, Radius cursorRadius = null, Color cursorColor = null,
                         Brightness?keyboardAppearance          = null, EdgeInsets scrollPadding = null,
                         DragStartBehavior dragStartBehavior    = DragStartBehavior.down,
                         bool?enableInteractiveSelection        = null,
                         GestureTapCallback onTap               = null,
                         InputCounterWidgetBuilder buildCounter = null
                         ) : base(key: key)
        {
            D.assert(maxLines == null || maxLines > 0);
            D.assert(maxLength == null || maxLength == TextField.noMaxLength || maxLength > 0);

            this.controller         = controller;
            this.focusNode          = focusNode;
            this.decoration         = noDecoration ? null : (decoration ?? new InputDecoration());
            this.textInputAction    = textInputAction;
            this.textCapitalization = textCapitalization;
            this.style                      = style;
            this.textAlign                  = textAlign;
            this.textDirection              = textDirection;
            this.autofocus                  = autofocus;
            this.obscureText                = obscureText;
            this.autocorrect                = autocorrect;
            this.maxLines                   = maxLines;
            this.maxLength                  = maxLength;
            this.maxLengthEnforced          = maxLengthEnforced;
            this.onChanged                  = onChanged;
            this.onEditingComplete          = onEditingComplete;
            this.onSubmitted                = onSubmitted;
            this.inputFormatters            = inputFormatters;
            this.enabled                    = enabled;
            this.cursorWidth                = cursorWidth;
            this.cursorColor                = cursorColor;
            this.cursorRadius               = cursorRadius;
            this.onSubmitted                = onSubmitted;
            this.keyboardAppearance         = keyboardAppearance;
            this.enableInteractiveSelection = enableInteractiveSelection;
            this.onTap                      = onTap;
            this.keyboardType               = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline);
            this.scrollPadding              = scrollPadding ?? EdgeInsets.all(20.0f);
            this.dragStartBehavior          = dragStartBehavior;
            this.buildCounter               = buildCounter;
        }
示例#4
0
 public TextInputConfiguration(TextInputType inputType               = null,
                               bool obscureText                      = false, bool autocorrect = true, TextInputAction inputAction = TextInputAction.done,
                               Brightness keyboardAppearance         = Brightness.light,
                               TextCapitalization textCapitalization = TextCapitalization.none,
                               bool unityTouchKeyboard               = false)
 {
     this.inputType          = inputType ?? TextInputType.text;
     this.inputAction        = inputAction;
     this.obscureText        = obscureText;
     this.autocorrect        = autocorrect;
     this.textCapitalization = textCapitalization;
     this.keyboardAppearance = keyboardAppearance;
     this.unityTouchKeyboard = unityTouchKeyboard;
 }
示例#5
0
 public TextFormField(
     Key key = null,
     TextEditingController controller = null,
     string initialValue                   = null,
     FocusNode focusNode                   = null,
     InputDecoration decoration            = null,
     TextInputType keyboardType            = null,
     TextCapitalization textCapitalization = TextCapitalization.none,
     TextInputAction?textInputAction       = null,
     TextStyle style             = null,
     TextDirection?textDirection = null,
     TextAlign textAlign         = TextAlign.left,
     bool autofocus                            = false,
     bool obscureText                          = false,
     bool autocorrect                          = true,
     bool autovalidate                         = false,
     bool maxLengthEnforced                    = true,
     int maxLines                              = 1,
     int?maxLength                             = null,
     VoidCallback onEditingComplete            = null,
     ValueChanged <string> onFieldSubmitted    = null,
     FormFieldSetter <string> onSaved          = null,
     FormFieldValidator <string> validator     = null,
     List <TextInputFormatter> inputFormatters = null,
     bool enabled                              = true,
     float cursorWidth                         = 2.0f,
     Radius cursorRadius                       = null,
     Color cursorColor                         = null,
     Brightness?keyboardAppearance             = null,
     EdgeInsets scrollPadding                  = null,
     bool enableInteractiveSelection           = true,
     InputCounterWidgetBuilder buildCounter    = null
     ) : base(
         key: key,
         initialValue: controller != null ? controller.text : (initialValue ?? ""),
         onSaved: onSaved,
         validator: validator,
         autovalidate: autovalidate,
         enabled: enabled,
         builder: (FormFieldState <string> field) => {
     _TextFormFieldState state           = (_TextFormFieldState)field;
     InputDecoration effectiveDecoration = (decoration ?? new InputDecoration())
                                           .applyDefaults(Theme.of(field.context).inputDecorationTheme);
     return(new TextField(
                controller: state._effectiveController,
                focusNode: focusNode,
                decoration: effectiveDecoration.copyWith(errorText: field.errorText),
                keyboardType: keyboardType,
                textInputAction: textInputAction,
                style: style,
                textAlign: textAlign,
                textDirection: textDirection ?? TextDirection.ltr,
                textCapitalization: textCapitalization,
                autofocus: autofocus,
                obscureText: obscureText,
                autocorrect: autocorrect,
                maxLengthEnforced: maxLengthEnforced,
                maxLines: maxLines,
                maxLength: maxLength,
                onChanged: field.didChange,
                onEditingComplete: onEditingComplete,
                onSubmitted: onFieldSubmitted,
                inputFormatters: inputFormatters,
                enabled: enabled,
                cursorWidth: cursorWidth,
                cursorRadius: cursorRadius,
                cursorColor: cursorColor,
                scrollPadding: scrollPadding ?? EdgeInsets.all(20.0f),
                keyboardAppearance: keyboardAppearance,
                enableInteractiveSelection: enableInteractiveSelection,
                buildCounter: buildCounter
                ));
 }
         ) {
     D.assert(initialValue == null || controller == null);
     D.assert(maxLines > 0);
     D.assert(maxLength == null || maxLength > 0);
     this.controller = controller;
 }
示例#6
0
        public CupertinoTextField(
            Key key = null,
            TextEditingController controller = null,
            FocusNode focusNode        = null,
            BoxDecoration decoration   = null,
            EdgeInsets padding         = null,
            string placeholder         = null,
            TextStyle placeholderStyle = null,
            Widget prefix = null,
            OverlayVisibilityMode prefixMode = OverlayVisibilityMode.always,
            Widget suffix = null,
            OverlayVisibilityMode suffixMode      = OverlayVisibilityMode.always,
            OverlayVisibilityMode clearButtonMode = OverlayVisibilityMode.never,
            TextInputType keyboardType            = null,
            TextInputAction?textInputAction       = null,
            TextCapitalization textCapitalization = TextCapitalization.none,
            TextStyle style       = null,
            StrutStyle strutStyle = null,
            TextAlign textAlign   = TextAlign.left,
            TextAlignVertical textAlignVertical = null,
            bool readOnly = false,
            ToolbarOptions toolbarOptions = null,
            bool?showCursor  = null,
            bool autofocus   = false,
            bool obscureText = false,
            bool autocorrect = true,
            SmartDashesType?smartDashesType = null,
            SmartQuotesType?smartQuotesType = null,
            bool enableSuggestions          = true,
            int?maxLines                              = 1,
            int?minLines                              = null,
            bool expands                              = false,
            int?maxLength                             = null,
            bool maxLengthEnforced                    = true,
            ValueChanged <string> onChanged           = null,
            VoidCallback onEditingComplete            = null,
            ValueChanged <string> onSubmitted         = null,
            List <TextInputFormatter> inputFormatters = null,
            bool?enabled                              = null,
            float cursorWidth                         = 2.0f,
            Radius cursorRadius                       = null,
            Color cursorColor                         = null,
            ui.BoxHeightStyle selectionHeightStyle    = ui.BoxHeightStyle.tight,
            ui.BoxWidthStyle selectionWidthStyle      = ui.BoxWidthStyle.tight,
            Brightness?keyboardAppearance             = null,
            EdgeInsets scrollPadding                  = null,
            DragStartBehavior dragStartBehavior       = DragStartBehavior.start,
            bool enableInteractiveSelection           = true,
            GestureTapCallback onTap                  = null,
            ScrollController scrollController         = null,
            ScrollPhysics scrollPhysics               = null
            ) : base(key: key)
        {
            this.smartDashesType = smartDashesType ?? (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled);
            this.smartQuotesType = smartQuotesType ?? (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled);
            D.assert(maxLines == null || maxLines > 0);
            D.assert(minLines == null || minLines > 0);
            D.assert(maxLines == null || minLines == null || maxLines >= minLines,
                     () => "minLines can't be greater than maxLines");
            D.assert(!expands || (maxLines == null && minLines == null),
                     () => "minLines and maxLines must be null when expands is true.");
            D.assert(maxLength == null || maxLength > 0);

            this.controller       = controller;
            this.focusNode        = focusNode;
            this.decoration       = decoration ?? CupertinoTextFieldUtils._kDefaultRoundedBorderDecoration;
            this.padding          = padding ?? EdgeInsets.all(6.0f);
            this.placeholder      = placeholder;
            this.placeholderStyle = placeholderStyle ?? new TextStyle(
                fontWeight: FontWeight.w400,
                color: CupertinoColors.placeholderText
                );
            this.prefix             = prefix;
            this.prefixMode         = prefixMode;
            this.suffix             = suffix;
            this.suffixMode         = suffixMode;
            this.clearButtonMode    = clearButtonMode;
            this.textInputAction    = textInputAction;
            this.textCapitalization = textCapitalization;
            this.style                      = style;
            this.strutStyle                 = strutStyle;
            this.textAlign                  = textAlign;
            this.textAlignVertical          = textAlignVertical;
            this.readOnly                   = readOnly;
            this.showCursor                 = showCursor;
            this.autofocus                  = autofocus;
            this.obscureText                = obscureText;
            this.autocorrect                = autocorrect;
            this.enableSuggestions          = enableSuggestions;
            this.maxLines                   = maxLines;
            this.minLines                   = minLines;
            this.expands                    = expands;
            this.maxLength                  = maxLength;
            this.maxLengthEnforced          = maxLengthEnforced;
            this.onChanged                  = onChanged;
            this.onEditingComplete          = onEditingComplete;
            this.onSubmitted                = onSubmitted;
            this.inputFormatters            = inputFormatters;
            this.enabled                    = enabled;
            this.cursorWidth                = cursorWidth;
            this.cursorRadius               = cursorRadius ?? Radius.circular(2.0f);
            this.cursorColor                = cursorColor;
            this.selectionHeightStyle       = selectionHeightStyle;
            this.selectionWidthStyle        = selectionWidthStyle;
            this.keyboardAppearance         = keyboardAppearance;
            this.scrollPadding              = scrollPadding ?? EdgeInsets.all(20.0f);
            this.dragStartBehavior          = dragStartBehavior;
            this.enableInteractiveSelection = enableInteractiveSelection;
            this.scrollPhysics              = scrollPhysics;
            this.onTap                      = onTap;
            this.scrollController           = scrollController;
            this.keyboardType               = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline);
            this.toolbarOptions             = toolbarOptions ?? (obscureText
                ? new ToolbarOptions(
                                                                     selectAll: true,
                                                                     paste: true
                                                                     )
                : new ToolbarOptions(
                                                                     copy: true,
                                                                     cut: true,
                                                                     selectAll: true,
                                                                     paste: true
                                                                     ));
        }
示例#7
0
        public CupertinoTextField(
            Key key = null,
            TextEditingController controller = null,
            FocusNode focusNode        = null,
            BoxDecoration decoration   = null,
            EdgeInsets padding         = null,
            string placeholder         = null,
            TextStyle placeholderStyle = null,
            Widget prefix = null,
            OverlayVisibilityMode prefixMode = OverlayVisibilityMode.always,
            Widget suffix = null,
            OverlayVisibilityMode suffixMode      = OverlayVisibilityMode.always,
            OverlayVisibilityMode clearButtonMode = OverlayVisibilityMode.never,
            TextInputType keyboardType            = null,
            TextInputAction?textInputAction       = null,
            TextCapitalization textCapitalization = TextCapitalization.none,
            TextStyle style                           = null,
            StrutStyle strutStyle                     = null,
            TextAlign textAlign                       = TextAlign.left,
            bool autofocus                            = false,
            bool obscureText                          = false,
            bool autocorrect                          = true,
            int?maxLines                              = 1,
            int?minLines                              = null,
            bool expands                              = false,
            int?maxLength                             = null,
            bool maxLengthEnforced                    = true,
            ValueChanged <string> onChanged           = null,
            VoidCallback onEditingComplete            = null,
            ValueChanged <string> onSubmitted         = null,
            List <TextInputFormatter> inputFormatters = null,
            bool?enabled                              = null,
            float cursorWidth                         = 2.0f,
            Radius cursorRadius                       = null,
            Color cursorColor                         = null,
            Brightness?keyboardAppearance             = null,
            EdgeInsets scrollPadding                  = null,
            DragStartBehavior dragStartBehavior       = DragStartBehavior.start,
            ScrollPhysics scrollPhysics               = null) : base(key: key)
        {
            D.assert(maxLines == null || maxLines > 0);
            D.assert(minLines == null || minLines > 0);
            D.assert(maxLines == null || minLines == null || maxLines >= minLines,
                     () => "minLines can't be greater than maxLines");
            D.assert(!expands || (maxLines == null && minLines == null),
                     () => "minLines and maxLines must be null when expands is true.");
            D.assert(maxLength == null || maxLength > 0);

            this.controller       = controller;
            this.focusNode        = focusNode;
            this.decoration       = decoration ?? CupertinoTextFieldUtils._kDefaultRoundedBorderDecoration;
            this.padding          = padding ?? EdgeInsets.all(6.0f);
            this.placeholder      = placeholder;
            this.placeholderStyle = placeholderStyle ?? new TextStyle(
                fontWeight: FontWeight.w300,
                color: CupertinoTextFieldUtils._kInactiveTextColor
                );
            this.prefix             = prefix;
            this.prefixMode         = prefixMode;
            this.suffix             = suffix;
            this.suffixMode         = suffixMode;
            this.clearButtonMode    = clearButtonMode;
            this.textInputAction    = textInputAction;
            this.textCapitalization = textCapitalization;
            this.style              = style;
            this.strutStyle         = strutStyle;
            this.textAlign          = textAlign;
            this.autofocus          = autofocus;
            this.obscureText        = obscureText;
            this.autocorrect        = autocorrect;
            this.maxLines           = maxLines;
            this.minLines           = minLines;
            this.expands            = expands;
            this.maxLength          = maxLength;
            this.maxLengthEnforced  = maxLengthEnforced;
            this.onChanged          = onChanged;
            this.onEditingComplete  = onEditingComplete;
            this.onSubmitted        = onSubmitted;
            this.inputFormatters    = inputFormatters;
            this.enabled            = enabled;
            this.cursorWidth        = cursorWidth;
            this.cursorRadius       = cursorRadius ?? Radius.circular(2.0f);
            this.cursorColor        = cursorColor;
            this.keyboardAppearance = keyboardAppearance;
            this.scrollPadding      = scrollPadding ?? EdgeInsets.all(20.0f);
            this.dragStartBehavior  = dragStartBehavior;
            this.scrollPhysics      = scrollPhysics;
            this.keyboardType       = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline);
        }
示例#8
0
        public TextField(Key key = null,
                         TextEditingController controller = null,
                         FocusNode focusNode                   = null,
                         InputDecoration decoration            = null,
                         bool noDecoration                     = false,
                         TextInputType keyboardType            = null,
                         TextInputAction?textInputAction       = null,
                         TextCapitalization textCapitalization = TextCapitalization.none,
                         TextStyle style       = null,
                         StrutStyle strutStyle = null,
                         TextAlign textAlign   = TextAlign.left,
                         TextAlignVertical textAlignVertical = null,
                         TextDirection textDirection         = TextDirection.ltr,
                         bool readOnly = false,
                         ToolbarOptions toolbarOptions = null,
                         bool?showCursor  = null,
                         bool autofocus   = false,
                         bool obscureText = false,
                         bool autocorrect = false,
                         SmartDashesType?smartDashesType = null,
                         SmartQuotesType?smartQuotesType = null,
                         bool enableSuggestions          = true,
                         int?maxLines                              = 1,
                         int?minLines                              = null,
                         bool expands                              = false,
                         int?maxLength                             = null,
                         bool maxLengthEnforced                    = true,
                         ValueChanged <string> onChanged           = null,
                         VoidCallback onEditingComplete            = null,
                         ValueChanged <string> onSubmitted         = null,
                         List <TextInputFormatter> inputFormatters = null,
                         bool?enabled                              = null,
                         float?cursorWidth                         = 2.0f,
                         Radius cursorRadius                       = null,
                         Color cursorColor                         = null,
                         BoxHeightStyle selectionHeightStyle       = BoxHeightStyle.tight,
                         BoxWidthStyle selectionWidthStyle         = BoxWidthStyle.tight,
                         Brightness?keyboardAppearance             = null,
                         EdgeInsets scrollPadding                  = null,
                         DragStartBehavior dragStartBehavior       = DragStartBehavior.start,
                         bool enableInteractiveSelection           = true,
                         GestureTapCallback onTap                  = null,
                         InputCounterWidgetBuilder buildCounter    = null,
                         ScrollController scrollController         = null,
                         ScrollPhysics scrollPhysics               = null
                         ) : base(key: key)
        {
            D.assert(maxLines == null || maxLines > 0);
            D.assert(minLines == null || minLines > 0);
            D.assert((maxLines == null) || (minLines == null) || (maxLines >= minLines),
                     () => "minLines can't be greater than maxLines");
            D.assert(!expands || (maxLines == null && minLines == null),
                     () => "minLines and maxLines must be null when expands is true.");
            D.assert(maxLength == null || maxLength == noMaxLength || maxLength > 0);
            D.assert(!obscureText || maxLines == 1, () => "Obscured fields cannot be multiline.");

            this.smartDashesType =
                smartDashesType ?? (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled);
            this.smartQuotesType =
                smartQuotesType ?? (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled);

            this.controller         = controller;
            this.focusNode          = focusNode;
            this.decoration         = noDecoration ? null : (decoration ?? new InputDecoration());
            this.textInputAction    = textInputAction;
            this.textCapitalization = textCapitalization;
            this.style                      = style;
            this.strutStyle                 = strutStyle;
            this.textAlign                  = textAlign;
            this.textAlignVertical          = textAlignVertical;
            this.textDirection              = textDirection;
            this.readOnly                   = readOnly;
            this.showCursor                 = showCursor;
            this.autofocus                  = autofocus;
            this.obscureText                = obscureText;
            this.autocorrect                = autocorrect;
            this.enableSuggestions          = enableSuggestions;
            this.maxLines                   = maxLines;
            this.minLines                   = minLines;
            this.expands                    = expands;
            this.maxLength                  = maxLength;
            this.maxLengthEnforced          = maxLengthEnforced;
            this.onChanged                  = onChanged;
            this.onEditingComplete          = onEditingComplete;
            this.onSubmitted                = onSubmitted;
            this.inputFormatters            = inputFormatters;
            this.enabled                    = enabled;
            this.cursorWidth                = cursorWidth;
            this.cursorColor                = cursorColor;
            this.selectionHeightStyle       = selectionHeightStyle;
            this.selectionWidthStyle        = selectionWidthStyle;
            this.cursorRadius               = cursorRadius;
            this.onSubmitted                = onSubmitted;
            this.keyboardAppearance         = keyboardAppearance;
            this.enableInteractiveSelection = enableInteractiveSelection;
            this.onTap                      = onTap;
            this.keyboardType               = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline);
            this.toolbarOptions             = toolbarOptions ?? (obscureText
                                      ? new ToolbarOptions(
                                                                     selectAll: true,
                                                                     paste: true
                                                                     )
                                      : new ToolbarOptions(
                                                                     copy: true,
                                                                     cut: true,
                                                                     selectAll: true,
                                                                     paste: true
                                                                     ));

            this.scrollPadding              = scrollPadding ?? EdgeInsets.all(20.0f);
            this.dragStartBehavior          = dragStartBehavior;
            this.enableInteractiveSelection = enableInteractiveSelection;
            this.buildCounter     = buildCounter;
            this.scrollPhysics    = scrollPhysics;
            this.scrollController = scrollController;
        }
示例#9
0
        public TextFormField(
            Key key = null,
            TextEditingController controller = null,
            string initialValue                   = null,
            FocusNode focusNode                   = null,
            InputDecoration decoration            = null,
            TextInputType keyboardType            = null,
            TextCapitalization textCapitalization = TextCapitalization.none,
            TextInputAction?textInputAction       = null,
            TextStyle style                     = null,
            StrutStyle strutStyle               = null,
            TextDirection?textDirection         = null,
            TextAlign textAlign                 = TextAlign.left,
            TextAlignVertical textAlignVertical = null,
            bool autofocus = false,
            bool readOnly  = false,
            ToolbarOptions toolbarOptions = null,
            bool?showCursor  = null,
            bool obscureText = false,
            bool autocorrect = true,
            SmartDashesType?smartDashesType = null,
            SmartQuotesType?smartQuotesType = null,
            bool enableSuggestions          = true,
            bool autovalidate                         = false,
            bool maxLengthEnforced                    = true,
            int?maxLines                              = 1,
            int?minLines                              = null,
            bool expands                              = false,
            int?maxLength                             = null,
            ValueChanged <string> onChanged           = null,
            GestureTapCallback onTap                  = null,
            VoidCallback onEditingComplete            = null,
            ValueChanged <string> onFieldSubmitted    = null,
            FormFieldSetter <string> onSaved          = null,
            FormFieldValidator <string> validator     = null,
            List <TextInputFormatter> inputFormatters = null,
            bool enabled                              = true,
            float cursorWidth                         = 2.0f,
            Radius cursorRadius                       = null,
            Color cursorColor                         = null,
            Brightness?keyboardAppearance             = null,
            EdgeInsets scrollPadding                  = null,
            bool enableInteractiveSelection           = true,
            InputCounterWidgetBuilder buildCounter    = null,
            ScrollPhysics scrollPhysics               = null
            ) : base(
                key: key,
                initialValue: controller != null ? controller.text : (initialValue ?? ""),
                onSaved: onSaved,
                validator: validator,
                autovalidate: autovalidate,
                enabled: enabled,
                builder: (FormFieldState <string> field) => {
            _TextFormFieldState state           = (_TextFormFieldState)field;
            InputDecoration effectiveDecoration = (decoration ?? new InputDecoration())
                                                  .applyDefaults(Theme.of(field.context).inputDecorationTheme);

            void onChangedHandler(string value)
            {
                if (onChanged != null)
                {
                    onChanged(value);
                }

                field.didChange(value);
            }

            return(new TextField(
                       controller: state._effectiveController,
                       focusNode: focusNode,
                       decoration: effectiveDecoration.copyWith(errorText: field.errorText),
                       keyboardType: keyboardType,
                       textInputAction: textInputAction,
                       style: style,
                       strutStyle: strutStyle,
                       textAlign: textAlign,
                       textAlignVertical: textAlignVertical,
                       textDirection: textDirection ?? TextDirection.ltr,
                       textCapitalization: textCapitalization,
                       autofocus: autofocus,
                       toolbarOptions: toolbarOptions,
                       readOnly: readOnly,
                       showCursor: showCursor,
                       obscureText: obscureText,
                       autocorrect: autocorrect,
                       smartDashesType: smartDashesType ??
                       (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled),
                       smartQuotesType: smartQuotesType ??
                       (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled),
                       enableSuggestions: enableSuggestions,
                       maxLengthEnforced: maxLengthEnforced,
                       maxLines: maxLines,
                       minLines: minLines,
                       expands: expands,
                       maxLength: maxLength,
                       onChanged: onChangedHandler,
                       onTap: onTap,
                       onEditingComplete: onEditingComplete,
                       onSubmitted: onFieldSubmitted,
                       inputFormatters: inputFormatters,
                       enabled: enabled,
                       cursorWidth: cursorWidth,
                       cursorRadius: cursorRadius,
                       cursorColor: cursorColor,
                       scrollPadding: scrollPadding ?? EdgeInsets.all(20.0f),
                       scrollPhysics: scrollPhysics,
                       keyboardAppearance: keyboardAppearance,
                       enableInteractiveSelection: enableInteractiveSelection,
                       buildCounter: buildCounter
                       ));
        }
                ) {
            D.assert(initialValue == null || controller == null);
            D.assert(maxLines > 0);
            D.assert(maxLines == null || maxLines > 0);
            D.assert(minLines == null || minLines > 0);
            D.assert((maxLines == null) || (minLines == null) || (maxLines >= minLines),
                     () => "minLines can't be greater than maxLines");
            D.assert(!expands || (maxLines == null && minLines == null),
                     () => "minLines and maxLines must be null when expands is true.");
            D.assert(!obscureText || maxLines == 1, () => "Obscured fields cannot be multiline.");
            D.assert(maxLength == null || maxLength > 0);
            this.controller = controller;
        }