Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix example #1195

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/freezed/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,19 @@ part 'my_file.freezed.dart';

```

**CONSIDER** also importing `package:flutter/foundation.dart`.\
**CONSIDER** also importing `package:flutter/foundation.dart`.
The reason being, importing `foundation.dart` also imports classes to make an
object nicely readable in Flutter's devtool.\
object nicely readable in Flutter's devtool.
If you import `foundation.dart`, [Freezed] will automatically do it for you.
Do note that if you override `toString`,
then you will need to manually add `@With<DiagnosticableTreeMixin>()` to your factories.

## Creating a Model using Freezed

Freezed offers two ways of creating data-classes:

- [Primary constructors](#primary-constructors) ; where you define a constructor and Freezed generates the associated fields.
This is simulating the [Primary Constructor](https://github.com/dart-lang/language/issues/2364 using `factory`.
This is simulating the [Primary Constructor](https://github.com/dart-lang/language/issues/2364) using `factory`.
- [Classic classes](#classic-classes), where you write a normal Dart class and Freezed only handles `toString/==/copyWith`

### Primary constructors
Expand Down
2 changes: 2 additions & 0 deletions packages/freezed/example/lib/diagnosticable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ abstract class ConcreteExample<T> with _$ConcreteExample<T> {
@freezed
abstract class ToString with _$ToString {
ToString._();

@With<DiagnosticableTreeMixin>()
factory ToString() = _ToString;

@override
Expand Down