Skip to content

Commit

Permalink
v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lijy91 committed Aug 18, 2024
1 parent ff816ba commit c1df36b
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 34 deletions.
68 changes: 51 additions & 17 deletions README-ZH.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# screen_retriever

[![pub version][pub-image]][pub-url] [![][discord-image]][discord-url] ![][visits-count-image]
[![pub version][pub-image]][pub-url] [![][discord-image]][discord-url]

[pub-image]: https://img.shields.io/pub/v/screen_retriever.svg
[pub-url]: https://pub.dev/packages/screen_retriever

[discord-image]: https://img.shields.io/discord/884679008049037342.svg
[discord-url]: https://discord.gg/zPa6EZ2jqb

[visits-count-image]: https://img.shields.io/badge/dynamic/json?label=Visits%20Count&query=value&url=https://api.countapi.xyz/hit/leanflutter.screen_retriever/visits

这个插件允许 Flutter 桌面应用检索关于屏幕大小,显示,光标位置等信息。

---
Expand All @@ -21,23 +18,23 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [screen_retriever](#screen_retriever)
- [平台支持](#平台支持)
- [快速开始](#快速开始)
- [安装](#安装)
- [用法](#用法)
- [谁在用使用它?](#谁在用使用它)
- [API](#api)
- [ScreenRetriever](#screenretriever)
- [许可证](#许可证)
- [平台支持](#%E5%B9%B3%E5%8F%B0%E6%94%AF%E6%8C%81)
- [快速开始](#%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B)
- [安装](#%E5%AE%89%E8%A3%85)
- [用法](#%E7%94%A8%E6%B3%95)
- [监听事件](#%E7%9B%91%E5%90%AC%E4%BA%8B%E4%BB%B6)
- [谁在用使用它?](#%E8%B0%81%E5%9C%A8%E7%94%A8%E4%BD%BF%E7%94%A8%E5%AE%83)
- [API](#api)
- [ScreenRetriever](#screenretriever)
- [许可证](#%E8%AE%B8%E5%8F%AF%E8%AF%81)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## 平台支持

| Linux | macOS | Windows |
| :---: | :---: | :-----: |
| ✔️ | ✔️ | ✔️ |
| ✔️ | ✔️ | ✔️ |

## 快速开始

Expand All @@ -57,6 +54,7 @@ dependencies:
screen_retriever:
git:
url: https://github.com/leanflutter/screen_retriever.git
path: packages/screen_retriever
ref: main
```
Expand All @@ -73,6 +71,42 @@ void _init() async {
}
```

### 监听事件

```dart
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);
}
}
```

> 请看这个插件的示例应用,以了解完整的例子。
## 谁在用使用它?
Expand All @@ -85,9 +119,9 @@ void _init() async {

| Method | Description | Linux | macOS | Windows |
| ---------------------- | --------------------------------------------- | ----- | ----- | ------- |
| `getCursorScreenPoint` | 返回 `Offset` - 鼠标指针的当前绝对位置。 | ✔️ | ✔️ | ✔️ |
| `getPrimaryDisplay` | 返回 `Display` - 主显示屏。 | ✔️ | ✔️ | ✔️ |
| `getAllDisplays` | 返回 `List<Display>` - 当前可用的显示器列表。 | ✔️ | ✔️ | ✔️ |
| `getCursorScreenPoint` | 返回 `Offset` - 鼠标指针的当前绝对位置。 | ✔️ | ✔️ | ✔️ |
| `getPrimaryDisplay` | 返回 `Display` - 主显示屏。 | ✔️ | ✔️ | ✔️ |
| `getAllDisplays` | 返回 `List<Display>` - 当前可用的显示器列表。 | ✔️ | ✔️ | ✔️ |

## 许可证

Expand Down
68 changes: 51 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# screen_retriever

[![pub version][pub-image]][pub-url] [![][discord-image]][discord-url] ![][visits-count-image]
[![pub version][pub-image]][pub-url] [![][discord-image]][discord-url]

[pub-image]: https://img.shields.io/pub/v/screen_retriever.svg
[pub-url]: https://pub.dev/packages/screen_retriever

[discord-image]: https://img.shields.io/discord/884679008049037342.svg
[discord-url]: https://discord.gg/zPa6EZ2jqb

[visits-count-image]: https://img.shields.io/badge/dynamic/json?label=Visits%20Count&query=value&url=https://api.countapi.xyz/hit/leanflutter.screen_retriever/visits

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

---
Expand All @@ -21,23 +18,23 @@ English | [简体中文](./README-ZH.md)
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [screen_retriever](#screen_retriever)
- [Platform Support](#platform-support)
- [Quick Start](#quick-start)
- [Installation](#installation)
- [Usage](#usage)
- [Who's using it?](#whos-using-it)
- [API](#api)
- [ScreenRetriever](#screenretriever)
- [License](#license)
- [Platform Support](#platform-support)
- [Quick Start](#quick-start)
- [Installation](#installation)
- [Usage](#usage)
- [Listening events](#listening-events)
- [Who's using it?](#whos-using-it)
- [API](#api)
- [ScreenRetriever](#screenretriever)
- [License](#license)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Platform Support

| Linux | macOS | Windows |
| :---: | :---: | :-----: |
| ✔️ | ✔️ | ✔️ |
| ✔️ | ✔️ | ✔️ |

## Quick Start

Expand All @@ -57,6 +54,7 @@ dependencies:
screen_retriever:
git:
url: https://github.com/leanflutter/screen_retriever.git
path: packages/screen_retriever
ref: main
```
Expand All @@ -73,6 +71,42 @@ void _init() async {
}
```

### Listening events

```dart
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?
Expand All @@ -85,9 +119,9 @@ void _init() async {

| Method | Description | Linux | macOS | Windows |
| ---------------------- | ---------------------------------------------------------------------------- | ----- | ----- | ------- |
| `getCursorScreenPoint` | Returns `Offset` - The current absolute position of the mouse pointer. | ✔️ | ✔️ | ✔️ |
| `getPrimaryDisplay` | Returns `Display` - The primary display. | ✔️ | ✔️ | ✔️ |
| `getAllDisplays` | Returns `List<Display>` - An array of displays that are currently available. | ✔️ | ✔️ | ✔️ |
| `getCursorScreenPoint` | Returns `Offset` - The current absolute position of the mouse pointer. | ✔️ | ✔️ | ✔️ |
| `getPrimaryDisplay` | Returns `Display` - The primary display. | ✔️ | ✔️ | ✔️ |
| `getAllDisplays` | Returns `List<Display>` - An array of displays that are currently available. | ✔️ | ✔️ | ✔️ |

## License

Expand Down

0 comments on commit c1df36b

Please sign in to comment.