You can try to pop dialog with the same BuildContext you opened it
Eg: using contextA to showDialog, then use Navigator.of(contextA).pop() to close it
Many BuildContext with the same name "context" may confuse usage