Dart doc comment escape square brackets

Dart doc comment escape square brackets

Problem Description:

I have a simple enum with a doc comment wanting to display [] inside the comment:

/// Define the brackets used when displaying a `List` in a cell.
///
/// Supported bracket types are:
/// * parentheses: ()
/// * curly: {}
/// * square: []
enum ListBrackets {
  /// Use parentheses
  parentheses,
  /// Use curly brackets
  curly,
  /// Use square brackets
  square;
}

However all i get is:
Define the brackets used when displaying a List in a cell. Supported bracket types are: parentheses: () curly: {} square:

Any help is appreciated

Solution – 1

Escape the square brackets with a :

/// Define the brackets used when displaying a `List` in a cell.
///
/// Supported bracket types are:
/// * parentheses: ()
/// * curly: {}
/// * square: []
enum ListBrackets {
  /// Use parentheses
  parentheses,
  /// Use curly brackets
  curly,
  /// Use square brackets
  square;
}

(You could also only escape the first one: [] but I prefer to escape both!)

Rate this post
We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.
Accept
Reject