| 1 |  |  | import '_impl/xplat/_platform.dart' | 
                
                
                    | 2 |  |  |     if (dart.library.io) '_impl/native/_platform.dart' | 
                
                
                    | 3 |  |  |     if (dart.library.html) '_impl/web/_platform.dart' | 
                
                
                    | 4 |  |  |     if (dart.library.js) '_impl/web/_platform.dart' | 
                
                
                    | 5 |  |  |     if (dart.library.js_interop) '_impl/web/_platform.dart' as impl; | 
                
                
                    | 6 |  |  | import 'converters/converter.dart'; | 
                
                
                    | 7 |  |  |  | 
                
                
                    | 8 |  | 2 | String get threadId => impl.threadId; | 
                
                
                    | 9 |  |  |  | 
                
                
                    | 10 |  |  | class Squadron { | 
                
                
                    | 11 |  | 0 |   Squadron._(); | 
                
                
                    | 12 |  |  |  | 
                
                
                    | 13 |  |  |   /// Gets the current platform type. | 
                
                
                    | 14 |  | 36 |   static final platformType = impl.getPlatformType(); | 
                
                
                    | 15 |  |  |  | 
                
                
                    | 16 |  |  |   /// Parse [url] and returns the corresponding [Uri]. | 
                
                
                    | 17 |  |  |   /// | 
                
                
                    | 18 |  |  |   /// On Web platforms, a leading '~' character will be replaced with the | 
                
                
                    | 19 |  |  |   /// current page's root URL. E.g. '~/workers' from '/path/to/index.html' | 
                
                
                    | 20 |  |  |   /// will return '/path/to/workers'. | 
                
                
                    | 21 |  | 0 |   static Uri uri(String url) => impl.mapUrl(url); | 
                
                
                    | 22 |  |  |  | 
                
                
                    | 23 |  | 8 |   static final identical = impl.isSameInstance; | 
                
                
                    | 24 |  |  |  | 
                
                
                    | 25 |  | 30 |   static final _platformConverter = impl.getPlatformConverter(); | 
                
                
                    | 26 |  | 30 |   static Converter _converter = _platformConverter; | 
                
                
                    | 27 |  |  |  | 
                
                
                    | 28 |  |  |   /// Gets the current converter. | 
                
                
                    | 29 |  | 20 |   static Converter get converter => _converter; | 
                
                
                    | 30 |  |  |  | 
                
                
                    | 31 |  |  |   /// Sets the current converter. If [value] is `null`, the default converter | 
                
                
                    | 32 |  |  |   /// will be restored. If the converter was updated, handlers registered with | 
                
                
                    | 33 |  |  |   /// [onConverterChanged] will be notified of the change. | 
                
                
                    | 34 |  | 1 |   static set converter(Converter? value) { | 
                
                
                    | 35 |  | 1 |     value ??= _platformConverter; | 
                
                
                    | 36 |  | 2 |     if (_converter != value) { | 
                
                
                    | 37 |  |  |       _converter = value; | 
                
                
                    | 38 |  | 3 |       for (var handler in _converterChangeHandlers.values) { | 
                
                
                    | 39 |  |  |         try { | 
                
                
                    | 40 |  | 1 |           handler(); | 
                
                
                    | 41 |  |  |         } catch (_) { | 
                
                
                    | 42 |  |  |           // ignore | 
                
                
                    | 43 |  |  |         } | 
                
                
                    | 44 |  |  |       } | 
                
                
                    | 45 |  |  |     } | 
                
                
                    | 46 |  |  |   } | 
                
                
                    | 47 |  |  |  | 
                
                
                    | 48 |  | 3 |   static final _converterChangeHandlers = <Object, void Function()>{}; | 
                
                
                    | 49 |  |  |  | 
                
                
                    | 50 |  |  |   /// Registers a callback that will be called whenever `converter` is changed. | 
                
                
                    | 51 |  |  |   /// Returns an object that can be used to unregister the callback by passing | 
                
                
                    | 52 |  |  |   /// it to [unregisterConverterChanged]. | 
                
                
                    | 53 |  | 1 |   static Object onConverterChanged(void Function() handler) { | 
                
                
                    | 54 |  | 1 |     final key = Object(); | 
                
                
                    | 55 |  | 2 |     _converterChangeHandlers[key] = handler; | 
                
                
                    | 56 |  |  |     return key; | 
                
                
                    | 57 |  |  |   } | 
                
                
                    | 58 |  |  |  | 
                
                
                    | 59 |  |  |   /// Unregisters a callback that was registered with [onConverterChanged]. | 
                
                
                    | 60 |  | 1 |   static void unregisterConverterChanged(Object key) { | 
                
                
                    | 61 |  | 2 |     _converterChangeHandlers.remove(key); | 
                
                
                    | 62 |  |  |   } | 
                
                
                    | 63 |  |  | } |