I have a requirement to display an alert each time that the user tries to save something in storage and it did not work (for example when the device storage is full). This alert has a button to try again which calls a local method of the page that displays it.
Having the alert in the page works as expected, however I have the same code repeated in many pages. The difference is that the “Try again” button calls different local handlers in each page that do different things.
Is it possible to unify all these alerts under one service? How could I call the corresponding handler if the alert is in a different class? Is this a correct approach to the problem? I would like to apply the same solution to the other alerts that are shared through my app and remove duplicated code.
I appreciate your support.