import 'package:flutter/material.dart'; import 'dart:async'; import 'package:flutter/services.dart'; import 'package:nearby_connections/nearby_connections.dart'; void main() => runApp(MyApp()); class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State { @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Plugin example app'), ), body: Body(), ), ); } } class Body extends StatefulWidget { @override _MyBodyState createState() => _MyBodyState(); } class _MyBodyState extends State { @override Widget build(BuildContext context) { // TODO: implement build return Center( child: Column( children: [ 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]); }, ), ], ), ); } }