Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile browser detection #11

Open
coastalgit opened this issue Mar 15, 2021 · 6 comments
Open

Mobile browser detection #11

coastalgit opened this issue Mar 15, 2021 · 6 comments

Comments

@coastalgit
Copy link

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.

@omartinma
Copy link

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)

@coastalgit
Copy link
Author

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!

@esDotDev
Copy link
Contributor

esDotDev commented May 5, 2021

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.

@polarby
Copy link

polarby commented May 17, 2023

Any update on this?

@crizant
Copy link

crizant commented Aug 3, 2023

You can check the defaultTargetPlatform property on web, it returns TargetPlatform.iOS on web.

@crizant
Copy link

crizant commented Aug 6, 2023

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~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants