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.new({required List<Line> lines, required ParagraphType type, Map<String, dynamic>? blockAttributes})
Paragraph.base()
factory
Paragraph.fromEmbed(Operation operation)
Constructs a Paragraph instance from a Quill Delta embed operation.
factory
Paragraph.fromRawEmbed({required Object data, Map<String, dynamic>? attributes, Map<String, dynamic>? blockAttributes})
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})
Paragraph.withLine()
factory
Paragraph.newLine({Map<String, dynamic>? blockAttributes})
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
first Line?
no setter
hashCode int
The hash code for this object.
no setteroverride
id String
final
isBlock bool
no setter
isEmbed bool
no setter
isEmpty bool
no setter
isInsertText bool
no setter
isNewLine bool
no setter
isNewLineWithBlockAttributes bool
no setter
isNotEmpty bool
no setter
isSealed bool
no setter
isTextInsert bool
no setter
last Line?
no setter
length int
no setter
lines List<Line>
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shouldBreakToNext bool
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
unseal() → void
updateLine(int index, Line line) → void

Operators

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