## 1. Project Overview & Quickstart (go-flutter-desktop/go-flutter)

## File: README.md

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

[](https://github.com/Solido/awesome-flutter)
[](http://godoc.org/github.com/go-flutter-desktop/go-flutter)
[](https://goreportcard.com/report/github.com/go-flutter-desktop/go-flutter)
[](https://gitter.im/go-flutter-desktop/go-flutter?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

## Purpose

[Flutter](http://flutter.io/) allows you to build beautiful native apps on iOS and Android from a single codebase.

This [unofficial](https://github.com/go-flutter-desktop/go-flutter/issues/191#issuecomment-511384007) project brings Flutter to the desktop through the power of [Go](http://golang.org/) and [GLFW](https://github.com/go-gl/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](https://github.com/flutter/flutter/wiki/Custom-Flutter-Engine-Embedders) using a single code base that runs on Windows, macOS, and Linux. For rendering, [**GLFW**](https://github.com/go-gl/glfw) fits the job because it provides the right abstractions over the OpenGL's Buffer/Mouse/Keyboard for each platform.

The choice of [Golang](https://github.com/golang/go) 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.



## Getting started

The best way to get started is to install [hover](https://github.com/go-flutter-desktop/hover), the official go-flutter tool to set up, build and run Flutter apps on the desktop, including hot-reload.

Read the [hover tutorial](https://github.com/go-flutter-desktop/hover) to run your app on the desktop, or start with [one of our example apps](https://github.com/go-flutter-desktop/examples).

If you want more in-depth information about go-flutter, read the [wiki](https://github.com/go-flutter-desktop/go-flutter/wiki).

## Supported features

- Linux :penguin:
- MacOS :apple:
- Windows :checkered_flag:
- [**Hot Reload**](https://github.com/go-flutter-desktop/go-flutter/issues/129#issuecomment-513590141)
- Plugin system
  - BinaryMessageCodec, BinaryMessageChannel
  - StandardMessageCodec, JSONMessageCodec
  - StandardMethodCodec, **MethodChannel**
- Plugin detection for [supported plugins](https://github.com/go-flutter-desktop/go-flutter/wiki/Create-a-hover-compatible-plugin)
- Importable as Go library into custom projects
- UTF-8 Text input
- Clipboard copy & paste
- Window title and icon
- Standard keyboard shortcuts
  - <kbd>ctrl-c</kbd>  <kbd>ctrl-v</kbd>  <kbd>ctrl-x</kbd>  <kbd>ctrl-a</kbd>
  - <kbd>Home</kbd>  <kbd>End</kbd>  <kbd>shift-Home</kbd>  <kbd>shift-End</kbd>
  - <kbd>Left</kbd>  <kbd>ctrl-Left</kbd>  <kbd>ctrl-shift-Left</kbd>
  - <kbd>Right</kbd>  <kbd>ctrl-Right</kbd>  <kbd>ctrl-shift-Right</kbd>
  - <kbd>Backspace</kbd>  <kbd>ctrl-Backspace</kbd> <kbd>Delete</kbd>
- 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!](https://github.com/go-flutter-desktop/go-flutter/issues/new)

## Examples

A separate repository contains example Flutter apps that also run on the desktop. Go to [github.com/go-flutter-desktop/examples](https://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](https://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](https://github.com/go-flutter-desktop/go-flutter/wiki/Implement-a-plugin).

## 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](https://github.com/flutter/flutter/wiki/Flutter-build-release-channels) of Flutter.

### Go version

Updating Go is simple and Go [seldomly has backwards-incompatible changes](https://golang.org/doc/go1compat). This project remains compatible with the [latest Go stable release](https://golang.org/dl/).

### GLFW version

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

## License

[BSD 3-Clause License](LICENSE)

---

## File: embedder/README.md

# embedder

This package wraps the [Flutter embedder API](https://raw.githubusercontent.com/flutter/engine/master/shell/platform/embedder/embedder.h) in Go and adds some helper functions to work with it. This package does NOT contain any platform specific code (glfw, etc.) and may eventualy be used for platforms other than the ones targeted by go-flutter right now. Note that this package does not promise a stable API: types, functions, methods may all change in a breaking way.

## Build

To build this package set the `CGO_LDFLAGS` and run `go build`. For example:

On Linux:
```bash
export CGO_LDFLAGS="-L${HOME}/.cache/hover/engine/linux/"
go build
```

To build this package on Mac OS
```bash
export CGO_LDFLAGS="-F ${HOME}/Library/Caches/hover/engine/darwin"
go build
```

To build this package on Windows
```cmd
set CGO_LDFLAGS="-L%HOMEPATH%/.cache/hover/engine/windows/"
go build
```

This works if [hover](https://github.com/go-flutter-desktop/hover) has cached the flutter engine for the local user.

## 2. Official Technical Reference & Guides (go-flutter-desktop/website)

## File: README.md

# hover.build website

This repository contains the source for the [hover.build](https://hover.build) website.

Additions are welcome. Feel free to [open an issue](https://github.com/go-flutter-desktop/go-flutter/issues/new) if you want to discuss your idea before working on a PR.

## Developing

Install [hugo](https://gohugo.io/) and run `hugo serve --cleanDestinationDir` to test local changes before opening a PR.

## Theme

The themes folder contains a slightly modified copy of the [kube](https://themes.gohugo.io/kube/) theme.

## Hosting

The site is manually deployed and served with love by [Caddy](https://caddyserver.com/) on `sherlock4.geertjohan.net`.

---

## File: content/faq/_index.md

+++
title = "FAQ"
description = "Asked and answered"
+++

#### How does this compare to the "official" flutter desktop?

A elaborate answer was given in [issue#191](https://github.com/go-flutter-desktop/go-flutter/issues/191).

#### Is hover compatible with Visual Studio Code?

Yes, more details available in [issue#129](https://github.com/go-flutter-desktop/go-flutter/issues/129).

#### Is hover compatible with Android Studio?

No, the flutter-intellij plugin doesn't support attaching to existing process,
[issue#213](https://github.com/go-flutter-desktop/go-flutter/issues/213).

#### Where can I find example of go-flutter plugins?

On our [examples](https://github.com/go-flutter-desktop/examples), we shared
multiples plugins implementations. They are easy to explore and run.

For more sophisticate plugins, look at our [plugins](https://github.com/go-flutter-desktop/plugins) repo.

---

## File: content/docs/fonts.md

+++
title = "Fonts"
description = "Configure fonts for desktop"
weight = 30
toc = true
bref = "Fonts style your application, but how to use fonts on desktop? This guide walks you thorugh setting up fonts for desktop"
+++

### Fonts are assets

**Question:** What is the issue with fonts and cross-platform?

**Answer:** No text visible? Make sure you have used fonts added to the project asset.  
The default font for `MaterialApp`, Roboto, is not installed on all machines.


### Example

If the host is missing some fonts, it can cause the text to not be rendered or worse the app might crash, the
the [pointer_demo](https://github.com/go-flutter-desktop/examples/tree/master/pointer_demo)
solves this issue by including the fonts as asset.

```dart
class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Code Sample for widgets.Listener',
      theme: ThemeData(
        // If the host is missing some fonts, it can cause the
        // text to not be rendered or worse the app might crash.
        fontFamily: 'Roboto',
        primarySwatch: Colors.blue,
      ),
      home: MyStatefulWidget(),
    );
  }
}
```

```yaml
# [...]
flutter:

  fonts:
    - family: Roboto
      fonts:
        - asset: fonts/Roboto/Roboto-Thin.ttf
          weight: 100
        - asset: fonts/Roboto/Roboto-Light.ttf
          weight: 300
        - asset: fonts/Roboto/Roboto-Regular.ttf
          weight: 400
        - asset: fonts/Roboto/Roboto-Medium.ttf
          weight: 500
        - asset: fonts/Roboto/Roboto-Bold.ttf
          weight: 700
        - asset: fonts/Roboto/Roboto-Black.ttf
          weight: 900
```

```
Directory structure
.
├── pubspec.yaml
└── fonts
    └── Roboto
        ├── LICENSE.txt
        ├── Roboto-Black.ttf
        ├── Roboto-Bold.ttf
        ├── Roboto-Light.ttf
        ├── Roboto-Medium.ttf
        ├── Roboto-Regular.ttf
        └── Roboto-Thin.ttf
```

---

## File: content/docs/quick-start.md

+++
title = "Quick Start"
description = "Up and running in under a minute"
weight = 10
toc = true
bref = "Hover is a simple build tool to create 'go-'flutter desktop applications"
+++

### Install

Hover uses [Go](https://golang.org) to build your Flutter application to desktop. Hover itself is also written using the Go language. You will need to [install go](https://golang.org/doc/install) on your development machine.
Then install hover like this:


```bash
go get -u github.com/go-flutter-desktop/hover
```

If you get this error: `cmdApp.ProcessState.ExitCode undefined (type *os.ProcessState has no field or method ExitCode)`,
then update Go to at least version 1.12.

Run the same command to update when a newer version becomes available.

Install these dependencies:

* You need to make sure you have a C compiler.  
  The recommended C compiler are documented [here](https://github.com/golang/go/wiki/InstallFromSource#install-c-tools).

* You need to make sure you have dependencies of GLFW:
	* On macOS, you need Xcode or Command Line Tools for Xcode (`xcode-select --install`) for required headers and libraries.
	* On Ubuntu/Debian-like Linux distributions, you need `libgl1-mesa-dev xorg-dev` packages.
	* On CentOS/Fedora-like Linux distributions, you need `libX11-devel libXcursor-devel libXrandr-devel libXinerama-devel mesa-libGL-devel libXi-devel` packages.
	* See [here](http://www.glfw.org/docs/latest/compile.html#compile_deps) for full details.

### Init

The first time you use hover for a project, you'll need to initialize the project for desktop. `hover init` requires a project path. This is usualy the path for your project on github or a self-hosted git service. _If you are unsure, just make something up, it can always be changed later._

First, cd into a flutter project.

```bash
cd projects/simpleApplication
```

```bash
hover init github.com/my-organization/simpleApplication
```

This creates the directory `desktop` and adds boilerplate files such as Go code and a default logo.

Make sure you have the following
[main_desktop.dart](https://github.com/go-flutter-desktop/examples/blob/master/pointer_demo/lib/main_desktop.dart)
in the root librairie of your application.


Optionally, you may add [plugins](https://github.com/go-flutter-desktop/plugins) to `desktop/cmd/options.go`  
Optionally, change the logo in `desktop/assets/logo.png`, which is used as icon for the window.

### Run with hot-restart

To run the application and attach flutter for hot-reload support:

```bash
hover run
```

By default, hover uses the file `lib/main_desktop.dart` as entrypoint. You may specify a different endpoint by using the `--target` flag.

The hot-reload is manual because you'll need to press 'r' in the terminal to hot-reload the application.  

If you want to integrate go-flutter with VSCode, read [this](https://github.com/go-flutter-desktop/go-flutter/issues/129#issuecomment-513590141) issue.

---

## File: content/docs/using-plugins.md

+++
title = "Using plugins"
description = "Plugins "
weight = 30
bref = "Plugins allow flutter applications to communicate with the host platform"
+++

  
Plugins are an important part when building applications that interact with the
host system. This guide explains how to use plugins across Android, iOS and
desktop with Hover.  

The [github wiki](https://github.com/go-flutter-desktop/go-flutter/wiki/Plugin-info) about using plugins is a good source of updated information.

---

## File: content/blog/one-year-in.md

---
title: "go-flutter: One Year In, What was the journey like?"
  The go-flutter project is now one year old. We want to let you know how the project has
  evolved over this past year.
date: 2019-08-17T19:19:27+02:00
categories: ["general"]
weight: 20
author: "Pierre Champion (@Drakirus)"
draft: false
---

**I'm very excited** to use this first post to talk about _go-flutter_, what it is, why it was created, and how it has evolved.

Before I explain what _go-flutter_ is, let's start with the **famous** flutter system overview.



Flutter's engine takes core technologies, Skia, a 2D graphics rendering library, and Dart, and hosts them in a shell. Different platforms have different shells; for example, there are [shells](https://github.com/flutter/engine/tree/master/shell/platform) available for Android and iOS.

The Flutter team also exposes an [embedder API](https://github.com/flutter/engine/tree/master/shell/platform/embedder) which allows Flutter's engine to be used as a library.

The _go-flutter_ project provides a shell that implements the embedder APIs using a single code base that runs on Windows, macOS, and Linux. Achieving cross-platform support from a single codebase was made easy by using Go as the primary programming language.

---

As the title says, this project was created a year ago, at that time, the embedder API was composed of [180 lines of C](https://github.com/go-flutter-desktop/go-flutter/blob/640dcea647f47ceca0e3fb67166d2ea124a09f24/flutter/library/flutter_embedder.h). **To begin with**, I wanted to reproduce a [simple example shell](https://gist.github.com/chinmaygarde/8abf44921f7d87f6da7bf026267c4792) created by **@chinmaygarde**, one of the core maintainer of the Flutter engine. At first, my goal was to learn the Golang programming language, but only after the first [commit](https://github.com/go-flutter-desktop/go-flutter/tree/640dcea647f47ceca0e3fb67166d2ea124a09f24), I realized that my approach had some advantage over [FDE](https://github.com/google/flutter-desktop-embedding):

- A single codebase for all desktops, instead of 3.  
  _(Doesn't this remind you one of Flutter main selling point?_ 😉).  
- At that time the Windows platform didn't support [text input](https://github.com/google/flutter-desktop-embedding/tree/1145c85a2f4717dabc7bf34387874ebb51d80ca8/windows).

_FDE is now part of the flutter project, making it the official desktop shell._

I was having fun, so I kept going, implementing features after feature. (Mostly by reproducing what **@stuartmorgan** added to _FDE_).

---

**Fast forward six months later**, I was having trouble with my studies/work/go-flutter/life balance, don't get me wrong, I did receive **fantastic** input from the community, but it was too much work, the embedder API was growing **fast** (it now has over [1100](https://github.com/flutter/engine/blob/master/shell/platform/embedder/embedder.h) LOC) and my poor Golang architectures decision started to become a burden.

That's when **@GeertJohan** showed up and joined the project. We [moved the project to an organization](https://github.com/go-flutter-desktop/go-flutter/issues/72) and began fixing architecture issues. Support for [flutter platform channels codecs/API](https://flutter.dev/docs/development/platform-integration/platform-channels) was implemented, along with support for plugins.

The [Hover](https://github.com/go-flutter-desktop/hover) tool was created to make building go-flutter applications easier.

---

**Additionally**, We also had minor input into the Flutter engine project. With *go-flutter*, we created a reliable unofficial shell that is used by dozens of users. We hope to create better consensus on desktop shells, differences between *go-flutter* and *FDE* were found and aligned, which is good. Interaction/discussion between different official/unofficial projects shapes the **'Google-controlled'** part of the Flutter project.

**Overall**, I'm very proud of what the project has become. I qualify the project to be **very** mature. We are now a real alternative to the official desktop shells, with a different approach. Our primary selling points are:

- Easy plugins writing, it is [more accessible](https://github.com/go-flutter-desktop/go-flutter/issues/191#issuecomment-511384007) (and by the nature of Golang, more maintainable) in *go-flutter* than on the official project.
- Single code-base for windows/mac/linux applications.
- Less dependencies.

We'd like to thank everyone who has contributed to the project so far. Many people have helped us, not just by writing code but also by testing new features, reporting [bugs](https://github.com/go-flutter-desktop/go-flutter/issues?q=is%3Aissue+is%3Aopen+label%3Abug), giving advice or sharing ideas. Also a big shout-out to the maintainers of the Flutter Engine project who've helped us out and shared their feedback. **Thanks!**

We hope to write more about *go-flutter* in future posts, to give you updates on the project.