如何在 Android Studio 中为 dart 函数自动生成 header 注释?

How to automatically generate header comments for dart functions in Android Studio?

因为我们可以通过在 Android Studio for Kotlin / Java 函数中键入 /** + Enter 来添加 header 注释。 dart of flutter 有没有生成评论的快捷方式或插件?

不幸的是,Dart 不遵循与 Java/Kotlin 相同的约定。

关于 documentation 的 Effective Dart 指南指出:

The convention in Dart is to integrate that into the description of the method and highlight parameters using square brackets.

其中单词 that 指的是 "...verbose tags and sections to describe what the parameters and returns of a method are"。文档应以散文形式编写。

所以这个 Java 方法文档:

/// Defines a flag with the given name and abbreviation.
///
/// @param name The name of the flag.
/// @param abbr The abbreviation for the flag.
/// @returns The new flag.
/// @throws ArgumentError If there is already an option with
///     the given name or abbreviation.
Flag addFlag(String name, String abbr) => ...

相当于 Dart 中的这个:

/// Defines a flag.
///
/// Throws an [ArgumentError] if there is already an option named [name] or
/// there is already an option using abbreviation [abbr]. Returns the new flag.
Flag addFlag(String name, String abbr) => ...

要使用 Dart Documentation Comments,请键入 /// 并按 Enter