canCaptureScreen static method

bool canCaptureScreen(
  1. String screenName,
  2. String jsonString
)

Asks the native layer if it can capture the screen with the given screenName. jsonString.

This is done by looking up the AutoLayout configuration for the given screen name. If the screen is found, its 'ScreenChange' property is returned. If the screen is not found, the 'GlobalScreenSettings' is used as a fallback.

Returns false if the screen name is not found in the AutoLayout configuration.

Implementation

static bool canCaptureScreen(String screenName, String jsonString) {
  if (jsonString.isEmpty) {
    return false;
  }

  // Decode JSON
  final Map<String, dynamic> jsonConfig = jsonDecode(jsonString);

  if (jsonConfig.containsKey(screenName)) {
    captureScreen = jsonConfig[screenName]['ScreenChange'] ?? false;
    return captureScreen;
  } else if (jsonConfig.containsKey('GlobalScreenSettings')) {
    captureScreen =
        jsonConfig['GlobalScreenSettings']['ScreenChange'] ?? false;
    return captureScreen;
  }

  return false;
}