Skip to content

Commit 6c141e7

Browse files
committed
🐛 add error message for link preview parse error #276
1 parent 6c5cc2a commit 6c141e7

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [UnReleased]
2+
3+
* **Fix**: [276](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/276) link preview custom error message
4+
15
## [2.3.0]
26

37
* **Breaking**: [257](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/257) update

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)