My code initially looked like this:

final constrainedTextScaleFactor = 
    mediaQueryData.textScaleFactor.clamp(1, 1.5);

The problem?

This is the type signature of clamp():

num clamp(num lowerLimit, num upperLimit);

I had assumed that clamp just works with doubles or ints.

So if the system textScaleFactor was less than 1.0, the clamp method returned 1 - which is an integer. And MediaQueryData requires it to be a double.

That silly bug meant that a lot of users weren't able to do anything with the app - it just crashed.

Replying to iiro on ""

Go ahead and write your reply below!

GitHub-flavored Markdown & a sane subset of HTML is supported.