-
Notifications
You must be signed in to change notification settings - Fork 282
Plugin info
Pierre Champion edited this page May 17, 2019
·
18 revisions
go-flutter exposes the flutter's platform-channels allowing you to write platform-specific code.
Plugins development is where this project shine, with the power of Golang we only have to write plugin once.
To add plugin you need to use AddPlugin
If you are using hover edit desktop/cmd/options.go
.
Example:
package main
import (
"github.com/go-flutter-desktop/go-flutter"
"github.com/go-flutter-desktop/plugins/path_provider"
)
var options = []flutter.Option{
flutter.WindowInitialDimensions(800, 600),
flutter.AddPlugin(&path_provider.PathProviderPlugin{
VendorName: "myOrganizationOrUsername",
ApplicationName: "myApplicationName",
}),
// flutter.AddPlugin(&SomeOtherPlugin),
}
hover will fetch the plugin, when building/running the app.
If you want to implement a plugin make sure to read an existing implementation, path_provider is a good example.
For more information, read the GoDoc: here and here.
Hover uses the Go modules, so If you want to add your plugin to desktop/cmd/options.go
, you can fake a plugin name by using the replace
directive in go.mod
.
Example:
go.mod
file
module github.com/go-flutter-desktop/examples/helllo/desktop
go 1.12
require (
github.com/go-flutter-desktop/go-flutter v0.16.0
github.com/go-flutter-desktop/plugins/not-exist v0.1.0
)
replace github.com/go-flutter-desktop/plugins/not-exist => /home/drakirus/lab/go/src/github.com/go-flutter-desktop/plugins/shared_preferences
desktop/cmd/options.go
package main
import (
"github.com/go-flutter-desktop/go-flutter"
"github.com/go-flutter-desktop/plugins/not-exist"
)
var options = []flutter.Option{
flutter.AddPlugin(&shared_preferences.SharedPreferencesPlugin{
VendorName: "myOrganizationOrUsername",
ApplicationName: "myApplicationName",
}),
// ...
}