go-flutter: github.com/go-flutter-desktop/go-flutter Index | Files | Directories

package flutter

import "github.com/go-flutter-desktop/go-flutter"

Package flutter combines the embedder API with GLFW and plugins. Flutter and Go on the desktop.

go-flutter is in active development. API's must be considered beta and may be changed.

Index

Package Files

accessibility.go application.go build-constant.go doc.go event-loop.go glfw.go isolate.go key-events.go lifecycle.go messenger.go mousecursor.go navigation.go option.go platform.go plugin.go pop.go text-input.go texture-registry.go texture.go window.go

Constants

const (
    // PopBehaviorNone means the system navigation pop event is ignored.
    PopBehaviorNone popBehavior = iota
    // PopBehaviorHide hides the application window on a system navigation pop
    // event.
    PopBehaviorHide
    // PopBehaviorIconify minimizes/iconifies the application window on a system
    // navigation pop event.
    PopBehaviorIconify
    // PopBehaviorClose closes the application on a system navigation pop event.
    PopBehaviorClose
)
const (
    // WindowModeDefault is the default window mode. Windows are created with
    // borders and close/minimize buttons.
    WindowModeDefault windowMode = iota
    // WindowModeBorderless removes decorations such as borders and
    // close/minimize buttons from the window.
    WindowModeBorderless
    // WindowModeBorderlessFullscreen starts the application in borderless
    // fullscreen mode. Currently, only fullscreen on the primary monitor is
    // supported. This option overrides WindowInitialDimensions. Note that on
    // some systems a fullscreen window is very hard to close. Make sure your
    // Flutter application has a close button and use PopBehaviorIconify to
    // minimize or PopBehaviorClose to close the application.
    WindowModeBorderlessFullscreen
    // WindowModeMaximize starts the application maximized.
    WindowModeMaximize
    // WindowModeBorderlessMaximize starts the application in borderless
    // maximize mode.
    WindowModeBorderlessMaximize
)

Variables

var (
    // ProjectVersion contains the version of the build
    ProjectVersion = "unknown"
    // ProjectVersion contains the version of the go-flutter been used
    PlatformVersion = "unknown"
    // ProjectName contains the application name
    ProjectName = "unknown"
    // ProjectOrganizationName contains the package org name, (Can by set upon flutter create (--org flag))
    ProjectOrganizationName = "unknown"
)

Compile configuration constants persistent across all flutter.Application. The values of config(option.go) can change between flutter.Run calls, those values contains informations that needs to be access globally, without requiring an flutter.Application.

Values overwritten by hover during the 'Compiling 'go-flutter' and plugins' phase.

func Run Uses

func Run(opt ...Option) (err error)

Run executes a flutter application with the provided options. given limitations this method must be called by the main function directly.

Run(opt) is short for NewApplication(opt).Run()

type Application Uses

type Application struct {
    // contains filtered or unexported fields
}

Application provides the flutter engine in a user friendly matter.

func NewApplication Uses

func NewApplication(opt ...Option) *Application

NewApplication creates a new application with provided options.

func (*Application) Run Uses

func (a *Application) Run() error

Run starts the application and waits for it to finish.

type EventLoop Uses

type EventLoop struct {
    // contains filtered or unexported fields
}

EventLoop is a event loop for the main thread that allows for delayed task execution.

func (*EventLoop) PostTask Uses

func (t *EventLoop) PostTask(task embedder.FlutterTask, targetTimeNanos uint64)

PostTask posts a Flutter engine tasks to the event loop for delayed execution. PostTask must ALWAYS be called on the same goroutine/thread as `newEventLoop`

func (*EventLoop) RunOnCurrentThread Uses

func (t *EventLoop) RunOnCurrentThread() bool

RunOnCurrentThread return true if tasks posted on the calling thread will be run on that same thread.

func (*EventLoop) WaitForEvents Uses

func (t *EventLoop) WaitForEvents(rendererWaitEvents func(float64))

WaitForEvents waits for an any Rendering or pending Flutter Engine events and returns when either is encountered. Expired engine events are processed

type ExternalTextureHanlderFunc Uses

type ExternalTextureHanlderFunc func(width int, height int) (bool, *PixelBuffer)

ExternalTextureHanlderFunc describes the function that handles external Texture on a given ID.

type Option Uses

type Option func(*config)

Option for Application

func AddPlugin Uses

func AddPlugin(p Plugin) Option

AddPlugin adds a plugin to the flutter application.

func ApplicationELFSnapshotPath Uses

func ApplicationELFSnapshotPath(p string) Option

ApplicationELFSnapshotPath specify the path to the ELF AOT snapshot. only required by AOT.

func ApplicationICUDataPath Uses

func ApplicationICUDataPath(p string) Option

ApplicationICUDataPath specify the path to the ICUData.

func ForcePixelRatio Uses

func ForcePixelRatio(ratio float64) Option

ForcePixelRatio forces the the scale factor for the screen. By default, go-flutter will calculate the correct pixel ratio for the user, based on their monitor DPI. Setting this option is not advised.

func OptionVMArguments Uses

func OptionVMArguments(a []string) Option

OptionVMArguments specify the arguments to the Dart VM.

func PopBehavior Uses

func PopBehavior(p popBehavior) Option

PopBehavior sets the PopBehavior on the application

func ProjectAssetsPath Uses

func ProjectAssetsPath(p string) Option

ProjectAssetsPath specify the flutter assets directory.

func ScrollAmount Uses

func ScrollAmount(amount float64) Option

ScrollAmount sets the number of pixels to scroll with the mouse wheel

