flutter-universal-platform
flutter-universal-platform copied to clipboard
Mobile browser detection
With the availability of Flutter 2, it would be hugely beneficial if the package could detect if it was running within a web browser on a mobile OS. Thus allowing users to restrict usage of their web app to desktop and prompting the user to utilize the equivalent mobile app from a Store.
Is there any update on that? I have the same issue, I need to detect whether the user is in web(Desktop) or web(mobile,tablet)
I have got around this for the moment by using the platform_detect package. It exposes a touchEvents property, which equates to true when running on Safari/iOS. If Apple releases a laptop with a touchscreen, then I will need to have a rethink!
The issue is that the entire point of this plugin is that it can not access dart.io
package, which is the easy way to sniff the current operating system.
I'll consider this touchEvents "hack", don't really love it.
Any update on this?
You can check the defaultTargetPlatform property on web, it returns TargetPlatform.iOS
on web.
Everyone, I have created a package for this purpose: simple_platform
Using this package, check for AppPlatform.isWeb && (DevicePlatform.isAndroid || DevicePlatform.isIOS)
, then you know it's mobile browser. Cheers~