temporal_js_polyfill library
Loads the TC39 Temporal polyfill for browsers that don't yet support it natively.
Usage — call loadTemporalPolyfill once at app startup, before any Temporal types are used:
import 'package:temporal/temporal.dart';
import 'package:temporal_js_polyfill/temporal_js_polyfill.dart';
void main() async {
await loadTemporalPolyfill(); // no-op on native and modern browsers
runApp(MyApp());
}
Cross-platform safe — on non-web (native / VM) platforms every symbol
in this library is a no-op or a trivially-true constant, so the same
main.dart works unchanged on every target.
To self-host the polyfill bundle or pin a specific version, pass a custom
URL via the src parameter of loadTemporalPolyfill.
Constants
- defaultPolyfillSrc → const String
- jsDelivr CDN URL for temporal-polyfill 1.0.1 (global / IIFE build).
- isTemporalAvailable → const bool
-
Always
trueon non-web platforms — the native Temporal implementation does not need a polyfill.
Functions
-
loadTemporalPolyfill(
{String src = defaultPolyfillSrc}) → Future< void> - No-op on non-web platforms. Returns a resolved Future immediately.
Exceptions / Errors
- TemporalPolyfillException
-
Thrown when the Temporal polyfill
<script>fails to load or execute.