How to mock Navigator.push result in an onchange callback

Viewed 33

I have this widget inside a Page :

FormSelectedWidget(
  onChanged: () async {
    Location? result = await Navigator.pushNamed(
      context,
      RouteName.searchLocationScreen,
    ) as Location?;

    if (result != null) {
      context.read<MyActionCubit>().updateForm();
    }
  }
)        

how do i verify updateForm() is called once ?

verify(
  () => MyActionCubit.updateForm(),
).called(1);

is there any way to mock Location? result using mocktail ?

0 Answers
Related