dart-lang / dart-lang/language
Constant from extension method?
Open
enhanced-const
feature
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
Any way something like this could work?
```dart
extension Time on int {
Duration get ms =>
Duration(microseconds: (this * Duration.microsecondsPerMillisecond).toInt());
}
main() {
// const time = Duration(milliseconds: 250);
const time = 250.ms;
print(time);
}
```
as long as `this` is itself `const`?
Contributor guide
Assessment
This issue has not been assessed yet.