mirror of
https://github.com/hackku21/nearby_connections.git
synced 2026-03-02 03:49:22 +00:00
added checkPermission method
This commit is contained in:
@@ -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]);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user