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.I有用SingleChildScrollView包装的列.Column包含作为最后一个小部件的TextField.当我点击文本字段时,默认情况下,我的键盘会与文本字段重叠.我看不到文本字段中的输入是什么.即使在键盘打开的情况下,我也希望看到Textfield. 如何在Flutter 翼中做到这一点?请给我带路.先谢谢你.

我希望屏幕滚动起来,文本字段应该是可见的,即使键盘是打开的.

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.

推荐答案

以下是您问题的正确解决方案.

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

如果您阅读文档中的"ResizeToAvoidBottomInset",它会指出,

/// If true the [body] and the scaffold's floating widgets should size
/// themselves to avoid the onscreen keyboard whose height is defined by the
/// ambient [MediaQuery]'s [MediaQueryData.viewInsets] `bottom` property.
///
/// For example, if there is an onscreen keyboard displayed above the
/// scaffold, the body can be resized to avoid overlapping the keyboard, which
/// prevents widgets inside the body from being obscured by the keyboard.
///
/// Defaults to true.
final bool? resizeToAvoidBottomInset;

晚些时候谢谢我!干杯!

Flutter相关问答推荐

当仅点击一行时,所有行都被选中

如何解决这个错误,同时获得的高度的小部件,因此高度的可用工作区域在Flutter ?

Android Emulator冻结,但在调整窗口大小时解冻

在保持标高=1的情况下更改AppBar立面 colored颜色 /遮罩

将图标呈现在Flutter 克牌小工具的角落上

在flutter web上渲染多个Youtube视频

如何在Flutter Webview包中触发基于URL导航的事件

集装箱堆放和定位时的高度问题

如何对齐 AppBar Actions 中的文本?

Flutter Riverpod 对提供者状态的变化做出react

PreferredSizeWidget类不能用作混合,因为它既不是混合类也不是混合

Flutter - firebase_auth_web 5.4.0 依赖于 intl ^0.17.0 但我必须使用更高版本 (intl ^0.18.0)

什么最接近 Dart 的 List.asMap().forEach() 返回列表?

为什么 ref.watch(otherProvider.stream) 在 Riverpod 2.x 中被弃用并且将在 3.x 中被删除?

在 Flutter 中读取 Firebase 数据库数据时遇到问题

如何获取 android 和 Ios (flutter) 的 CircularProgress 指示器?

如何在 flutter 中更改日期 Select 器 colored颜色 ?

Flutter如何从左到右连续 Select 多个列表项而不跳过任何

扫描flutter生成的二维码后如何弹出文本字段值

解密 Modulr 安全令牌