โ† Core
In the workslicense: BSD-3-Clause

tom_flutter_ui

tom_flutter_ui ยท v1.1.0

The Flutter widget library of the framework: a Material/Cupertino-aware widget set, a declarative form system with authorizers, the Tom Action system, theming, and the fluent row-based Advanced Container Layout engine. Every widget understands the kernel's tomId/tomGroup visibility, the four-state authorization model and resource-driven styling, so a UI is configured from resources rather than hard-coded.

See License
Status
In the works
LOC
57.9k
Tests
2.5k
Test LOC
356.4k

Overview

From the module readme.md file:

What it enables

Enables Resource-driven UI, Four-state field authorization, Responsive ACL layouts.

Relationships

Standalone โ€” no declared relationships.

tom_flutter_ui

> Part of the Tom Framework. ยฉ Peter Nicolai Alexis Kyaw โ€” BSD 3-Clause > licensed.

The Flutter widget library of the Tom Framework: authorization-aware, resource-bound, observable widgets, a declarative form system, the Tom Action system, and a fluent row-based layout engine over tom_core_kernel.

Overview

tom_flutter_ui pairs the platform-neutral state, security, and resource primitives in tom_core_kernel with a Material- and Cupertino-aware widget set, a declarative form system, a behavioural action system, and a fluent row-based layout engine โ€” so an application is assembled from authorization-aware, observable, resource-bound widgets rather than hand-wired Flutter ones.

Every Tom widget understands the kernel's cross-cutting concerns:

  • a tomId / tomGroup for collective visibility control;
  • the kernel's four-state TomAuthState

authorization model (hidden / disabled / read-only / editable) โ€” the UI honours all four distinctly, eliding hidden elements from the tree, greying disabled ones, and locking read-only ones; - resource-driven colours / icons / config resolved by tomId; - observable state binding to the kernel's TomObject<T> family.

You opt into as much or as little of that as you need: the general widget kit renders with nothing but an app-level resource provider, while the form and ACL layers add reflection-backed binding and authorization on top.

Installation

dependencies:
  tom_flutter_ui:
    path: ../tom_flutter_ui

Or:

flutter pub add tom_flutter_ui --path ../tom_flutter_ui

This package is internal to the Tom workspace (publish_to: none) and is consumed by path. It targets Dart SDK ^3.11.0 / Flutter >=1.17.0 and depends on the sibling tom_core_kernel (state, security, resources, reflection). A single barrel re-exports every module:

import 'package:tom_flutter_ui/tom_flutter_ui.dart';

Features

Widget kit (widgets/)

The general-purpose widget toolkit โ€” every common Flutter widget given a Tom wrapper that adds tomId, authorization, and resource resolution.

TypeWhat it is
TomElevatedButton, TomTextButton, TomIconButton Authorization-aware buttons
TomText, TomRichText, TomBadge, TomChip Resource-bound display widgets
TomCard , TomListTile , TomColumn , TomCenter , TomAlign Containers & layout
TomCheckbox , TomSwitch , TomSlider , TomAutocomplete Inputs & toggles
TomLinearProgressIndicator, TomCircularProgressIndicator Progress
TomAlertDialog , TomAboutDialog , TomBottomSheet , TomBanner Dialogs & surfaces
TomAnimated* (TomAnimatedContainer, TomAnimatedOpacity, โ€ฆ) Animated variants
TomAclBuilderWidget-level entry point into the ACL layout engine

ACL โ€” advanced container layout (advanced_container_layout/)

A fluent, row-based layout engine modelled on the Java Swing StdAdvancedContainer / AdvancedContainerLike API, with first-class authorization integration.

TypeResponsibility
AclBuilder Fluent builder โ€” append, newRow, sizing, growth, variants
Acl / AclLayout / AclContainer The rendered layout widgets
AclFlags expandX / expandY / expand growth flags
AclBorderStyle, AclBorderKind, AclTitlePosition Border & titled-group styling
AclVariant, AclRowBreakpoint, AclVariantDetector Responsive variants & breakpoints
AclGroupVisibilityController, AclBinaryVisibilityController Group show/hide control
AclDeviceContext, AclFormFactor, AclDensity Adaptive device sizing inputs

Forms (forms/)

The declarative form system: the TomForm data model, validators, selectable sources, the form event bus, the Material+Cupertino style/decoration system, and the full field catalogue behind a FormFieldFamily factory.

