'Natalie Weizenbaum' via Dart Misc
2018-04-02 23:08:47 UTC
Hey folks,
As Leaf announced last month
<https://groups.google.com/a/dartlang.org/forum/#!topic/misc/l0oYjyyFD7c>,
SCREAMING_CAPS constants are deprecated in Dart 2 in favor of camelCase
names, and will be removed entirely in an upcoming release. Unfortunately,
this means that capitalized constants won't be usable in Dart 1 and
camel-case constants won't be usable in Dart 2.
For packages that want to continue supporting both Dart 1 and Dart 2, I've
just released a utility package called dart2_constant
<https://pub.dartlang.org/packages/dart2_constant>. It contains a library
for each dart: library that provides camel-case constants with the same
names as that dart: library's Dart 2 constants. However, it's compatible
with both Dart 1 *and* Dart 2, so it can be used to polyfill the new
constant names on old Dart implementations. These libraries should be
imported using a prefix so as to avoid colliding with core library names:
import 'package:dart2_constant/convert.dart' as convert;
String decodeUtf8(List<int> bytes) => convert.utf8.decode(bytes);
Note that dart2_constant even supports constants that haven't yet migrated
in the core libraries, such as those in dart:io and dart:html. These are
provided for compatibility with future SDK changes.
Enjoy!
- Natalie
As Leaf announced last month
<https://groups.google.com/a/dartlang.org/forum/#!topic/misc/l0oYjyyFD7c>,
SCREAMING_CAPS constants are deprecated in Dart 2 in favor of camelCase
names, and will be removed entirely in an upcoming release. Unfortunately,
this means that capitalized constants won't be usable in Dart 1 and
camel-case constants won't be usable in Dart 2.
For packages that want to continue supporting both Dart 1 and Dart 2, I've
just released a utility package called dart2_constant
<https://pub.dartlang.org/packages/dart2_constant>. It contains a library
for each dart: library that provides camel-case constants with the same
names as that dart: library's Dart 2 constants. However, it's compatible
with both Dart 1 *and* Dart 2, so it can be used to polyfill the new
constant names on old Dart implementations. These libraries should be
imported using a prefix so as to avoid colliding with core library names:
import 'package:dart2_constant/convert.dart' as convert;
String decodeUtf8(List<int> bytes) => convert.utf8.decode(bytes);
Note that dart2_constant even supports constants that haven't yet migrated
in the core libraries, such as those in dart:io and dart:html. These are
provided for compatibility with future SDK changes.
Enjoy!
- Natalie
--
For more ways to connect visit https://www.dartlang.org/community
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/misc/CAKDS1k79nQ8EZQ8%3D5ycuC8719L04kPFfQOvWgT%2BWy8w27qZdmg%40mail.gmail.com.
For more ways to connect visit https://www.dartlang.org/community
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/misc/CAKDS1k79nQ8EZQ8%3D5ycuC8719L04kPFfQOvWgT%2BWy8w27qZdmg%40mail.gmail.com.