Update Stac parsers and core models#475
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds 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. ChangesText Decoration, Input Formatting, and Theme Enhancements
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
There was a problem hiding this comment.
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 winMissing
decorationfield in theme text style override.The
StacThemeTextStyle.copyWithcall includesdecorationColor,decorationStyle, anddecorationThicknessbut omits the newdecorationfield. 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
decorationfield toStacThemeTextStyleinpackages/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
copyWithmethod 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 winAdd 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
📒 Files selected for processing (27)
docs/concepts/theming.mdxdocs/styles/text_style.mdxdocs/widgets/dropdown_menu.mdxdocs/widgets/icon_button.mdxdocs/widgets/text_field.mdxdocs/widgets/text_form_field.mdxpackages/stac/lib/src/parsers/foundation/decoration/stac_input_decoration_parser.dartpackages/stac/lib/src/parsers/foundation/forms/stac_input_formatter_type_parser.dartpackages/stac/lib/src/parsers/foundation/text/stac_text_decoration_line_parser.dartpackages/stac/lib/src/parsers/foundation/text/stac_text_style_parser.dartpackages/stac/lib/src/parsers/theme/stac_button_style_parser.dartpackages/stac/lib/src/parsers/theme/stac_floating_action_button_theme_data_parser.dartpackages/stac/lib/src/parsers/widgets/stac_dropdown_menu/stac_dropdown_menu_parser.dartpackages/stac/lib/src/parsers/widgets/stac_selectable_text/stac_selectable_text_parser.dartpackages/stac/lib/src/parsers/widgets/stac_text/stac_text_parser.dartpackages/stac/lib/src/parsers/widgets/stac_text_form_field/stac_text_form_field_parser.dartpackages/stac/lib/src/utils/input_formatters.dartpackages/stac/test/utils/input_formatters_test.dartpackages/stac_core/lib/foundation/decoration/stac_input_decoration/stac_input_decoration.dartpackages/stac_core/lib/foundation/decoration/stac_input_decoration/stac_input_decoration.g.dartpackages/stac_core/lib/foundation/forms/stac_input_formatter/stac_input_formatter.dartpackages/stac_core/lib/foundation/forms/stac_input_formatter/stac_input_formatter.g.dartpackages/stac_core/lib/foundation/text/stac_text_style/stac_text_style.dartpackages/stac_core/lib/foundation/text/stac_text_style/stac_text_style.g.dartpackages/stac_core/lib/foundation/text/stac_text_types.dartpackages/stac_core/lib/foundation/theme/stac_floating_action_button_theme_data/stac_floating_action_button_theme_data.dartpackages/stac_core/lib/foundation/theme/stac_floating_action_button_theme_data/stac_floating_action_button_theme_data.g.dart
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/stac/test/utils/input_formatters_test.dart (1)
17-18: ⚡ Quick winVerify 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
📒 Files selected for processing (2)
packages/stac/lib/src/utils/input_formatters.dartpackages/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
Description
Updates Stac parser and core model support for additional Flutter configuration surface area in
stacandstac_core, with matching documentation updates.Changes
StacInputFormatterType.maskandmasksupport for structured input formatting.TextFormFieldandDropdownMenuparsers.floatingLabelBehaviorsupport toStacInputDecoration.StacTextDecorationLineand custom text style decoration parsing.shapeandsizeConstraintssupport.shapeparsing for icon button styles.StacTextFormField.Documentation
TextFormFieldandDropdownMenudocs for input formatters and masks.TextFielddocs forfloatingLabelBehavioron input decorations.Text Styledocs forStacTextDecorationLinevalues.IconButtondocs forstyle.shape.Related Issues
None.
Type of Change
Validation
flutter test test/utils/input_formatters_test.dartfrompackages/stacdart analyzefrompackages/stacdart analyzefrompackages/stac_coreSummary by CodeRabbit
New Features
Bug Fixes
Tests