r/FlutterDev • • Jun 03 '21

Article Introducing NativeShell for Flutter

https://matejknopp.com/post/introducing-nativeshell/
177 Upvotes

24 comments sorted by

19

u/MyNameIsIgglePiggle Jun 03 '21

This is amazing. I'm building some desktop apps at the moment and particularly the drag and drop will come in handy.

I don't know enough about the underlying layers, but would it be possible to provide a webview with this? It's the one thing really getting in the way for one of my apps that means I need to ship it as a web app when a desktop app would be so much better

2

u/airflow_matt Jun 03 '21

Depends on the exact requirements. WebView as a separate window or on top of the Flutter view would technically be doable. WebView integrated as a widget (within Flutter hierarchy) would require PlatformView support, which might only be feasible on macOS.

1

u/MyNameIsIgglePiggle Jun 03 '21

Ideally it would be a platformview, but a window will do as well... In fact a window could be perfect if I just give them an "edit html" button and it pops up a browser based WYSIWYG editor.

1

u/ren3f Jun 04 '21

Don't know about your specific usecase of course, but maybe you could even try the new super_editor? (Might not be feasibly if you really want it to be html.) https://pub.dev/packages/super_editor

1

u/MyNameIsIgglePiggle Jun 04 '21

I'm not too fussed about editing in HTML, but I need to be able to export basic html with simple formatting, so lists, bold, italic, paragraphs, and images.

The use case is that I need my users to be able to write up product listings which will go on ecommerce stores such as Shopify and Amazon. It an internal admin tool to manage ~16000 products.

13

u/definev Jun 03 '21

Cool! I am very exciting to see Flutter growing everyday.

4

u/gedw999 Jun 03 '21

So what happens when I run on the web with the menu features ? I presume it just ignores them ?

I am using rust and golang with flutter using FFI but only or business logic.

Ok mobile flutter does not attempt to render native widgets at all but instead imitates then using flutter as we all know.

But menus are really a different thing and maybe and rendering them using native OS is perhaps a sustainable approach .

The dart api btw is really well done . It’s a no brainier to use .

I wonder if the flutter team would ever consider using the code in some way to provide these things in flutter upstream?

4

u/airflow_matt Jun 03 '21

Right now everything in nativeshell is done through platform channels (i don't mind FFI but so far didn't really have any use for it, though I'll probably have soon). So on web if you ask NativeShell to create menu you'd just get no response (or an exception about missing platform channel I'd assume).

The nice thing about NativeShell is that it's separate from upstream embedders. That gives me some room to experiment and also iterate faster.

1

u/gedw99 Jun 04 '21

NativeShell

thanks for the info.

i also have written native code, and also dont use FFI, but instead platform channels. FFI gen for rust does look compelling but its only just gotten stable recently. I have seen a few rust flutter devs using it.

thanks for the answer about what happens on web and mobile. Might be possible to use conditional compilation of some sort so that on the unsupported platforms the code is not even there perhaps ? I honestly dont know though.. Never tried it.

1

u/airflow_matt Jun 04 '21

Both web and desktop (AOT) compilation does tree shaking, so it should remove all code that's not used. You should be able to use conditional imports for this. Just import the code relevant to your platform and the rest should not be included in final bundle.

4

u/Maistho Jun 03 '21

This is really cool, I was looking for a good drag and drop solution for a desktop app earlier today, so I'm probably going to take a look at this. :)

7

u/KalilPedro Jun 03 '21

Oh wow, this is amazing! Congratulations!!

2

u/airflow_matt Jun 03 '21

Thanks! :)

2

u/[deleted] Jun 04 '21

This is very cool, though I hope most of this stuff can be integrated into Flutter itself at some point (presumably that is their eventual plan).

2

u/tabinnorway Jun 04 '21

If the good folks at Google has any sense they will hire you and integrate this into flutter as the standard native launcher for Flutter. This is more than awesome.

2

u/ggsalazar_Struq Jun 03 '21

Wow, looks amazing.

New options for Flutter.

1

u/za3b Jun 04 '21

nice.. i'm a web developer, but i'm intrigued. i might try desktop development next :D

1

u/jrheisler Jun 04 '21

Remarkable!

-1

u/m9dhatter Jun 03 '21

I like the idea. But I’m not happy about having to install yet another compiler and package manager.

12

u/airflow_matt Jun 03 '21 edited Jun 03 '21

Hi, NativeShell author here :) I understand the concern, but installing rust is really, really straightforward. On macOS and Linux it's one copy and paste in terminal, on Windows it's one executable (rustup-init). The alternative unfortunately is much worse. There's no standard ABI in C++ and no standard package manager, that's why on windows and linux part of Flutter embedder gets dumped directly into the project as "ephemeral" library. I've been writing c++ since MSVC 6, but language aside, even for practical reason I wouldn't do NativeShell in c++.

2

u/returnFutureVoid Jun 04 '21

Rust is crazy easy to install. I wanted to get started with it and may have taken me all of 3 minutes to running my first hello world.

3

u/gedw999 Jun 03 '21

Rust up and off you go. It’s pretty nice with rust . It’s not cmake hell :)

I presume that this flutter project could provide the already compiled plugin ?

-4

u/SilverMarcs Jun 03 '21

I'm no developer and I know very little shit flutter. But would it be possible to build proper gtk apps with this? Gnome-styled apps look really cool and it would be nice to be able to create then the through the flutter/dart language