generateIconsFor function

void generateIconsFor({
  1. required Config config,
  2. required String? flavor,
  3. required String prefixPath,
  4. required FLILogger logger,
  5. required List<IconGenerator> platforms(
    1. IconGeneratorContext context
    ),
})

Generates Icon for given platforms

Implementation

void generateIconsFor({
  required Config config,
  required String? flavor,
  required String prefixPath,
  required FLILogger logger,
  required List<IconGenerator> Function(IconGeneratorContext context) platforms,
}) {
  try {
    final platformList = platforms(
      IconGeneratorContext(
        config: config,
        logger: logger,
        prefixPath: prefixPath,
        flavor: flavor,
      ),
    );
    if (platformList.isEmpty) {
      // ? maybe we can print help
      logger.info('No platform provided');
    }

    for (final platform in platformList) {
      final progress =
          logger.progress('Creating Icons for ${platform.platformName}');
      logger.verbose(
        'Validating platform requirements for ${platform.platformName}',
      );
      // in case a platform throws an exception it should not effect other platforms
      try {
        if (!platform.validateRequirements()) {
          logger.error(
            'Requirements failed for platform ${platform.platformName}. Skipped',
          );
          progress.cancel();
          continue;
        }
        platform.createIcons();
        progress.finish(message: 'done', showTiming: true);
      } catch (e, st) {
        progress.cancel();
        logger
          ..error(e.toString())
          ..verbose(st);
        continue;
      }
    }
  } catch (e, st) {
    // TODO(RatakondalaArun): better error handling
    // stacktrace should only print when verbose is turned on
    // else a normal help line
    logger
      ..error(e.toString())
      ..verbose(st);
    exit(1);
  }
}