Experimental embedder for Flutter

Related tags

desktop-app desktop flutter
Overview

NativeShell (Experimental embedder for Flutter)

Features

  • Leverages existing Flutter desktop embedder on each platform
  • Unlike Flutter desktop embedders, NativeShell provides consistent platform agnostic API
  • Multi-window support
  • Window management
    • Adjusting window styles and geometry
    • Modal dialogs
    • Windows can be set to track content size and resize automatically when content changes
  • Platform menus (popup menu, menu bar)
  • Drag and Drop
  • Written in Rust, Flutter build transparently integrated with cargo

Status

  • This is project in a very experimental stage

Getting started

Prerequisites:

  1. Install Rust
  2. Install Flutter
  3. Enable Flutter desktop support
  4. Switch to Fluttter Master (flutter channel master; flutter upgrade)

Clone and run examples:

git clone https://github.com/nativeshell/examples.git
cd examples
cargo run

For Apple Silicon Macs, you might need to run the example using the flag to force x86_64 architecture

rustup target add x86_64-apple-darwin
cargo run --target=x86_64-apple-darwin

For more information read the introductory post or go to nativeshell.dev.

Issues
  • Is the app template only way to use nativeshell? Or can we integrate it into existing Flutter projects

    Is the app template only way to use nativeshell? Or can we integrate it into existing Flutter projects

    There doesn't seem to be any documentation regarding this, one way or another.

    opened by GroovinChip 14
  • Error running template on Mac with Apple Silicon

    Error running template on Mac with Apple Silicon

    I just tried to run the example project on an apple silicon mac, but cargo run produces this error:

    Target debug_unpack_macos failed: Exception: Binary /Users/wilson/Developer/Play/examples/target/debug/build/nativeshell_examples-c8fe034cd50a97c9/out/flutter/./FlutterMacOS.framework/FlutterMacOS does not contain arm64.
    

    All logs:

    failed to run custom build command for `nativeshell_examples v0.1.0 (/Users/wilson/Developer/Play/examples)`
    
    Caused by:
      process didn't exit successfully: `/Users/wilson/Developer/Play/examples/target/debug/build/nativeshell_examples-0c7a4a584dad4c99/build-script-build` (exit code: 101)
      --- stdout
      Build failed with error:
      Flutter Tool Failed!
      Status: ExitStatus(ExitStatus(256))
      Command: "\"flutter\" \"assemble\" \"--output=.\" \"--define=BuildMode=debug\" \"--define=TargetPlatform=darwin\" \"--define=DarwinArchs=arm64\" \"--define=TargetFile=../../../../../../lib/main.dart\" \"-v\" \"--suppress-analytics\" \"debug_macos_bundle_flutter_assets\""
      Stderr:
      [   +5 ms] Target debug_unpack_macos failed: Exception: Binary /Users/wilson/Developer/Play/examples/target/debug/build/nativeshell_examples-c8fe034cd50a97c9/out/flutter/./FlutterMacOS.framework/FlutterMacOS does not contain arm64. Running lipo -info:
                 Non-fat file: /Users/wilson/Developer/Play/examples/target/debug/build/nativeshell_examples-c8fe034cd50a97c9/out/flutter/./FlutterMacOS.framework/FlutterMacOS is architecture: x86_64
    
                 #0      UnpackMacOS._thinFramework (package:flutter_tools/src/build_system/targets/macos.dart:97:7)
                 #1      UnpackMacOS.build (package:flutter_tools/src/build_system/targets/macos.dart:76:5)
                 #2      _BuildInstance._invokeInternal (package:flutter_tools/src/build_system/build_system.dart:836:27)
                 <asynchronous suspension>
                 #3      Future.wait.<anonymous closure> (dart:async/future.dart)
                 <asynchronous suspension>
                 #4      _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:774:32)
                 <asynchronous suspension>
                 #5      FlutterBuildSystem.build (package:flutter_tools/src/build_system/build_system.dart:603:16)
                 <asynchronous suspension>
                 #6      AssembleCommand.runCommand (package:flutter_tools/src/commands/assemble.dart:314:32)
                 <asynchronous suspension>
                 #7      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1126:27)
                 <asynchronous suspension>
                 #8      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
                 <asynchronous suspension>
                 #9      CommandRunner.runCommand (package:args/command_runner.dart:196:13)
                 <asynchronous suspension>
                 #10     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:284:9)
                 <asynchronous suspension>
                 #11     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
                 <asynchronous suspension>
                 #12     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:232:5)
                 <asynchronous suspension>
                 #13     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
                 <asynchronous suspension>
                 #14     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
                 <asynchronous suspension>
                 #15     main (package:flutter_tools/executable.dart:91:3)
                 <asynchronous suspension>
    
      [   +4 ms] 
                 #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
                 #1      AssembleCommand.runCommand (package:flutter_tools/src/commands/assemble.dart:331:7)
                 <asynchronous suspension>
                 #2      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1126:27)
                 <asynchronous suspension>
                 #3      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
                 <asynchronous suspension>
                 #4      CommandRunner.runCommand (package:args/command_runner.dart:196:13)
                 <asynchronous suspension>
                 #5      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:284:9)
                 <asynchronous suspension>
                 #6      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
                 <asynchronous suspension>
                 #7      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:232:5)
                 <asynchronous suspension>
                 #8      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
                 <asynchronous suspension>
                 #9      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
                 <asynchronous suspension>
                 #10     main (package:flutter_tools/executable.dart:91:3)
                 <asynchronous suspension>
    
    
    
      Stdout:
      [ +150 ms] executing: sysctl hw.optional.arm64
      [  +38 ms] Exit code 0 from: sysctl hw.optional.arm64
      [   +3 ms] hw.optional.arm64: 1
      [   +7 ms] executing: [/Users/wilson/Developer/SDK/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
      [  +26 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
      [        ] 320f27713bc843be7024b8e4216ab31a67e352ad
      [   +1 ms] executing: [/Users/wilson/Developer/SDK/flutter/] git tag --points-at 320f27713bc843be7024b8e4216ab31a67e352ad
      [  +59 ms] Exit code 0 from: git tag --points-at 320f27713bc843be7024b8e4216ab31a67e352ad
      [   +2 ms] executing: [/Users/wilson/Developer/SDK/flutter/] git describe --match *.*.* --long --tags 320f27713bc843be7024b8e4216ab31a67e352ad
      [  +57 ms] Exit code 0 from: git describe --match *.*.* --long --tags 320f27713bc843be7024b8e4216ab31a67e352ad
      [        ] 2.3.0-16.0.pre-180-g320f27713b
      [  +10 ms] executing: [/Users/wilson/Developer/SDK/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
      [  +17 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
      [        ] origin/master
      [        ] executing: [/Users/wilson/Developer/SDK/flutter/] git ls-remote --get-url origin
      [  +16 ms] Exit code 0 from: git ls-remote --get-url origin
      [        ] https://github.com/flutter/flutter.git
      [  +81 ms] executing: [/Users/wilson/Developer/SDK/flutter/] git rev-parse --abbrev-ref HEAD
      [  +30 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
      [        ] master
      [   +7 ms] executing: sw_vers -productName
      [  +17 ms] Exit code 0 from: sw_vers -productName
      [        ] macOS
      [        ] executing: sw_vers -productVersion
      [  +16 ms] Exit code 0 from: sw_vers -productVersion
      [        ] 11.3
      [        ] executing: sw_vers -buildVersion
      [  +16 ms] Exit code 0 from: sw_vers -buildVersion
      [        ] 20E232
      [ +183 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
      [        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
      [        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
      [        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
      [   +3 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
      [        ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required, skipping update.
      [        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
      [        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
      [        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
      [        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
      [        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
      [        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
      [ +127 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
      [        ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
      [        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
      [        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
      [        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
      [        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
      [        ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
      [        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
      [        ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required, skipping update.
      [   +1 ms] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
      [        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
      [        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
      [        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
      [        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
      [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
      [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
      [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
      [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
      [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
      [        ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
      [        ] Artifact Instance of 'PubDependencies' is not required, skipping update.
      [  +38 ms] Initializing file store
      [   +8 ms] Done initializing file store
      [  +47 ms] Skipping target: gen_localizations
      [  +16 ms] Skipping target: gen_dart_plugin_registrant
      [   +6 ms] Skipping target: debug_macos_framework
      [   +1 ms] debug_unpack_macos: Starting due to {}
      [ +441 ms] Skipping target: kernel_snapshot
      [   +6 ms] Persisting file store
      [   +9 ms] Done persisting file store
      [  +17 ms] "flutter assemble" took 772ms.
      [  +10 ms] ensureAnalyticsSent: 6ms
      [   +1 ms] Running shutdown hooks
      [        ] Shutdown hooks complete
      [   +2 ms] exiting with code 1
    
    
      --- stderr
      thread 'main' panicked at 'explicit panic', build.rs:26:9
      note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    
    opened by wilsonowilson 11
  • Build error under Linux

    Build error under Linux

    Hello!

    Thanks for making nativeshell! It had me very curious, so following the README I cloned the example repository and tried to run it, only to find the following output:

    examples on ξ‚  main [?] is πŸ“¦ v0.1.0 via 🎯 v2.14.0-188.0.dev via πŸ¦€ v1.50.0
    πŸ”‹πŸ”½32% ❯ cargo run                                                                                                                     [22:22:53]
       Compiling nativeshell_examples v0.1.0 (/home/dureuill/flutter/examples)
       Compiling gtk v0.9.2
    error: failed to run custom build command for `nativeshell_examples v0.1.0 (/home/dureuill/flutter/examples)`
    
    Caused by:
      process didn't exit successfully: `/home/dureuill/flutter/examples/target/debug/build/nativeshell_examples-2bba2697ebaef4c9/build-script-build` (exit code: 101)
      --- stdout
    
      ** Build failed with error **
    
      Flutter artifact location path at "/bin/cache/artifacts/engine/linux-x64" does not exist! Try running 'flutter precache'
    
      --- stderr
      thread 'main' panicked at 'explicit panic', build.rs:26:9
      note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    warning: build failed, waiting for other jobs to finish...
    error: build failed
    

    I installed flutter, enabled desktop support and switched to the master channel following the readme, here is the output of flutter doctor:

    examples on ξ‚  main [?] is πŸ“¦ v0.1.0 via 🎯 v2.14.0-188.0.dev via πŸ¦€ v1.50.0 took 6s
    πŸ”‹πŸ”½32% ❯ flutter doctor                                                                                                                [22:23:01]
    Doctor summary (to see all details, run flutter doctor -v):
    [βœ“] Flutter (Channel master, 2.3.0-17.0.pre.265, on Manjaro Linux 5.10.36-2-MANJARO, locale fr_FR.UTF-8)
    [βœ—] Android toolchain - develop for Android devices
        βœ— Unable to locate Android SDK.
          Install Android Studio from: https://developer.android.com/studio/index.html
          On first launch it will assist you in installing the Android SDK components.
          (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
          If the Android SDK has been installed to a custom location, please use
          `flutter config --android-sdk` to update to that location.
    
    [βœ—] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
        ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
    [βœ“] Linux toolchain - develop for Linux desktop
    [!] Android Studio (not installed)
    [βœ“] Connected device (1 available)
    
    ! Doctor found issues in 3 categories.
    

    Running flutter -v create hello_world followed by a flutter run -d linux does result in me seeing the flutter hello world in my linux.

    I also tried flutter precache like recommended, and it did something the first time around (not on subsequent runs), but this doesn't appear to solve the problem.

    Anything I can do to fix the build?

    I'm running manjaro with kernel 5.10.36-2.

    I'm new to flutter, so apologies if I misstepped!

    opened by dureuill 8
  • Any way to use this without Dart?

    Any way to use this without Dart?

    I would really like to be able to build a Rust application with Flutter UI without writing code in Dart. Is this at all possible? (I'm willing to have to install dart and stuff, but I don't want to write the ui code in it)

    opened by iMplode-nZ 4
  • Higher-level Plugin api akin to flutter-rs

    Higher-level Plugin api akin to flutter-rs

    I'm working on an application written in rust with flutter as the UI and was using flutter-rs until now. I've implemented some custom channels and flutter-rs has a nice abstraction for flutter plugins as well as the different channel types.

    Do you have any intentions to implement something similar?

    enhancement 
    opened by maxjoehnk 4
  • Add note for M1 Macs on how to run the examples

    Add note for M1 Macs on how to run the examples

    Run into the same error as in #1 - thought it's better to update the README.

    opened by bk-one 3
  • Fix Build on Linux When Not Using Plugins

    Fix Build on Linux When Not Using Plugins

    When compiling the template app I ran into an error on Linux that said the libflutter_linux_gtk.so symlink could not be created. The problem was just that the target/debug/lib dir needed to be created first. This change fixes that.


    Great project BTW! This looks amazing and I'm very excited to try it out. I've been looking for a good way to hook Flutter up to Rust for making apps and the example app just worked right out-of-the box, which is pretty amazing.

    opened by zicklag 2
  • Add support for platform plugins

    Add support for platform plugins

    This issue tracks progress for platform plugins support.

    NativeShell support Flutter packages, but it does not yet support packages that contain native code (plugins).

    • [x] Support of macOS platform plugins
    • [x] Support of Windows platform plugins
    • [x] Support of Linux platform plugins
    opened by knopp 1
  • Requires

    Requires "Developer mode" to be enabled on Windows for symlinks to work

    This is looking great!

    I decided to try out building and running the example on Windows too and hit an issue where permission was denied creating a symlink to flutter_export.h in the build process.

    It turns out you can't create symlinks on Windows without elevated permissions unless you've enabled "Developer mode". It might be worth capturing this panic on Windows and pointing them at the official docs: https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development

    opened by timfish 1
  • Implement support for Flutter plugins

    Implement support for Flutter plugins

    Fixes https://github.com/nativeshell/nativeshell/issues/6.

    opened by knopp 0
  • Mobile Support

    Mobile Support

    I know the point of nativeshell is to support desktop applications, but would it be possible to build nativeshell for iOS and Android, too, so that we could still use Rust to write mobile apps as well?

    opened by zicklag 3
  • Add support for system tray icons

    Add support for system tray icons

    See https://github.com/flutter/flutter/issues/81644 and https://github.com/google/flutter-desktop-embedding/issues/595

    opened by cbenhagen 0
  • Create issues for roadmap items

    Create issues for roadmap items

    It would be nice to be able to get notified on progress of certain roadmap items. I was about to create the issues for you but opted to create this meta issue first as you might prefer to create them yourself. I will add some more feature requests meanwhile if you don't mind :)

    Thank you very much for this project btw!

    opened by cbenhagen 0
Experimental embedder for Flutter

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

NativeShell 103 Jun 7, 2021
A data-first Rust-native UI design toolkit.

Druid A data-first Rust-native UI toolkit. Druid is an experimental Rust-native UI toolkit. Its main goal is to offer a polished user experience. Ther

null 3.8k Jun 13, 2021
The Rust UI-Toolkit.

The Orbital Widget Toolkit is a cross-platform (G)UI toolkit for building scalable user interfaces with the programming language Rust. It's based on t

Redox OS 3.2k Jun 13, 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 17.3k Jun 13, 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 438 Jun 12, 2021
A cross-platform GUI library for Rust, inspired by Elm

Iced A cross-platform GUI library for Rust focused on simplicity and type-safety. Inspired by Elm. Features Simple, easy-to-use, batteries-included AP

HΓ©ctor RamΓ³n 9.6k Jun 13, 2021
Fuse filesystem that returns symlinks to executables based on the PATH of the requesting process.

Envfs Fuse filesystem that returns symlinks to executables based on the PATH of the requesting process. This is useful to execute shebangs on NixOS th

JΓΆrg Thalheim 38 Jun 15, 2021
Rust docs for the Windows API

Windows API documentation for Rust This is an experimental documentation generator for the Rust for Windows project. The documentation is published he

Microsoft 37 Jun 14, 2021