Reputation: 1382
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) ?
Upvotes: 1
Views: 798
Reputation: 3263
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.
Upvotes: 3
Reputation: 1297
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!'))
Upvotes: 1