简体   繁体   中英

What is the purpose of a double point operator in Dart?

在以下代码中使用双点运算符是什么意思?

var _tabController = TabController(length: 2, vsync: this)..addListener(_onTabChange);

It's called cascade notation , a syntax sugar for subsequent statements of the object.

It's equivalent of:

var _tabController = TabController(length: 2, vsync:this);
_tabController.addListener(_onTabChange);

Instead writing the object name again and again, you can sequently write the statements without breaking the object assignment.

docs:https://dart.dev/guides/language/language-tour#cascade-notation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM