iosfluttermobile

How I can Detect Developer options enable or disable in flutter?


In My Application I want to show if the developer mode is on then show one screen for restriction of developer mode

My Application in Flutter

I try to get devoption value from the settings

int devOptions =Settings.Secure.getInt(this.getContentResolver(),Settings.Global.DEVELOPMENT_SETTINGS_ENABLED , 0);

Solution

  • Here's a quick solution to detect developer options in Flutter:

    Don't forget: device_info_plus: ^9.1.0 in pubspec.yaml

    import 'package:device_info_plus/device_info_plus.dart';
    
    Future<bool> isDevMode() async {
      if (Platform.isAndroid) {
        AndroidDeviceInfo info = await DeviceInfoPlugin().androidInfo;
        return info.isPhysicalDevice ?? false;
      }
      return false;
    }
    
    // Usage
    if (await isDevMode()) {
      // Show restriction screen
    } else {
      // Show normal screen
    }