Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It's been a wild ride of Niku with you all.
Since Niku 2.0 has been released, Niku has been getting a lot of attention lately, and we really want to say thank you to all for joining us on how we could reimagine composing UI in the Flutter together.
For this release, 2.1 or ga1ahad have been working on for quite some time, drafted even before the release of 2.0 rc.
The name "Ga1ahad" comes from Ga1ahad and Scientific Witchery.
Without further ado, let's see what's new in Niku 2.1~
Proxy
Previously, with Niku, composing nested objects would required you an additional, for example composing
n.Button
.This is good for grouping the styling, easily indicating which style is for which part, but to be honest, it's slow and annoying to write.
That's why Proxy is created to fix this problem.
Proxy is an abstract class for mapping your setter and shortcut to a nested object property without using a hook.
It handles creating object if doesn't exist and just write the property, that's it, no magic or expensive calculation.
This allows you to write the direct setter without having
useTextStyle
oruseButtonStyle
hook.Not only that you can use Proxy to handle the style of nested objects, but you can also handle the parent property builder as well.
Proxy support
Button
andTextFormField
with all properties, and shortcuts.Parent Proxy
Same as Proxy but for parents.
Parent Proxy allows you to compose your parent with access to parent property without having to create
useParent
.For the layout widget like
Column
andRow
which usually required explicit set of width or other property likew100
,bg
,scrollable
,rounded
,border
and etc.Providing a shortcut proxy would be really convenient, so the parent proxy is here for the job.
With parent proxy, you can now compose some parent shortcut for some specific widget starting with
Column
andRow
.Because some widgets might have conflict names with parent property and shortcuts like
padding
, only a specific selection of widgets are get to have Parent Proxy.But every parent has limited access to some convenient Parent Proxy, starting with
margin
andm
.useThemeSelector
Dark theme has become an essential part of app development, with Niku you can use
useDarkMode
to handle the case.But the handler is quite, imperative to say the least.
You are provided with child and
isDark
as an indicator for dark mode but you still have to handle the logic yourself.For a single property, it's quite simple but when there's more property it gets annoying.
Besides what about some property you might want to have in specific mode only? You have to handle the case yourself.
This is why
useThemeSelector
is introduced.Basically, it provide you the same syntax as
useScreen
but for dark mode and handle the rest of for diffing and applyment for you.GridView and ListView
Gridview and ListView are now supported as Niku widgets, with all the factory property and utilities you can use.
It's recommended to use GridView and ListView for Style Sheet Pattern because of the redundant syntax provided.
Breaking Change
flexible
is nowflex
onNiku
TextFormField
in favor ofhint
..hint
or add it asnamed parameter
Minor Feature
ConstraintsMacro
toNikuInputDecoration
useTextStyle
toDropdownButton
NikuButton
color
setter toNikuButtonStyle
of
alias forapply
Change
border
is nowbaseBorder
, andallBorder
is nowborder
Padding
instead ofContainer
because that's how native Flutter doing it. Yes, margin is actually padding in Flutter._init
ofMapTextStyleMacro
center
toNikuColumn
, andNikuRow
childrenWithGap
with$internalComposeGap
inGapMacro
gap
property to AxisLayoutchildrenWithGap
now only composed on buildborderWidth
is nowbaseBorderWidth
to follow the same convention withborder
,borderColor
, andborderStyle
on proxyAxisLayoutMacro
is nowAxisLayoutProxy
Fix
Bug fix:
print
fromPaddingMacro
'owner!._debugCurrentBuildTarget == this': is not true.
when usinguseDarkMode
useDarkMode
anduseThemeSelector
not switching context between