universal_web 1.1.0 copy "universal_web: ^1.1.0" to clipboard
universal_web: ^1.1.0 copied to clipboard

Lightweight browser API bindings built around JS interop.

Dart CI pub package package publisher

Wrapper around package:web that adds compatibility for non-web environments.

What's this? #

This package provides (non-functional) stubs for all interfaces and elements from web to allow being imported in cross-environment codebases (e.g. compiled to both web and native).

It is designed to be a drop-in replacement for package:web.

Usage #

import 'package:universal_web/web.dart';

void main() {
  // Make sure to only call the api when actually on web.
  if (kIsWeb) {
    final div = document.querySelector('div')!;
    div.text = 'Text set at ${DateTime.now()}';
  }
}

The stubs are non-functional in non-web environments and should not be used (they will throw). The main purpose of this package is to allow being imported in other environments, not being used.

Migrate #

The package is generated from the same Web IDL definitions that web uses. It also uses the same versioning.

To migrate:

  • change the dependency from web to universal_web.
  • change all package:web/web.dart imports to package:universal_web/web.dart.
14
likes
0
points
107
downloads

Publisher

verified publisherschultek.dev

Weekly Downloads

Lightweight browser API bindings built around JS interop.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

web

More

Packages that depend on universal_web