Skip to content

How kIsWeb works in Flutter

Do you know how kIsWeb is implemented in Flutter?

Here it is:

const bool kIsWeb = identical(0, 0.0);

Explanation:

  • on web, Dart’s doubles and ints are backed by the same kind of object (JS doesn’t support integers)
  • on the Dart VM, doubles and ints are different


Here’s the official documentation:

Previous Next
Explicit error types with Either The HtmlUnescape package

Last update: 18 septembre 2023
Created: 18 septembre 2023