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

后端 未结 2 689
遇见更好的自我
遇见更好的自我 2021-02-03 18:10

I know that I can detect the operating system with Platform.isAndroid, Platform.isIOS, etc. but there isn\'t something like Platform.isWeb

2条回答
  •  猫巷女王i
    2021-02-03 18:19

    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"); }
    

提交回复
热议问题