screen_retriever
screen_retriever copied to clipboard
ScreenListener support for macos and windows
Are ScreenListener events supported on macos and windows? Looking at the code, it seems that the only version that emits events is Linux when displays are added/removed in the following lines:
https://github.com/leanflutter/screen_retriever/blob/4f3831a2fefd8da3ed924ce8f6b2be6637c85f64/linux/screen_retriever_plugin.cc#L192
https://github.com/leanflutter/screen_retriever/blob/4f3831a2fefd8da3ed924ce8f6b2be6637c85f64/linux/screen_retriever_plugin.cc#L195
I would like to have that ability on the other systems, but don't have the knowledge enough to know how to modify your code to do so.
As a side note, there's also no documentation on the README going over the event and whether it is supported on different systems.
I have gotten this working with MacOS. If you are running on mac and want to detect when the screen changes, update your pubspec.yml to:
screen_retriever:
git:
url: https://github.com/holotrek/screen_retriever
ref: "ad04fd32637ac901e1d64d0725ac6343a0347255"
Then mark a widget as inheriting ScreenListener and add an event that can update your display list, i.e.:
class MyDisplaysState extends State<MyDisplays> with ScreenListener {
@override
void initState() {
super.initState();
screenRetriever.addListener(this);
}
@override
void onScreenEvent(String eventName) {
// eventName may be "monitor-added" or "monitor-removed"
super.onScreenEvent(eventName);
setState(() {});
}
@override
void dispose() {
screenRetriever.removeListener(this);
super.dispose();
}
}
I'll post back with an updated ref if I get this working with Windows and also will submit a PR.
Supported, please update to 0.2.0