mirror of
https://github.com/hackku21/nearby_connections.git
synced 2024-10-27 19:14:01 +00:00
minor fix
This commit is contained in:
parent
89a9403312
commit
e6935b59d2
@ -55,7 +55,7 @@ class _MyBodyState extends State<Body> {
|
||||
},
|
||||
),
|
||||
RaisedButton(
|
||||
child: Text("askPermission(permission handler)"),
|
||||
child: Text("askPermission(location)"),
|
||||
onPressed: () async {
|
||||
await Nearby().askPermission();
|
||||
},
|
||||
@ -120,78 +120,86 @@ class _MyBodyState extends State<Body> {
|
||||
RaisedButton(
|
||||
child: Text("Start Discovery"),
|
||||
onPressed: () async {
|
||||
await Nearby().startDiscovery(
|
||||
userName,
|
||||
strategy,
|
||||
onEndpointFound: (id, name, serviceId) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (builder) {
|
||||
return Center(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Text("id: " + id),
|
||||
Text("Name: " + name),
|
||||
Text("ServiceId: " + serviceId),
|
||||
RaisedButton(
|
||||
child: Text("Request Connection"),
|
||||
onPressed: () {
|
||||
Nearby().requestConnection(
|
||||
userName,
|
||||
id,
|
||||
onConnectionInitiated: (id, info) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (builder) {
|
||||
return Center(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Text("id: " + id),
|
||||
Text("Token: " +
|
||||
info.authenticationToken),
|
||||
Text("Name" + info.endpointName),
|
||||
Text("Incoming: " +
|
||||
info.isIncomingConnection
|
||||
.toString()),
|
||||
RaisedButton(
|
||||
child:
|
||||
Text("Accept Connection"),
|
||||
onPressed: () {
|
||||
Nearby().acceptConnection(id);
|
||||
},
|
||||
),
|
||||
RaisedButton(
|
||||
child:
|
||||
Text("Reject Connection"),
|
||||
onPressed: () {
|
||||
Nearby().rejectConnection(id);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
onConnectionResult: (id, status) {
|
||||
showSnackbar(status);
|
||||
},
|
||||
onDisconnected: (id) {
|
||||
showSnackbar(id);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
onEndpointLost: (id) {
|
||||
showSnackbar(id);
|
||||
},
|
||||
);
|
||||
try {
|
||||
bool a = await Nearby().startDiscovery(
|
||||
userName,
|
||||
strategy,
|
||||
onEndpointFound: (id, name, serviceId) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (builder) {
|
||||
return Center(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Text("id: " + id),
|
||||
Text("Name: " + name),
|
||||
Text("ServiceId: " + serviceId),
|
||||
RaisedButton(
|
||||
child: Text("Request Connection"),
|
||||
onPressed: () {
|
||||
Nearby().requestConnection(
|
||||
userName,
|
||||
id,
|
||||
onConnectionInitiated: (id, info) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (builder) {
|
||||
return Center(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Text("id: " + id),
|
||||
Text("Token: " +
|
||||
info.authenticationToken),
|
||||
Text(
|
||||
"Name" + info.endpointName),
|
||||
Text("Incoming: " +
|
||||
info.isIncomingConnection
|
||||
.toString()),
|
||||
RaisedButton(
|
||||
child:
|
||||
Text("Accept Connection"),
|
||||
onPressed: () {
|
||||
Nearby()
|
||||
.acceptConnection(id);
|
||||
},
|
||||
),
|
||||
RaisedButton(
|
||||
child:
|
||||
Text("Reject Connection"),
|
||||
onPressed: () {
|
||||
Nearby()
|
||||
.rejectConnection(id);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
onConnectionResult: (id, status) {
|
||||
showSnackbar(status);
|
||||
},
|
||||
onDisconnected: (id) {
|
||||
showSnackbar(id);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
onEndpointLost: (id) {
|
||||
showSnackbar(id);
|
||||
},
|
||||
);
|
||||
showSnackbar(a);
|
||||
} catch (e) {
|
||||
showSnackbar(e);
|
||||
}
|
||||
},
|
||||
),
|
||||
RaisedButton(
|
||||
|
Loading…
Reference in New Issue
Block a user