SocialPreview class

Manages social media preview cards for various platforms.

Configures how your page appears when shared on social media. Each platform has different requirements and display formats.

// Quick setup for all platforms
SocialPreview.apply(
  title: 'My Amazing Product',
  description: 'The best product ever made',
  imageUrl: 'https://example.com/preview.png',
  url: 'https://example.com/products/amazing',
);

// Platform-specific setup
SocialPreview.applyForPlatform(
  platform: SocialPlatform.facebook,
  title: 'Facebook-specific title',
  description: 'Facebook-specific description',
  imageUrl: 'https://example.com/fb-preview.png',
);

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

apply({required String title, required String description, required String imageUrl, String? url, String? siteName, String? twitterSite, String? twitterCreator, TwitterCardType twitterCardType = TwitterCardType.summaryLargeImage, OgType ogType = OgType.website, String? imageWidth, String? imageHeight, String? imageAlt, String? locale}) → void
Apply social preview tags for all platforms at once.
applyForPlatform({required SocialPlatform platform, required String title, required String description, required String imageUrl, String? url, String? siteName, String? imageAlt}) → void
Apply social preview tags for a specific platform.
recommendedImageSpec(SocialPlatform platform) SocialImageSpec
Get recommended image dimensions for each platform