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?
Flutter's web support delivers the same experiences on the web as on mobile. Building on the portability of Dart, the power of the web platform and the flexibility of the Flutter framework, you can now build apps for iOS, Android, and the browser from the same codebase.
There is a global boolean kIsWeb
which can tell you whether or not the app was compiled to run on the web.
Documentation: https://api.flutter.dev/flutter/foundation/kIsWeb-constant.html
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. }
There is a code written Below to get OS/web where flutter is running...
if(kIsWeb) return Text("It's web"); else if(Platform.isAndroid){ return Text("it's Android"); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With