autoDispose of Riverpod (8)

Foreword autoDispose is another modifier besides family, which can add an additional function to various Providers: automatic recycling. The life cycle of the various Providers used before is as long as the application, especially the Providers produced by the family, which cannot be recycled will lead to memory leaks. So if your Provider does not […]

The crash problem caused by onError/onSuccess execution of the observer task in DISPOSED state in RxJava

DoOnError is written in RxJava, but it still causes the application to crash. 1. Problem background 1.1 Crash stack 1.2 Write demo code to reproduce the same logic 2. Equivalent restoration of the problem – recurrence 2.1 Code location: io.reactivex.internal.operators.single.SingleCreate.Emitter#onError 3. Repair method 3.1 Solution 1: Set the global errorHandler, you need this one to […]

[Solved] Solve the problem of reporting the error A ViewModel was used after being disposed when using get_it to get the viewodel instance

get_it can get the nearest viewmodel instance globally, provided you need to register it import ‘package:get_it/get_it.dart’; import ‘package:http/http.dart’; import ‘package:lasttest/activity/login/login_view_model.dart’; import ‘package:lasttest/activity/splash/splash_view_model.dart’; GetIt getIt = GetIt.instance; //Initialize all viewmodels initGetIt(){ getIt.registerSingleton<SplashViewModel>(SplashViewModel(), signalsReady: true); getIt.registerSingleton<LoginViewModel>(LoginViewModel(), signalsReady: true); } When we use getIt.registerSingleton to register the viewmodel, there is no problem when we enter this page for […]