A Flutter Plugin for Detecting the Airplane Mode in Android and iOS
Add the following import to your Dart code:
import 'package:airplane_mode_detection/airplane_mode_detection.dart';
import 'package:fluttertoast/fluttertoast.dart';
In order to detect the airplane mode, use AirplaneModeDetection.detectAirplaneMode()
as below.
You will get the return value 'ON' or 'OFF'.
String state = await AirplaneModeDetection.detectAirplaneMode();
static Future<String> detectAirplaneMode() async {
final String airplanemode = await _channel.invokeMethod('detectAirplaneMode');
return airplanemode;
}
iOS is available from version 12
@available(iOS 12.0, *)
public class SwiftAirplaneModeDetectionPlugin: NSObject, FlutterPlugin {
public static func register(with registrar: FlutterPluginRegistrar) {
let channel = FlutterMethodChannel(name: "airplane_mode_detection", binaryMessenger: registrar.messenger())
let instance = SwiftAirplaneModeDetectionPlugin()
registrar.addMethodCallDelegate(instance, channel: channel)
}
Find the example wiring in the example app
See the airplane_mode_detection.dart for more API details.
Please file issues to send feedback or report a bug. Thank you!
MIT License