使用的組件名字為 TestField 組件
- TestField 配置 占位文字 設置??decoration 屬性??InputDecoration 中hintText
- 去掉輸入到 輸入框的間距?InputDecoration 中contentPadding? ==?EdgeInsets.zero
- 去掉邊框中的間距?InputDecoration 中?使用 isDense:true
- 設置輸入框內文字的顏色 樣式??TextField 中?style
- 文字居中?strutStyle
-
obscureText 設置輸入框為密碼類型
發現比較全的 屬性解說
Flutter輸入框TextField屬性介紹及相關問題_flutter 密碼輸入框-CSDN博客
樣式如下
完整代碼如下
Container(decoration: BoxDecoration(border: Border.all(color: Colors.blue),),child: const TextField(decoration: InputDecoration(hintText: "請輸入手機號碼",border: InputBorder.none,contentPadding: EdgeInsets.zero,isDense: true,),style: TextStyle(fontSize: 13),strutStyle: StrutStyle(fontSize: 13,leading: 0,height: 1.1,// 1.1更居中forceStrutHeight: true, // 關鍵屬性 強制改為文字高度),textAlign: TextAlign.center,),),