MediaData class

Media refers to any image, GIF, or video attached to a Tweet. The media object is not a primary object on any endpoint, but can be found and expanded in the Tweet object.

The object is available for expansion with expansions=attachments.media_keys to get the condensed object with only default fields. Use the expansion with the field parameter: media.fields when requesting additional fields to complete the object.

Note that video URLs are not currently available, only static images.

Annotations
  • @freezed

Constructors

MediaData({@JsonKey(name: 'media_key') required String key, required MediaType type, String? url, String? altText, @JsonKey(name: 'duration_ms') int? durationMilliseconds, int? height, int? width, @JsonKey(name: 'non_public_metrics') PrivateMediaMetrics? privateMetrics, OrganicMediaMetrics? organicMetrics, String? previewImageUrl, PromotedMediaMetrics? promotedMetrics, PublicMediaMetrics? publicMetrics, List<Variant>? variants})
const
factory
MediaData.fromJson(Map<String, Object?> json)
factory

Properties

altText String?
A description of an image to enable and support accessibility. Can be up to 1000 characters long. Alt text can only be added to images at the moment.
no setterinherited
copyWith → $MediaDataCopyWith<MediaData>
no setterinherited
durationMilliseconds int?
Available when type is video. Duration in milliseconds of the video.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
height int?
Height of this content in pixels.
no setterinherited
key String
Unique identifier of the expanded media content.
no setterinherited
organicMetrics OrganicMediaMetrics?
Engagement metrics for the media content, tracked in an organic context, at the time of the request. Requires user context authentication.
no setterinherited
previewImageUrl String?
URL to the static placeholder preview of this content.
no setterinherited
privateMetrics PrivateMediaMetrics?
Non-public engagement metrics for the media content at the time of the request. Requires user context authentication.
no setterinherited
promotedMetrics PromotedMediaMetrics?
Engagement metrics for the media content, tracked in a promoted context, at the time of the request. Requires user context authentication.
no setterinherited
publicMetrics PublicMediaMetrics?
Public engagement metrics for the media content at the time of the request.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type MediaType
Type of content (animated_gif, photo, video).
no setterinherited
url String?
A direct URL to the media file on Twitter.
no setterinherited
variants List<Variant>?
Variants of media attached in the MediaObject.
no setterinherited
width int?
Width of this content in pixels.
no setterinherited

Methods

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

Operators

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