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

Related tags

GUI rust gui flutter
Overview

flutter-rs

Crates.io flutter version Discord chat MIT licensed

Build flutter desktop app in dart & rust.

flutter-app-template

Get Started

Install requirements

Develop

  • install the cargo flutter command

    cargo install cargo-flutter

  • create your new project from the template

    git clone https://github.com/flutter-rs/flutter-app-template

  • To develop with cli hot-reloading:

    cd flutter-app-template

    cargo flutter run

Distribute

  • To build distribution, use: cargo flutter --format appimage build --release

Contribution

To contribute to flutter-rs, please see CONTRIBUTING.

ChangeLog

CHANGELOG.

Issues
  • Hack to make X11 work

    Hack to make X11 work

    This is a lot less invasive than my previous pull requests. Feels like a hack though. I am checking against the OS which doesn't specifically block out X11, but seeing as how flutter uses X11 for linux, we shouldn't run into any issues.

    opened by j4qfrost 11
  • build and link `libflutter_engine` statically

    build and link `libflutter_engine` statically

    Hello, Is there is any reason why we don't already build the flutter-engine and link it as a static library? it would make it easier to bundle the whole application and send it to the consumer.

    Also, I made a try to build my simple (counter) project to musl target. but it failed to compile glfw, anyway it's not related maybe I would open another issue for that.

    Here is some information about my system:

    $ uname -a
    Linux Hex 4.19.60-1-MANJARO #1 SMP PREEMPT Sun Jul 21 12:17:26 UTC 2019 x86_64 GNU/Linux
    
    $ rustc -Vv                
    rustc 1.38.0-nightly (dddb7fca0 2019-07-30)
    binary: rustc
    commit-hash: dddb7fca09dc817ba275602b950bb81a9032fb6d
    commit-date: 2019-07-30
    host: x86_64-unknown-linux-gnu
    release: 1.38.0-nightly
    LLVM version: 9.0
    
    opened by shekohex 10
  • Add flutter-winit

    Add flutter-winit

    This works on linux wayland and kind of works on android using a simple test app.

    Things that are missing:

    • [x] window and platform handlers need to be implemented properly
    • [x] text plugin needs to be hooked up
    • [ ] https://github.com/rust-windowing/winit/pull/1328
    • [ ] https://github.com/rust-windowing/glutin/pull/1249
    • [x] app demo needs to be updated and some android specific code added
    opened by dvc94ch 10
  • flutter + rs on (macos) desktop

    flutter + rs on (macos) desktop

    I've been investigating flutter for the desktop for a new project. I develop on Mac, but want to develop for cross-platform.

    I was happy to see and be able to use the flutter desktop support as documented here: https://flutter.dev/desktop

    But I haven't figured out how to do flutter development in rust using flutter-rs for the desktop.

    I think the problems are related to the use of a specific flutter-engine?

    Sorry it's a bit of a vague question - but, is it possible for me to configure things to use flutter-rs, compatible with flutter master channel to get support for desktop on macos?

    opened by andrewdavidmackenzie 9
  • Android support?

    Android support?

    Hey any plan on supporting Android as well?

    opened by bkchr 8
  • Use builder pattern

    Use builder pattern

    An initial step towards supporting more configuration options.

    In the future, handler will be broken down in opengl handler or something of the likes, allowing the engine to be constructed with with_gl_backend(), with_software_backend() etc.

    It also then allows for optional features to be added in the future, such as with_semantics_handler, or with_persistent_cache.

    Currently, FlutterEngine::new is going to get bloated, one solution is some sort of FlutterConfig struct for data that doesn't change, then allowing engine.config().assets()

    opened by csnewman 8
  • Make flutter engine independent of GLFW

    Make flutter engine independent of GLFW

    As a follow up to #88, I propose refactoring the library into:

    flutter-engine-sys: the ffi code flutter-engine: codec, channels, pointer events, tasks etc (i.e. wrapper around sys crate) flutter-engine-plugins: text-input etc, each plugin could be a feature flag flutter-engine-glfw: current logic around glfw rendering

    This means that the flutter-engine crate is no longer dependent on opengl etc, or glfw, and can be used as an independent library in the following manor:

    
    struct MyHandler {
    
    }
    
    impl FlutterEngineHandler for MyHandler {
        fn swap_buffers(&self) -> bool {
            unimplemented!()
        }
    
        fn make_current(&self) -> bool {
            unimplemented!()
        }
    
        fn clear_current(&self) -> bool {
            unimplemented!()
        }
    
        fn fbo_callback(&self) -> u32 {
            unimplemented!()
        }
    
        fn make_resource_current(&self) -> bool {
            unimplemented!()
        }
    
        fn gl_proc_resolver(&self, proc: *const i8) -> *mut c_void {
            unimplemented!()
        }
    
        fn wake_platform_thread(&self) {
            unimplemented!()
        }
    
        fn run_in_background(&self,  func: Box<dyn Future<Output = ()> + Send + 'static>) {
            unimplemented!()
        }
    
        fn get_texture_frame(
            &self,
            texture_id: i64,
            size: (usize, usize),
        ) -> Option<ExternalTextureFrame> {
            unimplemented!()
        }
    }
    
    // Handler is called by the engine on different threads to handle embedder specific tasks
    let handler = Arc::new(MyHandler);
    let engine = FlutterEngine::new(Arc::downgrade(&handler) as _);
    
    // Add plugins (plugins can registered before the engine starts)
    engine.add_plugin(KeyEventPlugin::default());
    
    // Start engine
    engine.run(assets_path, icu_data_path, arguments).expect("Failed to create engine");
    
    // In some sort of loop, you can call execute_platform_tasks, which will give the time you should sleep to for the next task
    let next_task_time = engine.execute_platform_tasks();
    

    If in the future flutter gets alternative renderers, such as Vulkan, we can break down the FlutterEngineHandler into multiple traits, or use a feature flag.

    TaskRunner are now an independent concept, meaning if flutter adds extra task runners in the future, the logic should be reusable.

    opened by csnewman 8
  • Better threading

    Better threading

    This PR adds a custom task runner to eliminate the deprecated call to __FlutterEngineFlushPendingTasksNow. The task runner will let glfw wait indefinitely for window events if no tasks have been posted. This improves performance by polling glfw events less often. There's also a new function available to plugins that allows tasks to be posted to the render thread. Plugins can use this function to do full OpenGL rendering to the resource window.

    I have also formatted the code and fixed some warnings.

    opened by 999eagle 6
  • Window flushes black when resizing

    Window flushes black when resizing

    I don't know if this is an issue on other platform or not, but in macOS, when you resize the window, it flush black then it render! so it's like there is no mechanism that resize the flutter content dynamically so it feel more natural.

    If you take a look to feather-apps, their application flush black less when resizing.

    That's the behavior, we suppose to get

    t-bug help wanted 
    opened by btwael 6
  • replace glfw with winit

    replace glfw with winit

    I think this would be a first step towards android/ios support, since winit already supports those platforms.

    t-enhancement 
    opened by dvc94ch 6
  • hover build error

    hover build error

    C:\Users\lichen\develop\myapp>hover build windows hover: Downloading engine for platform windows-release at version fbeb7e22bd6d594a16c487cc138970fbd2a77d40... hover: Failed to download engine: failed to get Content-Length header: strconv.Atoi: parsing "": invalid syntax hover: Engine builds are a bit delayed after they are published in flutter. hover: You can either try again later or switch the flutter channel to beta, because these engines are more likely to be already built. hover: To dig into the already built engines look at https://github.com/flutter-rs/engine-builds/releases and https://github.com/flutter-rs/engine-builds/actions

    opened by 3990995 4
  • Dart <-> Flutter automated FFI

    Dart <-> Flutter automated FFI

    This guy made a very very very good Dart<->Flutter FFI automation/generation, but the project is Sponsorware:

    https://github.com/thlorenz/rid-examples

    I just wanted to make it more visible to more people can sponsor it and thus make it open source

    opened by lucaszanella 0
  • Meet unsupported platform

    Meet unsupported platform

    thread 'main' panicked at 'unsupported platform', /Users/davirain/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-flutter-0.1.12/src/engine.rs:53:18 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

    computer: apple m1 rust: stable

    opened by DaviRain-Su 0
  • Project Status: Does This Project Need Maintenance Help?

    Project Status: Does This Project Need Maintenance Help?

    Hey there, I'm new to flutter, but experienced in Rust and I noticed that this project seems to be a little bit inactive since last april or so. I'm likely going to be getting into Flutter development and I wondered if this project could use maintainers to help. There's one PR that's been open for a few months, right now the template repo isn't compiling, and I had to patch cargo-flutter to make it compile my projects. Seems like there are some maintenance tasks to take care of.

    While I can't guarantee anything about how much time I'll be able to spend on it, I might be able to put some time into helping with this. If Flutter ends up working as well as it looks like it could then this would potentially become an important part of the applications that me and my organization make and I'll have more time to help make sure that this keeps working.

    Any thoughts?

    opened by zicklag 4
  • Unable to Close Application

    Unable to Close Application

    Hey there! I'm just getting started with flutter-rs and I think it looks really neat. It looks like I've caught this at a bit of a transition period, but I'm working through it. I found that the template repository won't compile, but I fount out how to get it to work by switching to flutter_glfw instead of using flutter_winit. I also had to make some modifications to cargo-flutter to fix bundling problems. ( if it's useful I can submit PRs for both of those repos with what fixed it for me )

    Now I've got everything working except for one problem I can't figure out how to fix: when closing the application by clicking the window-manager "x" button, the application freezes and goes into "not responding". The apparent cause is shown in the debug logs:

    [2021-05-03T14:33:17Z DEBUG glfw] Attempted to drop a Window before the `RenderContext` was dropped.
    [2021-05-03T14:33:17Z DEBUG glfw] Blocking until the `RenderContext` was dropped.
    

    I dove into the code to try and figure out how to fix it, but I'm kind of stuck. As far as I can tell, when the window loop exits there are still two strong references to the Arc that holds the FlutterEngine, which in turn is holding the RenderContext that glfw is complaining about. After a couple hours or so trying to debug, though, I can't figure out what is holding the references to that Arc and how to get it to shut-down. It's also worth noting that the engine.shutdown() function never returns.

    I'm willing to try to fix it, but I need some pointers to be able to make futher progress I think.

    opened by zicklag 0
  • thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Os { code: 2

    thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Os { code: 2

    Right after cloning git clone https://github.com/flutter-rs/flutter-app-template and trying cargo flutter run:

    thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })', /home/st4ck/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-flutter-0.1.12/src/main.rs:127:57
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    
    opened by agavrel 1
  • Updated to newer version of Rust

    Updated to newer version of Rust

    • fixed code and made it compile. (There was a lot of errors because 'usize' moved from u64 to u128)
    • cleaned up Markdown documents.
    • updated dependencies
    opened by MGlolenstine 2
  • armv7-unknown-linux-gnueabihf support

    armv7-unknown-linux-gnueabihf support

    It looks like the yocto flutter layer supports building flutter for armv7-unknown-linux-gnueabihf. Is it possible to enable the same for flutter-rs?

    opened by flukejones 1
  • method not found in `flutter_engine::FlutterEngine`

    method not found in `flutter_engine::FlutterEngine`

    error[E0599]: no method named `add_plugin` found for struct `flutter_engine::FlutterEngine` in the current scope
      --> C:\Users\mayn\.cargo\git\checkouts\flutter-rs-c358db22f6da0f29\69c6706\flutter-winit\src\window.rs:88:16
       |
    88 |         engine.add_plugin(KeyEventPlugin::default());
       |                ^^^^^^^^^^ method not found in `flutter_engine::FlutterEngine`
    
    
    opened by zhuxiujia 3
  • Unable to run the template project

    Unable to run the template project

    I get the following error message when trying to run flutter-app-template project.

    thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })', /home/actuday/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-flutter-0.1.12/src/main.rs:127:32
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    
    

    backtrace if it is necessary:

    thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })', /home/actuday/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-flutter-0.1.12/src/main.rs:127:32
    stack backtrace:
       0: backtrace::backtrace::libunwind::trace
                 at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
       1: backtrace::backtrace::trace_unsynchronized
                 at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
       2: std::sys_common::backtrace::_print_fmt
                 at src/libstd/sys_common/backtrace.rs:78
       3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
                 at src/libstd/sys_common/backtrace.rs:59
       4: core::fmt::write
                 at src/libcore/fmt/mod.rs:1076
       5: std::io::Write::write_fmt
                 at src/libstd/io/mod.rs:1537
       6: std::sys_common::backtrace::_print
                 at src/libstd/sys_common/backtrace.rs:62
       7: std::sys_common::backtrace::print
                 at src/libstd/sys_common/backtrace.rs:49
       8: std::panicking::default_hook::{{closure}}
                 at src/libstd/panicking.rs:198
       9: std::panicking::default_hook
                 at src/libstd/panicking.rs:218
      10: std::panicking::rust_panic_with_hook
                 at src/libstd/panicking.rs:486
      11: rust_begin_unwind
                 at src/libstd/panicking.rs:388
      12: core::panicking::panic_fmt
                 at src/libcore/panicking.rs:101
      13: core::option::expect_none_failed
                 at src/libcore/option.rs:1272
      14: cargo_flutter::main
      15: std::rt::lang_start::{{closure}}
      16: std::rt::lang_start_internal::{{closure}}
                 at src/libstd/rt.rs:52
      17: std::panicking::try::do_call
                 at src/libstd/panicking.rs:297
      18: std::panicking::try
                 at src/libstd/panicking.rs:274
      19: std::panic::catch_unwind
                 at src/libstd/panic.rs:394
      20: std::rt::lang_start_internal
                 at src/libstd/rt.rs:51
      21: main
      22: __libc_start_main
      23: _start
    note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
    
    
    opened by actuday6418 1
Releases(0.3.0)
Experimental embedder for Flutter

NativeShell (Experimental embedder for Flutter) Features Leverages existing Flutter desktop embedder on each platform Unlike Flutter desktop embedders

NativeShell 359 Nov 25, 2021
Build smaller, faster, and more secure desktop applications with a web frontend.

TAURI Tauri Apps footprint: minuscule performance: ludicrous flexibility: gymnastic security: hardened Current Releases Component Descrip

Tauri 24.5k Nov 21, 2021
A WIP Float32 soft FPU implementation

Software-emulated FPU in Rust Use 32-bit unsigned integer to represent Float32 in IEEE-754 and do float calculation. Usage There is an operator-trait-

Inoki 19 Jun 25, 2021
Automatically create GUI applications from clap3 apps

Automatically create GUI applications from clap3 apps

Michał Gniadek 220 Nov 14, 2021
SixtyFPS is a toolkit to efficiently develop fluid graphical user interfaces for any display: embedded devices and desktop applications. We support multiple programming languages, such as Rust, C++ or JavaScript.

SixtyFPS is a toolkit to efficiently develop fluid graphical user interfaces for any display: embedded devices and desktop applications. We support multiple programming languages, such as Rust, C++ or JavaScript.

SixtyFPS 2.5k Nov 25, 2021
ZeroTier Desktop Tray Application and UI

