Skip to content

Plugin info

Pierre Champion | Drakirus edited this page May 26, 2020 · 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 for desktops.

Some popular plugins are already implemented over at github.com/go-flutter-desktop/plugins. If you have implemented a flutter/plugins that you would like to share, feel free to open a PR on the plugins repository!

Add plugin to your application

Adding plugins to your application can be done in 2 manners:

1) Using hover (preferred method)

Newly created go-flutter plugin implements a import.go.tmpl file used to register the plugin when running hover plugins get.

  • To list available plugins, run: hover plugins list.
  • To import missing plugins, run: hover plugins get.
  • To delete unused plugins, run: hover plugin tidy. (--purge flag is available to delete all plugins)

2) Manual/direct import

To add plugin you can use the AddPlugin option. The file to edit is go/cmd/options.go.

Adding path_provider to your hover app:

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.