Niku 2 roadmap #17
SaltyAom
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
TLDR; Niku 2 is a complete rewrite working on branch: Heaven and Earth
Outline
I have been working experimenting with a lot of ways to style widgets in Flutter both private and publicly.
In fact, I've been released some libraries like Desire and Floret as an experimental and brought a lot of great ideas to make Niku better.
And currently, I'm thrilled to introduce that now, I'm working on Niku 2 candidate, codename
Heaven and Earth
.Niku 2
Niku 2 aims to reduce as much code as possible, making it lightweight.
I'm removing all the callstack instead, using direct property
setter
.Which indeed, will likely have a complete breaking change, but the compatibility layer will be shipped if you want to use Niku 2 alongside Niku 1 for at least 2-3 versions just like Dart Nullsafety.
Here's what's new
Dot Cascade
All method is now assigned with cascade notation
Previously, one Niku widget contains a lot of property and methods, each property is private and set via methods.
Which I found redundant and allocate double-triple up memory as it shouldn't.
On Niku 2, the property is now public and can be directly assigned, removing the need for setter methods.
This doesn't not only make it use significantly lesser memory but eliminate up to 60-70% of line of codes and make it much easier to maintain and faster to develop.
As the property is now public, you can easily get the property if need.
As the new way of assigning property to become cascade notation, I also found a
getter
hack for setting property instead.This means any property that doesn't need any parameter doesn't require any assignment and removing the redundant bracket.
For example:
![carbon (9)](https://user-images.githubusercontent.com/35027979/140598775-0abbea6c-aec6-468d-aa00-db904fc9c613.png)
Property Grouping
As you might notice from above, Niku 2 will be using a grouping system for property for clear separation of styling intent
![carbon (14)](https://user-images.githubusercontent.com/35027979/140598905-1cd9e810-e249-43b0-9106-49be933e76df.png)
This has great 2 benefits.
First, grouping helps separate property from Widget.
Complex object like
InputDecoration
,TextStyle
,BoxConstraints
is independent. It can be used anywhere not limiting to one Widget.Niku 1 merge and flatten all of the complex objects to Niku Widget, which results in more method allocation than it should but is unarguably easy to develop.
With Niku 2, Complex Objects will be independent but also can be built with Niku.
Prefixed with Niku, the complex objects now can be created with a property builder just like Widget, and you can save and reuse it across any widget, for instance, using
NikuTextStyle
withNikuText
andNikuButton
.This not only deallocates lots of memory but also makes it reusable.
However, it's hard to main with a lot of property, as the property has no clear separation, mixing all the property together.
Now you can see clear separation, let's say if you're looking for
TextStyle
, you can skip all properties and just find a style that refers to Text instead of looking one by one.Ok, the generated snippet looks a bit too hard, but here's my screenshot.
The highlight can be directly distinct between function and property, so you can easily skip most of the things and find what you're looking for.
Transform
Niku 1 allows you to transform Widget to Niku Widget with
.niku
However, properties are not transformed with the Widget.
Which mean this
Will be transform into this
And can be transform back to this
This allows you to do anything with the Widget and can even be transformed back to support another library and extension.
However, note that most of the Widget is supported which means not everything is supported.
For now, known not support is :
NikuTextFormField
for TextFieldNikuState
forMaterialStateProperty
Thank you for your time in reading and using Niku.
I'm excited that you find my work useful and looking forward to seeing what you'll build with Niku.
Roadmap
Beta Was this translation helpful? Give feedback.
All reactions