Skip to content

Commit

Permalink
🐛 add error message for link preview parse error #276
Browse files Browse the repository at this point in the history
  • Loading branch information
apurva780 committed Nov 16, 2024
1 parent 6c5cc2a commit 052c0ce
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions lib/src/models/config_models/link_preview_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -60,5 +63,6 @@ class LinkPreviewConfiguration {
this.linkStyle,
this.padding,
this.proxyUrl,
this.errorBody,
});
}
1 change: 1 addition & 0 deletions lib/src/widgets/link_preview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class LinkPreview extends StatelessWidget {
: AnyLinkPreview(
link: url,
removeElevation: true,
errorBody: linkPreviewConfig?.errorBody,
proxyUrl: linkPreviewConfig?.proxyUrl,
onTap: _onLinkTap,
placeholderWidget: SizedBox(
Expand Down

0 comments on commit 052c0ce

Please sign in to comment.