screen_retriever

March 29, 2025 ยท View on GitHub

๐Ÿš€ Ship Your App Faster: Try Fastforge - The simplest way to build, package and distribute your Flutter apps.

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.git
      path: packages/screen_retriever
      ref: main

Usage

Display? _primaryDisplay;
List<Display> _displayList = [];

void _init() async {
  _primaryDisplay = await screenRetriever.getPrimaryDisplay();
  _displayList = await screenRetriever.getAllDisplays();
  setState(() {});
}

Listening events

class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> with ScreenListener {
  @override
  void initState() {
    screenRetriever.addListener(this);
    super.initState();
  }

  @override
  void dispose() {
    screenRetriever.removeListener(this);
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    // ...
  }

  @override
  void onScreenEvent(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?

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