Skip to content

Commit

Permalink
🐛 add error message for link preview parse error #276 (#277)
Browse files Browse the repository at this point in the history
Co-authored-by: Apurva Kanthraviya <apurvakanthraviya2001@gmail.com>
  • Loading branch information
apurva010 and apurva780 authored Dec 8, 2024
1 parent 863a7e8 commit 8659c68
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* **Fix**: [282](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/282) Upgrade
version of audio wave forms 1.2.0
* **Fix**: [276](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/276) link preview
custom error message

## [2.3.0]

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 8659c68

Please sign in to comment.