How to create a static extension method in Dart?
问题 I'm trying to create a static extension method on one of my classes (which is autogenerated, so I can't easily modify it). According to the docs, this should be possible: Extensions can also have static fields and static helper methods. Yet even this small example does not compile: extension Foo on String { static String foo() => 'foo!'; } void main() { print(String.foo()); } Error: Method not found: 'String.foo'. print(String.foo()); ^^^ What am I doing wrong? 回答1: The docs mean that the