suppose we have:
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Wrap(
children: [
Row(
children: [
Text('a'),
],
),
Row(
children: [
Text('b'),
],
),
],
);
}
}
notice how each of the Row
's is taking a whole line
how can I fix this and make them side by side?
you should wrap your Row
's with FittedBox
, which will make them only consume the space they need, so your code should be like this:
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Wrap(
children: [
FittedBox(
child: Row(
children: [
Text('a'),
],
),
),
FittedBox(
child: Row(
children: [
Text('b'),
],
),
),
],
);
}
}