fromMap static method

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

Gets a possible DownloadJobInfo instance from a Map value.

Implementation

static DownloadJobInfo? fromMap(
  Map<String, dynamic>? map, {
  EnumMethod? enumMethod,
}) {
  if (map == null) {
    return null;
  }
  final instance = DownloadJobInfo(
    error: map['error'],
    id: map['id'],
    progress: map['progress'],
    resultFilePath: map['resultFilePath'],
    resumeDataBase64: map['resumeDataBase64'],
    state: switch (enumMethod ?? EnumMethod.nativeValue) {
      EnumMethod.nativeValue => DownloadJobState.fromNativeValue(
        map['state'],
      ),
      EnumMethod.value => DownloadJobState.fromValue(map['state']),
      EnumMethod.name => DownloadJobState.byName(map['state']),
    },
    url: map['url'] != null ? WebUri(map['url']) : null,
  );
  return instance;
}