[英]How to change TextFormField height and Font color from default on Flutter
我想更改 TextFormField 高度和字體顏色。
TextFormField(
decoration: const InputDecoration(
border: OutlineInputBorder(),
filled: true,
icon: Icon(Icons.person),
hintText: 'Nick Name',
labelText: 'Nick Name',
),
),
我怎么寫呢?
您可以使用contentPadding調整大小和樣式屬性以更改顏色和文本相關屬性。
TextFormField(
decoration: const InputDecoration(
contentPadding: EdgeInsets.all(20), // change height
border: OutlineInputBorder(),
filled: true,
icon: Icon(Icons.person),
hintText: 'Nick Name',
labelText: 'Nick Name',
hintStyle:
TextStyle(color: Colors.amber)), // change hint text color
style: TextStyle(color: Colors.red), // change input text color
),
要增加TextFormField
高度,您可以在InputDecoration
中使用contentPadding
屬性並將值賦給vertical
參數,如下所示:
decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(vertical: 30),
要更改label
和hint
的字體顏色,您可以使用MaterialApp
中的Theme
來執行此操作,如下所示:
theme: ThemeData(
inputDecorationTheme: InputDecorationTheme(
labelStyle: TextStyle(color: Colors.black),
hintStyle: TextStyle(color: Colors.black),
)),
希望這可以幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.