Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
490 views
in Technique[技术] by (71.8m points)

Dismissing a Dismissible with Flutter/Dart

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

What I am currently doing is 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()

After I dismiss the text box, I get the error:

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.

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.

question from:https://stackoverflow.com/questions/47735143/dismissing-a-dismissible-with-flutter-dart

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

key: UniqueKey(), 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...