Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:todos_app_core/todos_app_core.dart';
- import 'package:meta/meta.dart';
- import 'package:equatable/equatable.dart';
- import 'package:todos_repository_core/todos_repository_core.dart';
- @immutable
- class Todo extends Equatable {
- final bool complete;
- final String id;
- final String note;
- final String task;
- Todo(this.task, {this.complete = false, String note = '', String id})
- : this.note = note ?? '',
- this.id = id ?? Uuid().generateV4(),
- super([complete, id, note, task]);
- Todo copyWith({bool complete, String id, String note, String task}) {
- return Todo(
- task ?? this.task,
- complete: complete ?? this.complete,
- id: id ?? this.id,
- note: note ?? this.note,
- );
- }
- @override
- String toString() {
- return 'Todo { complete: $complete, task: $task, note: $note, id: $id }';
- }
- TodoEntity toEntity() {
- return TodoEntity(task, id, note, complete);
- }
- static Todo fromEntity(TodoEntity entity) {
- return Todo(
- entity.task,
- complete: entity.complete ?? false,
- note: entity.note,
- id: entity.id ?? Uuid().generateV4(),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement