For the latest Dart news, visit our new blog at https://medium.com/dartlang .
The RegExp constructor will have its const keyword removed today.
Anders Johnsen writes:
Anders Johnsen writes:
As always, we invite you to join our Dart mailing list, ask questions on Stack Overflow, or file feature requests on dartbug.com.The reason for this change is that const classes can only initialize their fields at construction. However a RegExp needs to check the given pattern for syntax errors and throw at construction.A few tips for converting old patterns:class A {const RegExp myRegExp = const RegExp(...);}Should now be written asclass A {static final RegExp myRegExp = new RegExp(...);}In extend to that, consider moving out 'const RegExp(...)' from inside function bodies, if it's in a critical path, and place it either as a static final class field or as a top-level final variable.