Skip to content

Update Stac parsers and core models#475

Merged
divyanshub024 merged 3 commits into
devfrom
dv/stac-changes
May 12, 2026
Merged

Update Stac parsers and core models#475
divyanshub024 merged 3 commits into
devfrom
dv/stac-changes

Conversation

@divyanshub024
Copy link
Copy Markdown
Member

@divyanshub024 divyanshub024 commented May 12, 2026

Description

Updates Stac parser and core model support for additional Flutter configuration surface area in stac and stac_core, with matching documentation updates.

Changes

  • Added StacInputFormatterType.mask and mask support for structured input formatting.
  • Wired mask input formatters through TextFormField and DropdownMenu parsers.
  • Added floatingLabelBehavior support to StacInputDecoration.
  • Added StacTextDecorationLine and custom text style decoration parsing.
  • Added floating action button theme shape and sizeConstraints support.
  • Enabled shape parsing for icon button styles.
  • Preserved existing scoped form values when initializing StacTextFormField.

Documentation

  • Updated TextFormField and DropdownMenu docs for input formatters and masks.
  • Updated TextField docs for floatingLabelBehavior on input decorations.
  • Updated Text Style docs for StacTextDecorationLine values.
  • Updated IconButton docs for style.shape.
  • Updated theming docs for floating action button theme shape and constraints.

Related Issues

None.

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Code refactor
  • Build configuration change
  • Documentation
  • Chore

Validation

  • flutter test test/utils/input_formatters_test.dart from packages/stac
  • dart analyze from packages/stac
  • dart analyze from packages/stac_core

Summary by CodeRabbit

  • New Features

    • Floating Action Button theme: shape and size constraint options
    • Mask-based input formatters for formatted entry (dates, phone numbers), supported in DropdownMenu and text form fields
    • Text decoration options (none, underline, overline, line-through)
    • Floating label behavior for text inputs (auto, always, never)
    • Icon button shape styling
  • Bug Fixes

    • Icon button shape now applied correctly
  • Tests

    • Added tests for mask input formatters

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 109fd6fd-6272-4c8b-8065-7be496586ca3

📥 Commits

Reviewing files that changed from the base of the PR and between 97a29d0 and af8b7e5.

📒 Files selected for processing (1)
  • packages/stac/test/utils/input_formatters_test.dart
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/stac/test/utils/input_formatters_test.dart

📝 Walkthrough

Walkthrough

Adds StacTextDecorationLine and decoration wiring; implements mask input formatter (model, parser, implementation, tests); adds StacInputDecoration.floatingLabelBehavior and parser mapping; extends FAB theme with shape/sizeConstraints; wires parsers/widgets; and updates docs/examples.

Changes

Text Decoration, Input Formatting, and Theme Enhancements

Layer / File(s) Summary
Text decoration line types and model
packages/stac_core/lib/foundation/text/stac_text_types.dart, packages/stac_core/lib/foundation/text/stac_text_style/stac_text_style.dart, packages/stac_core/lib/foundation/text/stac_text_style/stac_text_style.g.dart
New StacTextDecorationLine enum (none, underline, overline, lineThrough); StacCustomTextStyle gains decoration field, constructor handling, copyWith, and JSON (de)serialization.
Text decoration parsing and widget application
packages/stac/lib/src/parsers/foundation/text/stac_text_decoration_line_parser.dart, packages/stac/lib/src/parsers/foundation/text/stac_text_style_parser.dart, packages/stac/lib/src/parsers/widgets/stac_text/stac_text_parser.dart, packages/stac/lib/src/parsers/widgets/stac_selectable_text/stac_selectable_text_parser.dart
Adds StacTextDecorationLineParser extension mapping enum to Flutter TextDecoration; integrates decoration parsing into style parsing and ensures widget parsers propagate decoration overrides.
Mask input formatter model and implementation
packages/stac_core/lib/foundation/forms/stac_input_formatter/stac_input_formatter.dart, packages/stac_core/lib/foundation/forms/stac_input_formatter/stac_input_formatter.g.dart, packages/stac/lib/src/utils/input_formatters.dart
Adds mask variant to StacInputFormatterType and mask field to StacInputFormatter with JSON support; extends InputFormatterType.format to accept mask; implements _StacMaskInputFormatter that filters by rule and applies mask patterns (# consumes characters).
Mask formatter parser & widget integration
packages/stac/lib/src/parsers/foundation/forms/stac_input_formatter_type_parser.dart, packages/stac/lib/src/parsers/widgets/stac_dropdown_menu/stac_dropdown_menu_parser.dart, packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field_parser.dart
Parser maps mask type; dropdown and text form field parsers construct mask formatters passing rule and mask; TextFormField initState resolves controller text from existing form data when available.
Mask formatter unit tests
packages/stac/test/utils/input_formatters_test.dart
Unit tests exercise InputFormatterType.mask.format for separator insertion, allowed-character filtering, anchored-rule behavior, and empty-mask passthrough.
Input decoration floating label behavior
packages/stac_core/lib/foundation/decoration/stac_input_decoration/stac_input_decoration.dart, packages/stac_core/lib/foundation/decoration/stac_input_decoration/stac_input_decoration.g.dart, packages/stac/lib/src/parsers/foundation/decoration/stac_input_decoration_parser.dart
StacInputDecoration adds floatingLabelBehavior string property (auto, always, never) with JSON support; parser helper maps strings to Flutter FloatingLabelBehavior.
Floating action button theme enhancements
packages/stac_core/lib/foundation/theme/stac_floating_action_button_theme_data/*, packages/stac/lib/src/parsers/theme/stac_floating_action_button_theme_data_parser.dart
StacFloatingActionButtonThemeData adds optional shape and sizeConstraints fields with JSON wiring; FAB theme parser imports shape/constraints parsers and applies parsed values.
Icon button shape styling
packages/stac/lib/src/parsers/theme/stac_button_style_parser.dart
Uncomments and forwards parsed shape into IconButton.styleFrom so configured shapes affect icon buttons.
Documentation: text style, dropdown, text field, text form field, icon button, and FAB theme
docs/styles/text_style.mdx, docs/widgets/dropdown_menu.mdx, docs/widgets/text_field.mdx, docs/widgets/text_form_field.mdx, docs/widgets/icon_button.mdx, docs/concepts/theming.mdx
Updates docs: text decoration options and examples; adds inputFormatters to dropdown docs; adds StacInputDecoration docs (floatingLabelBehavior) to TextField/TextFormField; updates TextFormField example to a date mask; IconButton and FAB theme docs updated with shape/size examples.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • StacDev/stac#450: Changes to text style parsing and custom style handling with decoration support.
  • StacDev/stac#379: Refactors theme-related parser/data code overlapping FAB theme changes.
  • StacDev/stac#350: Updates to text style model and parsing pipeline related to decoration handling.

Suggested reviewers

  • Potatomonsta

Poem

🐰 I stitched a mask of # and rule,

Lines underline and labels float like fuel,
Buttons shaped with gentle curve and size,
Forms remember values, neat and wise,
Docs and tests hop in cheerful guise.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Update Stac parsers and core models' accurately reflects the main objective of the PR, which adds parser support, updates core models, and includes documentation changes across multiple files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dv/stac-changes

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/stac/lib/src/parsers/foundation/text/stac_text_style_parser.dart (1)

67-88: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Missing decoration field in theme text style override.

The StacThemeTextStyle.copyWith call includes decorationColor, decorationStyle, and decorationThickness but omits the new decoration field. This creates an inconsistency where users can override decoration styling properties but cannot override the decoration line itself (underline/overline/lineThrough) when using theme-based text styles.

🔧 Proposed fix

First, add the decoration field to StacThemeTextStyle in packages/stac_core/lib/foundation/text/stac_text_style/stac_text_style.dart:

class StacThemeTextStyle extends StacTextStyle {
  StacThemeTextStyle({
    required this.textTheme,
    this.inherit,
    // ... other fields ...
    this.leadingDistribution,
    this.decoration,  // Add this
    this.decorationColor,
    // ... rest of fields ...
  }) : super._(type: StacTextStyleType.theme);

  // ... other fields ...

  /// Drawn line on the text (underline, strikethrough, etc.).
  ///
  /// Type: [StacTextDecorationLine]
  final StacTextDecorationLine? decoration;

  // ... rest of class ...
}

Then update the parser to include it:

     return textStyle?.copyWith(
       inherit: themeRef.inherit,
       color: themeRef.color?.toColor(context),
       backgroundColor: themeRef.backgroundColor?.toColor(context),
       fontSize: themeRef.fontSize,
       fontWeight: themeRef.fontWeight?.parse,
       fontStyle: themeRef.fontStyle?.parse,
       letterSpacing: themeRef.letterSpacing,
       wordSpacing: themeRef.wordSpacing,
       textBaseline: themeRef.textBaseline?.parse,
       height: themeRef.height,
       leadingDistribution: themeRef.leadingDistribution?.parse,
+      decoration: themeRef.decoration?.parse,
       decorationColor: themeRef.decorationColor?.toColor(context),
       decorationStyle: themeRef.decorationStyle?.parse,
       decorationThickness: themeRef.decorationThickness,
       debugLabel: themeRef.debugLabel,
       fontFamily: themeRef.fontFamily,
       fontFamilyFallback: themeRef.fontFamilyFallback,
       package: themeRef.package,
       overflow: themeRef.overflow?.parse,
     );

Also update the copyWith method and regenerate the JSON serialization code.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/stac/lib/src/parsers/foundation/text/stac_text_style_parser.dart`
around lines 67 - 88, The theme text style override is missing the decoration
field—add a nullable decoration property (type StacTextDecorationLine) to
StacThemeTextStyle in stac_text_style.dart, include it in the StacThemeTextStyle
constructor and class fields, update StacThemeTextStyle.copyWith to accept and
assign decoration, then modify the parser in stac_text_style_parser.dart (the
copyWith call on themeRef) to pass themeRef.decoration (parsed to the framework
TextDecoration via the existing parse helper) alongside
decorationColor/decorationStyle/decorationThickness, and finally regenerate the
JSON serialization code so the new field is persisted.
🧹 Nitpick comments (1)
packages/stac/test/utils/input_formatters_test.dart (1)

6-26: ⚡ Quick win

Add a regression test for permissive regex patterns (e.g., \d*).

A case like rule: r'\d*' should not allow letters through the mask filter. This will lock in the expected behavior once the matcher is anchored.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/stac/test/utils/input_formatters_test.dart` around lines 6 - 26, Add
a regression test that verifies permissive regex patterns like r'\d*' still
filter out letters when used with InputFormatterType.mask; call
InputFormatterType.mask.format with rule r'\d*' and a mask (e.g., '##/##/####'),
feed a TextEditingValue containing letters (e.g., '1a2345678') to
formatter.formatEditUpdate, and assert the resulting text has letters removed
and separators applied (e.g., '12/34/5678') and the selection is at the end; add
this as a new test case similar to the existing 'applies separators and filters
disallowed characters' test to lock in the anchored-matcher behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/widgets/text_form_field.mdx`:
- Around line 92-112: The example showing a formatter with type: "mask" is
invalid—STAC only supports inputFormatters with type values "allow" or "deny";
remove the mask-based example and replace it with an allow/deny example that
uses inputFormatters with type set to "allow" and a rule that matches digits
(e.g., use rule "[0-9]"), and remove the unsupported mask property; also add a
brief note under Input Formatters (near the inputFormatters, type, rule, and
mask descriptions) that complex masking (like date masks) is not supported by
STAC and requires custom Flutter input handling.

In `@packages/stac/lib/src/utils/input_formatters.dart`:
- Around line 29-31: The RegExp for allowed characters in
_StacMaskInputFormatter is built directly from rule and stored in _allowed, but
hasMatch(character) can succeed on empty-substring patterns (e.g. r'\d*');
change the construction of _allowed to anchor the pattern to full-character
matches by wrapping rule with ^ and $ (use '^' + (rule.isEmpty ? '.' : rule) +
'$') so hasMatch(character) only returns true when the entire character matches
the rule; update references in the constructor for _StacMaskInputFormatter and
ensure code that calls _allowed.hasMatch(character) continues to operate the
same way.

---

Outside diff comments:
In `@packages/stac/lib/src/parsers/foundation/text/stac_text_style_parser.dart`:
- Around line 67-88: The theme text style override is missing the decoration
field—add a nullable decoration property (type StacTextDecorationLine) to
StacThemeTextStyle in stac_text_style.dart, include it in the StacThemeTextStyle
constructor and class fields, update StacThemeTextStyle.copyWith to accept and
assign decoration, then modify the parser in stac_text_style_parser.dart (the
copyWith call on themeRef) to pass themeRef.decoration (parsed to the framework
TextDecoration via the existing parse helper) alongside
decorationColor/decorationStyle/decorationThickness, and finally regenerate the
JSON serialization code so the new field is persisted.

---

Nitpick comments:
In `@packages/stac/test/utils/input_formatters_test.dart`:
- Around line 6-26: Add a regression test that verifies permissive regex
patterns like r'\d*' still filter out letters when used with
InputFormatterType.mask; call InputFormatterType.mask.format with rule r'\d*'
and a mask (e.g., '##/##/####'), feed a TextEditingValue containing letters
(e.g., '1a2345678') to formatter.formatEditUpdate, and assert the resulting text
has letters removed and separators applied (e.g., '12/34/5678') and the
selection is at the end; add this as a new test case similar to the existing
'applies separators and filters disallowed characters' test to lock in the
anchored-matcher behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3caf727b-d8e5-4085-9d86-8a60b66f9d09

📥 Commits

Reviewing files that changed from the base of the PR and between c806ed6 and c5484cf.

📒 Files selected for processing (27)
  • docs/concepts/theming.mdx
  • docs/styles/text_style.mdx
  • docs/widgets/dropdown_menu.mdx
  • docs/widgets/icon_button.mdx
  • docs/widgets/text_field.mdx
  • docs/widgets/text_form_field.mdx
  • packages/stac/lib/src/parsers/foundation/decoration/stac_input_decoration_parser.dart
  • packages/stac/lib/src/parsers/foundation/forms/stac_input_formatter_type_parser.dart
  • packages/stac/lib/src/parsers/foundation/text/stac_text_decoration_line_parser.dart
  • packages/stac/lib/src/parsers/foundation/text/stac_text_style_parser.dart
  • packages/stac/lib/src/parsers/theme/stac_button_style_parser.dart
  • packages/stac/lib/src/parsers/theme/stac_floating_action_button_theme_data_parser.dart
  • packages/stac/lib/src/parsers/widgets/stac_dropdown_menu/stac_dropdown_menu_parser.dart
  • packages/stac/lib/src/parsers/widgets/stac_selectable_text/stac_selectable_text_parser.dart
  • packages/stac/lib/src/parsers/widgets/stac_text/stac_text_parser.dart
  • packages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field_parser.dart
  • packages/stac/lib/src/utils/input_formatters.dart
  • packages/stac/test/utils/input_formatters_test.dart
  • packages/stac_core/lib/foundation/decoration/stac_input_decoration/stac_input_decoration.dart
  • packages/stac_core/lib/foundation/decoration/stac_input_decoration/stac_input_decoration.g.dart
  • packages/stac_core/lib/foundation/forms/stac_input_formatter/stac_input_formatter.dart
  • packages/stac_core/lib/foundation/forms/stac_input_formatter/stac_input_formatter.g.dart
  • packages/stac_core/lib/foundation/text/stac_text_style/stac_text_style.dart
  • packages/stac_core/lib/foundation/text/stac_text_style/stac_text_style.g.dart
  • packages/stac_core/lib/foundation/text/stac_text_types.dart
  • packages/stac_core/lib/foundation/theme/stac_floating_action_button_theme_data/stac_floating_action_button_theme_data.dart
  • packages/stac_core/lib/foundation/theme/stac_floating_action_button_theme_data/stac_floating_action_button_theme_data.g.dart

Comment thread docs/widgets/text_form_field.mdx
Comment thread packages/stac/lib/src/utils/input_formatters.dart
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/stac/test/utils/input_formatters_test.dart (1)

17-18: ⚡ Quick win

Verify that the selection is collapsed, not just positioned at the end.

The test currently only checks baseOffset, but should also confirm the selection is collapsed (cursor with no range) rather than potentially spanning text.

✨ Suggested enhancement to verify collapsed selection
-      expect(value.text, '12/34/5678');
-      expect(value.selection.baseOffset, value.text.length);
+      expect(value.text, '12/34/5678');
+      expect(value.selection.isCollapsed, isTrue);
+      expect(value.selection.baseOffset, value.text.length);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/stac/test/utils/input_formatters_test.dart` around lines 17 - 18,
The test only verifies the cursor position by checking
value.selection.baseOffset but not that the selection is collapsed; update the
assertions for value (in the test using value.text and value.selection) to
assert that value.selection.isCollapsed is true and that both baseOffset and
extentOffset equal value.text.length (i.e., the cursor is collapsed at the end).
This uses the existing value.selection and value.text symbols to ensure the
selection is a single caret at the end rather than a range.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/stac/test/utils/input_formatters_test.dart`:
- Around line 17-18: The test only verifies the cursor position by checking
value.selection.baseOffset but not that the selection is collapsed; update the
assertions for value (in the test using value.text and value.selection) to
assert that value.selection.isCollapsed is true and that both baseOffset and
extentOffset equal value.text.length (i.e., the cursor is collapsed at the end).
This uses the existing value.selection and value.text symbols to ensure the
selection is a single caret at the end rather than a range.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6fe55b01-a71d-4ef0-bfe6-2453b4859a90

📥 Commits

Reviewing files that changed from the base of the PR and between c5484cf and 97a29d0.

📒 Files selected for processing (2)
  • packages/stac/lib/src/utils/input_formatters.dart
  • packages/stac/test/utils/input_formatters_test.dart
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/stac/lib/src/utils/input_formatters.dart

@divyanshub024 divyanshub024 merged commit 2907c6a into dev May 12, 2026
6 checks passed
@divyanshub024 divyanshub024 deleted the dv/stac-changes branch May 12, 2026 17:20
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