TypeResponsibility
TomForm<T> The form base โ€” bind / save / discard, validation, authorization
FormFieldFamily Factory selecting the Material or Cupertino concrete per field
TomFormStyle, TomFormStyleScope Presets (material3, compact, bordered) + inherited scoping
LabelPlacement, DescriptionPlacement, RequiredIndicator Field decoration controls
TomSelectableSourcePluggable option sources (sync / async / filtered)
TomEnumSelectableSource<E> Enum options labelled from the text bundle, relabelled on a locale change
TomFormEvent, TomFormEventSource, TomFormEventListener The form event bus
TomListForm, TomMasterDetailListForm, TomListFormToolbar Collection / master-detail forms
TomFormErrorBanner, TomFormInspector Error surfacing & debug inspection

The field catalogue spans a parallel Material/Cupertino set: string (TomFormStringInput, TomFormStringDropdown, TomFormStringRadioGroup, TomFormStringFilterChips, TomFormStringListField), boolean (TomFormBoolSwitch, TomFormBoolCheckbox, TomFormBoolToggle), numeric (TomFormIntInput, TomFormIntStepper, TomFormDoubleSlider, TomFormIntRangeField, TomFormIntListField), date/time (TomFormDateField, TomFormTimeField, TomFormDateTimeField, TomFormDurationField, TomFormDateRangeField), enum/object (TomFormEnumDropdown, TomFormEnumSegmented, TomFormObjectField, TomFormLookupField, TomFormSearchField), file (TomFormFileField, TomFormFileUpload, TomFormFileDropzone, TomFormFileThumbnail), and nullable wrappers (TomFormNStringInput, TomFormNIntInput, TomFormNDateInput, TomFormNEnumDropdown).

