is_gps_open 0.0.2 copy "is_gps_open: ^0.0.2" to clipboard
is_gps_open: ^0.0.2 copied to clipboard

Check if the device GPS is turned on

example/lib/main.dart

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

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

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

class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
  bool? _gpsOpen;

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addObserver(this);
  }

  @override
  void dispose() {
    WidgetsBinding.instance.removeObserver(this);
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              Text('GPS Status: $_gpsOpen'),
              SizedBox(height: 20),
              ElevatedButton(
                child: Text("Get Status"),
                onPressed: () async {
                  _gpsOpen = await GpsStatus.isOpen();
                  setState(() {});
                },
              ),
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
140
pub points
2%
popularity

Publisher

unverified uploader

Check if the device GPS is turned on

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on is_gps_open