1
Widget customWidget(int position){
    return Transform(
    transform: Matrix4.identity()..rotateY(position),
    child: Container(
      color: position % 2 == 0 ? Colors.lightBlueAccent: Colors.black87,
    ),
  )
}

What is .. in Matrix4.identity()..rotateY(position) ?

Kavin Raju S
  • 1,214
  • 2
  • 17
  • 25
  • 5
    Possible duplicate of [What does that 2 dots mean? What is the difference between 1 and 2?](https://stackoverflow.com/questions/53136945/what-does-that-2-dots-mean-what-is-the-difference-between-1-and-2) – Joshua T Jun 10 '19 at 06:42

2 Answers2

3

Cascade notation

From the official documentation

Cascades (..) allow you to make a sequence of operations on the same object.

In addition to function calls, you can also access fields on that same object. This often saves you the step of creating a temporary variable and allows you to write more fluid code.

shb
  • 5,957
  • 2
  • 15
  • 32
1

From the official docs ,

Cascades (..) allow you to make a sequence of operations on the same object. In addition to function calls, you can also access fields on that same object. This often saves you the step of creating a temporary variable and allows you to write more fluid code.

Consider the following code:

querySelector('#confirm') // Get an object.
  ..text = 'Confirm' // Use its members.
  ..classes.add('important')
  ..onClick.listen((e) => window.alert('Confirmed!'));

The first method call, querySelector(), returns a selector object. The code that follows the cascade notation operates on this selector object, ignoring any subsequent values that might be returned.

The previous example is equivalent to:

var button = querySelector('#confirm');
button.text = 'Confirm';
button.classes.add('important');
button.onClick.listen((e) => window.alert('Confirmed!'))
TheMri
  • 1,217
  • 8
  • 12