writeAndRunSplash static method

Future<void> writeAndRunSplash({
  1. required RebrandConfig config,
  2. required String imagePath,
  3. String? darkImagePath,
  4. required String android12ImagePath,
  5. String? android12DarkImagePath,
})

Implementation

static Future<void> writeAndRunSplash({
  required RebrandConfig config,
  required String imagePath,
  String? darkImagePath,
  required String android12ImagePath,
  String? android12DarkImagePath,
}) async {
  final yamlFile = File('assets/rebrand/rebrand_splash.yaml');
  yamlFile.writeAsStringSync(
    buildSplashYaml(
      config,
      imagePath: imagePath,
      darkImagePath: darkImagePath,
      android12ImagePath: android12ImagePath,
      android12DarkImagePath: android12DarkImagePath,
    ),
  );

  print("   💦 Running flutter_native_splash...");
  final result = await Process.run('dart', [
    'run',
    'flutter_native_splash:create',
    '--path=assets/rebrand/rebrand_splash.yaml',
  ], runInShell: true);

  if (result.exitCode != 0) {
    throw "Failed to generate splash screen: ${result.stderr}";
  }
}