build method
Widget
build(
- BuildContext context,
- Message message,
- Map<
String, List< attachmentsAttachment> >
override
Builds a widget for the given message
and attachments
.
This will only be called if canHandle returns true
.
Implementation
@override
Widget build(
BuildContext context,
Message message,
Map<String, List<Attachment>> attachments,
) {
assert(debugAssertCanHandle(message, attachments), '');
final galleryAttachments = [...attachments.values.expand((it) => it)];
return Padding(
padding: padding,
child: StreamGalleryAttachment(
shape: shape,
message: message,
spacing: spacing,
runSpacing: runSpacing,
constraints: constraints,
attachments: galleryAttachments,
itemBuilder: (context, index) {
final attachment = galleryAttachments[index];
VoidCallback? onTap;
if (onAttachmentTap != null) {
onTap = () => onAttachmentTap!(message, attachment);
}
return InkWell(
onTap: onTap,
child: Stack(
children: [
StreamMediaAttachmentThumbnail(
media: attachment,
width: constraints.maxWidth,
height: constraints.maxHeight,
fit: BoxFit.cover,
),
Padding(
padding: const EdgeInsets.all(8),
child: StreamAttachmentUploadStateBuilder(
message: message,
attachment: attachment,
),
),
],
),
);
},
),
);
}