modular_permission_location 0.1.0
modular_permission_location: ^0.1.0 copied to clipboard

Location permission plugin to be used with Modular Permissions.

example/lib/main.dart

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

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

class DemoApp extends StatefulWidget {
  @override
  _DemoAppState createState() => _DemoAppState();
}

class _DemoAppState extends State<DemoApp> {
  bool _granted = false;
  MethodChannel _channelLocation =
  MethodChannel('ch.upte.modularPermissionsLocation');

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Modular Location Permission'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              OutlineButton(
                shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(4.0)),
                borderSide: BorderSide(color: Colors.red),
                child: Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: Text(
                    'Check Location Permission',
                    style: Theme.of(context).textTheme.button,
                    textAlign: TextAlign.center,
                  ),
                ),
                onPressed: () async {
                  final String info = await _channelLocation.invokeMethod(
                      'checkLocationPermission',
                      {'permissionArgs': 'LocationWhenInUse'});
                  setState(() {
                    _granted = info == "granted";
                  });
                },
              ),
              OutlineButton(
                shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(4.0)),
                borderSide: BorderSide(color: Colors.red),
                child: Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: Text(
                    'Request Location Permission',
                    style: Theme.of(context).textTheme.button,
                    textAlign: TextAlign.center,
                  ),
                ),
                onPressed: () async {
                  final String info = await _channelLocation.invokeMethod(
                      'requestLocationPermission',
                      {'permissionArgs': 'LocationWhenInUse'});
                  setState(() {
                    _granted = info == "granted";
                  });
                },
              ),
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: Text(
                  'Location Permission is ${_granted ? 'granted' : 'not granted'}',
                  textAlign: TextAlign.center,
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
105
pub points
0%
popularity

Publisher

upte.ch

Location permission plugin to be used with Modular Permissions.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on modular_permission_location