printDescription method

String printDescription(
  1. String? description, [
  2. String indentation = '',
  3. bool firstInBlock = true
])

Implementation

String printDescription(
  String? description, [
  String indentation = '',
  // ignore: avoid_positional_boolean_parameters
  bool firstInBlock = true,
]) {
  if (description == null) {
    return '';
  }

  final preferMultipleLines = description.length > 70;
  final blockString = _printBlockString(
    description,
    preferMultipleLines: preferMultipleLines,
  );
  final prefix = indentation.isNotEmpty && !firstInBlock
      ? '\n' + indentation
      : indentation;

  return prefix +
      blockString.replaceAll(RegExp('\n'), '\n' + indentation) +
      '\n';
}