Skip to content

Commit 2614414

Browse files
committed
feat return a boolean indicating whether the [data] was successfully sent using the [shareData] method
doc improve documentation form [shareData] method feat return the original Future from the [disposeOverlayListener] method
1 parent c0f2bbc commit 2614414

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

lib/src/overlay_window.dart

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,24 @@ class FlutterOverlayWindow {
8181
return _res;
8282
}
8383

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

89104
/// Streams message shared between overlay and main app
@@ -123,7 +138,7 @@ class FlutterOverlayWindow {
123138
/// Dispose overlay stream.
124139
///
125140
/// Once disposed, only a complete restart of the application will re-initialize the listener.
126-
static void disposeOverlayListener() {
127-
_controller.close();
141+
static Future<dynamic> disposeOverlayListener() {
142+
return _controller.close();
128143
}
129144
}

0 commit comments

Comments
 (0)