Ejemplo n.º 1
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;
            }
        }
Ejemplo n.º 2
0
 protected override void SelectionChanged(IList <int> selectedIds)
 {
     SelectionChangedCallback?.Invoke(selectedIds.Select(id => id - UniqueId).ToArray());
 }