tryUnlockViaDialog method
Tries to unlock this padlock using a dialog.
Implementation
Future<void> tryUnlockViaDialog(BuildContext context, EscapeGame escapeGame) async {
if (this is PadlockSequence) {
Padlock? firstLocked = (this as PadlockSequence).firstLocked;
while (firstLocked != null) {
if (!context.mounted) {
return;
}
await firstLocked.tryUnlockViaDialog(context, escapeGame);
tryUnlock(null);
Padlock? newFirstLocked = (this as PadlockSequence).firstLocked;
if (firstLocked == newFirstLocked || newFirstLocked == null) {
return;
}
firstLocked = newFirstLocked;
}
}
if (context.mounted) {
await showDialog(
context: context,
builder: (context) =>
_buildPadlockDialog(context, escapeGame, this) ??
EscapeGameAlertDialog.oneChild(
actions: const [EscapeGameAlertDialogCloseButton(cancel: false)],
child: Text('Dialog not found for padlock type "${runtimeType.toString()}".'),
),
);
}
}