LinkPreview class

A widget that renders text with highlighted links. Eventually unwraps to the full preview of the first found link if the parsing was successful.

Inheritance
Annotations

Constructors

LinkPreview({Key? key, Duration? animationDuration, String? corsProxy, bool? enableAnimation = false, String? header, TextStyle? headerStyle, bool? hideImage, Widget imageBuilder(String)?, TextStyle? linkStyle, TextStyle? metadataTextStyle, TextStyle? metadataTitleStyle, void onLinkPressed(String)?, required void onPreviewDataFetched(PreviewData), bool openOnPreviewImageTap = false, bool openOnPreviewTitleTap = false, EdgeInsets? padding, Widget previewBuilder(BuildContext, PreviewData)?, required PreviewData? previewData, Duration? requestTimeout, required String text, TextStyle? textStyle, Widget? textWidget, String? userAgent, required double width})
Creates LinkPreview.
const

Properties

animationDuration Duration?
Expand animation duration.
final
corsProxy String?
CORS proxy to make more previews work on web. Not tested.
final
enableAnimation bool?
Enables expand animation. Default value is false.
final
hashCode int
The hash code for this object.
no setterinherited
Custom header above provided text.
final
headerStyle TextStyle?
Style of the custom header.
final
hideImage bool?
Hides image data from the preview.
final
imageBuilder Widget Function(String)?
Function that allows you to build a custom image.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
linkStyle TextStyle?
Style of highlighted links in the text.
final
metadataTextStyle TextStyle?
Style of preview's description.
final
metadataTitleStyle TextStyle?
Style of preview's title.
final
onLinkPressed → void Function(String)?
Custom link press handler.
final
onPreviewDataFetched → void Function(PreviewData)
Callback which is called when PreviewData was successfully parsed. Use it to save PreviewData to the state and pass it back to the LinkPreview.previewData so the LinkPreview would not fetch preview data again.
final
openOnPreviewImageTap bool
Open the link when the link preview image is tapped. Defaults to false.
final
openOnPreviewTitleTap bool
Open the link when the link preview title/description is tapped. Defaults to false.
final
padding EdgeInsets?
Padding around initial text widget.
final
previewBuilder Widget Function(BuildContext, PreviewData)?
Function that allows you to build a custom link preview.
final
previewData PreviewData?
Pass saved PreviewData here so LinkPreview would not fetch preview data again.
final
requestTimeout Duration?
Request timeout after which the request will be cancelled. Defaults to 5 seconds.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
text String
Text used for parsing.
final
textStyle TextStyle?
Style of the provided text.
final
textWidget Widget?
Widget to display above the preview. If null, defaults to a linkified text.
final
userAgent String?
User agent to send as GET header when requesting link preview url.
final
width double
Width of the LinkPreview widget.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<LinkPreview>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited