简体   繁体   中英

How to change textsize and widget size according to screen in flutter?

How to change textsize , widgetsize , padding according to screen size?

1st Screen :

screenHeight:640.0
screenWidth:360.0
PixelRatio:2.0
TextScaleFactor:1.0

2nd Screen :

screenHeight:912.0
screenWidth:540.0
PixelRatio:2.0
ScaleFactor:1.0

Rather using hard coded values, you can use MediaQuery to get the screen size and according to that, you can adjust your widget's height, width. In most cases hard coded values may throw an error due to different screen sizes of different devices.

For your screen to be of specific height, wrap it in a widget that has size properties, like

Container(height: YOUR_HEIGHT, width: YOUR_WIDTH, child: HOME())

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM