Line data Source code
1 : import 'package:matrix/matrix_api_lite.dart';
2 :
3 : class CachedProfileInformation extends ProfileInformation {
4 : final bool outdated;
5 : final DateTime updated;
6 :
7 4 : CachedProfileInformation.fromProfile(
8 : ProfileInformation profile, {
9 : required this.outdated,
10 : required this.updated,
11 4 : }) : super(
12 4 : avatarUrl: profile.avatarUrl,
13 4 : displayname: profile.displayname,
14 : );
15 :
16 2 : factory CachedProfileInformation.fromJson(Map<String, Object?> json) =>
17 2 : CachedProfileInformation.fromProfile(
18 2 : ProfileInformation.fromJson(json),
19 2 : outdated: json['outdated'] as bool,
20 4 : updated: DateTime.fromMillisecondsSinceEpoch(json['updated'] as int),
21 : );
22 :
23 4 : @override
24 4 : Map<String, Object?> toJson() => {
25 4 : ...super.toJson(),
26 8 : 'outdated': outdated,
27 12 : 'updated': updated.millisecondsSinceEpoch,
28 : };
29 : }
|