Skip to content

Commit c98d54b

Browse files
committed
Wrap CSS.supports() with try-catch block
in case the feature isn't supported on some old browsers.
1 parent 45999fe commit c98d54b

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

lib/src/flutter_web_file_selector_platform_view_web.dart

+12-7
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,18 @@ class WebFileSelectorPlatformView {
157157
labelElement.style.backgroundColor = 'transparent';
158158
labelElement.style.cursor = 'pointer';
159159

160-
// This is to prevent mobile version of Chrome from
161-
// applying a highlight color when tapped.
162-
if (web.CSS.supports('-webkit-tap-highlight-color: transparent')) {
163-
labelElement.attributeStyleMap.set(
164-
'-webkit-tap-highlight-color',
165-
'transparent'.toJS,
166-
);
160+
try {
161+
// This is to prevent mobile version of Chrome from
162+
// applying a highlight color when tapped.
163+
if (web.CSS.supports('-webkit-tap-highlight-color: transparent')) {
164+
labelElement.attributeStyleMap.set(
165+
'-webkit-tap-highlight-color',
166+
'transparent'.toJS,
167+
);
168+
}
169+
} catch (_) {
170+
// CSS.support() is probably not supported the
171+
// browser this code is currently running on.
167172
}
168173

169174
// Add HTML input element

0 commit comments

Comments
 (0)