get method
Return the generator for this instance.
Implementation
@override
IconsGenerator 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? fontExportPath = options?['font_export_path'] ??
argResults?['font-export-path'] as Object?;
final Object? exportEncoding = options?['export_encoding'] ??
argResults?['export-encoding'] as Object?;
final Object? encoding =
options?['encoding'] ?? argResults?['encoding'] as Object?;
final Object? baseName =
options?['base_name'] ?? argResults?['base-name'] as Object?;
final Object? fontFamily =
options?['font_family'] ?? argResults?['font-family'] as Object?;
final Object? baseCodePoint = options?['base_code_point'] ??
argResults?['base-code-point'] as Object?;
final Object? height =
options?['height'] ?? argResults?['height'] as Object?;
final Object? descent =
options?['descent'] ?? argResults?['descent'] as Object?;
final Object? normalize =
options?['normalize'] ?? argResults?['normalize'] as Object?;
Object? package = options?['package'] ?? argResults?['package'] as Object?;
final Object? convert =
options?['convert'] ?? argResults?['convert'] as Object?;
final Object? yarn = options?['yarn'] ?? argResults?['yarn'] as Object?;
final Object? force = options?['force'] ?? argResults?['force'] 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 if (fontExportPath is! String || fontExportPath.isEmpty) {
throw const FormatException('The font export path is not provided.');
} else {
if (package is String) {
final String packageExtension = extension(package);
if (<String>{'.json', '.yaml'}.contains(packageExtension)) {
final File packageFile = File(package);
if (packageFile.existsSync()) {
package = packageFile.readAsStringSync(
encoding: encoding is String && encoding.isNotEmpty
? Encoding.getByName(encoding) ?? utf8
: utf8,
);
package = packageExtension == '.json'
? json.decode(package)
: loadYaml(package);
}
}
}
return DartIconsGenerator(
importPath: importPath,
exportPath: exportPath,
fontExportPath: fontExportPath,
exportEncoding: exportEncoding is String
? Encoding.getByName(exportEncoding)
: null,
encoding: encoding is String && encoding.isNotEmpty
? Encoding.getByName(encoding)
: null,
baseName: baseName is String && baseName.isNotEmpty
? baseName.normalize()
: null,
fontFamily: fontFamily is String && fontFamily.isNotEmpty
? fontFamily.normalize()
: null,
baseCodePoint: baseCodePoint is int ? baseCodePoint : null,
height: height is int ? height : null,
descent: descent is int ? descent : null,
normalize: normalize is bool ? normalize : null,
package: package is Map<Object?, Object?> && package.isNotEmpty
? package.cast<String, Object?>().normalize()
: package is MapMixin<Object?, Object?> && package.isNotEmpty
? package.cast<String, Object?>().normalize()
: null,
convert: convert is bool ? convert : null,
yarn: yarn is bool ? yarn : null,
force: force is bool ? force : null,
);
}
}