fromMap static method

InfospectLog fromMap(
  1. Map map
)

Creates an instance of the InfospectLog class from a Map representation.

Parameters:

  • map: A Map containing the key-value pairs representing the InfospectLog object.

Returns an instance of the InfospectLog class with the data populated from the provided Map.

Implementation

static InfospectLog fromMap(Map map) {
  return InfospectLog(
    message: map['message'] ?? '',
    level: DiagnosticLevel.values
            .firstWhereOrNull((element) => element.name == map['level']) ??
        DiagnosticLevel.info,
    timestamp: map['timestamp'] != null
        ? DateTime.fromMillisecondsSinceEpoch(
            int.tryParse(map['timestamp'].toString()) ?? 0)
        : null,
    error: map['error'] ?? '',
    stackTrace: map['stackTrace'] != null
        ? StackTrace.fromString(map['stackTrace'].toString())
        : null,
  );
}