freezed_go_style 1.0.4
freezed_go_style: ^1.0.4 copied to clipboard
A Dart formatter that applies Go-style alignment to Freezed models, making your code more readable and consistent.
Freezed GoStyle Formatter 🎨 #
A Dart formatter that applies Go-style alignment to Freezed models, making your code more readable and consistent.
Features #
- ⚡ Go-style alignment - Beautiful column alignment for Freezed factory constructors
- 🎯 Multiple annotations support - Proper alignment of multiple annotations per field
- 🔄 Automatic formatting - Works seamlessly with
dart formatvia CLI or VS Code extension - ⚙️ Zero configuration - Just add
@FreezedGoStyle()annotation
Installation #
Add to your pubspec.yaml:
dev_dependencies:
freezed_go_style: ^1.0.4
Or install globally:
dart pub global activate freezed_go_style
Usage #
1. Add annotation to your Freezed models #
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:freezed_go_style/freezed_go_style.dart';
part 'user.freezed.dart';
part 'user.g.dart';
@FreezedGoStyle() // Add this annotation
@freezed
class User with _$User {
const factory User({
@JsonKey(name: 'id') @Default(0) int id,
@JsonKey(name: 'email') required String email,
@JsonKey(name: 'full_name') @Default('') String fullName,
@JsonKey(name: 'age') int? age,
@JsonKey(name: 'is_active') @Default(true) bool isActive,
@JsonKey(name: 'tags') @Default([]) List<String> tags,
@JsonKey(name: 'metadata') Map<String, dynamic>? metadata,
}) = _User;
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
}
2. Format your code #
CLI
# Format a single file
dart run freezed_go_style -f lib/models/user.dart
# Format entire directory
dart run freezed_go_style -d lib/models/
# Verbose output
dart run freezed_go_style -f lib/models/user.dart -v
VS Code / Cursor / Gravity Extension
Install the Freezed GoStyle Formatter extension:
- VS Code Marketplace: Install from Visual Studio Marketplace
- Open VSX Registry: Install from Open VSX (preferred for Cursor, Gravity, VSCodium)
How to use:
- Install the extension.
- Save your Dart file (Cmd+S / Ctrl+S) - formatting happens automatically if
@FreezedGoStyleis present! - Alternatively, use the command palette and run
Format with Freezed GoStyle.
The extension:
- Runs automatically after
dart formaton save - Only processes files with
@FreezedGoStyle()annotation - Works seamlessly with your existing workflow
How it works #
Before:
@freezed
class User with _$User {
const factory User({
@JsonKey(name: 'id') @Default(0) int id,
@JsonKey(name: 'email') required String email,
@JsonKey(name: 'full_name') @Default('') String fullName,
}) = _User;
}
After:
@FreezedGoStyle()
@freezed
class User with _$User {
const factory User({
@JsonKey(name: 'id') @Default(0) int id,
@JsonKey(name: 'email') required String email,
@JsonKey(name: 'full_name') @Default('') String fullName,
}) = _User;
}
Configuration #
No configuration needed! Just add the @FreezedGoStyle() annotation to classes you want to format.
Requirements #
- Dart SDK:
^3.10.4 - Works with
freezedandfreezed_annotation
Contributing #
Contributions are welcome! Please feel free to submit a Pull Request.
Support #
- 📖 Documentation: GitHub
- 🐛 Issues: Issues
- 📝 Changelog: CHANGELOG.md
Support the project #
If you find this package helpful, consider supporting its development:
License #
MIT License - see LICENSE file for details.
