fromMap static method

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

Gets a possible NavigationAction instance from a Map value.

Implementation

static NavigationAction? fromMap(
  Map<String, dynamic>? map, {
  EnumMethod? enumMethod,
}) {
  if (map == null) {
    return null;
  }
  final instance = NavigationAction(
    androidHasGesture: map['hasGesture'],
    androidIsRedirect: map['isRedirect'],
    hasGesture: map['hasGesture'],
    iosSourceFrame: IOSWKFrameInfo.fromMap(
      map['sourceFrame']?.cast<String, dynamic>(),
      enumMethod: enumMethod,
    ),
    iosTargetFrame: IOSWKFrameInfo.fromMap(
      map['targetFrame']?.cast<String, dynamic>(),
      enumMethod: enumMethod,
    ),
    iosWKNavigationType: switch (enumMethod ?? EnumMethod.nativeValue) {
      EnumMethod.nativeValue => IOSWKNavigationType.fromNativeValue(
        map['navigationType'],
      ),
      EnumMethod.value => IOSWKNavigationType.fromValue(
        map['navigationType'],
      ),
      EnumMethod.name => IOSWKNavigationType.byName(map['navigationType']),
    },
    isForMainFrame: map['isForMainFrame'],
    isRedirect: map['isRedirect'],
    navigationType: switch (enumMethod ?? EnumMethod.nativeValue) {
      EnumMethod.nativeValue => NavigationType.fromNativeValue(
        map['navigationType'],
      ),
      EnumMethod.value => NavigationType.fromValue(map['navigationType']),
      EnumMethod.name => NavigationType.byName(map['navigationType']),
    },
    request: URLRequest.fromMap(
      map['request']?.cast<String, dynamic>(),
      enumMethod: enumMethod,
    )!,
    shouldPerformDownload: map['shouldPerformDownload'],
    sourceFrame: FrameInfo.fromMap(
      map['sourceFrame']?.cast<String, dynamic>(),
      enumMethod: enumMethod,
    ),
    targetFrame: FrameInfo.fromMap(
      map['targetFrame']?.cast<String, dynamic>(),
      enumMethod: enumMethod,
    ),
  );
  return instance;
}