debugAssertCanHandle method

bool debugAssertCanHandle(
  1. Message message,
  2. Map<String, List<Attachment>> attachments
)

Asserts that this builder can handle the given message and attachments.

This is used to ensure that the defaultBuilders are used correctly.

Note: This method is only called in debug mode.

Implementation

bool debugAssertCanHandle(
  Message message,
  Map<String, List<Attachment>> attachments,
) {
  assert(() {
    if (!canHandle(message, attachments)) {
      throw FlutterError.fromParts(<DiagnosticsNode>[
        ErrorSummary(
          'A $runtimeType was used to build a attachment for a message, but '
          'it cant handle the message.',
        ),
        ErrorDescription(
          'The builders in the list must be checked in order. Check the '
          'documentation for $runtimeType for more details.',
        ),
      ]);
    }
    return true;
  }(), '');
  return true;
}