addRectangle method

Future<ShapeId> addRectangle({
  1. required GeoPoint center,
  2. required double distance,
  3. required Color color,
  4. Color? borderColor,
  5. double strokeWidth = 1,
  6. ShapeId? shapeId,
})

Implementation

Future<ShapeId> addRectangle({
  required GeoPoint center,
  required double distance,
  required Color color,
  Color? borderColor,
  double strokeWidth = 1,
  ShapeId? shapeId,
}) async {
  if (!distance.isFinite ||
      distance <= 0 ||
      !strokeWidth.isFinite ||
      strokeWidth <= 0) {
    throw _argumentException(_controller, 'addRectangle', 'invalid_shape');
  }
  final id = _issue(shapeId, 'addRectangle');
  try {
    final transport = await _controller._readyTransport();
    await transport.addRectangle(
      shapeId: id,
      center: center,
      distance: distance,
      fillColor: _signedArgb(color),
      borderColor: _signedArgb(borderColor ?? color),
      strokeWidth: strokeWidth,
    );
    return id;
  } catch (_) {
    _issuedIds.remove(id);
    rethrow;
  }
}