A port of Flutter to Go
v1.18.0
Flutter's widgets. Written in Go.
Glutter is a port of Flutter to Go. It gives Go the framework API of Flutter. Widgets, state, gestures, animation, Material 3 and Cupertino have the names you know, and they are drawn by Glutter's own engine on the GPU.
Get started I know Flutter GitHub
go get github.com/rm4n0s/glutter@latest
This is the app, not a picture of it. It is a Go program, compiled to WebAssembly.
6
platforms from one code base
0
lines of C to compile on the desktop and the web
400 fps
with a million triangles and their edges, on a Radeon RX 6800M
17
apps of the Playground run in this site
One code base, six platforms
- LinuxVulkan, OpenGL ES
- WindowsDirect3D 12
- macOSMetal
- iOSMetal
- AndroidVulkan
- WebWebGPU, WebGL 2
The API you know
StatefulWidget,BuildContext,SetState,ThemeOf,Navigator, animation controllers,CustomPaint. What you know of Flutter carries over, name by name.Only Go
There is no cgo on the desktop and the web.
CGO_ENABLED=0 go buildmakes the app, and Go is all you install: no C compiler, no SDK, no other tool.An engine of its own
It is not Flutter’s engine, and it is not a web view. Glutter lays out, paints and draws with the GPU itself, through Vulkan, Direct3D 12, Metal, WebGPU and WebGL 2.
If you know Flutter, you can read this
A constructor is a function NewX. Required parameters are arguments, optional ones are fields of XOpts, and State<Counter> is m.StateOf[*Counter]. A few rules like these turn the whole API into Go.
class Counter extends StatefulWidget {
const Counter({super.key});
@override
State<Counter> createState() => _CounterState();
}
class _CounterState extends State<Counter> {
int _count = 0;
@override
Widget build(BuildContext context) {
return TextButton(
onPressed: () => setState(() => _count++),
child: Text('Pushed $_count times'),
);
}
}
type Counter struct{ m.StatefulWidget }
func NewCounter() *Counter { return &Counter{} }
func (c *Counter) CreateState() m.State {
return &counterState{}
}
type counterState struct {
m.StateOf[*Counter]
count int
}
func (s *counterState) Build(bc m.BuildContext) m.Widget {
return m.NewTextButton(
func() { s.SetState(func() { s.count++ }) },
m.NewText("Pushed "+strconv.Itoa(s.count)+" times"))
}
Drawn by Go, at every frame
These are not videos. Each one is a Go program that runs in this page when you press Run.
Charts with no chart library
The line with its glow, the ring and the bars are custom painters, about 200 lines of Go. Change the period, and every shape moves to its new values.
- A painter listens to an animation controller, and no widget is built again while it moves
- Gradients, blur, arcs and curves, with the
Canvasof Flutter - The mouse over the line shows the value under it
Thousands of particles
A loop in Go moves every particle, and one painter draws them all, sixty times a second. The pointer pulls them, and a click pushes them away.
- 4,000 particles at the start, and up to 8,000 with the slider
- Light that adds up where the lines cross
- Material widgets over the picture, in the same widget tree
3D is part of the toolkit
A 3D view is a widget. It shows glTF models with their materials, skins and shadows, has a camera you can orbit, and sits in the tree beside buttons and sliders. A program can also draw with shaders of its own.
Coin Run, a 3D gameA character runs and jumps through a small level, collects twelve coins and keeps out of the lava.
CAD viewerA 3D viewer for parts, with display modes, a section plane, picks and a measured distance.
A cube on the GPUA lit cube that turns, drawn by the program's own shader inside a Material page.
Two looks
The Material 3 components and the Cupertino ones of iOS and macOS are both there, in light and in dark. An app chooses the one it wants.
Test a screen without a window
gluttertest runs a widget on a fake platform, as Flutter’s WidgetTester does: it builds the app, taps what a finder finds, lets time pass and compares a screen with a golden image. The tests of the apps of this page run in well under a second, with go test.
func TestTapIncrements(t *testing.T) {
ts := gluttertest.New(t)
ts.PumpWidget(NewMyApp())
ts.Tap(gluttertest.ByType[*m.FloatingActionButton]())
ts.Pump(50 * time.Millisecond)
if n := ts.Count(gluttertest.ByText("1")); n != 1 {
t.Errorf("the text 1 is shown %d times, want 1", n)
}
}
Run them all
The PlaygroundApplications built with Glutter
My own desktop applications use it every day.
EmetosA code editor in the spirit of Visual Studio Code, in one Go binary. No Electron, no Node.js and no cgo.JailcatA desktop app for firejail. Choose what a sandboxed copy of an application may see and do, and install that copy in your application menu.
CaveAn SSH server that you start, watch and stop yourself. It does the job of sshd, but it is an ordinary program and needs no root.
PassbankMerges two KeePass databases into a new one, and lets you choose what the new database keeps.
mardpUse a Mac from another computer over your home network, with a remote desktop program that speaks RDP.TubeRuns one application through a VPN, and only that application. Every other program keeps using the machine's own network.
SoftInstalls and updates applications written in Go. An application with a window also goes into your desktop's menu, with its name and its logo.
English TutorA desktop app for practising written English. An LLM finds the errors in what you write, and the app explains each one.
Radio TutorA desktop tutoring app for children. It plays narrated lessons, the child solves the exercises on paper, and an AI checks the photos.Save EditorA desktop editor for the save files of games. Change the money, the names, the flags and the stats, and save again.
Desktop MirrorShow your phone's camera on your PC, and your PC's camera on your phone, over WebRTC.
Under the hood#
Glutter is a port of Flutter’s framework, written again in Go. It runs on its own engine, not on Flutter’s. On Linux that is a Wayland and X11 platform layer and a Vulkan renderer with an OpenGL ES 3.0 fallback. On Windows it uses Win32 and Direct3D 12, and on macOS and iOS it uses AppKit, UIKit and Metal. In a browser the same Go code is compiled with GOOS=js GOARCH=wasm by the standard Go toolchain, and draws with WebGPU or WebGL 2.
The system libraries are called through purego, and text is laid out with go-text. Android is the one target that uses cgo, for the NDK.
Apps import one package, the way Flutter’s apps import material.dart:
import m "github.com/rm4n0s/glutter/material"
- Language
- Go
- Runs on
- Linux, macOS, Windows, Web, Android, iOS
- License
- BSD-3-Clause
- Version
- v1.18.0
Guides for Glutter
- Write your first Glutter app Make a Go module, write the counter app with a stateless and a stateful widget, run it as a window, and test it without a window.
- Glutter for Flutter developers The rules that turn Flutter's API into Go, with Dart and Go side by side, and the few things that are not the same.
- Run a Glutter app in the browser Compile a Glutter app to WebAssembly with glutter-web, serve it while you work, and make the folder that goes on a web server.
Start with one command
You need Go 1.27.4 or newer, and nothing else to build.
# Add Glutter to your module
$ go get github.com/rm4n0s/glutter@latest
# Run your app in a window
$ go run .
# Or in a browser
$ go run github.com/rm4n0s/glutter/cmd/glutter-web serve .
Showcase
Pulse, a dashboard
Flow, a field of particles
Material 3 gallery
Cupertino gallery
Coin Run, a 3D game
CAD viewer
Text editor
To-do list
Counter
Layout
Animations
Scrolling
Navigation
Custom painting
SVG pictures
A cube on the GPU