TextElementDefinition constructor

TextElementDefinition({
  1. String? type,
  2. DiagramTextDefinition textType = const PlainTextDefinition(),
  3. String? placeholder = 'Type something…',
  4. ShapeConnectionDefinition connection = const ShapeConnectionDefinition.outline(),
  5. DiagramTextFontSizeRange fontSizeRange = const DiagramTextFontSizeRange(),
  6. ShapeTextCreation textCreation = const ShapeTextCreation(clickSizingMode: DiagramTextSizingMode.autoWidth),
  7. DiagramSize minimumSize = const DiagramSize(24, diagramDefaultLineHeight),
  8. DiagramSize size = const DiagramSize(160, diagramDefaultLineHeight),
  9. ShapeBehavior behavior = const ShapeBehavior(textSizing: ShapeTextSizing.growHeight),
})

Implementation

TextElementDefinition({
  String? type,
  this.textType = const PlainTextDefinition(),
  this.placeholder = 'Type something…',
  this.connection = const ShapeConnectionDefinition.outline(),
  this.fontSizeRange = const DiagramTextFontSizeRange(),
  this.textCreation = const ShapeTextCreation(
    clickSizingMode: DiagramTextSizingMode.autoWidth,
  ),
  this.minimumSize = const DiagramSize(24, diagramDefaultLineHeight),
  this.size = const DiagramSize(160, diagramDefaultLineHeight),
  this.behavior = const ShapeBehavior(textSizing: ShapeTextSizing.growHeight),
}) : type = type ?? textType.type {
  fontSizeRange.validate();
  if (this.type.isEmpty || this.type.trim() != this.type) {
    throw ArgumentError('Invalid text element type: ${this.type}');
  }
  if (connection.usesPorts) {
    throw ArgumentError(
      'Standalone text supports outline anchors or no connections.',
    );
  }
  if (placeholder != null && placeholder!.trim().isEmpty) {
    throw ArgumentError('Standalone text placeholders cannot be empty');
  }
  textCreation.validate(behavior);
  _validateShapeDimensions('text', minimumSize, size);
}