-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy patharticle.dart
More file actions
35 lines (29 loc) · 845 Bytes
/
article.dart
File metadata and controls
35 lines (29 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/// A simple Article class with a title and content.
class Article {
final String title;
final String content;
Article({
required this.title,
required this.content,
});
/// Creates a copy of this article with the given fields replaced with the new values.
Article copyWith({
String? title,
String? content,
}) {
return Article(
title: title ?? this.title,
content: content ?? this.content,
);
}
@override
String toString() => 'Article(title: $title, content: $content)';
/// Compares two articles based on their titles and contents.
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is Article && other.title == title && other.content == content;
}
@override
int get hashCode => title.hashCode ^ content.hashCode;
}