ZeroTier Desktop Tray Application and User Interface This is (as of ZeroTier 1.8) the system tray application and user interface for controlling a loc

ZeroTier, Inc. 34 Nov 23, 2021
Desktop GUI Framework

Azul - Desktop GUI framework WARNING: The features advertised in this README may not work yet. Azul is a free, functional, immediate mode GUI framewor

Maps4Print 4.9k Nov 30, 2021
Better GNOME Desktop Experience

Better GNOME Desktop Experience Tired of having the best feeling DE with the worst defaults? This app is for you. Transform the default GNOME look to:

Dimitar Dimitrov 2 Oct 3, 2021
Build GUI applications with minimal dependencies in Rust

winapi-app-windows A crate to build applications' windows in Windows using WinAPI. This would be less confusing if the operating system was called som

Lonami 3 Nov 4, 2021
Prototype for a Deno to npm package build tool.

dnt - Deno to Node Transform Prototype for a Deno to npm package build tool. What does this do? It takes a Deno module and creates an npm package for

David Sherret 119 Nov 22, 2021
Prototype for a Deno to npm package build tool.

dnt - Deno to Node Transform Prototype for a Deno to npm package build tool. What does this do? It takes a Deno module and creates an npm package for

Deno Land 126 Nov 30, 2021
Rust bindings to Core Foundation and other low level libraries on Mac OS X and iOS

