Flutter 如何在颤振时从默认值更改TextFormField高度和字体颜色
我想更改TextFormField的高度和字体颜色Flutter 如何在颤振时从默认值更改TextFormField高度和字体颜色,flutter,Flutter,我想更改TextFormField的高度和字体颜色 TextFormField( decoration: const InputDecoration( border: OutlineInputBorder(), filled: true, icon: Icon(Icons.person), hintTex
TextFormField(
decoration: const InputDecoration(
border: OutlineInputBorder(),
filled: true,
icon: Icon(Icons.person),
hintText: 'Nick Name',
labelText: 'Nick Name',
),
),
如何编写它?您可以使用内容填充来调整大小和样式属性来更改颜色和与文本相关的属性
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
),
您可以使用contentPadding调整大小,并使用style属性更改颜色和与文本相关的属性
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),
要更改标签
和提示
的字体颜色,您可以使用主题
内材质应用
进行更改,如下所示:
theme: ThemeData(
inputDecorationTheme: InputDecorationTheme(
labelStyle: TextStyle(color: Colors.black),
hintStyle: TextStyle(color: Colors.black),
)),
希望这有帮助。要增加
TextFormField
高度,可以在InputDecoration
中使用contentPadding
属性,并将垂直
参数的值设置为:
decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(vertical: 30),
要更改标签
和提示
的字体颜色,您可以使用主题
内材质应用
进行更改,如下所示:
theme: ThemeData(
inputDecorationTheme: InputDecorationTheme(
labelStyle: TextStyle(color: Colors.black),
hintStyle: TextStyle(color: Colors.black),
)),
希望这有帮助。嗨,这个“主题”属性去哪里了?嗨,这个“主题”属性去哪里了?