-1
if (ref.read(connectivityStatusProviders)) {
   _goBackToHome(ref: ref, isUserCanceled: false);
 }
void _goBackToHome(
      {required WidgetRef ref, required bool isUserCanceled}) async {
//-----------------
ref.watch(apiPostFutureProvider(registerResult))
.whenData((settingResponse) {
             // this block not trigger, but the response is OK
//------------------
          ref.read(goRouterProvider).pushReplacementNamed(
                AppRoutesName.posInfoRoute,
                extra: widget.posInfo,
              );
//-----------------
            },
          );
}

//------------------------------ I try chatGPT, it's answer: "you can use the whenData method provided by Riverpod."

Mo_Ho
  • 9
  • 2

1 Answers1

0

I fixed it with the help of: selectAsync https://riverpod.dev/docs/concepts/combining_providers

final configProvider = StreamProvider<Configuration>(...);

final productsProvider = FutureProvider<List<Product>>((ref) async {
  // Listens only to the host. If something else in the configurations
  // changes, this will not pointlessly re-evaluate our provider.
  final host = await ref.watch(configProvider.selectAsync((config) => config.host));

  return dio.get('$host/products');
});
Mo_Ho
  • 9
  • 2