Skip to content

Commit

Permalink
Change ToString()
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrikvdkaaden committed May 29, 2024
1 parent 1be9afa commit ffcd220
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class TaskListCell extends StatelessWidget {
child: ListTile(
title: Text(task.message),
subtitle: Text('Status: ${task.statusTitle}'),
trailing: Text(task.timestamp.toString()),
trailing: Text(task.timestamp.format()),
),
confirmDismiss: (direction) async {
String? statusMessage;
Expand Down
10 changes: 7 additions & 3 deletions example/lib/timestamp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ class Timestamp {
@override
int get hashCode => createdAt.hashCode ^ updatedAt.hashCode;

@override
String toString() {
String format() {
final DateFormat formatter = DateFormat('yyyy-MM-dd');
final String formattedCreatedAt = formatter.format(createdAt);
final String formattedUpdatedAt = formatter.format(updatedAt);
return 'createdAt: $formattedCreatedAt \n updatedAt: $formattedUpdatedAt';
return 'Created at: $formattedCreatedAt \nUpdated at: $formattedUpdatedAt';
}

@override
String toString() {
return 'Timestamp(createdAt: $createdAt, updatedAt: $updatedAt)';
}
}

0 comments on commit ffcd220

Please sign in to comment.