add method

dynamic add(
  1. Widget widget
)

Implementation

add(Widget widget) {
  // Generate a unique key for the widget.
  Key key = Key('lindi-${DateTime.now().millisecondsSinceEpoch}-${_nrRnd()}');

  // Create a DraggableWidget with specified properties.
  widgets.add(DraggableWidget(
      key: key,
      icons: icons,
      borderColor: borderColor,
      borderWidth: borderWidth,
      showBorders: showBorders,
      shouldMove: shouldMove,
      shouldRotate: shouldRotate,
      shouldScale: shouldScale,
      minScale: minScale,
      maxScale: maxScale,
      insidePadding: insidePadding,
      position: _ensureWithinBounds(Alignment.center),
      onBorder: (key) {
        _border(key);
      },
      onDelete: (key) {
        _delete(key);
      },
      onLayer: (key) {
        _layer(key);
      },
      child: widget));

  // Highlight the border of the added widget.
  _border(key);
}