Last updated:
0 purchases
plugins
Plugins #
A simple plugin loading system.
A plugin system allows you to extend functionality of your system. Other
developers can hook into your APIs through the plugins library and interact
with each other at ease.
Example #
Initializing the loader is very simple
import 'package:plugins/loader.dart';
void main() {
PluginManager pm = new PluginManager();
Directory path = new Directory("plugins");
pm.loadAll(path).then((_) {
pm.listenAll((name, data) {
print("Received data from plugin '$name': ${data[0]}");
pm.killAll();
});
Map m = new Map();
m[0] = "Hello from loader!";
pm.sendAll(m);
});
}
copied to clipboard
The plugins folder will look something like:
.
+-- test
| +-- main.dart
| +-- pubspec.yaml
| +-- lib/
| +-- packages/
copied to clipboard
Your lib folder can contain more code as needed for functionality. Dependencies
will work the same as usual for plugins. The pubspec.yaml file must contain, at
a minimum, the name.
Creating a plugin for a loader is just as simple as creating a loader.
import 'package:plugins/plugin.dart';
import 'dart:isolate';
void main(List<String> args, SendPort port) {
Receiver rec = new Receiver(port);
rec.listen((Map<dynamic, dynamic> data) {
print("Received data in plugin: ${data[0]}");
Map info = new Map();
info[0] = "Hello from plugin!";
rec.send(info);
});
}
copied to clipboard
The examples can give you more insight for more powerful APIs.
Visit the documentation for more information about the APIs.
Open an issue for any
problems or suggestions.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.