added checkPermission method

This commit is contained in:
Prerak Mann
2019-05-10 18:24:38 +05:30
parent 59cb4ba91d
commit 6ee7aba035
5 changed files with 90 additions and 8 deletions

View File

@@ -19,9 +19,44 @@ class _MyAppState extends State<MyApp> {
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Text('Welcome'),
),
body: Body(),
),
);
}
}
class Body extends StatefulWidget {
@override
_MyBodyState createState() => _MyBodyState();
}
class _MyBodyState extends State<Body> {
@override
Widget build(BuildContext context) {
// TODO: implement build
return Center(
child: Column(
children: <Widget>[
RaisedButton(
child: Text("checkPermission"),
onPressed: () async {
if (await Nearby.instance.checkPermissions()) {
Scaffold.of(context)
.showSnackBar(SnackBar(content: Text("yes")));
} else {
Scaffold.of(context)
.showSnackBar(SnackBar(content: Text("No")));
}
},
),
RaisedButton(
child: Text("askPermission(permission handler)"),
onPressed: () async {
// await PermissionHandler()
// .requestPermissions([PermissionGroup.location]);
},
),
],
),
);
}

View File

@@ -8,7 +8,7 @@ environment:
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2