admin管理员组

文章数量:1278789

For the ideal separation of view and logic how does one initialize a mobx store that makes an asynchronous API call, for a page/widget without the use of FutureBuilder? e.g. I log in and navigate to home page, home page needs to initialize 3 stores to get a bunch of info and display it.

I don’t believe initialization in initState is the way to do it as initState cannot be async and making an async call without await inside initState for something that impacts the UI directly is not ideal?

One could initialize the stores at startup but most of the API calls requiring authentication happen post login. For the stores that don’t need authentication it’s simple to initialize them at startup.

Trying to find the cleanest way to do this following a design pattern.

This question most likely applies to other state management methods also.

本文标签: dartCorrect use of MobX stores without using FutureBuilder in FlutterStack Overflow