'How can I apply Navigator.pop given the status of a provider within a ModalBottomSheet flutter?

I have the following method that launches a bottom sheet modal and inside that modal, I have a button that is responsible for carrying out a process,

enter image description here

the button calls a method of a provider and within that method I have several status changes, what I want is that when the status is Payed the modal closes automatically, I've already tried adding Navigator.pop, any suggestions?

enter image description here

The _toPay method triggers the process to make the payment and calls the provider's register method.

enter image description here

This is the provider method

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source