We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dart supports conditional imports, when running in a browser environment it would be possible to simply use: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
This would not only be faster, but also reduce the size of compiled javascript code :)
The text was updated successfully, but these errors were encountered:
Here's what I came up with for accessing this, using the official js-interop package. I don't know if it's the best way.
import 'package:js/js.dart'; @JS('String') @staticInterop class JsString { external JsString(String s); } extension JsStringExtension on JsString { external String normalize(String form); } extension StringExtensionHtml on String { String unicodeNormalize(String form) { // For now, this throws in debug mode, but it's fine in (web-)production final value = JsString(this); return value.normalize(form); } }
If this is placed into a file normalizer_web.dart, one can do a conditional import from another file using
normalizer_web.dart
import 'normalizer_regular.dart' if (dart.library.html) 'normalizer_web.dart';
This way you can use the browser's normalize function (named unicodeNormalize above) on the web, and use something else on non-web.
unicodeNormalize
Sorry, something went wrong.
No branches or pull requests
Dart supports conditional imports, when running in a browser environment it would be possible to simply use:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
This would not only be faster, but also reduce the size of compiled javascript code :)
The text was updated successfully, but these errors were encountered: