Skip to content

Commit

Permalink
docs: add nullable props example to README
Browse files Browse the repository at this point in the history
  • Loading branch information
felangel committed Oct 14, 2023
1 parent ad6e389 commit 183182d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,22 @@ class Person extends Equatable {
}
```

Equatable also supports nullable props:

```dart
import 'package:equatable/equatable.dart';
class Person extends Equatable {
const Person(this.name, [this.age]);
final String name;
final int? age;
@override
List<Object?> get props => [name, age];
}
```

### `toString` Implementation

Equatable can implement `toString` method including all the given props. If you want that behaviour for a specific `Equatable` object, just include the following:
Expand Down

0 comments on commit 183182d

Please sign in to comment.