minor fix

This commit is contained in:
Prerak Mann 2019-05-11 16:17:02 +05:30
parent 89a9403312
commit e6935b59d2

View File

@ -55,7 +55,7 @@ class _MyBodyState extends State<Body> {
}, },
), ),
RaisedButton( RaisedButton(
child: Text("askPermission(permission handler)"), child: Text("askPermission(location)"),
onPressed: () async { onPressed: () async {
await Nearby().askPermission(); await Nearby().askPermission();
}, },
@ -120,78 +120,86 @@ class _MyBodyState extends State<Body> {
RaisedButton( RaisedButton(
child: Text("Start Discovery"), child: Text("Start Discovery"),
onPressed: () async { onPressed: () async {
await Nearby().startDiscovery( try {
userName, bool a = await Nearby().startDiscovery(
strategy, userName,
onEndpointFound: (id, name, serviceId) { strategy,
showModalBottomSheet( onEndpointFound: (id, name, serviceId) {
context: context, showModalBottomSheet(
builder: (builder) { context: context,
return Center( builder: (builder) {
child: Column( return Center(
children: <Widget>[ child: Column(
Text("id: " + id), children: <Widget>[
Text("Name: " + name), Text("id: " + id),
Text("ServiceId: " + serviceId), Text("Name: " + name),
RaisedButton( Text("ServiceId: " + serviceId),
child: Text("Request Connection"), RaisedButton(
onPressed: () { child: Text("Request Connection"),
Nearby().requestConnection( onPressed: () {
userName, Nearby().requestConnection(
id, userName,
onConnectionInitiated: (id, info) { id,
showModalBottomSheet( onConnectionInitiated: (id, info) {
context: context, showModalBottomSheet(
builder: (builder) { context: context,
return Center( builder: (builder) {
child: Column( return Center(
children: <Widget>[ child: Column(
Text("id: " + id), children: <Widget>[
Text("Token: " + Text("id: " + id),
info.authenticationToken), Text("Token: " +
Text("Name" + info.endpointName), info.authenticationToken),
Text("Incoming: " + Text(
info.isIncomingConnection "Name" + info.endpointName),
.toString()), Text("Incoming: " +
RaisedButton( info.isIncomingConnection
child: .toString()),
Text("Accept Connection"), RaisedButton(
onPressed: () { child:
Nearby().acceptConnection(id); Text("Accept Connection"),
}, onPressed: () {
), Nearby()
RaisedButton( .acceptConnection(id);
child: },
Text("Reject Connection"), ),
onPressed: () { RaisedButton(
Nearby().rejectConnection(id); child:
}, Text("Reject Connection"),
), onPressed: () {
], Nearby()
), .rejectConnection(id);
); },
}, ),
); ],
}, ),
onConnectionResult: (id, status) { );
showSnackbar(status); },
}, );
onDisconnected: (id) { },
showSnackbar(id); onConnectionResult: (id, status) {
}, showSnackbar(status);
); },
}, onDisconnected: (id) {
), showSnackbar(id);
], },
), );
); },
}, ),
); ],
}, ),
onEndpointLost: (id) { );
showSnackbar(id); },
}, );
); },
onEndpointLost: (id) {
showSnackbar(id);
},
);
showSnackbar(a);
} catch (e) {
showSnackbar(e);
}
}, },
), ),
RaisedButton( RaisedButton(