AnyLinkPreview class
Constructors
AnyLinkPreview ({Key ? key , required String link , Duration cache = const Duration(days: 1) , TextStyle ? titleStyle , TextStyle ? bodyStyle , UIDirection displayDirection = UIDirection.uiDirectionVertical , bool showMultimedia = true , Color ? backgroundColor = const Color.fromRGBO(235, 235, 235, 1) , int bodyMaxLines = 3 , TextOverflow bodyTextOverflow = TextOverflow.ellipsis , Widget ? placeholderWidget , Widget ? errorWidget , String ? errorBody , String ? errorImage , String ? errorTitle , double ? borderRadius , List <BoxShadow > ? boxShadow , bool removeElevation = false , String ? proxyUrl , void onTap ()?, double ? previewHeight , LaunchMode urlLaunchMode = LaunchMode.platformDefault })
AnyLinkPreview.builder ({Key ? key , required String link , required Widget itemBuilder (BuildContext , Metadata , ImageProvider <Object > ? , SvgPicture? )?, Duration cache = const Duration(days: 1) , Widget ? placeholderWidget , Widget ? errorWidget , String ? proxyUrl , })
Properties
backgroundColor
→ Color ?
Customize background colour
Defaults to Color.fromRGBO(235, 235, 235, 1)
final
bodyMaxLines
→ int
Give the limit to body text (Description)
Defaults to 3
final
bodyStyle
→ TextStyle ?
Customize body TextStyle
final
bodyTextOverflow
→ TextOverflow
Give the overflow type for body text (Description)
Deaults to TextOverflow.ellipsis
final
borderRadius
→ double ?
BorderRadius for the card. Deafults to 12
final
boxShadow
→ List <BoxShadow > ?
Box shadow for the card. Deafults to [BoxShadow(blurRadius: 3, color: Colors.grey)]
final
cache
→ Duration
Cache result time, default cache 1 day
Pass null
to disable or to fetch latest
final
displayDirection
→ UIDirection
Display direction. One among uiDirectionVertical, uiDirectionHorizontal
By default it is uiDirectionVertical
final
errorBody
→ String ?
Body that need to be shown if something goes wrong
Defaults to Oops! Unable to parse the url. We have sent feedback to our developers & we will try to fix this in our next release. Thanks!
final
errorImage
→ String ?
Image that will be shown if something goes wrong
& when multimedia enabled & no meta data is available
Defaults to A semi-soccer ball image that looks like crying
final
errorTitle
→ String ?
Title that need to be shown if something goes wrong
Defaults to Something went wrong!
final
errorWidget
→ Widget ?
Widget that need to be shown if something goes wrong
Defaults to plain container with given background colour
If the issue is know then we will show customized UI
Other options of error params are used
final
hashCode
→ int
The hash code for this object.
no setter inherited
Headers to be added in the HTTP request to the link
final
itemBuilder
→ (Widget Function(BuildContext , Metadata , ImageProvider <Object > ? , SvgPicture? ) ?)
Function only in AnyLinkPreview.builder
allows to build a custom Widget from the Metadata and either ImageProvider or SvgPicture
fetched
final
key
→ Key ?
Controls how one widget replaces another widget in the tree.
final inherited
link
→ String
Web address (Url that need to be parsed)
For IOS & Web, only HTTP and HTTPS are support
For Android, all url's are supported
final
onTap
→ (void Function() ?)
Function that needs to be called when user taps on the card.
If not given then given URL will be launched.
To disable, Pass empty function.
final
placeholderWidget
→ Widget ?
Widget that need to be shown when
plugin is trying to fetch metadata
If not given anything then default one will be shown
final
previewHeight
→ double ?
Height of the preview card. Defaults to
(MediaQuery.of(context).size.height) * 0.15
in case of horizontal and
(MediaQuery.of(context).size.height) * 0.25
in case of vertical
final
proxyUrl
→ String ?
Proxy URL to pass that resolve CORS issues on web.
For example, https://cors-anywhere.herokuapp.com/
.
final
removeElevation
→ bool
To remove the card elevation set it to true
Default value is false
final
runtimeType
→ Type
A representation of the runtime type of the object.
no setter inherited
showMultimedia
→ bool
Show or Hide image if available defaults to true
final
titleStyle
→ TextStyle ?
Customize body TextStyle
final
urlLaunchMode
→ LaunchMode
Parameter to choose how you'd like the app to handle the link
Default is LaunchMode.platformDefault
final
Static Methods
getMetadata ({required String link , String ? proxyUrl = '' , Duration ? cache = const Duration(days: 1) , })
→ Future <Metadata ? >
Method to fetch metadata directly
isValidLink (String link , {List <String > protocols = const ['http', 'https', 'ftp'] , List <String > hostWhitelist = const [] , List <String > hostBlacklist = const [] , bool requireTld = true , bool requireProtocol = false , bool allowUnderscore = false })
→ bool
Method to verify if the link is valid or not