Line data Source code
1 : /// Class that contains the facebook access token data 2 : class AccessToken { 3 : /// DateTime with the expires date of this token 4 : final DateTime? expires; 5 : 6 : /// DateTime with the last refresh date of this token 7 : final DateTime? lastRefresh; 8 : 9 : /// the facebook user id 10 : final String? userId; 11 : 12 : /// token provided by facebook to make api calls to the GRAPH API 13 : final String? token; 14 : 15 : // the facebook application Id 16 : final String? applicationId; 17 : 18 : final String? graphDomain; 19 : 20 : /// list of string with the rejected permission by the user 21 : final List<String>? declinedPermissions; 22 : 23 : /// list of string with the approved permission by the user 24 : final List<String>? grantedPermissions; 25 : 26 : // is `true` when the token is expired 27 : final bool? isExpired; 28 : 29 : /// constrcutor 30 1 : AccessToken({ 31 : this.declinedPermissions, 32 : this.grantedPermissions, 33 : this.userId, 34 : this.expires, 35 : this.lastRefresh, 36 : this.token, 37 : this.applicationId, 38 : this.graphDomain, 39 : this.isExpired, 40 : }); 41 : 42 : /// convert the data provided for the platform channel to one instance of AccessToken 43 : /// 44 : /// [json] data returned by the platform channel 45 1 : factory AccessToken.fromJson(Map<String, dynamic> json) { 46 1 : return AccessToken( 47 1 : userId: json['userId'], 48 1 : token: json['token'], 49 2 : expires: DateTime.fromMillisecondsSinceEpoch(json['expires']), 50 2 : lastRefresh: DateTime.fromMillisecondsSinceEpoch(json['lastRefresh']), 51 1 : applicationId: json['applicationId'], 52 1 : graphDomain: json['graphDomain'], 53 1 : isExpired: json['isExpired'], 54 1 : declinedPermissions: json['declinedPermissions'] != null 55 2 : ? List<String>.from(json['declinedPermissions']) 56 0 : : [], 57 1 : grantedPermissions: json['grantedPermissions'] != null 58 2 : ? List<String>.from(json['grantedPermissions']) 59 0 : : [], 60 : ); 61 : } 62 : 63 : /// convert this instance to one Map 64 2 : Map<String, dynamic> toJson() => { 65 1 : 'userId': userId, 66 1 : 'token': token, 67 2 : 'expires': expires?.toIso8601String(), 68 2 : 'lastRefresh': lastRefresh?.toIso8601String(), 69 1 : 'applicationId': applicationId, 70 1 : 'graphDomain': graphDomain, 71 1 : 'isExpired': isExpired, 72 1 : 'grantedPermissions': grantedPermissions, 73 1 : 'declinedPermissions': declinedPermissions, 74 : }; 75 : }