[英]What is the @macro annotation in Flutter and Dart documentation
当我阅读源代码时,我经常看到这样的东西(来自TextField ):
/// {@macro flutter.widgets.editableText.keyboardType}
final TextInputType keyboardType;
@macro
是什么意思?
我找到了答案,所以我将其作为自我回答问答发布在下面。
@macro
是一种插入一些在其他地方编写的dartdoc文档的方法。 这样您就没有必须维护的重复文档。
@macro
的字符串是模板的名称,其中包括您将插入的文档。 所以在TextField示例中:
/// {@macro flutter.widgets.editableText.keyboardType}
final TextInputType keyboardType;
模板名称是flutter.widgets.editableText.keyboardType
。 如果您转到EditableText的源代码,您将找到带有文档文本的模板:
/// {@template flutter.widgets.editableText.keyboardType}
/// The type of keyboard to use for editing the text.
///
/// Defaults to [TextInputType.text] if [maxLines] is one and
/// [TextInputType.multiline] otherwise.
/// {@endtemplate}
final TextInputType keyboardType;
注释@template
启动模板,后跟其名称。 @endtemplate
完成它。
当您查看EditableText.keyboardType
和TextField.keyboardType
的文档时,您会发现它们完全相同:
在dartdoc 文档中阅读更多内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.