Home > Software design >  Padding inside Expanded also effect outside it (Flutter)
Padding inside Expanded also effect outside it (Flutter)

Time:11-11

I have top & bottom text.

I want to add padding for top text, but Padding applied for bottom text too.

Why does it happen?

enter image description here

return Scaffold(
      body: SafeArea(
        child: Column(
          children: [
            Expanded(
              child: Padding(
                padding: const EdgeInsets.symmetric(
                  vertical: 30.0,
                  horizontal: 80.0,
                ),
                child: Column(
                  children: [
                    Text('Top text'),
                  ],
                ),
              ),
            ),
            Text('Footer text'),
          ],
        ),
      ),
    );

CodePudding user response:

add crossAxisAlignment : CrossAxisAlignment.start for the column widget. By default it aligns to the center.

  • Related