简体   繁体   中英

Is there any way to re-render a widget outside Stateful class in flutter

Iam working with data table, and i want to add remove action on every data rows. I use this as my reference code: Screen Data Source I insert a remove button as the element of the last cell, and use _dessert.remove(desert) to remove the row from the list. The row is already deleted, but the element stay in the table unless I refresh the page. Any solution for this?

If you can get BuildContext, you can use:

(context as Element).markNeedsBuild()

but it's not recommended!

Use setState. It will re-render the widgets.

setState(() { _myState = newValue; });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM