You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a use case where I want to open a window and immediately show some data passed from the parent app to the window. I don't want to start FloatwingPlugin until the user actually needs to see the window because some users never use windows so it is unnecessary to have it always running.
I am using the following code to start the app and show the window:
Future<void> _initAsyncState() async {
awaitFloatwingPlugin().initialize();
// get permission firstif (!awaitFloatwingPlugin().checkPermission()) {
FloatwingPlugin().openPermissionSetting();
returnFuture.value(false);
}
awaitFloatwingPlugin().isServiceRunning().then((running) async {
if (!running)
awaitFloatwingPlugin().startService().then((_) {
print("start the background service success.");
});
});
final existingWindow =FloatwingPlugin().windows[_window.id];
if (existingWindow !=null) {
_window.share(
'Re-opened at ${DateTime.now().second % 60}',
name:'myOverlayData',
);
} else {
_window.on(EventType.WindowStarted, (window, data) {
_window.share(
'Opened at ${DateTime.now().second % 60}',
name:'myOverlayData',
);
});
await _window.create(start:true);
}
}
When I open the window the data is null, probably because the onData listener is registered after _window.share() gets called so it misses the data. If I run _initAsyncState() again it successfully passes the data with the 'Re-opened...' message, so the data sharing is working.
Is there a way to make sure the window is ready to receive the data instead so it doesn't get missed whilst the window is opening? If not, one potential solution for this problem would be to add a new EventType.WindowListen event which gets triggered when the window starts listening to data, then the shareData call can be placed in this callback.
WDYT?
The text was updated successfully, but these errors were encountered:
Thanks for this plugin @jiusanzhou.
I have a use case where I want to open a window and immediately show some data passed from the parent app to the window. I don't want to start FloatwingPlugin until the user actually needs to see the window because some users never use windows so it is unnecessary to have it always running.
I am using the following code to start the app and show the window:
My window is run via an entrypoint:
The NormalView widget listens to shared data in the initState like so:
When I open the window the data is null, probably because the
onData
listener is registered after_window.share()
gets called so it misses the data. If I run_initAsyncState()
again it successfully passes the data with the 'Re-opened...' message, so the data sharing is working.Is there a way to make sure the window is ready to receive the data instead so it doesn't get missed whilst the window is opening? If not, one potential solution for this problem would be to add a new
EventType.WindowListen
event which gets triggered when the window starts listening to data, then the shareData call can be placed in this callback.WDYT?
The text was updated successfully, but these errors were encountered: