Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Replace dart:html with dart:js_interop #180

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading