源碼如下:
const TextField({
Key? key,
this.controller,//控制正在編輯文本
this.focusNode,// 獲取控制鍵盤焦點(diǎn)
this.decoration = const InputDecoration(),//邊框裝飾
TextInputType? keyboardType,//鍵盤類型
this.textInputAction,//鍵盤的操作按鈕類型
this.textCapitalization = TextCapitalization.none,//配置大小寫鍵盤
this.style,//輸入文本樣式
this.strutStyle,//使用的支柱風(fēng)格
this.textAlign = TextAlign.start,//對(duì)齊方式 值為 left穿香、 right 、center绎速、 justify 皮获、 start、 end
this.textAlignVertical,//文本垂直方向?qū)R方式 纹冤。 值為 top 洒宝、 center 、 bottom
this.textDirection,//文本方向 rtl(right to left) ltr(left to right)
this.readOnly = false,//只讀(當(dāng)true 粘貼和剪切將被禁用:暫時(shí)沒(méi)實(shí)踐過(guò)等以后實(shí)踐再補(bǔ)充)
ToolbarOptions? toolbarOptions,//工具欄選項(xiàng)的配置
this.showCursor,//是否顯示光標(biāo)
this.autofocus = false,//是否自動(dòng)對(duì)焦
this.obscuringCharacter = '?',//隱藏內(nèi)容時(shí)萌京,顯示的文字
this.obscureText = false,//是否隱藏內(nèi)容雁歌,例如密碼格式
this.autocorrect = true,//是否自動(dòng)校正
SmartDashesType? smartDashesType,//指示如何處理文本輸入中破折號(hào)的智能替換
SmartQuotesType? smartQuotesType,//指示如何處理文本輸入中引號(hào)的智能替換。
this.enableSuggestions = true,//啟用建議
this.maxLines = 1,//最大行數(shù)
this.minLines,//最小行數(shù)
this.expands = false,
this.maxLength,//允許輸入的最大長(zhǎng)度
@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,//是否允許超過(guò)輸入最大長(zhǎng)度
this.maxLengthEnforcement,
this.onChanged,//文本內(nèi)容變更時(shí)回調(diào)
this.onEditingComplete,//輸入完成回調(diào) 主要配合TextInputAction.done使用
this.onSubmitted,//提交 配合TextInputAction
this.onAppPrivateCommand,
this.inputFormatters,//驗(yàn)證及格式
this.enabled,//是否不可點(diǎn)擊
this.cursorWidth = 2.0,//光標(biāo)寬度
this.cursorHeight,//光標(biāo)高度
this.cursorRadius,//光標(biāo)圓角弧度
this.cursorColor,//光標(biāo)顏色
this.selectionHeightStyle = ui.BoxHeightStyle.tight,
this.selectionWidthStyle = ui.BoxWidthStyle.tight,
this.keyboardAppearance,//鍵盤亮度
this.scrollPadding = const EdgeInsets.all(20.0),//滾動(dòng)到視圖中時(shí)知残,填充邊距
this.dragStartBehavior = DragStartBehavior.start,
this.enableInteractiveSelection = true,//長(zhǎng)按是否展示【剪切/復(fù)制/粘貼菜單】
this.selectionControls,
this.onTap,//點(diǎn)擊時(shí)回調(diào)
this.mouseCursor,//鼠標(biāo)指針進(jìn)入或懸停在鼠標(biāo)指針上時(shí)的光標(biāo)
this.buildCounter,
this.scrollController,//控制可滾動(dòng)的小部件
this.scrollPhysics,//確定[Scrollable]小部件的物理性質(zhì)靠瞎。
this.autofillHints,//自動(dòng)填充提示
this.restorationId,//恢復(fù)ID以保存和恢復(fù)文本字段的狀態(tài)。
})