toString method

  1. @override
String toString()
override

A string representation of this object.

Some classes have a default textual representation, often paired with a static parse function (like int.parse). These classes will provide the textual representation as their string representation.

Other classes have no meaningful textual representation that a program will care about. Such classes will typically override toString to provide useful information when inspecting the object, mainly for debugging or logging.

Implementation

@override
String toString() {
  final allowedBuffer = StringBuffer();

  for (var i = 0; i < allowedGlobs.length; i++) {
    if (i > 0) {
      if (i == allowedGlobs.length - 1) {
        allowedBuffer.write(' or ');
      } else {
        allowedBuffer.write(', ');
      }
    }

    allowedBuffer.write(allowedGlobs[i]);
  }

  return 'InvalidInputException: $assetId\n'
      'For this package, only assets matching $allowedBuffer can be used as '
      'inputs. \n'
      'A package can mark a file as public by including it in its '
      '`additional_public_assets` in a build.yaml file.';
}