pin_code_fields icon indicating copy to clipboard operation
pin_code_fields copied to clipboard

Expose textScaler

Open jakobleck opened this issue 1 year ago • 2 comments

Accessibility text sizes in system settings are currently not really supported by PinCodeTextField: The field does not resize to accommodate very large text, which is thus clipped. Currently a workaround for this was to set fontSize in the textStyle to the intended font size (20.0, usually) divided by the textScaleFactor, such that fontSize * textScaleFactor would yield 20.0. With the introduction of TextScaler and deprecation of textScaleFactor in the latest Flutter versions this is no longer a viable solution. (In mathematical terms: The mentioned workaround uses the multiplicative inverse of textScaleFactor, while with the potentially nonlinear textScaler an inverse is difficult to find and not guaranteed to exist.)

Thus, expose textScaler of the PinCodeTextField to allow setting it to TextScaler.noScaling. (This PR does not include a scaling for the validator as I'm not sure how to do this and do not need it.)

To test, just add

                    textScaler: TextScaler.noScaling,
                    hintCharacter: "1",

in the PinCodeTextField of the example app and run on a device where in system settings you set font size to the maximum (preferrably iOS, which allows more radical sizes than Android, at least on the devices I tested). Tested with Flutter 3.16.0.

P.S.: You may need to upgrade deployment targets or Gradle version for the example app.

jakobleck avatar Dec 11 '23 17:12 jakobleck

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Feb 10 '24 06:02 stale[bot]

activity

jakobleck avatar Feb 12 '24 06:02 jakobleck

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 13 '24 04:04 stale[bot]

activity

jakobleck avatar Apr 13 '24 06:04 jakobleck