Skip to content

RFC: Size-Aware Design Systems and Tree-Shakable Theme Defaults - #43

Open
kevmoo wants to merge 3 commits into
flutter:mainfrom
kevmoo:rfc-310-size-aware-design-systems
Open

kevmoo wants to merge 3 commits into
flutter:mainfrom
kevmoo:rfc-310-size-aware-design-systems

Conversation

@kevmoo

@kevmoo kevmoo commented Nov 3, 2026 •

Copy link
Copy Markdown

Proposes RFC 310.0000: Size-Aware Design Systems and Tree-Shakable Theme Defaults, eliminating whole-program tree-shaking retention cycles in package:material_ui across native AOT (gen_snapshot) and WebAssembly (dart2wasm) for apps using a subset of Material widgets, and introducing deterministic presubmit symbol-retention regression tests.

  • Tree-shakable design-system boundaries (package:material_ui only): Breaks the Theme.build -> InheritedCupertinoTheme -> Theme.of -> CupertinoBasedMaterialThemeData -> ColorScheme.fromSeed retention cycle (flutter/packages#13515) and migrates ThemeData's 47 component themes to Type Flow Analysis (TFA)-foldable lazy backing fields (flutter/packages#13516) with zero breaking changes to public APIs or equality/interpolation invariants.
  • Measured impact and trade-offs: On focused apps using a subset of Material widgets (kevmoo/slide_puzzle), these changes cut release binaries by -180 KB (-5.8%) on Linux x64 AOT (libapp.so), -81 KB (-3.3%) on WebAssembly (main.dart.wasm), and -34 KB (-1.6%) on JavaScript (main.dart.js). On widget-dense apps (flutter/devtools), they prune 16 unused *_theme.dart libraries for -22 KB (-0.4%) on WebAssembly while adding +8 KB (+0.1%) on dart2js.
  • Size-aware CI guardrails: Proposes deterministic presubmit symbol-retention tests in flutter/packages alongside postsubmit --wasm and native AOT size tracking for material_ui canary benchmarks.

Tracking issue: flutter/flutter#196349 (related: flutter/flutter#91772, flutter/flutter#101479)

Pre-launch Checklist

  • I read RFC 000.0001: Taxonomy and followed the file and path naming and metadata standards.
  • I read RFC 000.0002: Process and confirmed this proposal meets the threshold for a full RFC.
  • I read and agree to the Code of Conduct.
  • I signed the CLA.
  • I have linked an issue from flutter/flutter with the label design doc.
  • All existing and new tests are passing.
  • I have enabled "Allow edits from maintainers" on this PR so the bot can automatically assign an RFC number (or I will run dart run bin/assign_rfc_number.dart locally when instructed).

If you need help, consider asking for advice on the #hackers channel on Discord.

…able Theme Defaults

- Documents breaking the `Theme.build` -> `InheritedCupertinoTheme` -> `Theme.of` -> `CupertinoBasedMaterialThemeData` -> `ColorScheme.fromSeed` retention cycle (`flutter/packages#13515`).
- Documents migrating `ThemeData`'s 47 component theme properties to Type Flow Analysis (TFA)-foldable lazy backing fields (`flutter/packages#13516`) with zero breaking changes.
- Reports controlled A/B binary size reductions across Native Linux x64 AOT (`libapp.so`: `-180.2 KB` / `-5.79%`), WebAssembly (`main.dart.wasm`: `-81.3 KB` raw / `-45.9 KB` code section), and Web JS (`main.dart.js`: `-34.2 KB`).
- Outlines Phase 2 tree-shaking patterns (`!kIsWeb` operand order, `.adaptive` / variant enum switches, `PageTransitionsTheme`, `ServicesBinding`, and `Tween<T>.lerp` dynamic operator dispatch) and deterministic presubmit symbol-retention regression tests.

@elliette elliette left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a quick first pass, left a few comments. Also there are some issues with the PR description:

  • Looks like the tracking issue link is wrong (currently is flutter/flutter#188444, which is closed)
  • None of the linked related issues seem related to this prosal

…d add DevTools benchmark

- Align structure and tags (`310-design-systems`) with `000.0003-rfc-template.md`.
- Scope proposal and CI guardrails exclusively to `package:material_ui` in `flutter/packages`, moving follow-up framework/engine/compiler items to `Non-goals`.
- Add `flutter/devtools` (`packages/devtools_app`) Wasm (`-22 KB` / `-0.4%`) and `dart2js` (`+8 KB` / `+0.1%`) benchmark results and document the widget-coverage, `TextField`, and `debugFillProperties` boundaries.
@kevmoo

kevmoo commented Nov 11, 2026

Copy link
Copy Markdown
Author

Addressed all feedback in ac5de47, filed open tracking issue flutter/flutter#196349, and fixed the PR description links — PTAL!

@kevmoo
kevmoo requested a review from elliette November 11, 2026 04:27
@kevmoo kevmoo closed this Nov 13, 2026
@kevmoo
kevmoo deleted the rfc-310-size-aware-design-systems branch November 13, 2026 04:37
@kevmoo
kevmoo restored the rfc-310-size-aware-design-systems branch November 13, 2026 04:40
@kevmoo kevmoo reopened this Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants