getDisplayString method

  1. @override
String getDisplayString({
  1. @Deprecated('Only non-nullable by default mode is supported') bool withNullability = true,
  2. bool multiline = false,
  3. bool preferTypeAlias = false,
})
inherited

Returns the presentation of this element as it should appear when presented to users.

If withNullability is true, then NullabilitySuffix.question and NullabilitySuffix.star in types will be represented as ? and *. NullabilitySuffix.none does not have any explicit presentation.

If withNullability is false, nullability suffixes will not be included into the presentation.

If multiline is true, the string may be wrapped over multiple lines with newlines to improve formatting. For example function signatures may be formatted as if they had trailing commas.

Clients should not depend on the content of the returned value as it will be changed if doing so would improve the UX.

Implementation

@override
String getDisplayString({
  @Deprecated('Only non-nullable by default mode is supported')
  bool withNullability = true,
  bool multiline = false,
  bool preferTypeAlias = false,
}) {
  var builder = ElementDisplayStringBuilder(
    multiline: multiline,
    preferTypeAlias: preferTypeAlias,
  );
  appendTo(builder);
  return builder.toString();
}