Ems
Ems

Reputation: 165

Is there an event listener whenever view is active after a navigator pop?

I have been developing an app using flutter, which has a bookmark section. In the bookmark page, you can click an entry to a view more page. While in the view more page, there is an option to unbookmark the entry.

Is there a way to communicate between flutter pages? Since, I want to sync the bookmarked entries between pages (in this case unbookmark the entry and updates the bookmark page once navigator pop is used). The initState() only runs once and will not be called on succeeding navigator pops, while didUpdateWidget() seems to inefficient.

Upvotes: 1

Views: 884

Answers (1)

Rainer Wittmann
Rainer Wittmann

Reputation: 7988

Why not provide a method removeFromList(bookmark) to the ViewMorePage as a constructor attribute.

void removeFromList(bookmark) {
  setState(() => bookmarkList.remove(bookmark));
}

The setState forces the widget to rebuild with the shorter list of bookmarks. Does that help?

Upvotes: 0

Related Questions