Ephenodrom / Dart-Basic-Utils

A dart package for many helper methods fitting common situations
MIT License
368 stars 79 forks source link

Many statics should be const #25

Closed awhitford closed 4 years ago

awhitford commented 4 years ago

Consider the following code:

class DateUtils {
  static int daysOfWeek = 7;
}  

main() {
  print("Hello, World!");
  print("DateUtils.daysOfWeek: ${DateUtils.daysOfWeek}");
  DateUtils.daysOfWeek = 8;
  print("DateUtils.daysOfWeek: ${DateUtils.daysOfWeek}");
}

It should be illegal to override the DateUtils.daysOfWeek. If this was declared as a const, the code would fail to compile (as it should).

Ephenodrom commented 4 years ago

@awhitford Hello and thanks for the improvements. The DateUtils class was more like a challenge to write the date parsing within a few hours, due to a request on gitter to implement such a feature. So far I have not developed an app where this can be used, so I think there is still a lot of space for improvements.

Regards