fromMap static method

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

Gets a possible WebViewEnvironmentSettings instance from a Map value.

Implementation

static WebViewEnvironmentSettings? fromMap(
  Map<String, dynamic>? map, {
  EnumMethod? enumMethod,
}) {
  if (map == null) {
    return null;
  }
  final instance = WebViewEnvironmentSettings(
    additionalBrowserArguments: map['additionalBrowserArguments'],
    allowSingleSignOnUsingOSPrimaryAccount:
        map['allowSingleSignOnUsingOSPrimaryAccount'],
    areBrowserExtensionsEnabled: map['areBrowserExtensionsEnabled'],
    automationAllowed: map['automationAllowed'],
    browserExecutableFolder: map['browserExecutableFolder'],
    cacheModel: switch (enumMethod ?? EnumMethod.nativeValue) {
      EnumMethod.nativeValue => CacheModel.fromNativeValue(map['cacheModel']),
      EnumMethod.value => CacheModel.fromValue(map['cacheModel']),
      EnumMethod.name => CacheModel.byName(map['cacheModel']),
    },
    channelSearchKind: switch (enumMethod ?? EnumMethod.nativeValue) {
      EnumMethod.nativeValue => EnvironmentChannelSearchKind.fromNativeValue(
        map['channelSearchKind'],
      ),
      EnumMethod.value => EnvironmentChannelSearchKind.fromValue(
        map['channelSearchKind'],
      ),
      EnumMethod.name => EnvironmentChannelSearchKind.byName(
        map['channelSearchKind'],
      ),
    },
    customSchemeRegistrations: map['customSchemeRegistrations'] != null
        ? List<CustomSchemeRegistration>.from(
            map['customSchemeRegistrations'].map(
              (e) => CustomSchemeRegistration.fromMap(
                e?.cast<String, dynamic>(),
                enumMethod: enumMethod,
              )!,
            ),
          )
        : null,
    enableTrackingPrevention: map['enableTrackingPrevention'],
    exclusiveUserDataFolderAccess: map['exclusiveUserDataFolderAccess'],
    isCustomCrashReportingEnabled: map['isCustomCrashReportingEnabled'],
    language: map['language'],
    preferredLanguages: map['preferredLanguages'] != null
        ? List<String>.from(map['preferredLanguages']!.cast<String>())
        : null,
    releaseChannels: switch (enumMethod ?? EnumMethod.nativeValue) {
      EnumMethod.nativeValue => EnvironmentReleaseChannels.fromNativeValue(
        map['releaseChannels'],
      ),
      EnumMethod.value => EnvironmentReleaseChannels.fromValue(
        map['releaseChannels'],
      ),
      EnumMethod.name => EnvironmentReleaseChannels.byName(
        map['releaseChannels'],
      ),
    },
    sandboxPaths: map['sandboxPaths'] != null
        ? List<String>.from(map['sandboxPaths']!.cast<String>())
        : null,
    scrollbarStyle: switch (enumMethod ?? EnumMethod.nativeValue) {
      EnumMethod.nativeValue => EnvironmentScrollbarStyle.fromNativeValue(
        map['scrollbarStyle'],
      ),
      EnumMethod.value => EnvironmentScrollbarStyle.fromValue(
        map['scrollbarStyle'],
      ),
      EnumMethod.name => EnvironmentScrollbarStyle.byName(
        map['scrollbarStyle'],
      ),
    },
    spellCheckingEnabled: map['spellCheckingEnabled'],
    spellCheckingLanguages: map['spellCheckingLanguages'] != null
        ? List<String>.from(map['spellCheckingLanguages']!.cast<String>())
        : null,
    targetCompatibleBrowserVersion: map['targetCompatibleBrowserVersion'],
    timeZoneOverride: map['timeZoneOverride'],
    userDataFolder: map['userDataFolder'],
    webProcessExtensionsDirectory: map['webProcessExtensionsDirectory'],
  );
  return instance;
}