fromMap static method

PrintJobInfo? fromMap(
  1. Map<String, dynamic>? map, {
  2. EnumMethod? enumMethod,
})

Gets a possible PrintJobInfo instance from a Map value.

Implementation

static PrintJobInfo? fromMap(
  Map<String, dynamic>? map, {
  EnumMethod? enumMethod,
}) {
  if (map == null) {
    return null;
  }
  final instance = PrintJobInfo(
    attributes: PrintJobAttributes.fromMap(
      map['attributes']?.cast<String, dynamic>(),
      enumMethod: enumMethod,
    ),
    canSpawnSeparateThread: map['canSpawnSeparateThread'],
    copies: map['copies'],
    creationTime: map['creationTime'],
    currentPage: map['currentPage'],
    firstPage: map['firstPage'],
    isCopyingOperation: map['isCopyingOperation'],
    label: map['label'],
    lastPage: map['lastPage'],
    numberOfPages: map['numberOfPages'],
    pageOrder: switch (enumMethod ?? EnumMethod.nativeValue) {
      EnumMethod.nativeValue => PrintJobPageOrder.fromNativeValue(
        map['pageOrder'],
      ),
      EnumMethod.value => PrintJobPageOrder.fromValue(map['pageOrder']),
      EnumMethod.name => PrintJobPageOrder.byName(map['pageOrder']),
    },
    preferredRenderingQuality: switch (enumMethod ?? EnumMethod.nativeValue) {
      EnumMethod.nativeValue => PrintJobRenderingQuality.fromNativeValue(
        map['preferredRenderingQuality'],
      ),
      EnumMethod.value => PrintJobRenderingQuality.fromValue(
        map['preferredRenderingQuality'],
      ),
      EnumMethod.name => PrintJobRenderingQuality.byName(
        map['preferredRenderingQuality'],
      ),
    },
    printer: Printer.fromMap(
      map['printer']?.cast<String, dynamic>(),
      enumMethod: enumMethod,
    ),
    showsPrintPanel: map['showsPrintPanel'],
    showsProgressPanel: map['showsProgressPanel'],
    state: switch (enumMethod ?? EnumMethod.nativeValue) {
      EnumMethod.nativeValue => PrintJobState.fromNativeValue(map['state']),
      EnumMethod.value => PrintJobState.fromValue(map['state']),
      EnumMethod.name => PrintJobState.byName(map['state']),
    },
  );
  return instance;
}