简体   繁体   中英

Flutter - how to call a method on all providers?

I'm using the Provider package with my Flutter app. When the user signs out I would like to reset all the providers to avoid stale data upon the next sign in.

Currently the only way I know to access providers is via Provider.of<T>() which I will have to call once per provider. Is there a simpler way to do this?

If you want to clear all state, see this answer from the provider creator himself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM