1 | | | import 'dart:js_interop'; |
2 | | | import 'dart:js_interop_unsafe'; |
3 | | |
|
4 | | | import 'package:web/web.dart'; |
5 | | |
|
6 | | 12 | String? getHome() { |
7 | | 0 | if (window.isUndefinedOrNull) return null; |
8 | | 12 | final components = window.location.pathname.split('/'); |
9 | | 12 | return components.take(components.length - 1).join('/'); |
10 | | 12 | } |
11 | | |
|
12 | | 2 | String? _getErrorEventMessage(JSObject? obj) { |
13 | | 2 | if (obj != null && obj.has('message')) { |
14 | | 0 | return obj['message'].dartify()?.toString(); |
15 | | | } else { |
16 | | 2 | return null; |
17 | | | } |
18 | | 2 | } |
19 | | |
|
20 | | 2 | Object? _getErrorEventError(JSObject? obj) { |
21 | | 2 | if (obj != null && obj.has('error')) { |
22 | | 0 | return obj['error'].dartify(); |
23 | | | } else { |
24 | | 2 | return null; |
25 | | | } |
26 | | 2 | } |
27 | | |
|
28 | | 1 | Object getError(JSObject? obj) => |
29 | | 2 | _getErrorEventError(obj) ?? _getErrorEventMessage(obj) ?? 'Unknown error'; |
30 | | |
|
31 | | 11 | List? getMessageEventData(JSObject? obj) { |
32 | | 11 | if (obj != null && obj.has('data')) { |
33 | | 11 | return obj['data'].dartify() as List?; |
34 | | | } else { |
35 | | 0 | return null; |
36 | | | } |
37 | | 11 | } |