Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix: minTextAdapt ignored by default fontSizeResolver (Added FontSizeResolvers.auto) #609

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

Open
emeleonufavour wants to merge 1 commit into OpenFlutter:master
base: master
Choose a base branch
Loading
from emeleonufavour:fix/minTextAdapt

Conversation

@emeleonufavour
Copy link

@emeleonufavour emeleonufavour commented Dec 13, 2025

Problem

I discovered that the minTextAdapt property in ScreenUtilInit is ignored in the library's current version.

This happens because ScreenUtilInit initializes with a default fontSizeResolver of FontSizeResolvers.width:

this.fontSizeResolver = FontSizeResolvers.width,

Because setSp prioritizes the resolver if it is not null, the logic delegates to setWidth. This completely bypasses the internal scaleText getter where the minTextAdapt logic is being used. Because of this, text always scales based on width, even when the user explicitly sets minTextAdapt: true.

Solution

I have introduced a new resolver method and updated the default behavior:

Added FontSizeResolvers.auto: This new static method calculates font size using instance.scaleText. This ensures that the minTextAdapt logic (which chooses the minimum between width and height scaling) is respected.

static double auto(num fontSize, ScreenUtil instance) {
 return fontSize * instance.scaleText;
}

Updated Default in ScreenUtilInit: Changed the default fontSizeResolver from .width to .auto.

Technical Note

In FontSizeResolvers.auto, I am performing the math directly (fontSize * instance.scaleText) rather than calling instance.setSp(fontSize). This is intentional to prevent an infinite recursion loop, as setSp internally calls the resolver.

Impact

  • For users with minTextAdapt: false (Default): No change in behavior. scaleText falls back to scaleWidth, so it matches the previous .width behavior.
  • For users with minTextAdapt: true: The feature will now work as intended, preventing text from becoming excessively large on wide screens (like tablets or web).

Checklist

  • The code compiles correctly.
  • Tested with minTextAdapt: true (verified text scales using the smaller factor).
  • Tested with minTextAdapt: false (verified text scales using width).

justerror and sauravgpt reacted with thumbs up emoji a1573595 reacted with eyes emoji
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /