Paragraph class

Represents a paragraph consisting of lines of text or embedded content with optional attributes.

This class encapsulates the structure of a paragraph, which can contain multiple lines and may have associated block-level attributes and a specific paragraph type.

  • lines property holds a list of Line objects representing individual lines within the paragraph.
  • type property specifies the type of paragraph, if any, such as normal text or an embedded content.
  • blockAttributes property is a map that can hold additional attributes specific to the paragraph block.

Example usage:

Paragraph paragraph = Paragraph(
  lines: [
    Line(data: 'First line'),
    Line(data: 'Second line'),
  ],
  blockAttributes: {'indent': 2,'align': 'right'},
  type: ParagraphType.block,
);

paragraph.insert(Line(data: 'Third line'));
paragraph.setType(ParagraphType.block);

// if after the insert, you want to avoid another types of
// changes in this paragraph use:
paragraph.seal();
if(paragraph.isSealed) {
 // do something
}

Constructors

Paragraph({required List<Line> lines, required ParagraphType type, Map<String, dynamic>? blockAttributes, String? id})
Paragraph.auto({required List<Line> lines, Map<String, dynamic>? blockAttributes, String? id})
Paragraph.base({String? id})
factory
Paragraph.fragment(TextFragment frag, {String? id, Map<String, dynamic>? blockAttributes})
factory
Paragraph.fromEmbed(Operation operation, {String? id, Map<String, dynamic>? blockAttributes})
Constructs a Paragraph instance from a Quill Delta embed operation.
factory
Paragraph.fromRawEmbed({required Object data, Map<String, dynamic>? attributes, Map<String, dynamic>? blockAttributes, String? id})
Constructs a Paragraph instance from a Object embed. operation is the Quill Delta operation representing the embed.
factory
Paragraph.sealed({required List<Line> lines, required ParagraphType type, Map<String, dynamic>? blockAttributes, String? id})
Paragraph.withLine({String? id, Iterable<TextFragment>? fragments})
factory
Paragraph.newLine({Map<String, dynamic>? blockAttributes, String? id})
factory

Properties

blockAttributes ↔ Map<String, dynamic>?
Additional attributes specific to the paragraph block.
getter/setter pair
clone → Paragraph
Creates a clone of the current paragraph.
no setter
deepClone → Paragraph
Creates a clone of the current paragraph.
no setter
first → Line?
Get the first element of this Paragraph
no setter
hashCode → int
The hash code for this object.
no setteroverride
id → String
final
isBlock → bool
Determines if this Paragraph is a block type one
no setter
isEmbed → bool
Determines if this Paragraph is an embed type one
no setter
isEmpty → bool
no setter
isInsertText → bool
no setter
isNewLine → bool
Determines if this Paragraph is a new line type one
no setter
isNewLineWithBlockAttributes → bool
Determines if this Paragraph is just a paragraph empty with a new line that has block attributes
no setter
isNotEmpty → bool
no setter
isSealed → bool
Determines if this paragraph cannot be modified
no setter
isTextInsert → bool
Determines if this Paragraph is just an inline type one
no setter
last → Line?
Get the last element of this Paragraph
no setter
length → int
Get the length of lines
no setter
lines → List<Line>
Get all the Lines into this Paragraph
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
shouldBreakToNext → bool
Determines whether the last line is empty (just a newline) and whether the next content should start in a new paragraph.
no setter
type ↔ ParagraphType
The type of the paragraph.
getter/setter pair

Methods

clean() → void
Clears all lines from the paragraph.
containsSameAttributes(Map<String, dynamic>? attrs) → bool
insert(Line line) → void
Inserts a new Line into the paragraph.
insertAll(Iterable<Line> lines) → void
Inserts a new Line into the paragraph.
insertEmptyLine() → void
insertTextFragment(TextFragment fragment) → void
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeLastLine() → Line
Removes last line from the paragraph.
removeLastLineIfNeeded() → void
removeLine(int index) → void
Removes a line from the paragraph at the specified index.
seal({bool sealLines = false}) → void
setAttributes(Map<String, dynamic>? attrs) → void
Sets additional attributes for the paragraph block.
setType(ParagraphType paragraphType) → void
Sets the type of the paragraph.
setTypeSafe(ParagraphType? paragraphType) → void
Sets the type of the paragraph if it hasn't been set already.
toPrettyString({String indent = ' '}) → String
toString() → String
A string representation of this object.
override
unsafeLines() → List<Line>
Get all direct instances of the lines into this Paragraph
unseal({bool unsealLines = false}) → void
updateLine(int index, Line line) → void

Operators

operator ==(covariant Paragraph other) → bool
The equality operator.
override