func VirtualKeyboardHide Uses

func VirtualKeyboardHide(hideCallback func()) Option

VirtualKeyboardHide sets an func called when the flutter framework want to hide the keyboard.

func VirtualKeyboardShow Uses

func VirtualKeyboardShow(showCallback func()) Option

VirtualKeyboardShow sets an func called when the flutter framework want to show the keyboard. This Option is interesting for people wanting to display the on-screen keyboard on TextField focus. It's up to the flutter developer to implement (or not) this function with the OS related call.

func WindowAlwaysOnTop Uses

func WindowAlwaysOnTop(enabled bool) Option

WindowAlwaysOnTop sets the application window to be always on top of other windows

func WindowDimensionLimits Uses

func WindowDimensionLimits(minWidth, minHeight, maxWidth, maxHeight int) Option

WindowDimensionLimits specify the dimension limits of the window. Does not work when the window is fullscreen or not resizable.

func WindowIcon Uses

func WindowIcon(iconProivder func() ([]image.Image, error)) Option

WindowIcon sets an icon provider func, which is called during window initialization. For tips on the kind of images to provide, see https://godoc.org/github.com/go-gl/glfw/v3.3/glfw#Window.SetIcon

func WindowInitialDimensions Uses

func WindowInitialDimensions(width, height int) Option

WindowInitialDimensions specify the startup's dimension of the window.

func WindowInitialLocation Uses

func WindowInitialLocation(xpos, ypos int) Option

WindowInitialLocation specify the startup's position of the window. Location, in screen coordinates, of the upper-left corner of the client area of the window.

func WindowMode Uses

func WindowMode(w windowMode) Option

WindowMode sets the window mode on the application.

func WindowTransparentBackground Uses

func WindowTransparentBackground(enabled bool) Option

WindowTransparentBackground sets the init window background to be transparent

type PixelBuffer Uses

type PixelBuffer struct {
    // Pix holds the image's pixels, in R, G, B, A order.
    Pix []uint8
    // Width and Height of the image's bounds
    Width, Height int
}

PixelBuffer is an in-memory (RGBA) image.

type Plugin Uses

type Plugin interface {
    // InitPlugin is called during the startup of the flutter application. The
    // plugin is responsible for setting up channels using the BinaryMessenger.
    // If an error is returned it is printend the application is stopped.
    InitPlugin(messenger plugin.BinaryMessenger) error
}

Plugin defines the interface that each plugin must implement. When InitPlugin is called, the plugin may execute setup operations. The BinaryMessenger is passed to allow the plugin to register channels. A plugin may optionally implement PluginGLFW.

type PluginGLFW Uses

type PluginGLFW interface {
    // Any type inmplementing PluginGLFW must also implement Plugin.
    Plugin
    // InitPluginGLFW is called after the call to InitPlugin. When an error is
    // returned it is printend the application is stopped.
    InitPluginGLFW(window *glfw.Window) error
}

PluginGLFW defines the interface for plugins that are GLFW-aware. Plugins may implement this interface to receive access to the *glfw.Window. Note that plugins must still implement the Plugin interface. The call to InitPluginGLFW is made after the call to InitPlugin.

PluginGLFW is separated because not all plugins need to know about glfw, Adding glfw.Window to the InitPlugin call would add glfw as dependency to every plugin implementation. Also, this helps in a scenarion where glfw is moved into a separate renderer/glfw package.

The PluginGLFW interface is not stable and may change at any time.

type PluginTexture Uses

type PluginTexture interface {
    // Any type inmplementing PluginTexture must also implement Plugin.
    Plugin
    // InitPluginTexture is called after the call to InitPlugin. When an error is
    // returned it is printend the application is stopped.
    InitPluginTexture(registry *TextureRegistry) error
}

PluginTexture defines the interface for plugins that needs to create and manage backend textures. Plugins may implement this interface to receive access to the TextureRegistry. Note that plugins must still implement the Plugin interface. The call to PluginTexture is made after the call to PluginGLFW.

PluginTexture is separated because not all plugins need to send raw pixel to the Flutter scene.

type Texture Uses

type Texture struct {
    ID int64
    // contains filtered or unexported fields
}

Texture is an identifier for texture declaration

func (*Texture) FrameAvailable Uses

func (t *Texture) FrameAvailable() error

FrameAvailable mark a texture buffer is ready to be draw in the flutter scene

func (*Texture) Register Uses

func (t *Texture) Register(handler ExternalTextureHanlderFunc) error

Register registers a textureID with his associated handler

func (*Texture) UnRegister Uses

func (t *Texture) UnRegister() error

UnRegister unregisters a textureID with his associated handler

type TextureRegistry Uses

type TextureRegistry struct {
    // contains filtered or unexported fields
}

TextureRegistry is a registry entry for a managed Texture.

func (*TextureRegistry) NewTexture Uses

func (t *TextureRegistry) NewTexture() Texture

NewTexture creates a new Texture

Directories

PathSynopsis
embedderPackage embedder wraps the Flutter Embedder C API to Go.
internal/debouncePackage debounce provides a debouncer func.
internal/execpath
internal/openglPackage opengl wraps the go-gl/gl OpenGL bindings with a compile-time OpenGL version selector.
internal/priorityqueue
internal/tasker
pluginPackage plugin contains message codecs, method codecs and channel implementations which allow plugins to communicate between the flutter framework and the host (Go).

Package flutter imports 27 packages (graph) and is imported by 10 packages. Updated 2020-05-29. Refresh now. Tools for package owners.