Skip to content

Repository files navigation

⚠️ Migration Notice: This plugin is being migrated to libnativeapi/nativeapi-flutter

The new version is based on a unified C++ core library (libnativeapi/nativeapi), providing more complete and consistent cross-platform native API support. r

screen_retriever

pub version

This plugin allows Flutter desktop apps to Retrieve information about screen size, displays, cursor position, etc.



English | 简体中文


Platform Support

LinuxmacOSWindows
✔️✔️✔️

Documentation

Quick Start

Installation

Add this to your package's pubspec.yaml file:

dependencies:
screen_retriever: ^0.2.0

Or

dependencies:
screen_retriever:
git:
url: https://github.com/leanflutter/screen_retriever.gitpath: packages/screen_retrieverref: main

Usage

Display? _primaryDisplay;
List<Display> _displayList = [];
void_init() async {
_primaryDisplay =await screenRetriever.getPrimaryDisplay();
_displayList =await screenRetriever.getAllDisplays();
setState(() {});
}

Listening events

classHomePageextendsStatefulWidget {
constHomePage({Key? key}) :super(key: key);
@overrideState<HomePage> createState() =>_HomePageState();
}
class_HomePageStateextendsState<HomePage> withScreenListener {
@overridevoidinitState() {
screenRetriever.addListener(this);
super.initState();
}
@overridevoiddispose() {
screenRetriever.removeListener(this);
super.dispose();
}
@overrideWidgetbuild(BuildContext context) {
// ...
}
@overridevoidonScreenEvent(String eventName) {
String log ='Event received: $eventName)';
print(log);
}
}

Please see the example app of this plugin for a full example.

Who's using it?

  • Biyi (比译) - A convenient translation and dictionary app.
  • FastForge - An efficient tool for rapid application development and prototyping.

API

ScreenRetriever

MethodDescriptionLinuxmacOSWindows
getCursorScreenPointReturns Offset - The current absolute position of the mouse pointer.✔️✔️✔️
getPrimaryDisplayReturns Display - The primary display.✔️✔️✔️
getAllDisplaysReturns List<Display> - An array of displays that are currently available.✔️✔️✔️

Contributors ✨

Thanks goes to these wonderful people (emoji key):

LiJianying
LiJianying

💻
Christian Padilla
Christian Padilla

💻
J-P Nurmi
J-P Nurmi

💻
Kingtous
Kingtous

💻
fufesou
fufesou

💻
lukasz-lukasz-lukasz
lukasz-lukasz-lukasz

💻
Add your contributions

This project follows the all-contributors specification. Contributions of any kind welcome!

License

MIT

About

This plugin allows Flutter desktop apps to Retrieve information about screen size, displays, cursor position, etc.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages