gutter

package module
v0.3.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2018 License: LGPL-3.0 Imports: 8 Imported by: 10

README

Go Flutter desktop embedder

Awesome Flutter

A Go (golang) Custom Flutter Engine Embedder for desktop

Purpose

This project doesn't compete with this awesome one. The purpose of this project is to support the Flutter framework on Windows, MacOS, and Linux using a SINGLE code base.

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, I hope, will encourage people to contribute 😁.

How to install

:package: :penguin: Linux

From binaries

Check out the Release page for prebuilt versions.

From source

Go read first: go-gl/glfw

# Clone
git clone https://github.com/Drakirus/go-flutter-desktop-embedder.git
cd go-flutter-desktop-embedder

# Build the flutter simpleDemo project
cd example/simpleDemo/
cd flutter_project/demo/
flutter build bundle
cd ../..

# Download the share library, the one corresponding to your flutter version.
go run engineDownloader.go

# REQUIRED before every `go build`. The CGO compiler need to know where to look for the share library
export CGO_LDFLAGS="-L${PWD}"
# The share library must stay next to the generated binary.

# Get the libraries
go get -u -v github.com/Drakirus/go-flutter-desktop-embedder

# Build the example project
go build main.go

# `go run main.go` is not working ATM.
:package: :checkered_flag: Windows

From binaries

Check out the Release page for prebuilt versions.

From source

Go read first: go-gl/glfw

# Clone
git clone https://github.com/Drakirus/go-flutter-desktop-embedder.git
cd go-flutter-desktop-embedder

# Build the flutter simpleDemo project
cd example/simpleDemo/
cd flutter_project/demo/
flutter build bundle
cd ../..

# Download the share library, the one corresponding to your flutter version.
go run engineDownloader.go

# REQUIRED before every `go build`. The CGO compiler need to know where to look for the share library
set CGO_LDFLAGS=-L%cd%
# The share library must stay next to the generated binary.
# If you ran into a MinGW ld error, checkout: https://github.com/Drakirus/go-flutter-desktop-embedder/issues/34

# Get the libraries
go get -u -v github.com/Drakirus/go-flutter-desktop-embedder

# Build the example project
go build main.go

# `go run main.go` is not working ATM.
:package: :apple: MacOS

From binaries

Check out the Release page for prebuilt versions.

From source

Go read first: go-gl/glfw

# Clone
git clone https://github.com/Drakirus/go-flutter-desktop-embedder.git
cd go-flutter-desktop-embedder

# Build the flutter simpleDemo project
cd example/simpleDemo/
cd flutter_project/demo/
flutter build bundle
cd ../..

# Download the share library, the one corresponding to your flutter version.
go run engineDownloader.go

# REQUIRED before every `go build`. The CGO compiler need to know where to look for the share library
export CGO_LDFLAGS="-F${PWD} -Wl,-rpath,@executable_path"
# The share library must stay next to the generated binary.

# Get the libraries
go get -u -v github.com/Drakirus/go-flutter-desktop-embedder

# Build the example project
go build main.go

# `go run main.go` is not working ATM.

Flutter Demos Projects

The examples are available here.

Screenshot of the Stocks demo app on macOS

Support

  • Linux 🐧
  • Windows 🏁
  • MacOS 🍎
  • Importable go library
  • Plugins Medium article on how the the Flutter's messaging works
    • JSON MethodChannel
    • StandardMethodCodec, ...
  • System plugins Platform channels used by the Flutter system
    • Window Title
    • Text input
    • Clipboard (through shortcuts)
    • Clipboard (through the click)
    • 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
      • ctrl-Delete
    • Key events

Documentation

Index

Constants

View Source
const (
	ModNone         int = 0
	ModShift        int = 1
	ModControl      int = 2
	ModShiftControl int = 3
	ModAlt          int = 4
	ModSuper        int = 8
)

Modifier keys from glfw

Variables

This section is empty.

Functions

func Run

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

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

Types

type ArgsAppSwitcherDescription

type ArgsAppSwitcherDescription struct {
	Label        string `json:"label"`
	PrimaryColor int64  `json:"primaryColor"`
}

ArgsAppSwitcherDescription Args content

type Option

type Option func(*config)

Option for gutter

func OptionAddPluginReceiver

func OptionAddPluginReceiver(handler PluginReceivers, channelName string) Option

OptionAddPluginReceiver add a new function that will be trigger when the FlutterEngine send a PlatformMessage to the Embedder

func OptionAssetPath

func OptionAssetPath(p string) Option

OptionAssetPath specify the flutter asset directory.

func OptionICUDataPath

func OptionICUDataPath(p string) Option

OptionICUDataPath specify the path to the ICUData.

func OptionPixelRatio

func OptionPixelRatio(ratio float64) Option

OptionPixelRatio specify the scale factor for the physical screen.

func OptionVMArguments

func OptionVMArguments(a []string) Option

OptionVMArguments specify the arguments to the Dart VM.

func OptionWindowDimension

func OptionWindowDimension(x int, y int) Option

OptionWindowDimension specify the startup's dimention of the window.

func OptionWindowInitializer

func OptionWindowInitializer(ini func(*glfw.Window) error) Option

OptionWindowInitializer allow initializing the window.

type PluginReceivers

type PluginReceivers func(
	message *flutter.PlatformMessage,
	flutterEngine *flutter.EngineOpenGL,
	window *glfw.Window,
) bool

PluginReceivers do stuff when receiving Message from the Engine, send result with `flutterEngine.SendPlatformMessageResponse`

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL