0
void _drawBackground(Canvas canvas, Rect shapeBounds, Rect avatarBounds) {
  //1
  final paint = Paint()..color = color;

  //2
  final backgroundPath = Path()
    ..moveTo(shapeBounds.left, shapeBounds.top) //3
    ..lineTo(shapeBounds.bottomLeft.dx, shapeBounds.bottomLeft.dy) //4
    ..arcTo(avatarBounds, -pi, pi, false) //5
    ..lineTo(shapeBounds.bottomRight.dx, shapeBounds.bottomRight.dy) //6
    ..lineTo(shapeBounds.topRight.dx, shapeBounds.topRight.dy) //7
    ..close(); //8

  //9
  canvas.drawPath(backgroundPath, paint);
}

what is this operator in flutter .. and what are the uses of this operator.

1 Answers1

2

It is a dart notation that allows you to perform series of operations on a dart object without affecting the returned type of the object. It is called the cascaded notation.

This

List<String> titles = [];
titles.add(title1);
titles.add(title2);
titles.add(title3);

Can be written as

 List<String> titles = []
 ..add(title1)
 ..add(title2)
 ..add(title3);
iDecode
  • 22,623
  • 19
  • 99
  • 186
Benedict
  • 441
  • 4
  • 14