airplane_mode_checker 3.2.1 copy "airplane_mode_checker: ^3.2.1" to clipboard
airplane_mode_checker: ^3.2.1 copied to clipboard

Flutter plugin allows you to check the status of Airplane Mode on iOS and Android mobile.

airplane_mode_checker #


Pub

A Flutter plugin allows you to check the status of Airplane Mode on iOS and Android mobile.

Platform Support #

Platform Supported Notes
Android Full support
iOS ⚠️ Limited - see below

iOS Limitations #

Important: iOS does not provide a public API to reliably detect Airplane Mode in all cases.

  • ✅ Works on cellular devices (iPhone, iPad with cellular)
  • Limited accuracy on WiFi-only devices (iPad WiFi, iPod Touch)
  • The plugin uses CTTelephonyNetworkInfo which only works with cellular radios
  • WiFi-only iOS devices return AirplaneModeStatus.off by default, but callers can override this with defaultValue

This is a platform limitation by Apple, not a plugin issue. The plugin provides the best detection possible within iOS constraints.

Usage #

Find the example wiring in the example app

Installation #

Add the following line to pubspec.yaml:

dependencies:
  airplane_mode_checker: ^3.2.1

Add the following import to your Dart code:

import 'package:airplane_mode_checker/airplane_mode_checker.dart';

Check Airplane Mode #

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');
}

On WiFi-only iOS devices, pass defaultValue to control the fallback value used when iOS cannot detect airplane mode through cellular APIs:

final status = await AirplaneModeChecker.instance.checkAirplaneMode(
  defaultValue: AirplaneModeStatus.on,
);

Listen to Airplane Mode Changes #

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');
  }
});

The stream API accepts the same iOS fallback:

AirplaneModeChecker.instance.listenAirplaneMode(
  defaultValue: AirplaneModeStatus.on,
);

Requirements #

  • iOS: 12.0 or higher
  • Android: API 16 (Jelly Bean) or higher
  • Flutter: 3.3.0 or higher
  • Dart: 3.3.0 or higher

iOS available #

iOS is available from version 12

@available(iOS 12.0, *)

ScreenShots #

AirplaneMode: ON AirplaneMode: OFF

Issues and feedback #

Please file issues to send feedback or report a bug. Thank you!

License #

MIT License

Buy Me A Coffee

18
likes
150
points
7.24k
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Flutter plugin allows you to check the status of Airplane Mode on iOS and Android mobile.

Repository (GitHub)
View/report issues

Topics

#airplane-mode #connectivity #network #mobile

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on airplane_mode_checker

Packages that implement airplane_mode_checker