相关疑难解决方法(0)

以编程方式滚动到ListView的末尾

我有一个可滚动项ListView,其中项目的数量可以动态更改.每当一个新项目添加到列表的末尾,我想以编程方式滚动ListView到最后.(例如,聊天消息列表,最后可以添加新消息)

我的猜测是我需要ScrollController在我的State对象中创建一个并将其手动传递给ListView构造函数,以便稍后在控制器上调用animateTo()/ jumpTo()method.但是,由于我无法轻易确定最大滚动偏移,因此似乎不可能简单地执行一种scrollToEnd()操作(而我可以轻松地传递0.0以使其滚动到初始位置).

有没有一种简单的方法来实现这一目标?

使用reverse: true对我来说不是一个完美的解决方案,因为当只有少量项目适合ListView视口时,我希望项目在顶部对齐.

flutter

51
推荐指数
9
解决办法
3万
查看次数

Flutter TextFormField被键盘隐藏

注意:我使用Navigator.of(context).push来推送ModalRoute,

嗨,我的页面上ModalRouteTextFormField,但是当键盘显示时,输入正被键盘隐藏,如何解决呢?

在此处输入图片说明

return Container(
      child: ListView(
          children: <Widget>[
            //other widget
            SizedBox(height: _qtyAnimation.value),
            Row(
              children: <Widget>[
                Expanded(
                  child: Text(
                    "Jumlah",
                    style: TextStyle(fontWeight: FontWeight.bold),
                  ),
                ),
                SizedBox(
                  width: 145.0,
                  child: TextFormField(
                    focusNode: _qtyFocusNode,
                    controller: qty,
                    keyboardType: TextInputType.number,
                    textAlign: TextAlign.center,
                    decoration: InputDecoration(
                      contentPadding: EdgeInsets.all(0.0),
                      prefixIcon: IconButton(
                        icon: Icon(Icons.remove),
                        onPressed: () {},
                      ),
                      border: OutlineInputBorder(
                        borderSide:
                            BorderSide(color: Colors.grey, width: 0.1),
                      ),
                      suffixIcon: IconButton(
                        icon: Icon(Icons.add),
                        onPressed: () {},
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ],
    );
Run Code Online (Sandbox Code Playgroud)

多数民众赞成在我的代码,我尝试与focusnode和更多,仍然相同的结果请帮助我

dart flutter flutter-layout

7
推荐指数
5
解决办法
6001
查看次数

标签 统计

flutter ×2

dart ×1

flutter-layout ×1