AnyLinkPreview class
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- AnyLinkPreview
- Available extensions
Constructors
-
AnyLinkPreview.new({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, Map<String, String> ? headers, VoidCallback? onTap, double? previewHeight, LaunchMode urlLaunchMode = LaunchMode.platformDefault, String? userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'}) -
const
-
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, Map<String, String> ? headers}) -
const
Properties
- backgroundColor → Color?
-
Customize background color. Defaults to
Color.fromRGBO(235, 235, 235, 1)
final - bodyMaxLines → int
-
Sets the limit to body text (description) of the link. Defaults to
3
.final - bodyStyle → TextStyle?
-
Customize body TextStyle.
final
- bodyTextOverflow → TextOverflow
-
Sets the overflow type for body text (description) of the link.
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
-
TTL of metadata cache. Defaults to 1 day. Pass
null
to disable caching and always make a request for latest metadata.final - displayDirection → UIDirection
-
Display direction. Either UIDirection.uiDirectionVertical or
UIDirection.uiDirectionHorizontal. Defaults to vertical direction.
final
- errorBody → String?
-
Error body message that will be shown in case of an error. 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 in case of an error when showMultimedia is set
to
true
and no metadata could be parsed. Defaults to "A semi-soccer ball image that looks like crying".final - errorTitle → String?
-
Error title message that will be shown in case of an error. Defaults to
"Something went wrong!".
final
- errorWidget → Widget?
-
Error widget that will be shown in case of an error. Defaults to a plain
Container with a given backgroundColor. If the issue is known, i.e.
either a title or a description of the error is present, errorTitle and
errorBody are used instead, with fallback to their default values.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
headers
→ Map<
String, String> ? -
Headers to be added in the HTTP request to the link
final
-
itemBuilder
→ Widget Function(BuildContext, Metadata, ImageProvider<
Object> ?, SvgPicture?)? -
Builder function that is used only in AnyLinkPreview.builder and
allows building a custom Widget from the Metadata, with either of
the optional ImageProvider or SvgPicture fetched.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- link → String
-
URL represented in string. For IOS & Web, only HTTP and HTTPS are
supported. For Android, all URLs are supported.
final
- onTap → VoidCallback?
-
Function that is called on card tap. If not provided, then launchUrl
will be used with the provided link. To disable calling launchUrl and
instead do nothing on tap, pass an empty function:
() {}
.final - placeholderWidget → Widget?
-
Placeholder widget that is shown while the metadata request is pending.
If not present, the default loading widget will be shown.
final
- previewHeight → double?
-
Height of the preview card. Defaults to
(MediaQuery.sizeOf(context).height) * 0.15
for the horizontal preview and(MediaQuery.sizeOf(context).height) * 0.25
for the vertical preview.final - proxyUrl → String?
-
Proxy URL that is used to resolve CORS issues on web.
For example,
https://cors-anywhere.herokuapp.com/
.final - pZero → Widget
-
Available on Widget, provided by the WidgetsExtension extension
no setter - removeElevation → bool
-
If set to true, removes card widget's elevation. Defaults to
false
.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- showMultimedia → bool
-
Whether to show metadata image if it's present. Defaults to
true
.final - sliverBox → Widget
-
Available on Widget, provided by the WidgetSliverBoxX extension
no setter - titleStyle → TextStyle?
-
Customize body TextStyle.
final
- urlLaunchMode → LaunchMode
-
Represents the mechanism used to open URLs via launchUrl. Defaults to
LaunchMode.platformDefault
final
- userAgent → String?
-
User-Agent to be used in the HTTP request to the link
Default: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'
final
Methods
-
alignAtBottomCenter(
{Key? key, double? heightFactor, double? widthFactor}) → Align -
Available on Widget, provided by the WidgetsExtension extension
-
alignAtBottomLeft(
{Key? key, double? heightFactor, double? widthFactor}) → Align -
Available on Widget, provided by the WidgetsExtension extension
-
alignAtBottomRight(
{Key? key, double? heightFactor, double? widthFactor}) → Align -
Available on Widget, provided by the WidgetsExtension extension
-
alignAtCenter(
{Key? key, double? heightFactor, double? widthFactor}) → Align -
Available on Widget, provided by the WidgetsExtension extension
-
alignAtCenterLeft(
{Key? key, double? heightFactor, double? widthFactor}) → Align -
Available on Widget, provided by the WidgetsExtension extension
-
alignAtCenterRight(
{Key? key, double? heightFactor, double? widthFactor}) → Align -
Available on Widget, provided by the WidgetsExtension extension
-
alignAtLERP(
Alignment a, Alignment b, double t, {Key? key, double? heightFactor, double? widthFactor}) → Align -
Available on Widget, provided by the WidgetsExtension extension
-
alignAtTopCenter(
{Key? key, double? heightFactor, double? widthFactor}) → Align -
Available on Widget, provided by the WidgetsExtension extension
-
alignAtTopLeft(
{Key? key, double? heightFactor, double? widthFactor}) → Align -
Available on Widget, provided by the WidgetsExtension extension
-
alignAtTopRight(
{Key? key, double? heightFactor, double? widthFactor}) → Align -
Available on Widget, provided by the WidgetsExtension extension
-
alignXY(
double x, double y, {Key? key, double? heightFactor, double? widthFactor}) → Align -
Available on Widget, provided by the WidgetsExtension extension
-
card(
{Color? backgroundColor, double elevation = 1, EdgeInsets? margin}) → Widget -
Available on Widget, provided by the WidgetsExtension extension
-
container(
{double? width, double? height, Alignment? alignment, Color? backgroundColor, double borderWidth = 1, double radius = 1, Color borderColor = Colors.transparent, EdgeInsets? padding, EdgeInsets? margin, BoxConstraints? constraints}) → Widget -
Available on Widget, provided by the WidgetsExtension extension
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → AnyLinkPreviewState -
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
-
expanded(
{int flex = 1}) → Widget -
Available on Widget, provided by the WidgetsExtension extension
-
fit(
{Alignment alignment = Alignment.center}) → Widget -
Available on Widget, provided by the WidgetsExtension extension
-
form(
GlobalKey< FormState> key) → Widget -
Available on Widget, provided by the WidgetsExtension extension
-
ltr(
) → Widget -
Available on Widget, provided by the WidgetsExtension extension
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onDoubleTap(
GestureTapCallback? onPressed) → Widget -
Available on Widget, provided by the WidgetsExtension extension
-
onLongPress(
GestureTapCallback? onPressed) → Widget -
Available on Widget, provided by the WidgetsExtension extension
-
onTap(
GestureTapCallback? onPressed) → Widget -
Available on Widget, provided by the WidgetsExtension extension
-
onTapInk(
GestureTapCallback? onPressed) → Widget -
Available on Widget, provided by the WidgetsExtension extension
-
pAll(
double padding) → Widget -
Available on Widget, provided by the WidgetsExtension extension
-
pOnly(
{double left = 0.0, double top = 0.0, double right = 0.0, double bottom = 0.0}) → Widget -
Available on Widget, provided by the WidgetsExtension extension
-
pSymmetric(
{double horizontal = 0.0, double vertical = 0.0}) → Widget -
Available on Widget, provided by the WidgetsExtension extension
-
rotate(
double scale) → Widget -
Available on Widget, provided by the WidgetsExtension extension
-
rtl(
) → Widget -
Available on Widget, provided by the WidgetsExtension extension
-
safeArea(
) → Widget -
Available on Widget, provided by the WidgetsExtension extension
-
scale(
double scale) → Widget -
Available on Widget, provided by the WidgetsExtension extension
-
scrollable(
{Axis scrollDirection = Axis.vertical}) → Widget -
Available on Widget, provided by the WidgetsExtension extension
-
showMenus(
List< PopupMenuEntry< items) → Widgetint> > -
Available on Widget, provided by the WidgetsExtension extension
-
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
-
translate(
Offset offset) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
getMetadata(
{required String link, String? proxyUrl = '', Duration? cache = const Duration(days: 1), Map< String, String> ? headers, String? userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'}) → 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