flutter_sdui_kit 0.3.1
flutter_sdui_kit: ^0.3.1 copied to clipboard
A server-driven UI framework for Flutter. Render native widgets from JSON with 23 components, data binding, forms, theming, and action handling.
Changelog #
0.3.1 #
Bug Fixes #
- Fixed:
cardBuildercaused a stack overflow on render when a card had an action. TheBuilderwidget's child referenced the reassignedcardvariable, creating infinite recursion (Builder → GestureDetector → card → Builder → …). Now uses a separatecardWidgetvariable.
New Features #
ActionHandler.navigatorKey— optionalGlobalKey<NavigatorState>fallback for navigation whenBuildContextdoesn't contain aNavigatorancestor (e.g. insideMaterialApp(builder:)orWidgetsApp(builder:)).ActionHandler.navigatorOf(context)— safe navigation helper that triesNavigator.of(context)first, then falls back tonavigatorKey.currentState. Throws a descriptive error if neither works.
0.3.0 #
Breaking Changes #
ActionTypeHandlersignature changed from(SduiAction, Map<String, dynamic>)to(BuildContext, SduiAction, Map<String, dynamic>).ActionCallbacksignature changed from(SduiAction)to(BuildContext, SduiAction).ActionHandler.handle()now requiresBuildContextas its first argument.ActionHandler.onUnhandledcallback now receivesBuildContextas its first argument.
Why #
Action handlers previously had no access to the widget tree's BuildContext. This made it impossible to call Navigator.of(context), show dialogs, or use any API that requires a context. Components now capture BuildContext from their build() method and forward it through the callback chain.
Migration Guide #
// Before (0.2.x)
handler.register('navigate', (action, payload) {
// no context available — navigation hacks needed
});
// After (0.3.0)
handler.register('navigate', (context, action, payload) {
Navigator.of(context).pushNamed(payload['route'] as String);
});
Improvements #
- Button, gesture, and card builders use
Builderwidget to provide liveBuildContextto action callbacks. - Form builders (text input, checkbox, switch, dropdown) pass
BuildContextthroughonChanged/onSubmittedcallbacks.
0.2.1 #
Bug Fixes #
- Fixed:
buttonBuildercrashed withBoxConstraints forces an infinite widthwhen afull_width: truebutton was placed inside aRowor other unconstrained parent. ReplacedCenter+SizedBox(width: infinity)with layout-safeAlignwidget. - Updated example to use
flex: 1on buttons inside aRowfor proper space distribution.
0.2.0 #
New Components #
expanded— JSON-side Expanded/Flexible wrapper withflexandfitpropscenter— Center wrappersafe_area— SafeArea wrapper with per-edge controlaspect_ratio— AspectRatio wrapperconstrained_box— ConstrainedBox with min/max width/height
Layout Safety #
- Column/Row now use
mainAxisSize: MainAxisSize.min— no more unbounded axis crashes - Column/Row support
scrollprop to auto-wrap in SingleChildScrollView - Per-child
flex/flex_fitprops on any child in a Column/Row (replaces blind Expanded wrapping) - List builder uses
ListView.builderwithshrinkWrap: true+NeverScrollableScrollPhysics - Horizontal lists accept
height/widthprops for cross-axis sizing LayoutErrorBoundary,SduiConstraints,ConstraintGuardlayout helpers
Error Handling #
SduiError— structured error with type, message, nodeType, exception, stackTraceSduiErrorTypeenum — parse, render, unknownComponent, expressiononErrorcallback on SduiWidget — receives every error during renderingerrorWidgetBuilderon SduiWidget — replaces broken nodes with custom widgetsfallbackwidget (renamed fromerrorWidget) — shown when JSON is null/empty/invalid- Renderer error boundary: broken nodes become
SizedBox.shrink(), siblings keep rendering - Expression evaluator wrapped in try-catch — bad
visible_ifhides node instead of crashing
API Changes #
- Breaking:
SduiWidgetno longer acceptsscreen:parameter — usejson:only - Breaking:
errorWidgetrenamed tofallback SduiWidget.jsonis nowrequired(nullableString?)- Exported
sdui_error.dartandlayout_helpers.dartfrom barrel file
Documentation #
- Complete README rewrite with Quick Start, JSON Protocol, all 23 components, state management examples (setState, Riverpod, Bloc, GetX), layout safety guide, architecture diagram, API reference
- Comprehensive doc comments on all public builders
Tests #
- 158 total tests (45 unit + 79 widget + 34 edge case)
- Widget tests for all 23 component types
- Edge case tests: infinite layouts, empty data, error resilience, state management patterns
0.1.1 #
Initial public release.
Core #
SduiNode— recursive JSON-to-model tree parserSduiScreen— top-level screen model with theme + metadataSduiAction— declarative action model (navigate, api_call, etc.)SduiTheme— server-side colour overridesSduiRenderer— walks the node tree and builds a Flutter widget treeComponentRegistry— extensible map oftype→ builder functionsActionHandler— dispatcher for user-interaction actionsSduiWidget— drop-in StatelessWidget that renders from JSON or model
Data Binding #
TemplateResolver—{{user.name}}placeholder resolution in stringsExpressionEvaluator— condition engine forvisible_ifexpressionsSduiDataProvider— InheritedWidget to flow data context down the tree
Built-in Components #
- Layout:
column,row,padding,sizedbox,container,scroll - Content:
text,image,button,icon - Composite:
card,list,divider - Form:
text_input,checkbox,switch,dropdown - Interaction:
gesture
Utilities #
StyleParser— hex→Color, EdgeInsets, TextStyle, alignment resolvers
0.1.0+1 #
Updated Home page and github repository