headingNode function

Node headingNode({
  1. required int level,
  2. String? text,
  3. Delta? delta,
  4. String? textDirection,
  5. Attributes? attributes,
})

Implementation

Node headingNode({
  required int level,
  String? text,
  Delta? delta,
  String? textDirection,
  Attributes? attributes,
}) {
  assert(level >= 1 && level <= 6);
  return Node(
    type: HeadingBlockKeys.type,
    attributes: {
      HeadingBlockKeys.delta: (delta ?? (Delta()..insert(text ?? ''))).toJson(),
      HeadingBlockKeys.level: level.clamp(1, 6),
      if (attributes != null) ...attributes,
      if (textDirection != null) HeadingBlockKeys.textDirection: textDirection,
    },
  );
}