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,7 +120,8 @@ class _MyBodyState extends State<Body> {
RaisedButton( RaisedButton(
child: Text("Start Discovery"), child: Text("Start Discovery"),
onPressed: () async { onPressed: () async {
await Nearby().startDiscovery( try {
bool a = await Nearby().startDiscovery(
userName, userName,
strategy, strategy,
onEndpointFound: (id, name, serviceId) { onEndpointFound: (id, name, serviceId) {
@ -149,7 +150,8 @@ class _MyBodyState extends State<Body> {
Text("id: " + id), Text("id: " + id),
Text("Token: " + Text("Token: " +
info.authenticationToken), info.authenticationToken),
Text("Name" + info.endpointName), Text(
"Name" + info.endpointName),
Text("Incoming: " + Text("Incoming: " +
info.isIncomingConnection info.isIncomingConnection
.toString()), .toString()),
@ -157,14 +159,16 @@ class _MyBodyState extends State<Body> {
child: child:
Text("Accept Connection"), Text("Accept Connection"),
onPressed: () { onPressed: () {
Nearby().acceptConnection(id); Nearby()
.acceptConnection(id);
}, },
), ),
RaisedButton( RaisedButton(
child: child:
Text("Reject Connection"), Text("Reject Connection"),
onPressed: () { onPressed: () {
Nearby().rejectConnection(id); Nearby()
.rejectConnection(id);
}, },
), ),
], ],
@ -192,6 +196,10 @@ class _MyBodyState extends State<Body> {
showSnackbar(id); showSnackbar(id);
}, },
); );
showSnackbar(a);
} catch (e) {
showSnackbar(e);
}
}, },
), ),
RaisedButton( RaisedButton(