Skip to content

Widget state attributes are not updated when widget updates #146

Open
@lhengl

Description

@lhengl

Hi first off, great package.

However, what I noticed is that when I change attributes in the widget, it is not reflected in the UI. This is because the attributes are stored in the state object during initState, so doing a rebuild of the IntroSlider widget will not update the UI. This is not a great user experience when trying to set up the widget for the first time using hot reload to see the changes in the UI.

May I suggest we add a didWidgetUpdate() in the state class or using the widget attributes directly rather than saving them as a state variable? What I noticed is that they are mostly defined as late final anyway, why not just refer to them as widget.attribute?

The workaround has been to use a UniqueKey() to force the widget to re-initialise itself on each refresh - however I feel that this must not be very efficient in the case where we need to change the widget attribute frequently (an example I could think of is when we need to enable/disable navigation based on some validation rules as user inputs data).

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