String message(String message_str, { String desc: '', Map<String, dynamic> examples: const {}, String locale, String name, List args, String meaning })

Use this for a message that will be translated for different locales. The expected usage is that this is inside an enclosing function that only returns the value of this call and provides a scope for the variables that will be substituted in the message.

The message_str is the string to be translated, which may be interpolated based on one or more variables. The name of the message must match the enclosing function name. For methods, it can also be className_methodName. So for a method hello in class Simple, the name can be either "hello" or "Simple_hello". The name must also be globally unique in the program, so the second form can make it easier to distinguish messages with the same name but in different classes.

The args repeats the arguments of the enclosing function, desc provides a description of usage, examples is a Map of examples for each interpolated variable. For example

  hello(yourName) => Intl.message(
    "Hello, $yourName",
    name: "hello",
    args: [yourName],
    desc: "Say hello",
    examples = const {"yourName": "Sparky"}.

The source code will be processed via the analyzer to extract out the message data, so only a subset of valid Dart code is accepted. In particular, everything must be literal and cannot refer to variables outside the scope of the enclosing function. The examples map must be a valid const literal map. Similarly, the desc argument must be a single, simple string. These two arguments will not be used at runtime but will be extracted from the source code and used as additional data for translators. For more information see the "Messages" section of the main package documentation (https://pub.dartlang.org/packages/intl).

The name and args arguments are required, and are used at runtime to look up the localized version and pass the appropriate arguments to it. We may in the future modify the code during compilation to make manually passing those arguments unnecessary.

Source Link to Crossdart

static String message(String message_str,
        {String desc: '',
        Map<String, dynamic> examples: const {},
        String locale,
        String name,
        List args,
        String meaning}) =>
    _message(message_str, locale, name, args, meaning);