get method

  1. @override
AssetsGenerator get([
  1. Map<String, Object?>? options
])

Return the generator for this instance.

Implementation

@override
AssetsGenerator get([final Map<String, Object?>? options]) {
  final Object? importPath =
      options?['import_path'] ?? argResults?['import-path'] as Object?;
  final Object? exportPath =
      options?['export_path'] ?? argResults?['export-path'] as Object?;
  final Object? exportEncoding = options?['export_encoding'] ??
      argResults?['export-encoding'] as Object?;
  final Object? baseName =
      options?['base_name'] ?? argResults?['base-name'] as Object?;
  final Object? convert =
      options?['convert'] ?? argResults?['convert'] as Object?;
  if (importPath is! String || importPath.isEmpty) {
    throw const FormatException('The import path is not provided.');
  } else if (exportPath is! String || exportPath.isEmpty) {
    throw const FormatException('The export path is not provided.');
  } else {
    return DartAssetsGenerator(
      importPath: importPath,
      exportPath: exportPath,
      exportEncoding: exportEncoding is String
          ? Encoding.getByName(exportEncoding)
          : null,
      baseName: baseName is String && baseName.isNotEmpty ? baseName : null,
      convert: convert is bool ? convert : null,
    );
  }
}