Skip to content

Commit 8659c68

Browse files
apurva010apurva780
andauthored
🐛 add error message for link preview parse error #276 (#277)
Co-authored-by: Apurva Kanthraviya <apurvakanthraviya2001@gmail.com>
1 parent 863a7e8 commit 8659c68

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

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

68
## [2.3.0]
79

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,20 @@ ChatView(
10111011
),
10121012
```
10131013

1014+
1015+
36. Use `errorBody` to displays an error message when the link cannot be parsed for preview.
1016+
1017+
1018+
```dart
1019+
ChatView(
1020+
...
1021+
linkPreviewConfig: LinkPreviewConfiguration(
1022+
errorBody: 'Error encountered while parsing the link for preview'
1023+
),
1024+
...
1025+
),
1026+
```
1027+
10141028
## How to use
10151029

10161030
Check out [blog](https://medium.com/simform-engineering/chatview-a-cutting-edge-chat-ui-solution-7367b1f9d772) for better understanding and basic implementation.

lib/src/models/config_models/link_preview_configuration.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ class LinkPreviewConfiguration {
5050
/// Provides callback when message detect url in message.
5151
final StringCallback? onUrlDetect;
5252

53+
/// Displays an error message when the link cannot be parsed for preview.
54+
final String? errorBody;
55+
5356
const LinkPreviewConfiguration({
5457
this.onUrlDetect,
5558
this.loadingColor,
@@ -60,5 +63,6 @@ class LinkPreviewConfiguration {
6063
this.linkStyle,
6164
this.padding,
6265
this.proxyUrl,
66+
this.errorBody,
6367
});
6468
}

lib/src/widgets/link_preview.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class LinkPreview extends StatelessWidget {
6464
: AnyLinkPreview(
6565
link: url,
6666
removeElevation: true,
67+
errorBody: linkPreviewConfig?.errorBody,
6768
proxyUrl: linkPreviewConfig?.proxyUrl,
6869
onTap: _onLinkTap,
6970
placeholderWidget: SizedBox(

0 commit comments

Comments
 (0)