emulator_checker 1.0.3 copy "emulator_checker: ^1.0.3" to clipboard
emulator_checker: ^1.0.3 copied to clipboard

A Flutter plugin that detects whether an application is running on an emulator or a physical device. This can be useful for security purposes, analytics, and feature flagging, allowing developers to t [...]

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:emulator_checker/emulator_checker.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _deviceStatus = 'Checking...';

  @override
  void initState() {
    super.initState();
    checkIfEmulator();
  }

  Future<void> checkIfEmulator() async {
    try {
      bool isEmulator = await EmulatorChecker.isEmulator();
      if (!mounted) return;
      setState(() {
        _deviceStatus = isEmulator
            ? 'Running on an Emulator'
            : 'Running on a Physical Device';
      });
    } on PlatformException {
      if (!mounted) return;
      setState(() {
        _deviceStatus = 'Failed to check emulator status';
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Emulator Checker Example'),
        ),
        body: Center(
          child: Text(
            _deviceStatus,
            style: const TextStyle(fontSize: 18),
          ),
        ),
      ),
    );
  }
}
2
likes
150
points
630
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin that detects whether an application is running on an emulator or a physical device. This can be useful for security purposes, analytics, and feature flagging, allowing developers to tailor app behavior based on the runtime environment. Supports Android and iOS platforms.

Repository (GitHub)
View/report issues

Documentation

API reference

License

GPL-3.0 (license)

Dependencies

flutter, get_radio_version_plugin

More

Packages that depend on emulator_checker

Packages that implement emulator_checker