Flutter TextField 輸入框屬性

源碼如下:

const TextField({
    Key? key,
    this.controller,//控制正在編輯文本
    this.focusNode,// 獲取控制鍵盤焦點
    this.decoration = const InputDecoration(),//邊框裝飾
    TextInputType? keyboardType,//鍵盤類型
    this.textInputAction,//鍵盤的操作按鈕類型
    this.textCapitalization = TextCapitalization.none,//配置大小寫鍵盤
    this.style,//輸入文本樣式
    this.strutStyle,//使用的支柱風格
    this.textAlign = TextAlign.start,//對齊方式  值為  left、  right  、center、  justify 、 start、  end
    this.textAlignVertical,//文本垂直方向對齊方式 。 值為 top   、 center 、  bottom
    this.textDirection,//文本方向 rtl(right to left)   ltr(left to right)
    this.readOnly = false,//只讀(當true 粘貼和剪切將被禁用:暫時沒實踐過等以后實踐再補充)
    ToolbarOptions? toolbarOptions,//工具欄選項的配置
    this.showCursor,//是否顯示光標
    this.autofocus = false,//是否自動對焦
    this.obscuringCharacter = '?',//隱藏內容時,顯示的文字
    this.obscureText = false,//是否隱藏內容,例如密碼格式
    this.autocorrect = true,//是否自動校正
    SmartDashesType? smartDashesType,//指示如何處理文本輸入中破折號的智能替換
    SmartQuotesType? smartQuotesType,//指示如何處理文本輸入中引號的智能替換。
    this.enableSuggestions = true,//啟用建議
    this.maxLines = 1,//最大行數
    this.minLines,//最小行數
    this.expands = false,
    this.maxLength,//允許輸入的最大長度
    @Deprecated(
      'Use maxLengthEnforcement parameter which provides more specific '
      'behavior related to the maxLength limit. '
      'This feature was deprecated after v1.25.0-5.0.pre.'
    )
    this.maxLengthEnforced = true,//是否允許超過輸入最大長度
    this.maxLengthEnforcement,
    this.onChanged,//文本內容變更時回調
    this.onEditingComplete,//輸入完成回調 主要配合TextInputAction.done使用
    this.onSubmitted,//提交 配合TextInputAction
    this.onAppPrivateCommand,
    this.inputFormatters,//驗證及格式
    this.enabled,//是否不可點擊
    this.cursorWidth = 2.0,//光標寬度
    this.cursorHeight,//光標高度
    this.cursorRadius,//光標圓角弧度
    this.cursorColor,//光標顏色
    this.selectionHeightStyle = ui.BoxHeightStyle.tight,
    this.selectionWidthStyle = ui.BoxWidthStyle.tight,
    this.keyboardAppearance,//鍵盤亮度
    this.scrollPadding = const EdgeInsets.all(20.0),//滾動到視圖中時,填充邊距
    this.dragStartBehavior = DragStartBehavior.start,
    this.enableInteractiveSelection = true,//長按是否展示【剪切/復制/粘貼菜單】
    this.selectionControls,
    this.onTap,//點擊時回調
    this.mouseCursor,//鼠標指針進入或懸停在鼠標指針上時的光標
    this.buildCounter,
    this.scrollController,//控制可滾動的小部件
    this.scrollPhysics,//確定[Scrollable]小部件的物理性質。
    this.autofillHints,//自動填充提示
    this.restorationId,//恢復ID以保存和恢復文本字段的狀態。
  })
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容