run method Null safety

  1. @override
Future<int> run()

Runs this command.

The return value is wrapped in a Future if necessary and returned by CommandRunner.runCommand.


Future<int> run() async {
  final args = argResults!;
  final config = l10nConfig;

  final target = args[_argFrom] as String;
  final baseLocale = args[_argLocale] as String? ?? config.baseLocaleForXml;

  try {
    switch (target) {
      case _sourceArb:
        return _exportArb(baseLocale);
      case _sourceJson:
        return _exportJson(baseLocale);
      case _sourceIos:
        return _exportIos(baseLocale);
        return error(1, message: 'Unknown target: $target');
  } on RunException catch (e) {
    return errorBy(e);
  } catch (e) {
    return error(2, message: 'Failed by: $e');