コード例 #1
0
        public List <TextBox> getBoxesForSelection(
            TextSelection selection,
            BoxHeightStyle boxHeightStyle = BoxHeightStyle.tight,
            BoxWidthStyle boxWidthStyle   = BoxWidthStyle.tight)
        {
            D.assert(!_needsLayout);
            var results = _paragraph.getBoxesForRange(
                selection.start,
                selection.end,
                boxHeightStyle: boxHeightStyle,
                boxWidthStyle: boxWidthStyle);

            return(results);
        }
コード例 #2
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;
        }