Programmatically creating UI through dart

42 views
Skip to first unread message

Abhishek Mohata

unread,
Oct 20, 2022, 4:07:29 AM10/20/22
to Dart Misc
Hi,

I am looking at Flutter for my cross platform UI framework. Most of my core logic would be in C++. Through dart:ffi, I would be able to interop with C apis.

Support I have a struct that tells me how my layout is going to be i.e. the title of the top bar, how many buttons or text fields or labels, their properties, arrangement etc. Based on this information, the UI code in Dart is written i.e. the right widgets are instantiated and properties are set based on what has been provided by this struct.

Can this be achieved ? Is there any reference material for the same ?

I am fairly new to flutter and have recently started exploring. So there can be a gap in my understanding of that all the capabilities provided.

Thanks !

Regards,
Abhishek

Daco Harkes

unread,
Oct 20, 2022, 4:55:57 AM10/20/22
to mi...@dartlang.org
Hi Abhishek,

Nice to meet you!

I believe this should be possible.
You can start from `flutter create --template=plugin_ffi` to get the boilerplate for building/bundling/runtime-binding C code in Flutter.
From there you can add more involved C calls to that return your struct. See https://api.flutter.dev/flutter/dart-ffi/Struct-class.html.
I'm not very familiar with Flutter widgets, but I believe it is possible to dynamically build your widget tree from the values you got from C. For questions about that you should ask Flutter people.

Kind regards,

 •  Daco Harkes
 •  Software Engineer
 •  dacoh...@google.com 
 •  🔵 Blue Dot Ally


--
For more ways to connect visit https://dart.dev/community
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/misc/506c435d-7c2a-42b4-9776-223af3ba83ddn%40dartlang.org.

Abhishek Mohata

unread,
Nov 3, 2022, 11:02:39 PM11/3/22
to mi...@dartlang.org
Thanks Daco. This helps.



--
Regards,
Abhishek Mohata
Reply all
Reply to author
Forward
0 new messages