dart - 使用 Flutter/Dart 关闭 Dismissible

在大多数 Dismissible Flutter 提供的示例,它们正在关闭 ListView 中的项目。例如,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()

关闭文本框后,出现错误:

A dismissed Dismissible widget is still part of the tree.

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

挖掘 Dismissible source在,我看到它检查了 _resizeAnimation 的状态,但我不确定它如何适合 Dismissible 构造函数或 onDismissed的宏大方案处理程序。

最佳答案

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

key: UniqueKey(), 

https://stackoverflow.com/questions/47735143/

相关文章:

flutter - 在 Flutter 应用中立即显示应用主题

flutter - Flutter ListView、SliverList 等中的当前滚动偏移量

flutter - 按下按钮时如何在 Flutter 上更改文本样式

android - 如何在 Flutter 中为文本创建气泡? (WhatsApp 用户界面)

dart - Flutter:无法将类型为 lib1::Object 的值分配给类型为 lib2::

flutter - 如何处理在 flutter 中动态创建的复选框列表?

android - 如何在 Flutter 中让 Android 状态栏变亮

android - flutter 的 Image.network 无法在发布 apk 上运行

flutter - 如何在 Flutter 中调整 IconButton 的大小(高度和宽度)

dart - Flutter 中的特殊字符