Flutter 文本字段中的标签文本不会居中?
我试图将我的labelText集中在文本字段中,但我无法让它集中在我的生活中。有人看到一个显而易见的问题会导致这种情况吗?谢谢Flutter 文本字段中的标签文本不会居中?,flutter,dart,Flutter,Dart,我试图将我的labelText集中在文本字段中,但我无法让它集中在我的生活中。有人看到一个显而易见的问题会导致这种情况吗?谢谢 Container( width: MediaQuery.of(context).size.width * .85, height: M
Container(
width:
MediaQuery.of(context).size.width * .85,
height:
MediaQuery.of(context).size.height * .12,
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: Colors.white),
borderRadius: BorderRadius.all(
Radius.circular(12))),
child: TextField(
textAlign: TextAlign.center,
controller: _notesEditingController,
obscureText: false,
decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(vertical: 40.0),
fillColor: Colors.white,
border: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(12.0)),
),
labelText: 'notes',
labelStyle: TextStyle(
color: Color.fromRGBO(105, 105, 105, 10),
)),
),
),
请尝试此操作,替换
labelText
并使用hintText
Container(
child: TextField(
textAlign: TextAlign.center,
decoration: InputDecoration(
hintText: 'Center the text',
),
),
)
您需要创建自定义组件,请检查下面的