defaultBuilders static method

List<StreamAttachmentWidgetBuilder> defaultBuilders({
  1. required Message message,
  2. ShapeBorder? shape,
  3. EdgeInsetsGeometry padding = const EdgeInsets.all(4),
  4. StreamAttachmentWidgetTapCallback? onAttachmentTap,
})

The default list of builders used by the AttachmentWidgetCatalog.

This list contains the following builders in order:

You can use this list as a starting point for your own list of builders.

Example:

final myBuilders = [
 ...StreamAttachmentWidgetBuilder.defaultBuilders,
 MyCustomAttachmentBuilder(),
 MyOtherCustomAttachmentBuilder(),
 ...
];

Note: The order of the builders in the list is important. The first builder that returns true from canHandle will be used to build the widget.

Implementation

static List<StreamAttachmentWidgetBuilder> defaultBuilders({
  required Message message,
  ShapeBorder? shape,
  EdgeInsetsGeometry padding = const EdgeInsets.all(4),
  StreamAttachmentWidgetTapCallback? onAttachmentTap,
}) {
  return [
    // Handles a mix of image, gif, video, url and file attachments.
    MixedAttachmentBuilder(
      padding: padding,
      onAttachmentTap: onAttachmentTap,
    ),

    // Handles a mix of image, gif, and video attachments.
    GalleryAttachmentBuilder(
      shape: shape,
      padding: padding,
      runSpacing: padding.vertical / 2,
      spacing: padding.horizontal / 2,
      onAttachmentTap: onAttachmentTap,
    ),

    // Handles file attachments.
    FileAttachmentBuilder(
      shape: shape,
      padding: padding,
      onAttachmentTap: onAttachmentTap,
    ),

    // Handles giphy attachments.
    GiphyAttachmentBuilder(
      shape: shape,
      padding: padding,
      onAttachmentTap: onAttachmentTap,
    ),

    // Handles image attachments.
    ImageAttachmentBuilder(
      shape: shape,
      padding: padding,
      onAttachmentTap: onAttachmentTap,
    ),

    // Handles video attachments.
    VideoAttachmentBuilder(
      shape: shape,
      padding: padding,
      onAttachmentTap: onAttachmentTap,
    ),
    // We don't handle URL attachments if the message is a reply.
    if (message.quotedMessage == null)
      UrlAttachmentBuilder(
        shape: shape,
        padding: padding,
        onAttachmentTap: onAttachmentTap,
      ),

    // Fallback builder should always be the last builder in the list.
    const FallbackAttachmentBuilder(),
  ];
}