RichBlock class sealed

This object represents a block in a rich formatted message.

Available extensions
Annotations
  • @Freezed.new(unionKey: 'type', unionValueCase: FreezedUnionCase.snake)

Constructors

RichBlock.anchor({@JsonKey.new(name: 'type') @Default.new(RichBlockType.anchor) RichBlockType type, @JsonKey.new(name: 'name') required String name})
A block with an anchor, corresponding to the HTML tag <a> with the attribute name.
const
factory
RichBlock.animation({@JsonKey.new(name: 'type') @Default.new(RichBlockType.animation) RichBlockType type, @JsonKey.new(name: 'animation') required Animation animation, @JsonKey.new(name: 'has_spoiler') bool? hasSpoiler, @JsonKey.new(name: 'caption') RichBlockCaption? caption})
A block with an animation, corresponding to the HTML tag <video>.
const
factory
RichBlock.audio({@JsonKey.new(name: 'type') @Default.new(RichBlockType.audio) RichBlockType type, @JsonKey.new(name: 'audio') required Audio audio, @JsonKey.new(name: 'caption') RichBlockCaption? caption})
A block with a music file, corresponding to the HTML tag <audio>.
const
factory
RichBlock.blockquote({@JsonKey.new(name: 'type') @Default.new(RichBlockType.blockquote) RichBlockType type, @JsonKey.new(name: 'blocks') required List<RichBlock> blocks, @JsonKey.new(name: 'credit') @RichTextConverter() RichText? credit})
A block quotation, corresponding to the HTML tag
const
factory
RichBlock.collage({@JsonKey.new(name: 'type') @Default.new(RichBlockType.collage) RichBlockType type, @JsonKey.new(name: 'blocks') required List<RichBlock> blocks, @JsonKey.new(name: 'caption') RichBlockCaption? caption})
A collage, corresponding to the custom HTML tag <tg-collage>.
const
factory
RichBlock.details({@JsonKey.new(name: 'type') @Default.new(RichBlockType.details) RichBlockType type, @JsonKey.new(name: 'summary') @RichTextConverter() required RichText summary, @JsonKey.new(name: 'blocks') required List<RichBlock> blocks, @JsonKey.new(name: 'is_open') bool? isOpen})
An expandable block for details disclosure, corresponding to the HTML tag <details>.
const
factory
RichBlock.divider({@JsonKey.new(name: 'type') @Default.new(RichBlockType.divider) RichBlockType type})
A divider, corresponding to the HTML tag <hr/>.
const
factory
RichBlock.footer({@JsonKey.new(name: 'type') @Default.new(RichBlockType.footer) RichBlockType type, @JsonKey.new(name: 'text') @RichTextConverter() required RichText text})
A footer, corresponding to the HTML tag <footer>.
const
factory
RichBlock.fromJson(Map<String, dynamic> json)
Creates a RichBlock object from JSON.
factory
RichBlock.heading({@JsonKey.new(name: 'type') @Default.new(RichBlockType.heading) RichBlockType type, @JsonKey.new(name: 'text') @RichTextConverter() required RichText text, @JsonKey.new(name: 'size') required int size})
A section heading, corresponding to the HTML tags <h1>, <h2>, <h3>, <h4>, <h5>, or <h6>.
const
factory
RichBlock.list({@JsonKey.new(name: 'type') @Default.new(RichBlockType.list) RichBlockType type, @JsonKey.new(name: 'items') required List<RichBlockListItem> items})
A list of blocks, corresponding to the HTML tag <ul> or <ol> with multiple nested tags <li>.
const
factory
RichBlock.map({@JsonKey.new(name: 'type') @Default.new(RichBlockType.map) RichBlockType type, @JsonKey.new(name: 'location') required Location location, @JsonKey.new(name: 'zoom') required int zoom, @JsonKey.new(name: 'width') required int width, @JsonKey.new(name: 'height') required int height, @JsonKey.new(name: 'caption') RichBlockCaption? caption})
A block with a map, corresponding to the custom HTML tag <tg-map>.
const
factory
RichBlock.mathematicalExpression({@JsonKey.new(name: 'type') @Default.new(RichBlockType.mathematicalExpression) RichBlockType type, @JsonKey.new(name: 'expression') required String expression})
A block with a mathematical expression in LaTeX format, corresponding to the custom HTML tag <tg-math-block>.
const
factory
RichBlock.paragraph({@JsonKey.new(name: 'type') @Default.new(RichBlockType.paragraph) RichBlockType type, @JsonKey.new(name: 'text') @RichTextConverter() required RichText text})
A text paragraph, corresponding to the HTML tag <p>.
const
factory
RichBlock.photo({@JsonKey.new(name: 'type') @Default.new(RichBlockType.photo) RichBlockType type, @JsonKey.new(name: 'photo') required List<PhotoSize> photo, @JsonKey.new(name: 'has_spoiler') bool? hasSpoiler, @JsonKey.new(name: 'caption') RichBlockCaption? caption})
A block with a photo, corresponding to the HTML tag <photo>.
const
factory
RichBlock.pre({@JsonKey.new(name: 'type') @Default.new(RichBlockType.pre) RichBlockType type, @JsonKey.new(name: 'text') @RichTextConverter() required RichText text, @JsonKey.new(name: 'language') String? language})
A preformatted text block, corresponding to the nested HTML tags <pre> and <code>.
const
factory
RichBlock.pullquote({@JsonKey.new(name: 'type') @Default.new(RichBlockType.pullquote) RichBlockType type, @JsonKey.new(name: 'text') @RichTextConverter() required RichText text, @JsonKey.new(name: 'credit') @RichTextConverter() RichText? credit})
A quotation with centered text, loosely corresponding to the HTML tag
const
factory
RichBlock.slideshow({@JsonKey.new(name: 'type') @Default.new(RichBlockType.slideshow) RichBlockType type, @JsonKey.new(name: 'blocks') required List<RichBlock> blocks, @JsonKey.new(name: 'caption') RichBlockCaption? caption})
A slideshow, corresponding to the custom HTML tag <tg-slideshow>.
const
factory
RichBlock.table({@JsonKey.new(name: 'type') @Default.new(RichBlockType.table) RichBlockType type, @JsonKey.new(name: 'cells') required List<List<RichBlockTableCell>> cells, @JsonKey.new(name: 'is_bordered') bool? isBordered, @JsonKey.new(name: 'is_striped') bool? isStriped, @JsonKey.new(name: 'caption') @RichTextConverter() RichText? caption})
A table, corresponding to the HTML tag <table>.
const
factory
RichBlock.thinking({@JsonKey.new(name: 'type') @Default.new(RichBlockType.thinking) RichBlockType type, @JsonKey.new(name: 'text') @RichTextConverter() required RichText text})
A block with a “Thinking…” placeholder, corresponding to the custom HTML tag <tg-thinking>.
const
factory
RichBlock.video({@JsonKey.new(name: 'type') @Default.new(RichBlockType.video) RichBlockType type, @JsonKey.new(name: 'video') required Video video, @JsonKey.new(name: 'has_spoiler') bool? hasSpoiler, @JsonKey.new(name: 'caption') RichBlockCaption? caption})
A block with a video, corresponding to the HTML tag <video>.
const
factory
RichBlock.voiceNote({@JsonKey.new(name: 'type') @Default.new(RichBlockType.voiceNote) RichBlockType type, @JsonKey.new(name: 'voice_note') required Voice voiceNote, @JsonKey.new(name: 'caption') RichBlockCaption? caption})
A block with a voice note, corresponding to the HTML tag <audio>.
const
factory

