How to check if my Flutter app is running on the web?
Flutter can be used to build mobile apps for Android and iOS. Recently, they have also added the ability to target the web and desktop. I can check if my Flutter app is running on Android or iOS using the
Platform.isIOS APIs but is there a method for checking if the app is running on a web browser?
The latest stable version of Flutter at the time of this answer is Flutter 1.7 which had added some improvements to the web support but it’s still on preview i.e not yet ready for production. Some of the new features added in Flutter 1.7 is a new flag (global boolean variable) that you can check to see if an app is running on the web platform. The flag is named kIsWeb.