fromMap static method

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

Gets a possible InAppBrowserSettings instance from a Map value.

Implementation

static InAppBrowserSettings? fromMap(
  Map<String, dynamic>? map, {
  EnumMethod? enumMethod,
}) {
  if (map == null) {
    return null;
  }
  final instance = InAppBrowserSettings(
    closeButtonCaption: map['closeButtonCaption'],
    closeButtonColor: map['closeButtonColor'] != null
        ? UtilColor.fromStringRepresentation(map['closeButtonColor'])
        : null,
    menuButtonColor: map['menuButtonColor'] != null
        ? UtilColor.fromStringRepresentation(map['menuButtonColor'])
        : null,
    toolbarBottomBackgroundColor: map['toolbarBottomBackgroundColor'] != null
        ? UtilColor.fromStringRepresentation(
            map['toolbarBottomBackgroundColor'],
          )
        : null,
    toolbarBottomTintColor: map['toolbarBottomTintColor'] != null
        ? UtilColor.fromStringRepresentation(map['toolbarBottomTintColor'])
        : null,
    toolbarTopBackgroundColor: map['toolbarTopBackgroundColor'] != null
        ? UtilColor.fromStringRepresentation(map['toolbarTopBackgroundColor'])
        : null,
    toolbarTopFixedTitle: map['toolbarTopFixedTitle'],
    toolbarTopTintColor: map['toolbarTopTintColor'] != null
        ? UtilColor.fromStringRepresentation(map['toolbarTopTintColor'])
        : null,
    windowFrame: InAppWebViewRect.fromMap(
      map['windowFrame']?.cast<String, dynamic>(),
      enumMethod: enumMethod,
    ),
    windowStyleMask: switch (enumMethod ?? EnumMethod.nativeValue) {
      EnumMethod.nativeValue => WindowStyleMask.fromNativeValue(
        map['windowStyleMask'],
      ),
      EnumMethod.value => WindowStyleMask.fromValue(map['windowStyleMask']),
      EnumMethod.name => WindowStyleMask.byName(map['windowStyleMask']),
    },
    windowTitlebarSeparatorStyle: switch (enumMethod ??
        EnumMethod.nativeValue) {
      EnumMethod.nativeValue => WindowTitlebarSeparatorStyle.fromNativeValue(
        map['windowTitlebarSeparatorStyle'],
      ),
      EnumMethod.value => WindowTitlebarSeparatorStyle.fromValue(
        map['windowTitlebarSeparatorStyle'],
      ),
      EnumMethod.name => WindowTitlebarSeparatorStyle.byName(
        map['windowTitlebarSeparatorStyle'],
      ),
    },
    windowType: switch (enumMethod ?? EnumMethod.nativeValue) {
      EnumMethod.nativeValue => WindowType.fromNativeValue(map['windowType']),
      EnumMethod.value => WindowType.fromValue(map['windowType']),
      EnumMethod.name => WindowType.byName(map['windowType']),
    },
  );
  instance.allowGoBackWithBackButton = map['allowGoBackWithBackButton'];
  instance.closeOnCannotGoBack = map['closeOnCannotGoBack'];
  instance.hidden = map['hidden'];
  instance.hideCloseButton = map['hideCloseButton'];
  instance.hideDefaultMenuItems = map['hideDefaultMenuItems'];
  instance.hideProgressBar = map['hideProgressBar'];
  instance.hideTitleBar = map['hideTitleBar'];
  instance.hideToolbarBottom = map['hideToolbarBottom'];
  instance.hideToolbarTop = map['hideToolbarTop'];
  instance.hideUrlBar = map['hideUrlBar'];
  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.shouldCloseOnBackButtonPressed =
      map['shouldCloseOnBackButtonPressed'];
  instance.toolbarBottomTranslucent = map['toolbarBottomTranslucent'];
  instance.toolbarTopBarTintColor = map['toolbarTopBarTintColor'] != null
      ? UtilColor.fromStringRepresentation(map['toolbarTopBarTintColor'])
      : null;
  instance.toolbarTopTranslucent = map['toolbarTopTranslucent'];
  instance.transitionStyle = switch (enumMethod ?? EnumMethod.nativeValue) {
    EnumMethod.nativeValue => ModalTransitionStyle.fromNativeValue(
      map['transitionStyle'],
    ),
    EnumMethod.value => ModalTransitionStyle.fromValue(
      map['transitionStyle'],
    ),
    EnumMethod.name => ModalTransitionStyle.byName(map['transitionStyle']),
  };
  instance.windowAlphaValue = map['windowAlphaValue'];
  return instance;
}