How can I detect if my Flutter app is running in the web?


I know that I can detect the operating system with Platform.isAndroid, Platform.isIOS, etc. but there isn’t something like Platform.isWeb so how can I detect this?


There is a global boolean kIsWeb which can tell you whether or not the app was compiled to run on the web.


import 'package:flutter/foundation.dart' show kIsWeb;

if (kIsWeb) {
  // running on the web!
} else {
  // NOT running on the web! You can check for additional platforms here.

Answered By – Westy92

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published