flutter_is_emulator 1.0.0 copy "flutter_is_emulator: ^1.0.0" to clipboard
flutter_is_emulator: ^1.0.0 copied to clipboard

discontinued

Plugin to detect whether the current device is an emulator or simulator

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'),
        ),
      ),
    );
  }
}
7
likes
40
pub points
38%
popularity

Publisher

verified publisherdaad.mobi

Plugin to detect whether the current device is an emulator or simulator

Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

flutter

More

Packages that depend on flutter_is_emulator