Created
March 20, 2025 17:18
-
-
Save fredgrott/5c9c73f036535e493f49d63a35cccdf0 to your computer and use it in GitHub Desktop.
person model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:json_annotation/json_annotation.dart'; | |
import 'package:equatable/equatable.dart'; | |
import 'package:uuid/uuid.dart'; | |
import 'data_id_mixin.dart'; | |
part 'person.g.dart'; | |
@immutable | |
@JsonSerializable() | |
class Person with DataIdMixin, EquatableMixin { | |
final String name; | |
Person({ id = Uuid().v4(), required this.name}); | |
factory Person.fromJson(Map<String, dynamic> json) => | |
_$PersonFromJson(json); | |
Map<String, dynamic> toJson() => _$PersonToJson(this); | |
Person copyWith({ | |
String name; | |
}) return Person( | |
name: name, | |
); | |
@override | |
List<Object> get props => [id, name]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment