diff --git a/CHANGELOG.md b/CHANGELOG.md index 21a9d081..391eb31b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [UnReleased] + +* **Fix**: [276](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/276) link preview custom error message + ## [2.3.0] * **Breaking**: [257](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/257) update diff --git a/README.md b/README.md index e54eed85..701b3870 100644 --- a/README.md +++ b/README.md @@ -1011,6 +1011,20 @@ ChatView( ), ``` + +36. Use `errorBody` to displays an error message when the link cannot be parsed for preview. + + +```dart +ChatView( + ... + linkPreviewConfig: LinkPreviewConfiguration( + errorBody: 'Error encountered while parsing the link for preview' +), + ... +), +``` + ## How to use Check out [blog](https://medium.com/simform-engineering/chatview-a-cutting-edge-chat-ui-solution-7367b1f9d772) for better understanding and basic implementation. diff --git a/lib/src/models/config_models/link_preview_configuration.dart b/lib/src/models/config_models/link_preview_configuration.dart index 0715087f..042f74bc 100644 --- a/lib/src/models/config_models/link_preview_configuration.dart +++ b/lib/src/models/config_models/link_preview_configuration.dart @@ -50,6 +50,9 @@ class LinkPreviewConfiguration { /// Provides callback when message detect url in message. final StringCallback? onUrlDetect; + /// Displays an error message when the link cannot be parsed for preview. + final String? errorBody; + const LinkPreviewConfiguration({ this.onUrlDetect, this.loadingColor, @@ -60,5 +63,6 @@ class LinkPreviewConfiguration { this.linkStyle, this.padding, this.proxyUrl, + this.errorBody, }); } diff --git a/lib/src/widgets/link_preview.dart b/lib/src/widgets/link_preview.dart index d85c67a5..33f00118 100644 --- a/lib/src/widgets/link_preview.dart +++ b/lib/src/widgets/link_preview.dart @@ -64,6 +64,7 @@ class LinkPreview extends StatelessWidget { : AnyLinkPreview( link: url, removeElevation: true, + errorBody: linkPreviewConfig?.errorBody, proxyUrl: linkPreviewConfig?.proxyUrl, onTap: _onLinkTap, placeholderWidget: SizedBox(