get method

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

Return the generator for this instance.

Implementation

@override
I18NGenerator 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? encoding =
      options?['encoding'] ?? argResults?['encoding'] as Object?;
  final Object? baseName =
      options?['base_name'] ?? argResults?['base-name'] as Object?;
  final Object? convert =
      options?['convert'] ?? argResults?['convert'] as Object?;
  final Object? onlyLanguageCode = options?['only_language_code'] ??
      argResults?['only-language-code'] as Object?;
  final Object? baseClassName = options?['base_class_name'] ??
      argResults?['base-class-name'] as Object?;
  final Object? enumClassName = options?['enum_class_name'] ??
      argResults?['enum-class-name'] as Object?;
  final Object? serialize =
      options?['serialize'] ?? argResults?['serialize'] as Object?;
  final Object? useFlutter =
      options?['use_flutter'] ?? argResults?['use-flutter'] as Object?;
  final Object? localizationsClassName =
      options?['localizations_class_name'] ??
          argResults?['localizations-class-name'] as Object?;
  final Object? delegateClassName = options?['delegate_class_name'] ??
      argResults?['delegate-class-name'] as Object?;
  final Object? delegateFallbackLocale =
      options?['delegate_fallback_locale'] ??
          argResults?['delegate-fallback-locale'] as Object?;
  final Object? $imports =
      options?['imports'] ?? argResults?['imports'] as Object?;
  final Iterable<String>? imports = $imports is String
      ? <String>[$imports]
      : $imports is Iterable<Object?>
          ? $imports.cast<String>()
          : null;

  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 DartI18NGenerator(
      importPath: importPath,
      exportPath: exportPath,
      exportEncoding: exportEncoding is String
          ? Encoding.getByName(exportEncoding)
          : null,
      encoding: encoding is String ? Encoding.getByName(encoding) : null,
      baseName: baseName is String && baseName.isNotEmpty
          ? baseName.normalize()
          : null,
      convert: convert is bool ? convert : null,
      onlyLanguageCode: onlyLanguageCode is bool ? onlyLanguageCode : null,
      baseClassName: baseClassName is String && baseClassName.isNotEmpty
          ? baseClassName.normalize()
          : null,
      enumClassName: enumClassName is String && enumClassName.isNotEmpty
          ? enumClassName.normalize()
          : null,
      serialize: serialize is bool ? serialize : null,
      useFlutter: useFlutter is bool ? useFlutter : null,
      localizationsClassName: localizationsClassName is String &&
              localizationsClassName.isNotEmpty
          ? localizationsClassName
          : null,
      delegateClassName:
          delegateClassName is String && delegateClassName.isNotEmpty
              ? delegateClassName
              : null,
      delegateFallbackLocale: delegateFallbackLocale is String &&
              delegateFallbackLocale.isNotEmpty
          ? delegateFallbackLocale
          : null,
      imports: imports == null ||
              imports.length == 1 && imports.single == null.toString()
          ? null
          : imports,
    );
  }
}