即使键盘在颤动中打开,我怎样才能看到包装在 SingleChildScrollView 中的 Column 中的最后一个小部件?

问题描述 投票:0回答:1
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,
                      ),
                    ),
                  ),
                ),
              ],
            ),

This is how screen looks when keyboard is opened.我用 SingleChildScrollView 包裹了 Column。列包含 TextField 作为最后一个小部件。当我单击文本字段时,默认情况下我的键盘与文本字段重叠。我看不到文本字段中的输入是什么。即使打开键盘,我也想看到文本字段。 如何在颤振中实现这一点?请指导我。预先感谢。

我希望屏幕向上滚动,并且即使打开键盘,文本字段也应该可见。

This discount row has a textfield. when i click on it, keyboard appears and textfield goes behind the keyboard. i want to whole screen to slide up to see the textfield even when the keyboard is opened.

flutter keyboard textfield singlechildscrollview
1个回答
0
投票

我理解的问题是,当您点击文本字段时,键盘会弹出,并且会过度循环。 要解决此问题,您可以设置

return Scaffold(
resizeToAvoidBottomInset : false,
      body: YourWidgets(),
    ); 

希望这会有所帮助

© www.soinside.com 2019 - 2024. All rights reserved.