I have a row with 3 items: an IconButton, a Text, and a SizedBox with a width set. The row is inside a Column with anther child which is Expanded.
I'm trying to get the IconButton to align to the TOP of the row. I thought that wrapping this inside an Align with alignment topCenter would work, but it doesnt:
I can't figure out why. Here's the code:
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: SafeArea(
child: Column(
children: [
Row(
children: [
Align(
alignment: Alignment.topCenter,
child: IconButton(onPressed: () {}, icon: Icon(Icons.arrow_back)),
),
const Expanded(child: Text("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat")),
SizedBox(
width: 80,
child: AspectRatio(
aspectRatio: 0.7,
child: Placeholder(),
),
)
],
),
const Expanded(
child: Placeholder(),
)
],
),
),
),
);
}
}
Interestingly, if I remove the outer Column, the Align works:
I'd like to understand why, and how to resolve this layout issue. Note that I don't want to set the Row crossAxisAlignment to start, because this would then misalign the SizedBox containing the Placeholder to the top instead of the center of the row.


