Convert Figma logo to code with AI

go-flutter-desktop logogo-flutter

Flutter on Windows, MacOS and Linux - based on Flutter Embedding, Go and GLFW.

5,852
283
5,852
66

Top Related Projects

164,677

Flutter makes it easy and fast to build beautiful apps for mobile and beyond

Build beautiful desktop apps with flutter and rust. 🌠 (wip)

83,441

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.

Quick Overview

Go-Flutter is an open-source project that enables developers to build desktop applications using Flutter and Go. It provides a Go-based embedder for Flutter, allowing Flutter apps to run natively on Windows, macOS, and Linux platforms.

Pros

  • Cross-platform development: Build desktop apps for multiple operating systems using a single codebase
  • Leverage Flutter's rich UI capabilities and ecosystem for desktop applications
  • Benefit from Go's performance and system-level access for native functionality
  • Active community and ongoing development

Cons

  • Limited documentation compared to official Flutter mobile development
  • Some Flutter plugins may not be compatible or require additional work for desktop use
  • Potential performance overhead compared to native desktop development
  • Learning curve for developers new to Go or Flutter

Code Examples

  1. Basic Go-Flutter setup:
package main

import (
    "github.com/go-flutter-desktop/go-flutter"
    "github.com/go-flutter-desktop/plugins/path_provider"
)

func main() {
    options := []flutter.Option{
        flutter.WindowInitialDimensions(800, 600),
        flutter.AddPlugin(&path_provider.PathProviderPlugin{}),
    }

    err := flutter.Run(options...)
    if err != nil {
        panic(err)
    }
}
  1. Implementing a platform channel:
import "github.com/go-flutter-desktop/go-flutter/plugin"

func init() {
    plugin.RegisterPlugin(&MyPlugin{})
}

type MyPlugin struct{}

func (p *MyPlugin) InitPlugin(messenger plugin.BinaryMessenger) error {
    channel := plugin.NewMethodChannel(messenger, "my_plugin_channel", plugin.StandardMethodCodec{})
    channel.HandleFunc("myMethod", p.handleMyMethod)
    return nil
}

func (p *MyPlugin) handleMyMethod(arguments interface{}) (reply interface{}, err error) {
    // Handle method call
    return "Result from Go", nil
}
  1. Adding custom window options:
import "github.com/go-gl/glfw/v3.3/glfw"

func main() {
    options := []flutter.Option{
        flutter.WindowIcon("assets/icon.png"),
        flutter.WindowInitialState(flutter.WindowStateMaximized),
        flutter.WindowDimensionLimits(400, 300, glfw.DontCare, glfw.DontCare),
    }

    err := flutter.Run(options...)
    if err != nil {
        panic(err)
    }
}

Getting Started

  1. Install Go and set up your Go environment
  2. Install Flutter and ensure it's in your PATH
  3. Clone the go-flutter repository:
    git clone https://github.com/go-flutter-desktop/go-flutter.git
    
  4. Create a new Flutter project and add the necessary dependencies to pubspec.yaml:
    dependencies:
      flutter:
        sdk: flutter
      go_flutter:
        git:
          url: https://github.com/go-flutter-desktop/go-flutter.git
    
  5. Create a main.go file in your project root with the basic setup (see first code example)
  6. Run go mod init and go mod tidy to set up Go modules
  7. Build and run your desktop app:
    go run main.go
    

Competitor Comparisons

164,677

Flutter makes it easy and fast to build beautiful apps for mobile and beyond

Pros of flutter

  • Official Flutter SDK with comprehensive documentation and support
  • Larger community and ecosystem, leading to more packages and resources
  • Seamless integration with mobile and web platforms

Cons of flutter

  • Larger file sizes and potentially slower performance on desktop
  • Less native look and feel on desktop platforms
  • Limited access to platform-specific features without plugins

Code Comparison

flutter:

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

go-flutter:

package main

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

func main() {
	flutter.Run(flutter.Options{})
}

Summary

flutter is the official Flutter SDK, offering a comprehensive solution for cross-platform development with strong mobile and web support. It benefits from a large community and extensive resources but may have limitations on desktop platforms.

go-flutter is a community-driven project focused on bringing Flutter to desktop environments using Go. It provides better native integration and potentially improved performance on desktop platforms but has a smaller ecosystem and may lack some features available in the official Flutter SDK.

The choice between the two depends on the specific requirements of your project, with flutter being more suitable for cross-platform development including mobile, and go-flutter offering advantages for desktop-focused applications.

Build beautiful desktop apps with flutter and rust. 🌠 (wip)

Pros of flutter-rs

  • Written in Rust, potentially offering better performance and memory safety
  • Supports multiple rendering backends (OpenGL, Vulkan, Metal)
  • Closer integration with native OS features due to Rust's low-level capabilities

Cons of flutter-rs

  • Less mature and less actively maintained compared to go-flutter
  • Smaller community and ecosystem support
  • May require more complex setup and configuration

Code Comparison

go-flutter example:

package main

import (
    "github.com/go-flutter-desktop/go-flutter"
    "github.com/go-flutter-desktop/plugins/path_provider"
)

func main() {
    flutter.Run(flutter.Options{
        MainDartFile: "lib/main.dart",
        Plugins:      []flutter.Plugin{path_provider.Plugin{}},
    })
}

flutter-rs example:

use flutter_engine::FlutterEngine;
use flutter_plugins::path_provider::PathProvider;

fn main() {
    let mut engine = FlutterEngine::new();
    engine.add_plugin(Box::new(PathProvider::default()));
    engine.run("lib/main.dart");
}

Both examples demonstrate initializing the Flutter engine and adding a plugin. The go-flutter version uses a more declarative approach with a single Run function, while flutter-rs requires explicit engine creation and method calls.

83,441

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.

Pros of Tauri

  • Smaller bundle sizes and better performance due to native system APIs
  • Supports multiple frontend frameworks (React, Vue, Svelte, etc.)
  • Strong security features with automatic updates and code signing

Cons of Tauri

  • Less mature ecosystem compared to Flutter
  • Steeper learning curve for developers new to Rust
  • Limited mobile support (currently in alpha)

Code Comparison

Tauri (Rust):

#[tauri::command]
fn greet(name: &str) -> String {
    format!("Hello, {}!", name)
}

fn main() {
    tauri::Builder::default()
        .invoke_handler(tauri::generate_handler![greet])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

go-flutter (Go):

func main() {
    options := []flutter.Option{
        flutter.WindowInitialDimensions(800, 600),
    }
    err := flutter.Run(append(options, flutter.AddPlugin(&example.ExamplePlugin{}))...)
    if err != nil {
        log.Fatalf("Failed to run the Flutter app: %v", err)
    }
}

Both frameworks allow for easy integration of native code with the UI layer, but Tauri offers more flexibility in terms of frontend technologies while go-flutter is specifically designed for Flutter applications.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

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