scenario where using findAncestorWidgetOfExactType() will lead to failure to rebuild

143 views
Skip to first unread message

Kent Tong

unread,
Mar 22, 2020, 5:47:35 AM3/22/20
to Flutter Development (flutter-dev)
Hi,

I understand using an InheritedWidget is recommended over findAncestorWidgetOfExactType() when a widget depends on an ancestor widget. However, I can't think of a scenario where findAncestorWidgetOfExactType() will lead to failure to rebuild. If as a widget is read-only, the only way it changes is when it is replaced by a new one. Then the whole subtree will be rebuilt and so the descendant widget will be replaced by a new one  and its element will be updated. Am I missing something?

Thanks in advance!
Reply all
Reply to author
Forward
0 new messages