createBackgroundImages function

void createBackgroundImages({
  1. required String? backgroundImage,
  2. required String? darkBackgroundImage,
})

Implementation

void createBackgroundImages({
  required String? backgroundImage,
  required String? darkBackgroundImage,
}) {
  const backgroundDestination = _webSplashImagesFolder + 'light-background.png';
  if (backgroundImage == null) {
    final file = File(backgroundDestination);
    if (file.existsSync()) file.deleteSync();
  } else {
    // Copy will not work if the directory does not exist, so createSync
    // will ensure that the directory exists.
    File(backgroundDestination).createSync(recursive: true);
    File(backgroundImage).copySync(backgroundDestination);
  }

  const darkBackgroundDestination =
      _webSplashImagesFolder + 'dark-background.png';
  if (darkBackgroundImage == null) {
    final file = File(darkBackgroundDestination);
    if (file.existsSync()) file.deleteSync();
  } else {
    // Copy will not work if the directory does not exist, so createSync
    // will ensure that the directory exists.
    File(darkBackgroundDestination).createSync(recursive: true);
    File(darkBackgroundImage).copySync(darkBackgroundDestination);
  }
}