flutter_is_emulator_fixed 1.0.1 copy "flutter_is_emulator_fixed: ^1.0.1" to clipboard
flutter_is_emulator_fixed: ^1.0.1 copied to clipboard

Plugin to detect whether the current device is an emulator or simulator (forked and fixed)

example/lib/main.dart

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

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _text = 'Unknown';

  @override
  initState() {
    super.initState();
    initPlatformState();
  }

  initPlatformState() async {
    String text;
    try {
      bool res = await FlutterIsEmulator.isDeviceAnEmulatorOrASimulator;
      text = res.toString();
    } on PlatformException {
      text = 'Error.';
    }

    if (!mounted) return;

    setState(() {
      _text = text;
    });
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Plugin example app'),
        ),
        body: new Center(
          child: new Text('Emulator/simulator: $_text\n'),
        ),
      ),
    );
  }
}
2
likes
40
pub points
23%
popularity

Publisher

unverified uploader

Plugin to detect whether the current device is an emulator or simulator (forked and fixed)

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_is_emulator_fixed