TransactionEvent.fromMap constructor

TransactionEvent.fromMap(
  1. Map map
)

Implementation

factory TransactionEvent.fromMap(Map<dynamic, dynamic> map) {
  TransactionEventType eventType =
      TransactionEventType.transactionDidComplete;
  if (map['type'] != null) {
    try {
      eventType = TransactionEventType.values.firstWhere(
        (e) => e.name == map['type'],
        orElse: () => TransactionEventType.transactionDidComplete,
      );
    } catch (e) {
      // Use default
    }
  }

  return TransactionEvent(
    type: eventType,
    data: Map<String, dynamic>.from(map['data'] ?? {}),
  );
}