@@ -29,6 +29,7 @@ class LinkPreview extends StatefulWidget {
2929 required this .previewData,
3030 required this .text,
3131 this .textStyle,
32+ this .textWidget,
3233 required this .width,
3334 }) : super (key: key);
3435
@@ -84,6 +85,9 @@ class LinkPreview extends StatefulWidget {
8485 /// Style of the provided text
8586 final TextStyle ? textStyle;
8687
88+ /// Widget to display above the preview. If null, defaults to a linkified [text] .
89+ final Widget ? textWidget;
90+
8791 /// Width of the [LinkPreview] widget
8892 final double width;
8993
@@ -193,7 +197,7 @@ class _LinkPreviewState extends State<LinkPreview>
193197 );
194198 }
195199
196- Widget _bodyWidget (PreviewData data, String text, double width) {
200+ Widget _bodyWidget (PreviewData data, double width) {
197201 final _padding = widget.padding ??
198202 const EdgeInsets .only (
199203 bottom: 16 ,
@@ -266,7 +270,7 @@ class _LinkPreviewState extends State<LinkPreview>
266270 style: widget.headerStyle,
267271 ),
268272 ),
269- _linkify (),
273+ widget.textWidget ?? _linkify (),
270274 if (withPadding && child != null )
271275 shouldAnimate ? _animated (child) : child,
272276 ],
@@ -325,7 +329,7 @@ class _LinkPreviewState extends State<LinkPreview>
325329 );
326330 }
327331
328- Widget _minimizedBodyWidget (PreviewData data, String text ) {
332+ Widget _minimizedBodyWidget (PreviewData data) {
329333 return Column (
330334 crossAxisAlignment: CrossAxisAlignment .start,
331335 children: [
@@ -401,8 +405,8 @@ class _LinkPreviewState extends State<LinkPreview>
401405 return _containerWidget (
402406 animate: shouldAnimate,
403407 child: aspectRatio == 1
404- ? _minimizedBodyWidget (_previewData, widget.text )
405- : _bodyWidget (_previewData, widget.text, _width),
408+ ? _minimizedBodyWidget (_previewData)
409+ : _bodyWidget (_previewData, _width),
406410 withPadding: aspectRatio == 1 ,
407411 );
408412 } else {
0 commit comments