fromMap static method

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

Gets a possible ChromeSafariBrowserSettings instance from a Map value.

Implementation

static ChromeSafariBrowserSettings? fromMap(
  Map<String, dynamic>? map, {
  EnumMethod? enumMethod,
}) {
  if (map == null) {
    return null;
  }
  final instance = ChromeSafariBrowserSettings(
    activityButton: ActivityButton.fromMap(
      map['activityButton']?.cast<String, dynamic>(),
      enumMethod: enumMethod,
    ),
    displayMode: _deserializeDisplayMode(
      map['displayMode'],
      enumMethod: enumMethod,
    ),
    eventAttribution: UIEventAttribution.fromMap(
      map['eventAttribution']?.cast<String, dynamic>(),
      enumMethod: enumMethod,
    ),
    exitAnimations: map['exitAnimations'] != null
        ? List<AndroidResource>.from(
            map['exitAnimations'].map(
              (e) => AndroidResource.fromMap(
                e?.cast<String, dynamic>(),
                enumMethod: enumMethod,
              )!,
            ),
          )
        : null,
    navigationBarColor: map['navigationBarColor'] != null
        ? UtilColor.fromStringRepresentation(map['navigationBarColor'])
        : null,
    navigationBarDividerColor: map['navigationBarDividerColor'] != null
        ? UtilColor.fromStringRepresentation(map['navigationBarDividerColor'])
        : null,
    packageName: map['packageName'],
    preferredBarTintColor: map['preferredBarTintColor'] != null
        ? UtilColor.fromStringRepresentation(map['preferredBarTintColor'])
        : null,
    preferredControlTintColor: map['preferredControlTintColor'] != null
        ? UtilColor.fromStringRepresentation(map['preferredControlTintColor'])
        : null,
    secondaryToolbarColor: map['secondaryToolbarColor'] != null
        ? UtilColor.fromStringRepresentation(map['secondaryToolbarColor'])
        : null,
    startAnimations: map['startAnimations'] != null
        ? List<AndroidResource>.from(
            map['startAnimations'].map(
              (e) => AndroidResource.fromMap(
                e?.cast<String, dynamic>(),
                enumMethod: enumMethod,
              )!,
            ),
          )
        : null,
    toolbarBackgroundColor: map['toolbarBackgroundColor'] != null
        ? UtilColor.fromStringRepresentation(map['toolbarBackgroundColor'])
        : null,
  );
  instance.additionalTrustedOrigins = map['additionalTrustedOrigins'] != null
      ? List<String>.from(map['additionalTrustedOrigins']!.cast<String>())
      : null;
  instance.alwaysUseBrowserUI = map['alwaysUseBrowserUI'];
  instance.barCollapsingEnabled = map['barCollapsingEnabled'];
  instance.dismissButtonStyle = switch (enumMethod ??
      EnumMethod.nativeValue) {
    EnumMethod.nativeValue => DismissButtonStyle.fromNativeValue(
      map['dismissButtonStyle'],
    ),
    EnumMethod.value => DismissButtonStyle.fromValue(
      map['dismissButtonStyle'],
    ),
    EnumMethod.name => DismissButtonStyle.byName(map['dismissButtonStyle']),
  };
  instance.enableUrlBarHiding = map['enableUrlBarHiding'];
  instance.entersReaderIfAvailable = map['entersReaderIfAvailable'];
  instance.instantAppsEnabled = map['instantAppsEnabled'];
  instance.isSingleInstance = map['isSingleInstance'];
  instance.isTrustedWebActivity = map['isTrustedWebActivity'];
  instance.keepAliveEnabled = map['keepAliveEnabled'];
  instance.noHistory = map['noHistory'];
  instance.presentationStyle = switch (enumMethod ?? EnumMethod.nativeValue) {
    EnumMethod.nativeValue => ModalPresentationStyle.fromNativeValue(
      map['presentationStyle'],
    ),
    EnumMethod.value => ModalPresentationStyle.fromValue(
      map['presentationStyle'],
    ),
    EnumMethod.name => ModalPresentationStyle.byName(
      map['presentationStyle'],
    ),
  };
  instance.screenOrientation = switch (enumMethod ?? EnumMethod.nativeValue) {
    EnumMethod.nativeValue =>
      TrustedWebActivityScreenOrientation.fromNativeValue(
        map['screenOrientation'],
      ),
    EnumMethod.value => TrustedWebActivityScreenOrientation.fromValue(
      map['screenOrientation'],
    ),
    EnumMethod.name => TrustedWebActivityScreenOrientation.byName(
      map['screenOrientation'],
    ),
  };
  instance.shareState = switch (enumMethod ?? EnumMethod.nativeValue) {
    EnumMethod.nativeValue => CustomTabsShareState.fromNativeValue(
      map['shareState'],
    ),
    EnumMethod.value => CustomTabsShareState.fromValue(map['shareState']),
    EnumMethod.name => CustomTabsShareState.byName(map['shareState']),
  };
  instance.showTitle = map['showTitle'];
  instance.transitionStyle = switch (enumMethod ?? EnumMethod.nativeValue) {
    EnumMethod.nativeValue => ModalTransitionStyle.fromNativeValue(
      map['transitionStyle'],
    ),
    EnumMethod.value => ModalTransitionStyle.fromValue(
      map['transitionStyle'],
    ),
    EnumMethod.name => ModalTransitionStyle.byName(map['transitionStyle']),
  };
  return instance;
}