Showing
1 changed file
with
20 additions
and
0 deletions
lib/src/web/javascript_map.dart
0 → 100644
| 1 | +import 'dart:js_interop'; | ||
| 2 | + | ||
| 3 | +/// A static interop stub for the `Map` class. | ||
| 4 | +/// | ||
| 5 | +/// This stub is here because the `js_types` from the Dart SDK do not yet provide a `Map` equivalent: | ||
| 6 | +/// https://github.com/dart-lang/sdk/issues/54365 | ||
| 7 | +/// | ||
| 8 | +/// See also: https://github.com/dart-lang/sdk/issues/54365#issuecomment-1856995463 | ||
| 9 | +/// | ||
| 10 | +/// Object literals can be made using [jsify]. | ||
| 11 | +@JS('Map') | ||
| 12 | +@staticInterop | ||
| 13 | +class JsMap<K extends JSAny, V extends JSAny> implements JSAny { | ||
| 14 | + external factory JsMap(); | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +extension JsMapExtension<K extends JSAny, V extends JSAny> on JsMap<K, V> { | ||
| 18 | + external V? get(K key); | ||
| 19 | + external JSVoid set(K key, V? value); | ||
| 20 | +} |
-
Please register or login to post a comment