cake_wallet/lib/twitter/twitter_user.dart

46 lines
1 KiB
Dart
Raw Normal View History

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,
this.tweets});
final String id;
final String username;
final String name;
final String description;
final List<Tweet>? tweets;
factory TwitterUser.fromJson(Map<String, dynamic> json) {
return TwitterUser(
id: json['data']['id'] as String,
username: json['data']['username'] as String,
name: json['data']['name'] as String,
description: json['data']['description'] as String? ?? '',
2023-02-13 22:23:57 +00:00
tweets: json['includes'] != null
? List.from(json['includes']['tweets'] as List)
.map((e) => Tweet.fromJson(e as Map<String, dynamic>))
.toList()
: null,
);
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
}
}