Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Is there any way to use viewModel in didUpdateWidget? #178

Open
@AsheKR

Description

When the arguments received from the widget changed, we wanted to clear the existing listener for the pagingController and populate a new one. How can i do this?

@override
void didUpdateWidget(convariant MyWidget oldWidget) {
 super.didUpdateWidget(oldWidget);
 
 if (oldWidget.path != widget.path) {
 _pagingController.removePageRequestListener(_pageRequestListener!);
 _pageRequestListener = null;
 _pageRequestListener = (pageKey) async {
 // This is where we use viewModel.
 }
 _pagingController.addPageRequestListener(_pageRequestListener!);
 _pagingController.refresh();
 }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /