這裏使用一個建議圖案Intl.message我已經隨處可見:爲什麼intl.Message需要封裝在封閉函數中?
final String learnMoreLabel = _learnMoreLabel; String get
_learnMoreLabel => Intl.message('Learn more',
name: 'HelpContentBase__learnMoreLabel',
desc: 'The label for a link or button which takes the user to the '
'Google Help Center to read more information on a topic.');
爲什麼我不能只是寫:
final String learnMoreLabel = Intl.message('Learn more',
name: 'HelpContentBase__learnMoreLabel',
desc: 'The label for a link or button which takes the user to the '
'Google Help Center to read more information on a topic.');
爲什麼它需要被包裹在吸氣?我在the docs中發現了這一點:
將此消息用於將被翻譯爲不同語言環境的消息。 預期的用法是它位於一個封閉函數中, 僅返回此調用的值,併爲將在消息中替換的 變量提供一個範圍。
但它不會說爲什麼。