rrousselGit / state_notifier

ValueNotifier, but outside Flutter and with some extra perks
MIT License
311 stars 28 forks source link

Use of the Future in the StateNotifier #47

Closed kmartins closed 3 years ago

kmartins commented 3 years ago

When I use the future in StateNotifier and the state is changed with the response this future, but the response arrives after the dispose of the Statenotifier.

Do I have to verify mounted before changed the state always?

Because I'm getting: Tried to use $runtimeType after `dispose` was called. Consider checking `mounted`.

rrousselGit commented 3 years ago

You should preferably override dispose to cancel pending futures.

kmartins commented 3 years ago

Right, but why do not replace assert (_debugIsMounted (), ‘’); for the if (mounted) in the set state?