l function

String l(
  1. BuildContext context,
  2. String key, [
  3. Map<String, Object>? namedParameters
])

Returns a localized string using the yaml file when L10n.lookup is called.

Specify the key set in the yaml file for key. If the key does not exist, it will return the key string.

By passing parameters to namedParameters, formatting compliant with MessageFormat is possible.

example:

yaml

example:
  title: Title

dart

l(context, 'example.title');

Implementation

String l(
  BuildContext context,
  String key, [
  Map<String, Object>? namedParameters,
]) =>
    Localizations.of<L10n>(context, L10n)?.lookup(
      key,
      namedParameters: namedParameters,
    ) ??
    key;