Details

Language / Topic
dartDart
Category
Libraries

Rules

balanced

Freezed

- Annotate classes with `@freezed` and use `factory` constructors for immutable data classes. Run `build_runner` after changes: `dart run build_runner build`. Use `.copyWith()` for creating modified copies of frozen objects.

Freezed

- Annotate classes with `@freezed` and use `factory` constructors for immutable data classes. Run `build_runner` after changes: `dart run build_runner build`. Use `.copyWith()` for creating modified copies of frozen objects.
- Use `@Default(value)` for default values and `@JsonKey` for JSON serialization customization. Use union types with multiple factory constructors for sealed classes: `factory State.loading()`, `factory State.data(List items)`. Pattern match with `.when()` and `.map()` methods on unions. Combine with `json_serializable` by adding `@JsonSerializable` config.