【发布时间】:2020-12-10 15:57:32
【问题描述】:
您好,我正在处理颤动,需要使用与所有屏幕尺寸匹配的 MediaQuery 使我的 TextField 响应。我尝试了两种方法,这两种方法都不适用于平板电脑,这是第一个
Container(
height: 100.0,
width: 300.0,
child: TextField(
cursorColor: Colors.black,
style: TextStyle(color: Colors.pinkAccent),
controller: itemNameController,
keyboardType: TextInputType.text,
decoration: new InputDecoration(
border: OutlineInputBorder(),
labelText: 'Hello input here',
isDense: true,
contentPadding: EdgeInsets.only(
left: 5, bottom: 11, top: 11, right: 5),
),
),
),
第二种方式是
TextField(
cursorColor: Colors.black,
style: TextStyle(color: Colors.pinkAccent, height:
MediaQuery.of(context).size.height/50),
controller: itemNameController,
keyboardType: TextInputType.text,
decoration: new InputDecoration(
border: OutlineInputBorder(),
labelText: 'Hello input here',
isDense: true,
contentPadding: EdgeInsets.only(
left: 5, bottom: 11, top: 11, right: 5),
),
),
他们都没有反映在平板电脑上。谢谢
【问题讨论】:
-
使用第一个实现并将容器的宽度设置为double.infinity
标签: flutter uitextfield flutter-layout