Skip to content

Commit

Permalink
feat: Replace dart:html with dart:js_interop (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
koji-1009 authored Dec 3, 2024
1 parent 8cb812a commit f7a668c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/src/testing/utils/detected_runtime.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
// limitations under the License.

import 'detected_runtime_stub.dart'
if (dart.library.html) 'detected_runtime_html.dart';
if (dart.library.js_interop) 'detected_runtime_js_interop.dart';

export 'detected_runtime_stub.dart'
if (dart.library.html) 'detected_runtime_html.dart' show detectedRuntime;
if (dart.library.js_interop) 'detected_runtime_js_interop.dart'
show detectedRuntime;

/// Return `null` instead of [value] on Firefox.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// ignore: avoid_web_libraries_in_flutter
import 'dart:html' show window;
import 'dart:js_interop';

@JS('window.navigator.userAgent')
external String get userAgent;

/// Detected runtime based on [rendering engine][1], this is one of:
/// * `'firefox'` (if rendering engine is `'gecko'`),
Expand All @@ -32,7 +34,7 @@ import 'dart:html' show window;
///
/// [1]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent
final String detectedRuntime = () {
final ua = window.navigator.userAgent;
final ua = userAgent;

if (ua.contains('Gecko/')) {
return 'firefox';
Expand Down

0 comments on commit f7a668c

Please sign in to comment.