TextElementDefinition constructor
TextElementDefinition({
- String? type,
- DiagramTextDefinition textType = const PlainTextDefinition(),
- String? placeholder = 'Type something…',
- ShapeConnectionDefinition connection = const ShapeConnectionDefinition.outline(),
- DiagramTextFontSizeRange fontSizeRange = const DiagramTextFontSizeRange(),
- ShapeTextCreation textCreation = const ShapeTextCreation(clickSizingMode: DiagramTextSizingMode.autoWidth),
- DiagramSize minimumSize = const DiagramSize(24, diagramDefaultLineHeight),
- DiagramSize size = const DiagramSize(160, diagramDefaultLineHeight),
- 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);
}