flutter - 编写这样的代码有什么好处?
问题描述
我正在阅读一篇关于颤振 bloc 编程的文章。https://bloclibrary.dev/#/flutterfirestoretodostutorial
Todo 类在文章中定义如下。
class Todo {
final bool complete;
final String id;
final String note;
final String task;
Todo(this.task, {this.complete = false, String note = '', String id})
: this.note = note ?? '',
this.id = id;
//... other code ...
我想知道像上面这样写构造函数的好处,对比下面的方式。我在那个网站上发现了很多类似的情况。
Todo(this.task, {this.complete = false, this.note = '', this.id});
谢谢。
解决方案
推荐阅读
- flutter - Flutter 运行错误 - 准备 SDK 包时发生错误
- snowflake-cloud-data-platform - 从 snowsql cli 删除数据时,Snowflake Invalid Identifier 错误
- node.js - 当任何shopify商店安装公共节点应用程序时,我们如何将点击事件动态添加到shopify商店的客户视图中
- html - 如何在css中选择似乎另一个的html元素
- python - python相当于curl命令
- php - 在 Laravel 5.8 的 console.log() 中获取未定义的 response()->json()
- paypal - 我正在寻找在 PayPal 购买后集成生成序列号和发送电子邮件的最简单方法
- scikit-learn - GaussianNB:获取条件概率
- flash - Haxe 与 swf 目标如何嵌入 PNG 图像
- javascript - UI-Grid 未填充 AngularJs