The file fields come with their own plumbing: TomFilePickerRegistry (one application-wide picker adaptor, so the package needs no dependency on file_picker / image_picker), TomFileTransferController (streaming upload and download with progress, cancel and retry over the kernel's TomFileTransferClient), and TomFileTransferIndicator. See doc/forms_file_fields.md.

Theming (theme/)

TypeResponsibility
TomTheme, TomThemeScope The Tom theme and its inherited scope
TomStateStyle The treatment of a withheld authorization state; the theme carries one per state ( read , disabled )
TomButtonVariantsButton style-variant set

Resource & configuration inputs (resource_auth/)

TypeResponsibility
TomUIColors, TomUIIcons Resource-resolved colour / icon namespaces
TomUIColorAdapter, TomUIIconAdapter The pluggable resource adapter contracts
AllColorsAdapter , AllIconsAdapter , and the MaterialOnlyโ€ฆ / CupertinoOnlyโ€ฆ pairs Full and single-family adapters for each namespace
TomConfigProvider, TomConfigEnvironment, TomConfigPlatform Config / environment inputs

Kernel types (kernel_types.dart)

The package does not re-export tom_core_kernel wholesale: the two packages answer different questions, and an application doing kernel work should import the kernel and say so. One explicit list is the bridge instead, and every kernel type named in a public tom_flutter_ui signature is on it. Importing both barrels into one library is legal โ€” the config enums above are named TomConfigโ€ฆ precisely so they do not collide with the TomEnvironment and TomPlatform that tom_basics (and so the kernel barrel) already declares.

GroupTypes
Authorization TomAuthState , TomAuthorizable , TomAuthorizationGroup , AuthGroupMode , TomAuthorizationAdapter , TomAuthorization , TomAuthorizer , TomAuthorizerStrategy , TomUIStateController
Scopes TomScope , TomScopeBase , TomScopeMixin โ€” the type of scope: on every Tom widget
Observables TomObservable , TomObserver , TomFunctionObserver , TomObject , TomClass , TomList , TomListLifecycleListener , TomObservableEnum
File transfer TomFileTransferClient , TomFileSource , TomFileMetadata , TomTransferProgress , TomTransferCancellation , TomFileTransferException

Anything outside that list is kernel work rather than UI work: import package:tom_core_kernel/tom_core_kernel.dart for it. See doc/kernel_types.md.

Actions (actions/)

The behavioural counterpart to widgets โ€” typed, authorization-aware actions with atomic transactions, undo/redo history, composites, and widget triggers.

TypeResponsibility
TomAction, TomSimpleAction, TomCompositeAction The action base & primitives
TomActionController, TomActionContext Action registry (canonical-path prefix) & per-invocation context
TomActionTransaction, TomUndoHistory, TomUndoRedoContext Atomicity & undo/redo
TomCompositeAction, TomCompositeStep Composed multi-step actions
TomActionTrigger Widget trigger binding โ€” the one type that dispatches an action

Foundation & groups (widget_base/, groups/, custom/)

TypeResponsibility
TomNodeBase, TomPolicyNodeBase, TomWidgetFamily The widget / family base classes
TomStatelessWidget, TomStatefulWidget, TomState Construction-time helpers
TomScreenElementsProviderBase, TomStyleResolvers, TomCtr Element provider & resolvers
TomAuthorizationGroup Collective visibility control without an id on every leaf
TomAuthGuard , TomAuthTreeView , TomEmptyState , TomErrorBoundary Non-form composites
TomInfiniteScroll , TomLoadingOverlay , TomChoiceGroup , TomSkeletonLoader More composites

Quick start

The general widget kit renders with nothing but an app-level resource provider โ€” no reflection or codegen required:

import 'package:flutter/material.dart';
import 'package:tom_core_kernel/tom_core_kernel.dart';
import 'package:tom_flutter_ui/tom_flutter_ui.dart';

void main() {
  // Tom widgets resolve labels/colours through the resource layer; install a
  // provider and the all-colours adapter so the kit renders with its explicit
  // values rather than failing a resource lookup.
  TomTextResourceProvider.setAppResourceProvider(
    TomTextResourceProvider.from(const {}),
  );
  TomUIColors.adapter = AllColorsAdapter();
  runApp(const MaterialApp(home: Scaffold(body: Center(child: _Demo()))));
}

class _Demo extends StatelessWidget {
  const _Demo();
  @override
  Widget build(BuildContext context) {
    // A two-row ACL layout: label + badge, then a button. Explicit text/child
    // values render without any resource entries in the provider.
    return AclBuilder()
        .append(TomText(text: 'Hello, Tom'))
        .append(TomBadge(labelText: '3', child: const Icon(Icons.star)))
        .newRow()
        .append(TomElevatedButton(
          onPressed: () {},
          child: const Text('Save'),
        ))
        .build(); // returns an Acl widget (a StatelessWidget)
  }
}

Run it with flutter run example/gallery_demo.dart for the full gallery.

Example projects

SampleDemonstrates
example/gallery_demo.dart A single runApp demo paging the three pillars โ€” widget kit, custom composites, and the form feature set (lifecycle, four authorization states, authorizers, nesting, validation)
example/widgets/ Per-widget usage snippets for the general kit
example/advanced_container_layout/ ACL sizing, growth, borders, variants, breakpoints
example/forms/ Form fields, validation, styles, list / master-detail forms
example/actions/ Actions, transactions, undo/redo, triggers
example/theme/ ยท example/resource_auth/ ยท example/groups/ ยท example/custom/ ยท example/widget_base/ Per-module samples

The companion demo/test apps tom_flutter_form_test and tom_flutter_ui_test exercise the whole library across dozens of interactive demos โ€” see their demo catalogues.

> Cross-package samples. The tom_core_samples showcases โ€” > core_flutter_ui_showcase, > core_flutter_form_showcase, > core_flutter_acl_sample, > and core_flutter_acl_responsive > โ€” teach this library surface by surface against one todo-management domain. See > the samples map for the full learning path.

Usage

A form

A TomForm is subclassed for each data model: declare the fields, build them in createFormElements(), and the form drives bind / save / discard, validation, authorization, and resource resolution for every field it owns.

@tomReflector
class AddressForm extends TomForm<AddressData> {
  AddressForm({super.parentForm}) : super(formId: 'address');

  late final TomFormStringInput street;
  late final TomFormStringInput city;

  @override
  void createFormElements() {
    // build the concrete fields and bind them to the model โ€ฆ
  }
}

Styling forms

TomFormStyle carries three presets โ€” material3 (default), compact (floating labels, tighter gaps), and bordered โ€” applied to a subtree via TomFormStyleScope. Fields below the scope resolve their decoration through it; LabelPlacement, DescriptionPlacement, and RequiredIndicator tune individual field chrome.

The ACL layout engine

AclBuilder is fluent: append() adds a component to the current row, newRow() starts a new one, setPSize / setMSize set preferred / minimum sizes, and expandX() distributes surplus width. addVariant / addRowBreakpoint make the layout responsive; AclBorderStyle + AclTitlePosition draw titled groups. build() returns an Acl widget you drop into any Flutter tree.

Actions

A TomActionController owns and names a group of TomActions, supplying the <scopePath>.<controllerId>.<actionId> canonical path used for authorization and resource lookup โ€” it is a registry and never runs an action. TomActionTrigger is what dispatches one: bind it to a widget callback and it checks canExecute, opens a TomActionTransaction so the mutation is atomic, and pushes the committed transaction onto the application's TomUndoHistory.

Architecture

tom_flutter_ui
โ”œโ”€โ”€ widget_base/                 # TomNodeBase / TomPolicyNodeBase / TomWidgetFamily,
โ”‚                                #   scope widgets, screen-elements provider, resolvers
โ”œโ”€โ”€ theme/                       # TomTheme + style-variant system
โ”œโ”€โ”€ resource_auth/               # TomUIColors / TomUIIcons / TomConfigProvider
โ”œโ”€โ”€ kernel_types.dart            # the one bridge to tom_core_kernel
โ”œโ”€โ”€ groups/                      # TomWidgetMixin โ€” collective-visibility wiring
โ”œโ”€โ”€ actions/                     # TomAction system (transactions, undo/redo, triggers)
โ”œโ”€โ”€ advanced_container_layout/   # AclBuilder fluent row engine + Acl render widgets
โ”œโ”€โ”€ forms/                       # TomForm model + FormFieldFamily field catalogue + styles
โ”œโ”€โ”€ widgets/                     # general widget kit (buttons โ€ฆ trees, animated variants)
โ””โ”€โ”€ custom/                      # non-form composites (auth guard/tree, overlays, skeleton)

Every layer rests on widget_base (the TomAuthorizable contract + base classes) and resolves cross-cutting concerns through resource_auth (colours, icons, configuration) and theme (appearance). forms, widgets, and advanced_container_layout are the three feature surfaces an app composes.

TypeResponsibility
TomNodeBase / TomPolicyNodeBase Base widget classes carrying tomId + authorization
TomWidgetFamilyMaterial/Cupertino family selection
TomForm<T>The form data model + lifecycle
FormFieldFamilyPer-field Material/Cupertino concrete factory
AclBuilder / Acl The fluent layout builder and its rendered widget
TomAction / TomActionController The action system entry points
TomUIColors / TomUIIcons Resource-resolved colour / icon namespaces
TomAuthorizationGroupCollective visibility control

Ecosystem

        tom_core_kernel  (state ยท security ยท resources ยท reflection)
                 โ”‚
   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
   โ”‚             โ”‚                       โ”‚
tom_core_flutter โ”‚                 tom_flutter_ui   โ† this package
 (kernel-on-     โ”‚              (widget kit ยท forms ยท
  Flutter        โ”‚               ACL ยท actions ยท theme)
  binding)       โ”‚
                 โ–ผ
                tom_core_server

tom_flutter_ui is the rich UI toolkit; the lower-level kernel-on-Flutter binding lives in tom_core_flutter. Both demo harnesses (tom_flutter_form_test, tom_flutter_ui_test) target tom_flutter_ui + tom_core_kernel and do not depend on tom_core_flutter. See the repository map at ../README.md.

Further documentation

Per-module guides live in doc/: widget_base.md, theme.md, actions.md, resource_auth.md, forms.md (+ form_authorizers.md, forms_file_fields.md, formstyle_migration.md), groups.md, advanced_container_layout.md (+ flutter_alignments_improvements.md), widgets.md, custom.md, kernel_types.md, and debug_and_inspection_system.md. Development guidelines live in _copilot_guidelines/, which is workspace tooling rather than part of this package's documentation.

Status

  • Version: 1.1.0 (publish_to: none)
  • Tests: run with flutter test. No count is given: a count is a claim

nothing checks, and every added test would be a README edit nobody makes. The version above is checked, because a wrong one is the claim that actively misleads.

License
BSD 3-Clause License

Copyright (c) 2024-2026, Peter Nicolai Alexis Kyaw
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
   contributors may be used to endorse or promote products derived from
   this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.