Categorygithub.com/go-flutter-desktop/go-flutter
modulepackage
0.52.2
Repository: https://github.com/go-flutter-desktop/go-flutter.git
Documentation: pkg.go.dev

# README

go-flutter - A package that brings Flutter to the desktop

Awesome Flutter Documentation Go Report Card Join the chat at https://gitter.im/go-flutter-desktop/go-flutter

Purpose

Flutter allows you to build beautiful native apps on iOS and Android from a single codebase.

This unofficial project brings Flutter to the desktop through the power of Go and GLFW.

The flutter engine itself doesn't know how to deal with desktop platforms (eg handling mouse/keyboard input). Instead, it exposes an abstraction layer for whatever platform to implement. This project implements the Flutter's Embedding API using a single code base that runs on Windows, macOS, and Linux. For rendering, GLFW fits the job because it provides the right abstractions over the OpenGL's Buffer/Mouse/Keyboard for each platform.

The choice of Golang comes from the fact that it has the same tooling on every platform. Plus Golang is a great language because it keeps everything simple and readable, which makes it easy to build cross-platform plugins.

Screenshot of the Stocks demo app on macOS

Getting started

The best way to get started is to install hover, the official go-flutter tool to set up, build and run Flutter apps on the desktop, including hot-reload.

Read the hover tutorial to run your app on the desktop, or start with one of our example apps.

If you want more in-depth information about go-flutter, read the wiki.

Supported features

  • Linux :penguin:
  • MacOS :apple:
  • Windows :checkered_flag:
  • Hot Reload
  • Plugin system
    • BinaryMessageCodec, BinaryMessageChannel
    • StandardMessageCodec, JSONMessageCodec
    • StandardMethodCodec, MethodChannel
  • Plugin detection for supported plugins
  • Importable as Go library into custom projects
  • UTF-8 Text input
  • Clipboard copy & paste
  • Window title and icon
  • Standard keyboard shortcuts
    • ctrl-c ctrl-v ctrl-x ctrl-a
    • Home End shift-Home shift-End
    • Left ctrl-Left ctrl-shift-Left
    • Right ctrl-Right ctrl-shift-Right
    • Backspace ctrl-Backspace Delete
  • Mouse-over/hovering
  • Mouse-buttons
  • RawKeyboard events
  • Distribution format (windows-msi, mac-dmg, linux-appimage, and more)
  • Cross-compiling using docker :whale:

Are you missing a feature? Open an issue!

Examples

A separate repository contains example Flutter apps that also run on the desktop. Go to github.com/go-flutter-desktop/examples to give them a try.

Plugins

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

For a detailed tutorial on how to create a plugin, read the wiki.

Version compatibility

Flutter version

Flutter itself is a relatively young project. Its framework and engine are updated often. The go-flutter project tries to stay compatible with the beta channel of Flutter.

Go version

Updating Go is simple and Go seldomly has backwards-incompatible changes. This project remains compatible with the latest Go stable release.

GLFW version

This project uses go-gl/glfw for GLFW v3.3.

License

BSD 3-Clause License

# Packages

Package embedder wraps the Flutter Embedder C API to Go.
Package plugin contains message codecs, method codecs and channel implementations which allow plugins to communicate between the flutter framework and the host (Go).

# Functions

AddPlugin adds a plugin to the flutter application.
ApplicationELFSnapshotPath specify the path to the ELF AOT snapshot.
ApplicationICUDataPath specify the path to the ICUData.
BackOnEscape controls the mapping of the escape key.
ForcePixelRatio forces the the scale factor for the screen.
NewApplication creates a new application with provided options.
OptionVMArguments specify the arguments to the Dart VM.
PopBehavior sets the PopBehavior on the application.
ProjectAssetsPath specify the flutter assets directory.
Run executes a flutter application with the provided options.
ScrollAmount sets the number of pixels to scroll with the mouse wheel.
VirtualKeyboardHide sets an func called when the flutter framework want to hide the keyboard.
VirtualKeyboardShow sets an func called when the flutter framework want to show the keyboard.
WindowAlwaysOnTop sets the application window to be always on top of other windows.
WindowDimensionLimits specify the dimension limits of the window.
WindowIcon sets an icon provider func, which is called during window initialization.
WindowInitialDimensions specify the startup's dimension of the window.
WindowInitialLocation specify the startup's position of the window.
WindowMode sets the window mode on the application.
WindowTransparentBackground sets the init window background to be transparent.

# Constants

PopBehaviorClose closes the application on a system navigation pop event.
PopBehaviorHide hides the application window on a system navigation pop event.
PopBehaviorIconify minimizes/iconifies the application window on a system navigation pop event.
PopBehaviorNone means the system navigation pop event is ignored.
WindowModeBorderless removes decorations such as borders and close/minimize buttons from the window.
WindowModeBorderlessFullscreen starts the application in borderless fullscreen mode.
WindowModeBorderlessMaximize starts the application in borderless maximize mode.
WindowModeDefault is the default window mode.
WindowModeMaximize starts the application maximized.

# Variables

ProjectVersion contains the version of the go-flutter been used.
ProjectName contains the application name.
ProjectOrganizationName contains the package org name, (Can by set upon flutter create (--org flag)).
ProjectVersion contains the version of the build.

# Structs

Application provides the flutter engine in a user friendly matter.
EventLoop is a event loop for the main thread that allows for delayed task execution.
PixelBuffer is an in-memory (RGBA) image.
Texture is an identifier for texture declaration.
TextureRegistry is a registry entry for a managed Texture.

# Interfaces

Plugin defines the interface that each plugin must implement.
PluginGLFW defines the interface for plugins that are GLFW-aware.
PluginTexture defines the interface for plugins that needs to create and manage backend textures.

# Type aliases

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