Godot-proposals: Godot Engine API for Dart and Flutter using "dart:ffi"

Created on 11 Sep 2019  路  16Comments  路  Source: godotengine/godot-proposals

As propsed to Dart
Dart 2.5 is introducing "Foreign Function Interface" (dart:ffi) that allows Dart-C interop.
Quoting the article in the link above:
"Dart enters the IEEE Spectrum programming language ratings as 16. It鈥檚 also 10 under trending, and 6 when filtering to languages for mobile (behind Java, C, C++, C#, and Swift).";
Flutter allows to build, with a single code base, mobile app for Android and iOS, PWA and soon desktop app for Windows, Linux and OSX.
Such an API would undoubtedly widen Godot adoption.

[edit] filling in template:

_Describe the project you are working on:_
I'm a Flutter developer and I'm working on a 2D game using flare
taking this as example

_Describe how this feature / enhancement will help your project:_
this feature would allow my creativity to express to a whole new level enabling the possibility of 3d rendering

_Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:_
it a technical proposal that doesn't impact a single feature, but the whole game complexity,
on the technical side what I picture is:
Flutter App => plugin (Godot Engine + Dart:ffi interface) => Flutter Widget Tree => Godot rendering inside a widget

_Describe implementation detail for your proposal (in code), if possible:_
please see the original post above

_If this enhancement will not be used often, can it be worked around with a few lines of script?:_
no, when available this enhancement will be used often and isn't possible for my knowledge to shrink it in few lines

_Is there a reason why this should be core and not an add-on in the asset library?:_
yes, it's a fully fledged feature, not an add-on

archived core

Most helpful comment

Hi, I read through your edit.

First off, I get the impression that you've not tried Godot before. I want to point out that Godot is a maturing game engine all on its own (with facilities for game logic, rendering, UI, exporting to multiple platforms from a single codebase, etc.), and if you were to use Godot by itself, there's a good chance you could achieve nearly the same results without the needed complexity of having to manage Flutter + Dart + Flare + Godot + any other libraries or workarounds you'd need for your task.

