Conversation
WalkthroughThe changes update the Changes
Sequence Diagram(s)sequenceDiagram
participant BuildConfig as Build Config (build.yaml)
participant Builder as Freezed Builder
participant Generator as FreezedGenerator
participant Output as Generated Output
BuildConfig->>Builder: Load options { format: true }
Builder->>Generator: Instantiate with config & format option
Generator->>Generator: Check if formatting is enabled
alt Formatting Enabled
Generator->>Output: Emit "// dart format off"
Generator->>Output: Generate code
Generator->>Output: Emit "// dart format on"
else
Generator->>Output: Generate code normally
end
sequenceDiagram
participant Dev as Developer
participant Freezed as Freezed Processor
participant CodeGen as Code Generator
Dev->>Freezed: Declare sealed class with private union constructor
Freezed->>CodeGen: Process and validate private constructor feature
CodeGen-->>Freezed: Generate union class code with private constructor support
Freezed-->>Dev: Return enhanced union type implementation
Possibly related PRs
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/freezed/build.yaml (1)
13-14: Consider settingformat: falseby default.Given that the PR objective is to disable format, setting
format: trueby default might be counterintuitive. Consider setting it tofalseby default to align with the PR objective.- format: true + format: falsepackages/freezed/CHANGELOG.md (1)
159-159: Remove trailing punctuation from heading.The heading has a trailing punctuation mark which should be removed according to markdown guidelines.
-### Other changes: +### Other changes🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
159-159: Trailing punctuation in heading
Punctuation: ':'(MD026, no-trailing-punctuation)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (52)
packages/freezed/CHANGELOG.md(1 hunks)packages/freezed/build.yaml(1 hunks)packages/freezed/lib/builder.dart(1 hunks)packages/freezed/lib/src/ast.dart(5 hunks)packages/freezed/lib/src/freezed_generator.dart(4 hunks)packages/freezed/lib/src/models.dart(25 hunks)packages/freezed/lib/src/parse_generator.dart(1 hunks)packages/freezed/lib/src/string.dart(1 hunks)packages/freezed/lib/src/templates/abstract_template.dart(1 hunks)packages/freezed/lib/src/templates/concrete_template.dart(14 hunks)packages/freezed/lib/src/templates/copy_with.dart(8 hunks)packages/freezed/lib/src/templates/from_json_template.dart(3 hunks)packages/freezed/lib/src/templates/parameter_template.dart(10 hunks)packages/freezed/lib/src/templates/properties.dart(2 hunks)packages/freezed/lib/src/templates/prototypes.dart(1 hunks)packages/freezed/lib/src/tools/imports.dart(1 hunks)packages/freezed/lib/src/tools/recursive_import_locator.dart(5 hunks)packages/freezed/lib/src/tools/type.dart(2 hunks)packages/freezed/pubspec.yaml(1 hunks)packages/freezed/test/bidirectional_test.dart(4 hunks)packages/freezed/test/common.dart(1 hunks)packages/freezed/test/common_types_test.dart(9 hunks)packages/freezed/test/compiles_test.dart(1 hunks)packages/freezed/test/concrete_test.dart(1 hunks)packages/freezed/test/data_test.dart(1 hunks)packages/freezed/test/decorator_test.dart(2 hunks)packages/freezed/test/deep_copy_test.dart(12 hunks)packages/freezed/test/equal_test.dart(1 hunks)packages/freezed/test/generic_test.dart(4 hunks)packages/freezed/test/generics_refs_test.dart(2 hunks)packages/freezed/test/hashcode_test.dart(2 hunks)packages/freezed/test/implements_decorator_test.dart(3 hunks)packages/freezed/test/integration/bidirectional.dart(1 hunks)packages/freezed/test/integration/concrete.dart(1 hunks)packages/freezed/test/integration/custom_equals.dart(1 hunks)packages/freezed/test/integration/decorator.dart(1 hunks)packages/freezed/test/integration/deep_copy2.dart(1 hunks)packages/freezed/test/integration/generic.dart(1 hunks)packages/freezed/test/integration/json.dart(12 hunks)packages/freezed/test/integration/multiple_constructors.dart(2 hunks)packages/freezed/test/integration/single_class_constructor.dart(10 hunks)packages/freezed/test/json_test.dart(24 hunks)packages/freezed/test/manual_test.dart(1 hunks)packages/freezed/test/multiple_constructors_test.dart(7 hunks)packages/freezed/test/nullable_test.dart(2 hunks)packages/freezed/test/options_test.dart(2 hunks)packages/freezed/test/recursive_import_locator_test.dart(1 hunks)packages/freezed/test/single_class_constructor_test.dart(18 hunks)packages/freezed/test/source_gen_src.dart(4 hunks)packages/freezed/test/source_gen_test.dart(1 hunks)packages/freezed/test/special_class_name_test.dart(1 hunks)packages/freezed/test/typedef_parameter_test.dart(1 hunks)
✅ Files skipped from review due to trivial changes (43)
- packages/freezed/test/recursive_import_locator_test.dart
- packages/freezed/test/special_class_name_test.dart
- packages/freezed/lib/src/templates/from_json_template.dart
- packages/freezed/test/implements_decorator_test.dart
- packages/freezed/lib/src/tools/type.dart
- packages/freezed/lib/src/templates/prototypes.dart
- packages/freezed/test/generics_refs_test.dart
- packages/freezed/test/manual_test.dart
- packages/freezed/test/common_types_test.dart
- packages/freezed/lib/src/string.dart
- packages/freezed/test/nullable_test.dart
- packages/freezed/test/integration/custom_equals.dart
- packages/freezed/test/integration/deep_copy2.dart
- packages/freezed/test/generic_test.dart
- packages/freezed/lib/src/templates/properties.dart
- packages/freezed/test/integration/decorator.dart
- packages/freezed/lib/src/ast.dart
- packages/freezed/test/decorator_test.dart
- packages/freezed/lib/src/templates/abstract_template.dart
- packages/freezed/test/integration/multiple_constructors.dart
- packages/freezed/test/typedef_parameter_test.dart
- packages/freezed/lib/src/tools/imports.dart
- packages/freezed/test/concrete_test.dart
- packages/freezed/test/common.dart
- packages/freezed/test/equal_test.dart
- packages/freezed/test/compiles_test.dart
- packages/freezed/test/source_gen_src.dart
- packages/freezed/test/integration/bidirectional.dart
- packages/freezed/test/bidirectional_test.dart
- packages/freezed/test/multiple_constructors_test.dart
- packages/freezed/lib/src/tools/recursive_import_locator.dart
- packages/freezed/test/integration/generic.dart
- packages/freezed/test/single_class_constructor_test.dart
- packages/freezed/test/hashcode_test.dart
- packages/freezed/lib/src/templates/concrete_template.dart
- packages/freezed/test/integration/concrete.dart
- packages/freezed/lib/src/models.dart
- packages/freezed/test/json_test.dart
- packages/freezed/lib/src/templates/copy_with.dart
- packages/freezed/lib/src/templates/parameter_template.dart
- packages/freezed/test/integration/single_class_constructor.dart
- packages/freezed/test/integration/json.dart
- packages/freezed/test/deep_copy_test.dart
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
packages/freezed/CHANGELOG.md
159-159: Trailing punctuation in heading
Punctuation: ':'
(MD026, no-trailing-punctuation)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: freezed (packages/freezed, master, get)
🔇 Additional comments (18)
packages/freezed/pubspec.yaml (1)
10-10:Details
✅ Verification successful
Verify the need for Dart SDK 3.7.0.
The SDK version constraint has been updated to require Dart 3.7.0 or higher. Please verify if this version bump is necessary and document the specific features or requirements that necessitate this change.
🌐 Web query:
What are the new features in Dart 3.7.0 that might be relevant for the freezed package?💡 Result:
Dart 3.7.0 introduces several changes that could impact usage of the freezed package for code generation:
1. Formatter Style Changes
- A new formatting style now applies to codebases using language version ≥3.7[1][4]
- Freezed-generated code (like union types) will adopt:
- Improved indentation for factory constructors
- More consistent spacing around type parameters
- Requires developers to run
dart formatwith updated rules[1]2. Wildcard Pattern Support
- New
_wildcard syntax for pattern matching[8]:switch (myFreezedUnion) { case Success(:final data, _) => // Ignore secondary parameter // ... }
- Works seamlessly with Freezed's sealed classes/union types
3. JS Interop Migration
- Legacy JS interop libraries (
dart:js,package:js) deprecated[1]- Freezed models interacting with JS should migrate to:
import 'package:web/web.dart' as web; // New recommended approach4. Toolchain Updates
- Removed
--fixflag fromdart format[1]- Freezed users should replace:
dart format --fixwith:
dart fix --apply && dart formatCompatibility Notes
- Freezed v3.x fully supports Dart 3.x features like native sealed classes[2]
- Formatting changes are backward-compatible but may require CI/CD updates[4]
- Wildcard patterns work with existing Freezed models without modifications[8]
Developers should update analysis options to handle new formatting rules and consider migrating JS-dependent models to the new web interop package[1][4].
Citations:
- 1: https://dart.dev/resources/breaking-changes
- 2: https://pub.dev/packages/freezed
- 3: https://dart.dev/resources/whats-new
- 4: https://codewithandrea.com/articles/new-formatting-style-dart-3-7/
- 5: glideapps/quicktype#2034
- 6: https://docs.flutter.dev/release/release-notes/release-notes-3.7.0
- 7: https://pub.dev/packages/freezed/versions
- 8: https://github.com/dart-lang/sdk/blob/main/CHANGELOG.md
- 9: isar/isar#518
- 10: https://pub.dev/packages/webdev/versions/3.7.0/changelog
SDK Bump Rationale Verification for
packages/freezed/pubspec.yamlThe update to the SDK constraint
"sdk: ">=3.7.0 <4.0.0""appears justified based on Dart 3.7.0’s new features that directly impact thefreezedpackage. In particular:
- Enhanced Formatting Rules: Updated formatting for factory constructors and union types may require running
dart formatwith new rules.- Wildcard Pattern Support: New wildcard syntax improves pattern matching within freezed-generated sealed classes.
- JS Interop Changes: The deprecation of legacy JS interop libraries mandates migration, impacting models generated by freezed.
- Toolchain Updates: Adjustments such as replacing the removed
--fixflag ensure compatibility with the latest tooling.Please verify that these changes are in use or will be leveraged in your implementation and update any accompanying documentation to reflect these requirements.
packages/freezed/lib/src/parse_generator.dart (1)
22-27: LGTM!The reformatting improves readability while maintaining the same functionality.
packages/freezed/test/data_test.dart (1)
19-28: LGTM!The reformatting improves readability while maintaining the same test logic.
Also applies to: 30-40
packages/freezed/test/source_gen_test.dart (2)
8-11: LGTM!The reformatting improves readability without affecting functionality.
17-17: LGTM!The addition of
format: falsealigns with the new feature to disable formatting in generated files, as documented in the changelog.packages/freezed/test/options_test.dart (5)
11-11: LGTM!The reformatting improves readability without affecting functionality.
17-21: LGTM!The reformatting of the error result assignment improves readability.
27-36: LGTM!The reformatting of the
expectLatercall improves readability.
47-48: LGTM!The reformatting of test assertions improves readability.
55-64: LGTM!The reformatting of the
expectLatercall improves readability.packages/freezed/lib/builder.dart (1)
10-15: LGTM!The reformatting and addition of the
formatparameter improve readability and implement the new formatting control feature.packages/freezed/CHANGELOG.md (1)
161-173: LGTM!The changelog entries properly document:
- Breaking changes regarding
map/whenand class requirements- The new formatting control feature
- The new private constructor feature for unions
packages/freezed/lib/src/freezed_generator.dart (6)
22-22: LGTM!The addition of the required
formatparameter and its corresponding final field follows Dart's best practices.Also applies to: 25-25
32-34: LGTM!The reformatting improves readability without affecting functionality.
60-60: LGTM!The formatting control comments are correctly placed and conditionally added based on the
formatparameter.Also applies to: 80-80
83-83: LGTM!The method signature reformatting improves consistency without affecting functionality.
86-103: LGTM!The reformatting of the
commonCopyWithvariable assignment improves readability without affecting functionality.
118-135: LGTM!The reformatting of the
copyWithparameter assignment improves readability without affecting functionality.
Summary by CodeRabbit
New Features
Refactor/Style
Chores