core-foundation-rs Compatibility Targets macOS 10.7 by default. To enable features added in macOS 10.8, set Cargo feature mac_os_10_8_features. To hav

Servo 486 Nov 25, 2021
Integrate Qml and Rust by building the QMetaObject at compile time.

QMetaObject crate for Rust The qmetaobject crate is a crate which is used to expose rust object to Qt and QML. Objectives Rust procedural macro (custo

Woboq GmbH 357 Nov 23, 2021
A cross-platform GUI library for Rust focused on simplicity and type-safety

A cross-platform GUI library for Rust, inspired by Elm

Héctor Ramón 12k Nov 29, 2021
Highly customizable finder with high performance. Written in Rust and uses GTK

Findex Highly customizable finder with high performance. Written in Rust and uses GTK Installation Automatic Binary Clone from https://aur.archlinux.o

MD Gaziur Rahman Noor 253 Nov 30, 2021
GUI based tool to sort and categorize images written in Rust

ImageSieve GUI based tool to sort out images based on similarity, categorize them according to their creation date and archive them in a target folder

Florian Fetz 4 Nov 21, 2021
A simple note taking application written in Rust and GTK4

Rnote A simple note taking application written in Rust and GTK4. Rnote aims to be a simple but functional note taking application for freehand drawing

Felix Zwettler 67 Nov 29, 2021
Simple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports.

libui: a portable GUI library for C This README is being written. Status It has come to my attention that I have not been particularly clear about how

Pietro Gagliardi 10.1k Nov 21, 2021
OS-native file dialogs on Linux, OS X and Windows

nfd-rs nfd-rs is a Rust binding to the library nativefiledialog, that provides a convenient cross-platform interface to opening file dialogs on Linux,

Saurav Sachidanand 139 Nov 13, 2021