2023-01-24 18:24:46 +00:00
|
|
|
class TwitterUser {
|
2023-02-13 22:23:57 +00:00
|
|
|
TwitterUser(
|
|
|
|
{required this.id,
|
|
|
|
required this.username,
|
|
|
|
required this.name,
|
|
|
|
required this.description,
|
2024-03-01 19:38:48 +00:00
|
|
|
required this.profileImageUrl,
|
2023-10-17 18:55:54 +00:00
|
|
|
this.pinnedTweet});
|
2023-02-13 22:23:57 +00:00
|
|
|
|
|
|
|
final String id;
|
|
|
|
final String username;
|
|
|
|
final String name;
|
|
|
|
final String description;
|
2024-03-01 19:38:48 +00:00
|
|
|
final String profileImageUrl;
|
2023-10-17 18:55:54 +00:00
|
|
|
final Tweet? pinnedTweet;
|
2023-02-13 22:23:57 +00:00
|
|
|
|
2023-10-17 18:55:54 +00:00
|
|
|
factory TwitterUser.fromJson(Map<String, dynamic> json, [Tweet? pinnedTweet]) {
|
2024-03-01 19:38:48 +00:00
|
|
|
final profileImageUrl = json['data']['profile_image_url'] as String? ?? '';
|
|
|
|
final scaledProfileImageUrl = profileImageUrl.replaceFirst('normal', '200x200');
|
2023-02-13 22:23:57 +00:00
|
|
|
return TwitterUser(
|
|
|
|
id: json['data']['id'] as String,
|
2024-03-01 19:38:48 +00:00
|
|
|
username: json['data']['username'] as String? ?? '',
|
2023-02-13 22:23:57 +00:00
|
|
|
name: json['data']['name'] as String,
|
2023-02-14 13:17:28 +00:00
|
|
|
description: json['data']['description'] as String? ?? '',
|
2024-03-01 19:38:48 +00:00
|
|
|
profileImageUrl: scaledProfileImageUrl,
|
2023-10-17 18:55:54 +00:00
|
|
|
pinnedTweet: pinnedTweet,
|
2023-02-13 22:23:57 +00:00
|
|
|
);
|
2023-02-12 22:38:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-13 22:23:57 +00:00
|
|
|
class Tweet {
|
|
|
|
Tweet({
|
2023-02-12 22:38:12 +00:00
|
|
|
required this.id,
|
|
|
|
required this.text,
|
|
|
|
});
|
|
|
|
|
2023-02-13 22:23:57 +00:00
|
|
|
final String id;
|
|
|
|
final String text;
|
2023-02-12 22:38:12 +00:00
|
|
|
|
2023-02-13 22:23:57 +00:00
|
|
|
factory Tweet.fromJson(Map<String, dynamic> json) {
|
|
|
|
return Tweet(
|
|
|
|
id: json['id'] as String,
|
|
|
|
text: json['text'] as String,
|
|
|
|
);
|
2023-01-24 18:24:46 +00:00
|
|
|
}
|
|
|
|
}
|