2017-12-10 7 views
0

Flutterによって提供されたDismissibleの例の大半は、ListView内のアイテムを破棄しています。たとえば、thisです。 、私はそれをチェックしていることがわかりFlutter/Dartで却下を解除する

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を掘り:私は、テキストボックスを閉じた後、私はエラーを取得する

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() 

は、私が現在やっていることはこれですその状態は_resizeAnimationですが、私はそれがDismissibleコンストラクタまたはonDismissedハンドラの壮大な仕組みにどのように適合するかはわかりません。

答えて

0

エラーメッセージはかなり明確です。

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

空の関数では不十分です。アイテムが一旦解消されると、そのウィジェットをウィジェットツリーから削除する必要があります。つまり、でなければならず、ListViewからDismissibleを削除してください。

+0

これは明らかにエラーメッセージの内容です。この特定のケースでは、DimissibleはListViewの一部ではありません。 ListViewの一部ではないウィジェットを削除する方法が見つかりませんでした。 –

+0

あなたが提供したコードでは、 'ListView'の' Dismissible'_is_部分 – Darky

関連する問題