README.md 2.2 KB
Newer Older
1 2
# Desktop Plugins

P
Peter Haddad 已提交
3
See [the Flutter desktop
S
stuartmorgan 已提交
4 5
page](https://github.com/flutter/flutter/wiki/Desktop-shells#plugins)
for an overview of the current state of plugin development on desktop.
6

7
This directory contains three types of plugins:
8
* `sample`, which like `example/` will eventually be replaced by
S
stuartmorgan 已提交
9
  `flutter create -t plugin` support for desktop.
S
stuartmorgan 已提交
10
* `flutter_plugins`, which contain Windows and Linux implementations of plugins
11
  from [the flutter/plugins repository](https://github.com/flutter/plugins)
S
stuartmorgan 已提交
12
  that are expected to move to that repository once the plugin APIs are
13
  sufficiently stable.
S
stuartmorgan 已提交
14 15
* Plugins that prototype functionality that will likely become part of
  Flutter itself.
16

S
stuartmorgan 已提交
17 18 19
## Using Plugins

Since the plugins in this repository are not intended to live here long term,
20
and the `flutter` tool's plugin support isn't finalized on all platforms yet, these
S
stuartmorgan 已提交
21 22
plugins are not published on pub.dev like normal Flutter plugins. Instead, you
should include them directly from this repository.
23

24
### Dart
25

26 27 28
Add dependencies for plugins to your `pubspec.yaml` as usual. For unpublished
plugins such as the ones in this repository, you can use a git reference. For
example:
29 30 31 32

```
dependencies:
  ...
33
  sample:
S
stuartmorgan 已提交
34 35 36 37
    git:
      url: git://github.com/google/flutter-desktop-embedding.git
      path: plugins/sample
      ref: INSERT_HASH_HERE
38 39
```

S
stuartmorgan 已提交
40 41 42 43 44
Replace `INSERT_HASH_HERE` with the hash of commit you want to pin to,
usually the latest commit to the repository at the time you add the plugin.
(While omitting the `ref` is possible, it is **strongly** discouraged, as
without it any breaking change to the plugin would break your project
without warning.)
45

46 47
Then import it in your dart code as you would any other package:
```dart
48
import 'package:sample/sample.dart';
49 50
```

S
stuartmorgan 已提交
51
The import step does not apply to `flutter_plugins` plugins, as the
52 53
Dart code for those plugins comes from the official plugin.

54
### Linux
55

56
Many of the Linux plugins in this project require the following libraries:
S
stuartmorgan 已提交
57 58 59 60 61 62 63

* GTK 3
* pkg-config

Installation example for debian-based systems:

```
64
$ sudo apt-get install libgtk-3-dev pkg-config
S
stuartmorgan 已提交
65
```
66

S
stuartmorgan 已提交
67
## Writing Your Own Plugins
68

69 70
See [the `sample` README](sample/README.md) for instructions on using
it as a starting point for a new plugin.