【问题标题】:TextFormField Cursor bubble and scrolling issue in flutter颤动中的TextFormField光标气泡和滚动问题
【发布时间】:2021-11-02 06:06:43
【问题描述】:

滚动页面时,光标气泡与其他小部件和Appbar 重叠。你能帮帮我吗?

这个 GIF 文件显示了我的问题

小部件

class Sample extends StatefulWidget {
  Sample({Key? key}) : super(key: key);

  @override
  _SampleState createState() => _SampleState();
}

class _SampleState extends State<Sample> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: true,
      extendBodyBehindAppBar: false,
      extendBody: false,
      appBar: AppBar(
        title: Text('AppBar'),
        backgroundColor: Colors.orange,
        elevation: 0.0,
      ),
      body: SafeArea(
        child: Column(
          children: [
            ListView(
              addAutomaticKeepAlives: true,
              shrinkWrap: true,
              children: [
                Container(
                  color: Colors.yellow,
                  height: 70,
                  width: MediaQuery.of(context).size.width,
                  child: Center(
                    child: Text(
                      'This part want not be scrolled',
                      style: TextStyle(color: Colors.red),
                    ),
                  ),
                )
              ],
            ),
            Expanded(
              child: Scrollbar(
                child: ListView(
                  shrinkWrap: true,
                  scrollDirection: Axis.vertical,
                  children: [
                    Table(
                      children: [
                        TableRow(children: [
                          Column(
                            children: [Text('Name')],
                          ),
                          Column(
                            children: [
                              TextFormField(decoration: InputDecoration())
                            ],
                          )
                        ]),
                        TableRow(
                          children: [
                            Column(
                              children: [Text('Name')],
                            ),
                            Column(
                              children: [
                                TextFormField(decoration: InputDecoration())
                              ],
                            )
                          ],
                        ),
                        TableRow(
                          children: [
                            Column(
                              children: [Text('Name')],
                            ),
                            Column(
                              children: [
                                TextFormField(decoration: InputDecoration())
                              ],
                            )
                          ],
                        ),
                        TableRow(
                          children: [
                            Column(
                              children: [Text('Name')],
                            ),
                            Column(
                              children: [
                                TextFormField(decoration: InputDecoration())
                              ],
                            )
                          ],
                        ),
                      ],
                    ),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

【问题讨论】:

    标签: flutter listview cursor vertical-scrolling flutter-textformfield


    【解决方案1】:

    Table 小部件用于不可滚动的GridView。它一次渲染完整的Table 小部件树并保持其子级存活。你可以认为它类似于SingleChildScrollView。在您的Table 中,孩子只生成一次并且即使它在屏幕上不可见也不调用 dispose,这是Table Widget 的本质。要对此进行测试,您需要创建一个 statefullWidget 并将其传递给列子项。

    了解更多

    解决方案 你可以简单地使用ListView.Builder

    【讨论】:

    • 谢谢。你的回答是正确的。当我删除表格时,它运行完美
    猜你喜欢
    • 2019-09-26
    • 1970-01-01
    • 2020-01-17
    • 2020-10-11
    • 2021-08-17
    • 2016-03-10
    • 2020-05-11
    • 1970-01-01
    • 2015-02-24
    相关资源
    最近更新 更多