Skip to content

gen_l10n: Using DateTime produces error during code generation #82713

Description

@goderbauer

Using DataTime in an app_en.arb file produces an error during code generation.

Example app_en.arb that reproduces the error:

{
  "helloWorldOn": "Hello World on {date}",
  "@helloWorldOn": {
    "description": "A message with a date parameter",
    "placeholders": {
      "date": {
        "type": "DateTime",
        "format": "yMd"
      }
    }
  }
}

Error shown:

.dart_tool/flutter_gen/gen_l10n/app_localizations_en.dart:12:11: Error: 'intl.DateFormat' can't be used as a type because 'intl' doesn't refer to an import prefix.
    final intl.DateFormat dateDateFormat = intl.DateFormat.yMd(localeName);
          ^^^^^^^^^^^^^^^
.dart_tool/flutter_gen/gen_l10n/app_localizations_en.dart:12:44: Error: The getter 'intl' isn't defined for the class 'AppLocalizationsEn'.
 - 'AppLocalizationsEn' is from 'package:flutter_gen/gen_l10n/app_localizations_en.dart' ('.dart_tool/flutter_gen/gen_l10n/app_localizations_en.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'intl'.
    final intl.DateFormat dateDateFormat = intl.DateFormat.yMd(localeName);

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions