Flutter row place one item at start and other item in the middle
You could use the Spacer widget to fill available space in the row:
void main() => runApp(App());
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: SpacedRow(),
),
),
),
);
}
}
class SpacedRow extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Row(
children: <Widget>[
Container(width: 50, height: 50, color: Colors.red),
Spacer(),
Container(width: 50, height: 50, color: Colors.yellow),
Spacer(),
],
);
}
}
Produces:
Though Jordan's answer achieved what the question mentioned, the yellow block does not look exactly center. I tried something like following
Stack(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Image.asset(
"images/toolbar_logo.webp",
width: 80,
height: 50,
),
],
),
IconButton(
icon: Icon(Icons.navigation),
onPressed: () {},
iconSize: 20,
),
],
),