fake_gps_detector 0.5.1
fake_gps_detector: ^0.5.1

Flutter Android

A Flutter plugin for detecting the emulator device and mock location / fake gps.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:fake_gps_detector/fake_gps_detector.dart';

import 'package:permission_handler/permission_handler.dart';

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

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

class _MyAppState extends State<MyApp> {
  dynamic _isFakeGps = 'Unknown';
  dynamic _isEmulator = 'Unknown';

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    bool isMock;
    bool isEmulator;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      if (await Permission.location.request().isGranted) {
        isMock = await FakeGpsDetector.isFakeGps;
        isEmulator = await FakeGpsDetector.isEmulator;
      }
    } on PlatformException {
      print("failed");
    }

    if (!mounted) return;
    setState(() {
      _isFakeGps = isMock;
      _isEmulator = isEmulator;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('Fake GPS : $_isFakeGps , Emulator : $_isEmulator'),
        ),
      ),
    );
  }
}
2
likes
70
pub points
52%
popularity

Publisher

andiksetyawan.dev

A Flutter plugin for detecting the emulator device and mock location / fake gps.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on fake_gps_detector