fix: issue-1049, issue-1039, issue-1035, issue-1032, issue-995, issue-993

This commit is contained in:
misha
2026-08-26 08:42:47 +03:00
parent 6265e865e9
commit de7bf8dc19
22 changed files with 509 additions and 192 deletions

View File

@@ -0,0 +1,22 @@
class NotificationPermissionRequester {
Future<void>? _inFlight;
/// Coalesces overlapping calls so the OS prompt is shown at most once at a time.
Future<void> requestOnce(Future<void> Function() requestPermission) async {
final inFlight = _inFlight;
if (inFlight != null) {
await inFlight;
return;
}
final future = requestPermission();
_inFlight = future;
try {
await future;
} finally {
if (identical(_inFlight, future)) {
_inFlight = null;
}
}
}
}