flutter_geolocation_service 0.1.0 copy "flutter_geolocation_service: ^0.1.0" to clipboard
flutter_geolocation_service: ^0.1.0 copied to clipboard

Flutter plugin for generic location functionality

example/lib/main.dart

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

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

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

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

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

class _MyAppState extends State<MyApp> {
  String _permission = 'Unknown';
  final _flutterGeolocationServicePlugin = FlutterGeolocationService();

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

  Future<void> initPlatformState() async {
    bool permisssion;
    try {
      permisssion = await FlutterGeolocationService.checkPermission() ?? false;
    } on PlatformException {
      permisssion = false;
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _permission = permisssion.toString();
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Geolocation example app'),
        ),
        body: Center(
          child: Text('Running on: $_permission\n'),
        ),
      ),
    );
  }
}
69
likes
100
pub points
47%
popularity

Publisher

unverified uploader

Flutter plugin for generic location functionality

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (LICENSE)

Dependencies

flutter, flutter_web_plugins, plugin_platform_interface

More

Packages that depend on flutter_geolocation_service