我希望能够apply()
在 Dart 中使用 Kotlin 做类似的事情。例如在科特林中
var userDetails: UserDetails = userRepo.getUser().apply{
//here 'this' is UserDetails so all the further calls are made in that context
name = "Name"
email = "email@test.com"
callSomeInnerMethodOfUserDetails()
};
Run Code Online (Sandbox Code Playgroud)
Dart 语言是否有类似的方法或方式?
我想知道标准库或语言本身是否有一些东西,而不是我自己的通用闭包扩展用于这种目的?
谢谢。