Group: style
Maturity: stable
Dart SDK: >= 2.0.0 • (Linter v0.1.31)
Since info is static, may be staleFrom Effective Dart:
PREFER naming a method to___()
if it copies the object's state to a new
object.
PREFER naming a method as___()
if it returns a different representation
backed by the original object.
BAD:
class Bar {
Foo myMethod() {
return Foo.from(this);
}
}
GOOD:
class Bar {
Foo toFoo() {
return Foo.from(this);
}
}
GOOD:
class Bar {
Foo asFoo() {
return Foo.from(this);
}
}
To enable the use_to_and_as_if_applicable
lint,
add use_to_and_as_if_applicable
under linter > rules in your
analysis_options.yaml
file:
linter:
rules:
- use_to_and_as_if_applicable