Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. import 'package:todos_app_core/todos_app_core.dart';
  2. import 'package:meta/meta.dart';
  3. import 'package:equatable/equatable.dart';
  4. import 'package:todos_repository_core/todos_repository_core.dart';
  5.  
  6. @immutable
  7. class Todo extends Equatable {
  8. final bool complete;
  9. final String id;
  10. final String note;
  11. final String task;
  12.  
  13. Todo(this.task, {this.complete = false, String note = '', String id})
  14. : this.note = note ?? '',
  15. this.id = id ?? Uuid().generateV4(),
  16. super([complete, id, note, task]);
  17.  
  18. Todo copyWith({bool complete, String id, String note, String task}) {
  19. return Todo(
  20. task ?? this.task,
  21. complete: complete ?? this.complete,
  22. id: id ?? this.id,
  23. note: note ?? this.note,
  24. );
  25. }
  26.  
  27. @override
  28. String toString() {
  29. return 'Todo { complete: $complete, task: $task, note: $note, id: $id }';
  30. }
  31.  
  32. TodoEntity toEntity() {
  33. return TodoEntity(task, id, note, complete);
  34. }
  35.  
  36. static Todo fromEntity(TodoEntity entity) {
  37. return Todo(
  38. entity.task,
  39. complete: entity.complete ?? false,
  40. note: entity.note,
  41. id: entity.id ?? Uuid().generateV4(),
  42. );
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement