hide method
Hides a specific dialog or the most recently shown dialog.
If a key is provided, the dialog with that specific key is hidden.
If no key is provided, the dialog at the top of the stack (the most recent)
is hidden.
Throws a CustomException if the provided key is not found in the stack or if there's an error during the hiding process.
Implementation
void hide([UniqueKey? key]) {
try {
if (isActive) {
_DialogEntry entry =
key != null
? _dialogsStack.firstWhere(
(element) => element.key == key,
orElse:
() =>
throw CustomException(
message:
'حصل خطأ في احدى الميزات, رمز الخطأ [SKM-404]',
),
)
: _dialogsStack.last;
_dialogsStack.remove(entry);
entry.controller?.close();
}
} on CustomException {
rethrow;
} catch (e, s) {
throw CustomException(
message: 'حصل خطأ في احدى الميزات, رمز الخطأ [SMK-null]',
hiddenMessage: '{\ne: $e\ns:$s\n}',
);
}
}