Stacked-Org / stacked

A Flutter application architecture created from real world scenarios
MIT License
977 stars 255 forks source link

[feature]: ability to unregister dialogs #1119

Closed WinXaito closed 1 month ago

WinXaito commented 3 months ago

Is your feature request related to a problem? Please describe.

In m'y application, I use a "FeatureSystem", it means I can activate or deactivate some functionalities with a license. (it's a little like a plugin system, but the code loading is not dynamic, because of dart).

Some of the functionalities use dialogs. So I'm able to register these dialogs when the package is initialised, but I have no way to unregister them when I dispose my package.

Describe the solution you would like

It would be cool if we can have a method like unregisterCustomDialogBuilders(List<dynamic>) here: https://github.com/Stacked-Org/services/blob/main/lib/src/dialog/dialog_service.dart#L25

Additional Context

No response

FilledStacks commented 2 months ago

@WinXaito Dos leaving them there cause any issues.

I like the idea of unregistering, but I'm wondering if the same functionality can't be achieved simply by not calling the showDialog function for that variant

WinXaito commented 1 month ago

Sorry for the delayed answer.

Yeah, at this time, I don't unregister them and that works fine.

I was wondering if it could be an issue if I register multiple time the same dialog?

In my software, I have a "features" system. Unlike standard plugin (as it is not possible with dart). All my feature are in my soft, but some can be enabled/disabled by a license or by the user itself. So, a feature can be enabled/disabled multiple time and the enabling action will call registerCustomDialogBuilders with the dialog used by the feature.

FilledStacks commented 1 month ago

@WinXaito yes that would not be an issue, the dialog would be overwritten with the new registration since we use a map to track the dialogs.

So if you register for the same enum twice, you'll have the last dialogFunction called when showing a dialog for that enum