Skip to content

Commit

Permalink
feat return a boolean indicating whether the [data] was successfully …
Browse files Browse the repository at this point in the history
…sent using the [shareData] method

doc improve documentation form [shareData] method

feat return the original Future from the [disposeOverlayListener] method
  • Loading branch information
serhiisdev committed Feb 5, 2024
1 parent c0f2bbc commit 2614414
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions lib/src/overlay_window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,24 @@ class FlutterOverlayWindow {
return _res;
}

/// Broadcast data to and from overlay app
static Future shareData(dynamic data) async {
return await _overlayMessageChannel.send(data);
/// Broadcast [data] to and from overlay app.
///
/// If `true` is returned, it indicates that the [data] was sent. However, it does not guarantee
/// that the [data] has arrived at its destination,
/// i.e. to the listeners of the [overlayListener] stream.
/// Typically, success in sending should imply successful delivery.
///
/// If `false` is returned, it means that there is no registered message channel to handle
/// sending this [data], and thus, the [data] was not sent.
///
/// This method may return `false` under the following conditions:
/// - The overlay is closed.
/// - The application is detached from the activity, i.e. the application is closed.
///
/// Returns `true` if the [data] was sent successfully, otherwise `false`.
static Future<bool> shareData(dynamic data) async {
final isSent = await _overlayMessageChannel.send(data);
return isSent as bool;
}

/// Streams message shared between overlay and main app
Expand Down Expand Up @@ -123,7 +138,7 @@ class FlutterOverlayWindow {
/// Dispose overlay stream.
///
/// Once disposed, only a complete restart of the application will re-initialize the listener.
static void disposeOverlayListener() {
_controller.close();
static Future<dynamic> disposeOverlayListener() {
return _controller.close();
}
}

0 comments on commit 2614414

Please sign in to comment.