Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 add error message for link preview parse error #276 #277

Merged
merged 2 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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