Second off, what you are asking for is for bindings to be created so that Godot can use Flutter/Dart, and Flutter/Dart can use Godot. Unfortunately, bindings are not something that will usually be added to core (exceptions may apply, but I haven't seen any yet). There just isn't the demand for Flutter/Dart to be usable within Godot by default... so we don't really have any motivaton to create bindings for them, unfortunately.

That said, if you still want to use Godot as a 3D renderer for Flutter/Dart (as you seem to have said you want to), then by all means go ahead, as we don't want to stop you. We want to see cool games made! You will need to create bindings though, so that you can control Godot's VisualServer or scene tree from Dart. If you need help creating bindings (or anything else Godot-related), then please don't be afraid to ask on one of the community channels.

With all that said, this isn't a bad idea, having Godot be usable within Flutter/Dart and vice versa. But it's not something that I think we could do for you, as we just don't see the demand for it.

All 16 comments

Please update your post filling out the template properly or it will be closed in accordance with Rule 1. Rules can be found on the README on the main page of the repo https://github.com/godotengine/godot-proposals

Please update your post filling out the template properly or it will be closed in accordance with Rule 1. Rules can be found on the README on the main page of the repo https://github.com/godotengine/godot-proposals

I've update the original post, sorry I didn't read carefully the guidelines.

This was already proposed, and I still don't see any reason to implement that. The only argument I can find here is that it may bring some Flutter users to Godot, but we don't really care that much.

Flutter allows to build, with a single code base, mobile app for Android and iOS, PWA and soon desktop app for Windows, Linux and OSX.

Godot is already a multiplatform solution.

Describe how this feature / enhancement will help your project:
this feature would allow my creativity to express to a whole new level enabling the possibility of 3d rendering

That quite a vague use case... I don't see why your creativity would be limited with Godot, and Godot is already capable of 3D rendering.

Hi, I read through your edit.

First off, I get the impression that you've not tried Godot before. I want to point out that Godot is a maturing game engine all on its own (with facilities for game logic, rendering, UI, exporting to multiple platforms from a single codebase, etc.), and if you were to use Godot by itself, there's a good chance you could achieve nearly the same results without the needed complexity of having to manage Flutter + Dart + Flare + Godot + any other libraries or workarounds you'd need for your task.

Second off, what you are asking for is for bindings to be created so that Godot can use Flutter/Dart, and Flutter/Dart can use Godot. Unfortunately, bindings are not something that will usually be added to core (exceptions may apply, but I haven't seen any yet). There just isn't the demand for Flutter/Dart to be usable within Godot by default... so we don't really have any motivaton to create bindings for them, unfortunately.

That said, if you still want to use Godot as a 3D renderer for Flutter/Dart (as you seem to have said you want to), then by all means go ahead, as we don't want to stop you. We want to see cool games made! You will need to create bindings though, so that you can control Godot's VisualServer or scene tree from Dart. If you need help creating bindings (or anything else Godot-related), then please don't be afraid to ask on one of the community channels.

With all that said, this isn't a bad idea, having Godot be usable within Flutter/Dart and vice versa. But it's not something that I think we could do for you, as we just don't see the demand for it.

This was already proposed, and I still don't see any reason to implement that. The only argument I can find here is that it may bring some Flutter users to Godot, but we don't really care that much.

that's an honest answer, I respect that
too bad, I really feel that this could have been an opportunity for both

Interesting, but why use Flare when you're already using Godot?

Interesting, but why use Flare when you're already using Godot?

flare is 2D there are no 3D engines for Dart that I'm aware of

@iapicca I think you misunderstood girng's question. Why are you using Dart, Flare, and Flutter when Godot already provides its own facilities for game logic, rendering, and UI components? Why use Dart, Flare, and Flutter when Godot more than likely can replace all three of those on its own?

Would GDNative/NativeScript bindings for Dart be possible, or desirable?

Imo: This is very much a "maybe in a few years if" case. (My estimate is about 5 or 6)

I don't want to speak for OP but I assume this is mostly for future compatibility with Google's Fuchsia project (A possible future replacement for android). Fuchsia only accepts flutter executables, ergo all applications must use it.

Opinions follow:
(I assume that dart is introducing C support because most people either use it or something that can be compiled to it, not dart itself. Gonna be honest in all my time as a developer I have only ever heard of it when researching the Fuchsia project. Several articles detail it's semi obscure history and are good reads for those interested.)

@LikeLakers2
the point is not to replace godot (or flutter),
if you want to go "full godot" you have no reason to use dart,
but...

Flutter gives an extremely good experience
in creating app for Android and iOS with a single code,
web and desktop (coming soon),
what flutter doesn't have is a 3D engine
(2D rendering is actually one of the selling point
of flutter, especially compared to React).

Imho the possibility to use Godot 's 3D engine in Flutter
would bring a lot of popularity to Godot itself
and since community is the flesh and blood of any
open source project I can only see this as a win win

I think the you are going the wrong way in this, honestly. You are saying "I'm using Flutter/Dart and want to bring in Godot 3D rendering". That is a task for Flutter, not for Godot. You can already do apps for Android, iOS, and desktop with Godot itself, bringing in Flutter is not a benefit in this regard.

For a proposal here, you should say "Bringing Flutter will make Godot better because it'll enable me to do X in my project, which wouldn't be possible without it". If you don't phrase it that way, it'll be hard for other people to see any benefit in this proposal.

I think the you are going the wrong way in this, honestly. You are saying "I'm using Flutter/Dart and want to bring in Godot 3D rendering". That is a task for Flutter, not for Godot. You can already do apps for Android, iOS, and desktop with Godot itself, bringing in Flutter is not a benefit in this regard.

For a proposal here, you should say "Bringing Flutter will make Godot better because it'll enable me to do X in my project, which wouldn't be possible without it". If you don't phrase it that way, it'll be hard for other people to see any benefit in this proposal.

it is possible, but I believe in open source
https://pub.dev/packages/flutter_unity_widget
also current solutions are based on "calling" the native code
which is greatly inefficient and now can be done differently
using dart:ffi

While using Flutter doesn't make sense to me for the same reasons already exposed, I would love using Dart as a scripting language.

Simply because I use Dart on a day to day basis, and it is always simpler when you can keep your environment and tools (just like C# support).

Well, it's not feasible for Godot to support every possible programming language out there. We support a few officially (GDScript, C#, C/C++) and provide an interface for the community to add support for other languages (Rust, Nim, and Python are some examples available). If there's something missing in the interface that don't allow Dart to be done, we will highly consider adding that, but official support won't happen.

i started working on it :
https://github.com/mahdisml/DartGodot

Was this page helpful?
0 / 5 - 0 ratings