flutter_dnd

pub package A Flutter plugin to manage Do Not Disturb settings on Android.

Usage

To use this plugin, add flutter_dnd as a dependency in your pubspec.yaml file.

Make sure you add the following permissions to your Android Manifest

<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY"/>

Example

// Import package
import 'package:flutter_dnd/flutter_dnd.dart';

if (await FlutterDnd.isNotificationPolicyAccessGranted) {
	await FlutterDnd.setInterruptionFilter(FlutterDnd.INTERRUPTION_FILTER_NONE); // Turn on DND - All notifications are suppressed.
} else {
	FlutterDnd.gotoPolicySettings();
}

Other filters

FilterDescription
INTERRUPTION_FILTER_ALLNo notifications are suppressed.
INTERRUPTION_FILTER_PRIORITYAllow priority notifications.
INTERRUPTION_FILTER_NONESuppress all notifications.
INTERRUPTION_FILTER_ALARMSAllow alarm notifications.

Libraries

flutter_dnd