jonataslaw / getx

Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get.
MIT License
10.19k stars 1.6k forks source link

Proper way to put GetxService in 5.0 rc #2718

Open LanceQuare opened 1 year ago

LanceQuare commented 1 year ago

ATTENTION: DO NOT USE THIS FIELD TO ASK SUPPORT QUESTIONS. USE THE PLATFORM CHANNELS FOR THIS. THIS SPACE IS DEDICATED ONLY FOR FEATURE REQUESTS

Is your feature request related to a problem? Please describe. Since Get.putAsync seems removed or deprecated from Getx, what is proper way to put GetxSevice, please advise.

Describe the solution you'd like Add Get.putAsync() back or other alternatives.

Describe alternatives you've considered N/A

lwx123 commented 1 year ago

遇到相同的问题,没有这个方法Get.putAsync()

OthmanShaker commented 1 year ago

same issue here

maybe like this?

await Get.putOrFind<Repository>( () => Repository()).onReady();
ltq918 commented 7 months ago

I also encountered this problem, I changed

await Get.putAsync(() => AuthService().init());

to

Get.put(AuthService());
await Get.find<AuthService>().init();

If I don't do this, my authentication status will be returned too late, so that the page I open through shortcut will not be able to obtain the correct authentication status.

Note that this will have a side effect, init will be executed twice, perhaps you can move the code from init into a custom function to avoid this problem