Deborah Deborah - 1 year ago 146
Dart Question

flutter.io (dart) - set padding as a percentage of device width?

How can I set padding as a percentage of screen width in Flutter?

The problem I'm trying to solve, I initially tried to solve with AspectRatio and FractionallySizedBox, as well as different attempts with Row and Columns, but the parent is a Positioned widget with a child image. Nothing worked.

Answer Source

Use MediaQuery by doing MediaQuery.of(context).size.width to get the screen width

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download