考虑到"named constructors and 102 in Dart give you all of the flexibility of static methods in other languages, while still allowing the callsite to appear like a regular constructor invocation",Dart Style Guide推荐使用constructors instead of static methods to create instances.
那么,将int.parse()
和double.parse()
声明为静态方法而不是工厂构造函数是否有技术原因呢?
更广泛地说,在DART中 Select 编写工厂构造函数而不是静电(工厂)方法的指导原则是什么?