brick
brick copied to clipboard
fix(build): handle line breaks after class names in model dictionary …
- Fixes #662 where model dictionary builder fails when Flutter formatter breaks lines after long class names
- Replaces fragile string matching with robust regex pattern that handles whitespace including newlines
- Prevents build failures for projects with class names exceeding 80-character limit
The original code used entry.value.contains('class ${annotation.element.name} ') which expected a space after class names. When Flutter's formatter formatted long declarations like:
class VeryLongClassNameThatExceedsTheEightyCharacterLimit
extends SomeBaseClass {
The space was replaced with a newline, causing the match to fail and breaking the build with "No element" errors.
Changes:
- Updated packages/brick_build/lib/src/builders/model_dictionary_builder.dart:67
- Changed from string match to RegExp(r'class\s+${annotation.element.name}\s*')
- Now correctly handles spaces, tabs, and newlines after class names
Testing:
- Verified regex matches all class declaration formats (with/without line breaks)
- Tested with various whitespace combinations
- Maintains backward compatibility with existing code
❌ AGENTS.md is missing from repository root
- Create AGENTS.md file at the root of your repository
- AI-Generated Content Suggestions:
-
Project Overview & Purpose
What should AGENTS.md contain?
Document the "why" behind your codebase for AI assistants:
- Purpose: Why this repo exists and what problem it solves
- Architecture: Key design patterns and structure
- Tech Stack: Main technologies and why they were chosen
- Gotchas: Non-obvious constraints or issues
See examples for inspiration.