From 162a144d976c23b38228d00f61e0140b9738c043 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Fri, 20 Aug 2021 15:56:18 +0200 Subject: [PATCH] fix(docs): update `Adding custom attachment guide` with updated code --- .../guides/adding_custom_attachments.mdx | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/docusaurus/docs/Flutter/guides/adding_custom_attachments.mdx b/docusaurus/docs/Flutter/guides/adding_custom_attachments.mdx index fb1f7bbe..9fe7f6aa 100644 --- a/docusaurus/docs/Flutter/guides/adding_custom_attachments.mdx +++ b/docusaurus/docs/Flutter/guides/adding_custom_attachments.mdx @@ -146,21 +146,25 @@ Next, we build the Static Maps URL (Add your API key before using the code snipp } ``` -And then modify the MessageListView and tell it how to build a location attachment: +And then modify the `MessageListView` and tell it how to build a location attachment, using the `messageBuilder` property and copying the default message implementation overriding the `customAttachmentBuilders` property: ```dart MessageListView( - customAttachmentBuilders: { - 'location': (context, message, attachments) { - var attachmentWidget = Image.network( - _buildMapAttachment( - attachments[0].extraData['latitude'], - attachments[0].extraData['longitude'], - ), - ); + messageBuilder: (context, details, messages, defaultMessage) { + return defaultMessage.copyWith( + customAttachmentBuilders: { + 'location': (context, message, attachments) { + final attachmentWidget = Image.network( + _buildMapAttachment( + attachments[0].extraData['latitude'], + attachments[0].extraData['longitude'], + ), + ); - return wrapAttachmentWidget(context, attachmentWidget, null, true, BorderRadius.circular(8.0)); - } + return wrapAttachmentWidget(context, attachmentWidget, null, true, BorderRadius.circular(8.0)); + } + }, + ); }, ), ```