I've started with Flutter and I´m currently working on a project which allows the application to mute the phone if you´re at a specified position. I´ve implemented Google Maps etc. Everything works except that the marker isn´t visible but that´s another question. My question is how I can mute the phone with an app. I didn´t find a solution anywhere.
Asked
Active
Viewed 456 times
2 Answers
0
I really doubt that Flutter provides such a fuctionality out of the box. I suggest searching 3rd party packages for it. If that fails you can implement this feature nativly on each platform using Platform Channels.
HERE you can find how to achieve this on Android, and HERE how to do it on IOS.

Karol Lisiewicz
- 654
- 5
- 15
0
There are 2 plugins avelable for this
- sound_mode: https://pub.dev/packages/sound_mode
Features,
- Detect device's current sound mode (both IOS & Android)
- Able to toggle between Normal, Silent & Vibrate mode (only Android)
- Grant Do No Disturb permissions for devices above platform version Android 6.0 (API 23) (only Android)
- flutter_mute: https://pub.dev/packages/flutter_mute
Features,
- Detect device current ringer mode
- Able to toggle between Normal, Silent & Vibrate mode (Only for Android)
- Grant notification policy access for devices above platform version Android 7.0 (API 24)
Both Pulgins can toggle your Android base device (Not IOS device)
Example(Android),
import 'package:sound_mode/utils/ringer_mode_statuses.dart';
// Handle Platform Exceptions for devices running above Android 6.0
try {
await SoundMode.setSoundMode(RingerModeStatus.silent);
} on PlatformException {
print('Please enable permissions required');
}
Example(ISO):
RingerModeStatus ringerStatus = RingerModeStatus.unknown;
// The one second delay is needed to get accurate results on IOS...
Future.delayed(const Duration(seconds: 1), () async {
try {
ringerStatus = await SoundMode.ringerModeStatus;
} catch (err) {
ringerStatus = RingerModeStatus.unknown;
}
print(ringerStatus);
});