本文介绍了用Flutter / Dart消除可解雇的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Flutter提供的大多数示例中,它们正在关闭ListView中的项目。例如,。

In the majority of the Dismissible examples provided by Flutter, they are dismissing items within a ListView. For example, this.

我目前正在做什么:

Widget build(BuildContext context) {
  return new Scaffold(
    key: _scaffoldKey,
    appBar: new AppBar(
      title: new Text(widget.title),
    ),
    body: new Center(
      child: new ListView(
        children: <Widget>[
          new Dismissible(
            key: personKey,
            child: new Text('Dismiss Me'),
            onDismissed: (DismissDirection direction) {}
          )
        ],
      ) // end ListView
    ) // end Center
  ); // end return
} // end build()

关闭文本框后,错误:

请确保实现onDismissed处理程序并立即在处理程序触发后立即从应用程序中删除Dismissible小部件。

Make sure to implement the onDismissed handler and to immediately remove the Dismissible widget from the application once that handler has fired.

在Dismissible 在,我看到它检查了的状态_resizeAnimation ,但是我不确定它是否适合 Dismissible 构造函数或 onDismissed 处理程序。

Digging through the Dismissible source at , I see that it checks that status of _resizeAnimation, but I'm not sure how that fits into the grand scheme of a Dismissible constructor or onDismissed handler.

推荐答案

请尝试一下。我提供了UniqueKey作为Dismissible小部件的键,它工作得很好。

Please try this.I provided UniqueKey as key to Dismissible widget, and it worked just fine.

key: UniqueKey(), 

这篇关于用Flutter / Dart消除可解雇的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 17:51