Skip to content

feat(mix): add BoxStyler.pressable() - #1088

Open
leoafarias wants to merge 9 commits into
mainfrom
feat/boxstyler-pressable
Open

leoafarias wants to merge 9 commits into
mainfrom
feat/boxstyler-pressable

Conversation

@leoafarias

@leoafarias leoafarias commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

Related issue

No linked issue.

Description

Add compose → .pressable() → call for interactive Box, Text, Icon, Image, FlexBox, StackBox, WrapBox, and GridBox styles.

final button = BoxStyler()
    .padding(.all(16))
    .onPressed(.scale(0.96))
    .pressable();
button(onPress: save, child: const Text('Save'));

Changes

  • Add instance methods through the existing private-mixin generation hook and directly on GridBoxStyler. Immutable callable builders capture unresolved styles and construct a fresh Pressable and styled child per call.
  • Preserve every Pressable option/default and native content signature. Keys belong to the outer widget; builders expose no further styling or overrides. Released constructors and ordinary styler APIs remain compatible. @MixWidget factories still return styles.
  • Cover forwarding, constructor signatures/defaults, terminal compile errors, generation, token/animation/state resolution, independent reuse, pointer/keyboard behavior, and semantics. Contract tests use resolved element APIs compatible with analyzer 10.2 and 14.5, including newer main-branch CI resolution.
  • Update README, API guidance and canonical skills; include a source-dependent runnable example and a 31-site showcase migration audit. The simplification review fixed a duplicated accessible label, removed seven unnecessary lint suppressions and four overlapping tests, and strengthened callback/state isolation coverage.

Review Checklist

  • Testing: Fresh validation below; independent review completed.
  • Breaking Changes: Replaces only this PR's unreleased extension API.
  • Documentation Updates: Examples, guidance, skills and migration audit updated.
  • Website Updates: Separate btwld/mix-docs migration remains a release follow-up.

Validation and release follow-ups

  • October 19 local melos run gen:build, melos run ci, and melos run format:check passed: 3,023 core tests, 383 generator tests and all dependent suites, including 129 showcase tests. Generated output has no further changes.
  • Contract analysis and all three contract tests passed with analyzer 14.5; the full generator suite passed with analyzer 10.2.
  • October 17 focused regression/example checks passed (101, including a temporary semantics probe). Standalone example analysis/web build and all five canonical/installed skill directories passed validation then; those unchanged checks were not rerun in this test-only follow-up.
  • melos run analyze: schema and Dart stages passed. DCM still reports four pre-existing findings in unchanged files: member ordering and sealed-switch wildcard in style_animation_builder.dart:81,90; argument ordering in decoration_style_mixin.dart:273,359. Full analysis remains non-green; no new DCM findings.

Callable builders are unreleased and absent from Mix 2.2.1. Hosted showcase and standalone Snacks retain published-compatible constructors until release. The migration audit maps all 22 PressableBox and 9 Pressable sites, including hit areas, nested controls, keyboard access and semantics. The October 19 GitHub workflow passed against current main, including repository analysis/tests and published-dependency showcase analysis/tests/web build.

Plan and review records

Plans and review records are committed with the implementation. Repository instructions require these records to be committed and pushed with future PRs.

Related issue

No linked issue.

Description

Add BoxStyler.pressable(...) so a composed BoxStyler can construct a PressableBox directly:

final button = BoxStyler()
    .padding(.all(16))
    .color(Colors.blue)
    .onPressed(.color(Colors.indigo));
final label = TextStyler().color(Colors.white).fontWeight(.w600);

button.pressable(onPress: save, child: label('Save'));

The five Pressable*Builder classes and per-styler .pressable() methods were dropped:

  • Stylers in Mix are already callable (button(...), label('Save')), so introducing a second callable wrapper layer was redundant.
  • Pressable must sit outside Box/StyleBuilder so its WidgetStateProvider is visible to .onHovered, .onPressed, .onFocused, and .onDisabled on the style itself (which is why .wrap(...) modifiers cannot be used).
  • Returning PressableBox(style: this, ...) from BoxStyler.pressable(...) avoids duplicating Pressable's parameter list across seven places. Follow-ups like Add semantics identifier support to Pressable #1092 (semanticsIdentifier) only need to add the parameter to Pressable, PressableBox, and this one method.

Changes

  • Add BoxStyler.pressable(...) forwarding all PressableBox parameters and defaults to PressableBox(style: this, ...).
  • Remove pressable_builders.dart, the five Pressable*Builder classes, the _...StylerPressableMixin hooks, and .pressable() on TextStyler, IconStyler, ImageStyler, FlexBoxStyler, StackBoxStyler, WrapBoxStyler, and GridBoxStyler.
  • Add focused tests in packages/mix/test/src/specs/pressable/box_styler_pressable_test.dart covering default values, parameter forwarding, and tap/onPressed interaction.
  • Update CHANGELOG.md, README.md, composition guidelines, packages/mix/example, and Mix skill docs.

Review Checklist

  • Testing: Have you tested your changes, including unit tests and integration tests for affected code?
  • Breaking Changes: Does this change introduce breaking changes affecting existing code or users?
  • Documentation Updates: Are all relevant documentation files (e.g. README, API docs) updated to reflect the changes in this PR?
  • Website Updates: Is the website containing the updates you make on documentation?
Open in Web Open in Cursor 

@github-actions github-actions Bot added the mix label Oct 3, 2026
@leoafarias
leoafarias marked this pull request as ready for review October 3, 2026 18:22
@leoafarias leoafarias changed the title feat(mix): add BoxStyler pressable builder feat(mix): add callable pressable builders across stylers Oct 3, 2026
@cursor
cursor Bot force-pushed the feat/boxstyler-pressable branch from 0811d72 to 2525770 Compare October 20, 2026 15:35
@cursor cursor Bot changed the title feat(mix): add callable pressable builders across stylers feat(mix): add BoxStyler.pressable() Oct 20, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants