A Flutter plugin allows you to check the status of Airplane Mode on iOS and Android mobile.
Find the example wiring in the example app
Add the following line to pubspec.yaml
:
dependencies:
airplane_mode_checker: ^3.1.0
Add the following import to your Dart code:
import 'package:airplane_mode_checker/airplane_mode_checker.dart';
In order to check the airplane mode, use AirplaneModeChecker.checkAirplaneMode()
as below.
You will get the return AirplaneModeStatus
:
AirplaneModeStatus.on
AirplaneModeStatus.off
final status = await AirplaneModeChecker.instance.checkAirplaneMode();
if (status == AirplaneModeStatus.on) {
print('Airplane mode is ON');
} else {
print('Airplane mode is OFF');
}
To listen for changes in the status of airplane mode, use AirplaneModeChecker.instance.listenAirplaneMode()
.
This will return a Stream<AirplaneModeStatus>
:
AirplaneModeChecker.instance.listenAirplaneMode().listen((status) {
if (status == AirplaneModeStatus.on) {
print('Airplane mode is ON');
} else {
print('Airplane mode is OFF');
}
});
iOS is available from version 12
@available(iOS 12.0, *)
AirplaneMode: ON
AirplaneMode: OFF
Please file issues to send feedback or report a bug. Thank you!
MIT License