我试图将我的labelText居中在TextField中,但是我无法终生使它居中。有人看到一个明显的问题会导致此吗?谢谢!
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),
)),
),
),
答案 0 :(得分:1)
请尝试此操作,替换labelText
并使用hintText
Container(
child: TextField(
textAlign: TextAlign.center,
decoration: InputDecoration(
hintText: 'Center the text',
),
),
)