Skip to content

How to know whether the screen is in standard or zoomed mode on iOS? #95421

Open

Description

@saibotma

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.

standard
zoomed

Activity

  1. darshankawar commented on Dec 17, 2021

    @darshankawar
    Member

    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.

    Keeping it open for further input from the team.

    /cc @jmagman

  2. added
    platform-iosiOS applications specifically
    frameworkflutter/packages/flutter repository. See also f: labels.
    and removed
    in triagePresently being triaged by the triage team
    on Dec 17, 2021
  3. added
    engineflutter/engine related. See also e: labels.
    on Dec 20, 2021
  4. chinmaygarde commented on Dec 20, 2021

    @chinmaygarde
    Contributor

    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.

  5. removed
    engineflutter/engine related. See also e: labels.
    on Dec 20, 2021
  6. added
    P3Issues that are less important to the Flutter project
    on Feb 9, 2022
  7. keiraperks commented on Feb 23, 2022

    @keiraperks

    @chinmaygarde which plugin we can use?

  8. jmagman commented on Feb 23, 2022

    @jmagman
    Member

    @chinmaygarde which plugin we can use?

    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.

  9. TheHypnoo commented on Jan 24, 2023

    @TheHypnoo

    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....

  10. binSaed commented on Feb 6, 2024

    @binSaed
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectd: api docsIssues with https://api.flutter.dev/frameworkflutter/packages/flutter repository. See also f: labels.platform-iosiOS applications specificallyteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions