Search code examples
flutterdartflutter-layout

How to adjust the margin of a Row Widget


I have this code for Row Widget here

child: Row(
  children: const [
    Expanded(
      flex: 1,
      child: Icon(
        Icons.house,
        size: 40,
      ),
    ),
    Expanded(
      flex: 9,
      child: Text('HELLOHELLO'),
    ),
  ],
),

This is the result. Margin on Row

As you can see on the left side there's a margin that is too big for my preference. Is there a way to adjust it?


Solution

  • The IconData comes with some default padding which is hard-coded. You can wrap Icon with Transform widget and translate it.

    Transform.translate(
      offset: Offset(-10, 0), // change based on your need
      child: Icon(
        Icons.house,
        size: 40,
      ),
    ),