Last active
March 26, 2020 17:46
-
-
Save dirisujesse/66e67e8b7eb6b68e1ccf45e3caf62fb2 to your computer and use it in GitHub Desktop.
Responsive font scaling strategy for flutter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/widgets.dart' show BuildContext, MediaQuery; | |
class FontSizer { | |
num _shortestSide; | |
FontSizer(BuildContext context) { | |
_shortestSide = MediaQuery.of(context).size.shortestSide; | |
} | |
num sp(double percentage) { | |
return ((_shortestSide) * (percentage / 1000)).ceil().toDouble(); | |
} | |
} |
Yep
😱
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The 1000 is a magic number?