Calling a method with Provider.of(context) inside of dispose() method cause “Looking up a deactivated widget’s ancestor is unsafe.”
It seems like you are trying to close something which is defined in your AppProvider class. If AppProvider class is extending ChangeNotifier, the change notifier class provides dispose method, you can override it and then call the close function inside the AppProvider class only.