Search code examples
flutterdartflutter-layout

Controlling element sizes depending on screen size


Is there any way in flutter in which we can size everything in our app depending on screen size like rem property in css. Because all widgets demand sizes in pixel sizes which can be different for different screen size.


Solution

  • Because all widgets demand sizes in pixel sizes

    Actually, flutter uses density independent pixels (dp) for width/height arguments. dp actually scale with resolution, meaning 1 dp is displayed as the same PHYSICAL distance on every device.

    But for relative layout there are some options:

    1. Flexible
    2. Expanded
    3. MediaQuery
    4. LayoutBuilder
    5. GridView
    6. other layout options