What does that 2 dots mean? What is the difference between 1 and 2?

1869 views dart
-1

I have seen a lot of tutorials using dot, while some use 2. What is the actual meaning of this?

Example,

Array().add()

Animation()..addListener(() {})

answered question

1 Answer

1

The .. operator is dart "cascade" operator. Useful for chaining operations when you don't care about the return value. This is also dart solution to chainable functions that always return this

It is made so that the following

final foo = Foo()
 ..first()
..second();

Is strictly equals to this:

final foo = Foo();
foo.first():
foo.second();

posted this

Have an answer?

JD

Please login first before posting an answer.