Skip to content

Instantly share code, notes, and snippets.

@RobertApikyan
Created November 23, 2023 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobertApikyan/16d5913df214830448e1ab58c40e6cda to your computer and use it in GitHub Desktop.
Save RobertApikyan/16d5913df214830448e1ab58c40e6cda to your computer and use it in GitHub Desktop.
class EventReport {
factory EventReport.fromMap(Map<String, dynamic> map) => EventReport(
legitimationStepType: map['legitimationStepType'] as String,
eventId: map['eventId'] as String,
timeStampInMillis: map['timeStampInMillis'] as int,
info: null,
);
EventReport(
{required this.legitimationStepType,
required this.eventId,
required this.timeStampInMillis,
this.info});
final String legitimationStepType;
final String eventId;
final int timeStampInMillis;
final Map<String, dynamic>? info;
Map<String, dynamic> toMap() => {
'legitimationStepType': this.legitimationStepType,
'eventId': this.eventId,
'timeStampInMillis': this.timeStampInMillis,
'info': '${[
for (final entity in info?.entries ?? {}.entries)
'\n${entity.key} : ${entity.value}'
].join(',')}',
};
@override
String toString() => 'legitimationStepType: $legitimationStepType,\n'
'eventId: $eventId,\n'
'timeStampInMillis: ${DateTime.fromMillisecondsSinceEpoch(timeStampInMillis)},\n'
'info: $info';
Map<String, dynamic> toJsonMap() => {
'legitimationStepType': this.legitimationStepType,
'eventId': this.eventId,
'timeStampInMillis': this.timeStampInMillis,
'info': this.info,
};
factory EventReport.fromJsonMap(dynamic map) => EventReport(
legitimationStepType: map['legitimationStepType'] as String,
eventId: map['eventId'] as String,
timeStampInMillis: map['timeStampInMillis'] as int,
info: map['info'] != null ? map['info'] as Map<String, dynamic> : null,
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment