Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
'Discount (%) :',
style: TextStyle(fontSize: 14),
),
Container(
width: 40,
height: 30,
decoration: BoxDecoration(
color: Colors.grey.shade200,
border: const Border.fromBorderSide(BorderSide.none),
borderRadius: BorderRadius.circular(10)),
child: Center(
child: TextField(
onChanged: (text) {
getDiscountedAmount(text);
},
cursorHeight: 18,
keyboardType: TextInputType.number,
controller: discountController,
decoration: const InputDecoration(
floatingLabelBehavior: FloatingLabelBehavior.never,
border: InputBorder.none,
contentPadding:
EdgeInsets.only(bottom: 12, right: 2),
labelText: ' 0',
labelStyle: TextStyle(
fontSize: 14,
),
),
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 14,
),
),
),
),
],
),
我用 SingleChildScrollView 包裹了 Column。列包含 TextField 作为最后一个小部件。当我单击文本字段时,默认情况下我的键盘与文本字段重叠。我看不到文本字段中的输入是什么。即使打开键盘,我也想看到文本字段。 如何在颤振中实现这一点?请指导我。预先感谢。
我希望屏幕向上滚动,并且即使打开键盘,文本字段也应该可见。
我理解的问题是,当您点击文本字段时,键盘会弹出,并且会过度循环。 要解决此问题,您可以设置
return Scaffold(
resizeToAvoidBottomInset : false,
body: YourWidgets(),
);
希望这会有所帮助