How to document function parameters while commenting in Flutter?

Viewed 526

I would like to make some functions in Flutter, and to comment functions and parameters. I was doing it earlyer in C#, but don't know how to document parameters in Flutter. For example, I want to document function with parameter

  /// Returns a number from a string.
  int stringToInt(String textString) {
    return int.parse(textString);
    }

How to comment parameter textString, for example /// a String contains numbers.

Best regards, Darko

1 Answers

Flutter uses Dart's comments (link to documentation)

Documentation comments start with a triple slash ///, from the docs:

For historical reasons, dart doc supports two syntaxes of doc comments: /// (“C# style”) and /** ... / (“JavaDoc style”). We prefer /// because it’s more compact. /* and */ add two content-free lines to a multiline doc comment. The /// syntax is also easier to read in some situations, such as when a doc comment contains a bulleted list that uses * to mark list items.

If you want to refer to any method or variable you use square brackets [] (reference)

Dart does not use comments to explain parameters, exceptions, and such (reference)

Other languages use verbose tags and sections to describe what the parameters and returns of a method are. [...] The convention in Dart is to integrate that into the description of the method and highlight parameters using square brackets.

Read the complete documentation for all the other details and conventions.

Related