No notification permission enforcement on web

This commit is contained in:
2026-02-25 18:39:39 +08:00
parent 0173e91d94
commit aef88de54b
3 changed files with 99 additions and 45 deletions
+29 -13
View File
@@ -1,4 +1,5 @@
import 'package:permission_handler/permission_handler.dart';
import 'package:flutter/foundation.dart' show kIsWeb;
/// Information about a permission that the application cares about.
///
@@ -24,19 +25,34 @@ class PermissionInfo {
/// it should be expanded as new features are added. Declaring a permission
/// here ensures it appears on the permissions screen and is considered when
/// performing bulk checks/requests.
const List<PermissionInfo> appPermissions = [
PermissionInfo(
permission: Permission.notification,
label: 'Notifications',
description: 'Deliver alerts and sounds',
),
PermissionInfo(
permission: Permission.location,
label: 'Location',
description: 'Access your location for geofencing',
),
// add new permissions here as necessary
];
List<PermissionInfo> get appPermissions {
// On web, browser notifications are handled separately; avoid including
// the notification runtime permission in the app permissions list so the
// permissions screen and bulk request flow do not attempt to enforce it.
if (kIsWeb) {
return [
PermissionInfo(
permission: Permission.location,
label: 'Location',
description: 'Access your location for geofencing',
),
];
}
return [
PermissionInfo(
permission: Permission.notification,
label: 'Notifications',
description: 'Deliver alerts and sounds',
),
PermissionInfo(
permission: Permission.location,
label: 'Location',
description: 'Access your location for geofencing',
),
// add new permissions here as necessary
];
}
/// Returns the current status for every permission in [appPermissions].
Future<Map<Permission, PermissionStatus>> getAllStatuses() async {