|
|
@ -159,18 +159,20 @@ class Nearby {
|
|
|
|
Future<void> askLocationPermission() async => await _channel.invokeMethod(
|
|
|
|
Future<void> askLocationPermission() async => await _channel.invokeMethod(
|
|
|
|
'askLocationPermission',
|
|
|
|
'askLocationPermission',
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/// Convinience method
|
|
|
|
/// Convinience method
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// retruns true/false based on external storage permissions.
|
|
|
|
/// retruns true/false based on external storage permissions.
|
|
|
|
Future<bool> checkExternalStoragePermission() async => await _channel.invokeMethod(
|
|
|
|
Future<bool> checkExternalStoragePermission() async =>
|
|
|
|
|
|
|
|
await _channel.invokeMethod(
|
|
|
|
'checkExternalStoragePermission',
|
|
|
|
'checkExternalStoragePermission',
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/// Convinience method
|
|
|
|
/// Convinience method
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// Asks external storage permission, required for file
|
|
|
|
/// Asks external storage permission, required for file
|
|
|
|
Future<void> askExternalStoragePermission() async => await _channel.invokeMethod(
|
|
|
|
Future<void> askExternalStoragePermission() async =>
|
|
|
|
|
|
|
|
await _channel.invokeMethod(
|
|
|
|
'askExternalStoragePermission',
|
|
|
|
'askExternalStoragePermission',
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
@ -252,6 +254,7 @@ class Nearby {
|
|
|
|
/// this will call the onDisconnected method on callbacks of
|
|
|
|
/// this will call the onDisconnected method on callbacks of
|
|
|
|
/// connected endPoint
|
|
|
|
/// connected endPoint
|
|
|
|
Future<void> disconnectFromEndpoint(String endpointId) async {
|
|
|
|
Future<void> disconnectFromEndpoint(String endpointId) async {
|
|
|
|
|
|
|
|
assert(endpointId != null);
|
|
|
|
await _channel.invokeMethod(
|
|
|
|
await _channel.invokeMethod(
|
|
|
|
'disconnectFromEndpoint', <String, dynamic>{'endpointId': endpointId});
|
|
|
|
'disconnectFromEndpoint', <String, dynamic>{'endpointId': endpointId});
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -274,6 +277,9 @@ class Nearby {
|
|
|
|
this._discoverConnectionResult = onConnectionResult;
|
|
|
|
this._discoverConnectionResult = onConnectionResult;
|
|
|
|
this._discoverDisconnected = onDisconnected;
|
|
|
|
this._discoverDisconnected = onDisconnected;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert(endpointId != null);
|
|
|
|
|
|
|
|
assert(userNickName != null);
|
|
|
|
|
|
|
|
|
|
|
|
return await _channel.invokeMethod(
|
|
|
|
return await _channel.invokeMethod(
|
|
|
|
'requestConnection',
|
|
|
|
'requestConnection',
|
|
|
|
<String, dynamic>{
|
|
|
|
<String, dynamic>{
|
|
|
@ -298,6 +304,9 @@ class Nearby {
|
|
|
|
}) async {
|
|
|
|
}) async {
|
|
|
|
this._onPayloadReceived = onPayLoadRecieved;
|
|
|
|
this._onPayloadReceived = onPayLoadRecieved;
|
|
|
|
this._onPayloadTransferUpdate = onPayloadTransferUpdate;
|
|
|
|
this._onPayloadTransferUpdate = onPayloadTransferUpdate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert(endpointId != null);
|
|
|
|
|
|
|
|
|
|
|
|
return await _channel.invokeMethod(
|
|
|
|
return await _channel.invokeMethod(
|
|
|
|
'acceptConnection',
|
|
|
|
'acceptConnection',
|
|
|
|
<String, dynamic>{
|
|
|
|
<String, dynamic>{
|
|
|
@ -316,6 +325,8 @@ class Nearby {
|
|
|
|
/// [OnConnectionResult] is called on both
|
|
|
|
/// [OnConnectionResult] is called on both
|
|
|
|
/// even if one of them rejects the connection
|
|
|
|
/// even if one of them rejects the connection
|
|
|
|
Future<bool> rejectConnection(String endpointId) async {
|
|
|
|
Future<bool> rejectConnection(String endpointId) async {
|
|
|
|
|
|
|
|
assert(endpointId != null);
|
|
|
|
|
|
|
|
|
|
|
|
return await _channel.invokeMethod(
|
|
|
|
return await _channel.invokeMethod(
|
|
|
|
'rejectConnection',
|
|
|
|
'rejectConnection',
|
|
|
|
<String, dynamic>{
|
|
|
|
<String, dynamic>{
|
|
|
@ -333,6 +344,8 @@ class Nearby {
|
|
|
|
/// Uint8List bytes = Uint8List.fromList(a.codeUnits);
|
|
|
|
/// Uint8List bytes = Uint8List.fromList(a.codeUnits);
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
Future<void> sendBytesPayload(String endpointId, Uint8List bytes) async {
|
|
|
|
Future<void> sendBytesPayload(String endpointId, Uint8List bytes) async {
|
|
|
|
|
|
|
|
assert(endpointId != null);
|
|
|
|
|
|
|
|
|
|
|
|
return await _channel.invokeMethod(
|
|
|
|
return await _channel.invokeMethod(
|
|
|
|
'sendPayload',
|
|
|
|
'sendPayload',
|
|
|
|
<String, dynamic>{
|
|
|
|
<String, dynamic>{
|
|
|
@ -350,6 +363,8 @@ class Nearby {
|
|
|
|
/// so that receiver can rename the file accordingly
|
|
|
|
/// so that receiver can rename the file accordingly
|
|
|
|
/// Send the payloadID and filename to receiver as bytes payload
|
|
|
|
/// Send the payloadID and filename to receiver as bytes payload
|
|
|
|
Future<int> sendFilePayload(String endpointId, String filePath) async {
|
|
|
|
Future<int> sendFilePayload(String endpointId, String filePath) async {
|
|
|
|
|
|
|
|
assert(endpointId != null);
|
|
|
|
|
|
|
|
|
|
|
|
return await _channel.invokeMethod(
|
|
|
|
return await _channel.invokeMethod(
|
|
|
|
'sendFilePayload',
|
|
|
|
'sendFilePayload',
|
|
|
|
<String, dynamic>{
|
|
|
|
<String, dynamic>{
|
|
|
@ -358,4 +373,15 @@ class Nearby {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> cancelPayload(int payloadId) async {
|
|
|
|
|
|
|
|
assert(payloadId != null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return await _channel.invokeMethod(
|
|
|
|
|
|
|
|
'cancelPayload',
|
|
|
|
|
|
|
|
<String, dynamic>{
|
|
|
|
|
|
|
|
'payloadId': payloadId.toString(),
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|