You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to know whether the screen is in standard or zoomed mode on iOS? #95421
On iOS, it is possible to put the screen into a zoomed mode. In this mode, all UI elements get scaled up. Also, the Flutter view scales accordingly.
I wonder whether it is possible to get the current zoom mode (standard or zoomed) of the device in Flutter? MediaQuery.of(context).devicePixelRatio always returns 2.0 on my iOS device, unfortunately.
Knowing the zoom mode would be great for stopping some UI elements from getting too big.
For example, the back button on iOS always keeps the same gap between the arrow and the text. However, without knowledge of the zoom mode in Flutter, it is impossible to reimplement this.
I tried to look at any documentation or reference to identify standard vs zoom mode, but couldn't find any, so not sure if there's an actual way to find this out. MediaQuery.of(context).devicePixelRatio does return 2.0 for both modes.
MediaQuery.of(context).devicePixelRatio reports the displays pixel ratio which shouldn't change based on a user preference. From a cursory search of UIKit APIs, [UIScreen mainScreen].nativeScale is the API that would respond to how zoomed in the screen is.
This can be done using a plugin today. Maybe the framework should decide if this needs to be exposed as a built in API.
There may already be a plugin that does this (we don't keep track of all the plugins that exist on pub), but if not you can write your own. It should be pretty trivial if it's just calling one native API.
It would be interesting to see if there is any existing plugin about it, if not, visualize if there is a native IOS API to modify it properly and make a plugin, if someone is up for it....
Activity
darshankawar commentedon Dec 17, 2021
I tried to look at any documentation or reference to identify standard vs zoom mode, but couldn't find any, so not sure if there's an actual way to find this out.
MediaQuery.of(context).devicePixelRatiodoes return 2.0 for both modes.Keeping it open for further input from the team.
/cc @jmagman
chinmaygarde commentedon Dec 20, 2021
MediaQuery.of(context).devicePixelRatioreports the displays pixel ratio which shouldn't change based on a user preference. From a cursory search of UIKit APIs,[UIScreen mainScreen].nativeScaleis the API that would respond to how zoomed in the screen is.This can be done using a plugin today. Maybe the framework should decide if this needs to be exposed as a built in API.
keiraperks commentedon Feb 23, 2022
@chinmaygarde which plugin we can use?
jmagman commentedon Feb 23, 2022
There may already be a plugin that does this (we don't keep track of all the plugins that exist on pub), but if not you can write your own. It should be pretty trivial if it's just calling one native API.
https://github.com/fluttercommunity/plus_plugins/tree/main/packages/device_info_plus/device_info_plus is probably a good example.
https://github.com/fluttercommunity/plus_plugins/blob/main/packages/device_info_plus/device_info_plus/ios/Classes/FLTDeviceInfoPlusPlugin.m#L18
If you run into issues, please check stackoverflow, let's keep this issue focused on potentially exposing this in the Flutter framework.
TheHypnoo commentedon Jan 24, 2023
It would be interesting to see if there is any existing plugin about it, if not, visualize if there is a native IOS API to modify it properly and make a plugin, if someone is up for it....
binSaed commentedon Feb 6, 2024
@TheHypnoo @keiraperks @saibotma
try this plugin
https://pub.dev/packages/flutter_zoom_checker