Properties

copyWith → $RichBlockCopyWith<RichBlock>
Create a copy of RichBlock with the given fields replaced by the non-null parameter values.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type RichBlockType
Type of the block, always "paragraph"
no setterinherited

Methods

map<TResult extends Object?>({required TResult paragraph(RichBlockParagraph value), required TResult heading(RichBlockSectionHeading value), required TResult pre(RichBlockPreformatted value), required TResult footer(RichBlockFooter value), required TResult divider(RichBlockDivider value), required TResult mathematicalExpression(RichBlockMathematicalExpression value), required TResult anchor(RichBlockAnchor value), required TResult list(RichBlockList value), required TResult blockquote(RichBlockBlockQuotation value), required TResult pullquote(RichBlockPullQuotation value), required TResult collage(RichBlockCollage value), required TResult slideshow(RichBlockSlideshow value), required TResult table(RichBlockTable value), required TResult details(RichBlockDetails value), required TResult map(RichBlockMap value), required TResult animation(RichBlockAnimation value), required TResult audio(RichBlockAudio value), required TResult photo(RichBlockPhoto value), required TResult video(RichBlockVideo value), required TResult voiceNote(RichBlockVoiceNote value), required TResult thinking(RichBlockThinking value)}) → TResult

Available on RichBlock, provided by the RichBlockPatterns extension

A switch-like method, using callbacks.
mapOrNull<TResult extends Object?>({TResult? paragraph(RichBlockParagraph value)?, TResult? heading(RichBlockSectionHeading value)?, TResult? pre(RichBlockPreformatted value)?, TResult? footer(RichBlockFooter value)?, TResult? divider(RichBlockDivider value)?, TResult? mathematicalExpression(RichBlockMathematicalExpression value)?, TResult? anchor(RichBlockAnchor value)?, TResult? list(RichBlockList value)?, TResult? blockquote(RichBlockBlockQuotation value)?, TResult? pullquote(RichBlockPullQuotation value)?, TResult? collage(RichBlockCollage value)?, TResult? slideshow(RichBlockSlideshow value)?, TResult? table(RichBlockTable value)?, TResult? details(RichBlockDetails value)?, TResult? map(RichBlockMap value)?, TResult? animation(RichBlockAnimation value)?, TResult? audio(RichBlockAudio value)?, TResult? photo(RichBlockPhoto value)?, TResult? video(RichBlockVideo value)?, TResult? voiceNote(RichBlockVoiceNote value)?, TResult? thinking(RichBlockThinking value)?}) → TResult?

Available on RichBlock, provided by the RichBlockPatterns extension

A variant of map that fallback to returning null.
maybeMap<TResult extends Object?>({TResult paragraph(RichBlockParagraph value)?, TResult heading(RichBlockSectionHeading value)?, TResult pre(RichBlockPreformatted value)?, TResult footer(RichBlockFooter value)?, TResult divider(RichBlockDivider value)?, TResult mathematicalExpression(RichBlockMathematicalExpression value)?, TResult anchor(RichBlockAnchor value)?, TResult list(RichBlockList value)?, TResult blockquote(RichBlockBlockQuotation value)?, TResult pullquote(RichBlockPullQuotation value)?, TResult collage(RichBlockCollage value)?, TResult slideshow(RichBlockSlideshow value)?, TResult table(RichBlockTable value)?, TResult details(RichBlockDetails value)?, TResult map(RichBlockMap value)?, TResult animation(RichBlockAnimation value)?, TResult audio(RichBlockAudio value)?, TResult photo(RichBlockPhoto value)?, TResult video(RichBlockVideo value)?, TResult voiceNote(RichBlockVoiceNote value)?, TResult thinking(RichBlockThinking value)?, required TResult orElse()}) → TResult

Available on RichBlock, provided by the RichBlockPatterns extension

A variant of map that fallback to returning orElse.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Serializes this RichBlock to a JSON map.
inherited
toString() String
A string representation of this object.
inherited

Operators

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