Update askLocationPermission method (#21)

* enableLocationService return type changed to Future<bool>
* typos fixes #15
* fix #15 added to changelog and bug fixes
* askLocationPermission return type changed to Future<bool> : fixes #9
This commit is contained in:
Gourav Saini
2020-08-16 00:21:27 +05:30
committed by GitHub
parent e7edb9865b
commit 00289fa7bc
8 changed files with 89 additions and 44 deletions

View File

@@ -3,8 +3,8 @@ import 'dart:math';
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:nearby_connections/nearby_connections.dart';
import 'package:image_picker/image_picker.dart';
import 'package:nearby_connections/nearby_connections.dart';
void main() => runApp(MyApp());
@@ -68,8 +68,15 @@ class _MyBodyState extends State<Body> {
),
RaisedButton(
child: Text("askLocationPermission"),
onPressed: () {
Nearby().askLocationPermission();
onPressed: () async {
if (await Nearby().askLocationPermission()) {
Scaffold.of(context).showSnackBar(SnackBar(
content: Text("Location Permission granted :)")));
} else {
Scaffold.of(context).showSnackBar(SnackBar(
content:
Text("Location permissions not granted :(")));
}
},
),
RaisedButton(
@@ -114,11 +121,12 @@ class _MyBodyState extends State<Body> {
child: Text("enableLocationServices"),
onPressed: () async {
if (await Nearby().enableLocationServices()) {
Scaffold.of(context).showSnackBar(
SnackBar(content: Text("Location Service Enabled :)")));
Scaffold.of(context).showSnackBar(SnackBar(
content: Text("Location Service Enabled :)")));
} else {
Scaffold.of(context).showSnackBar(
SnackBar(content: Text("Enabling Location Service Failed :(")));
Scaffold.of(context).showSnackBar(SnackBar(
content:
Text("Enabling Location Service Failed :(")));
}
},
),