Reputation: 3051
I am trying to have 2 rows
inside my snackbar
and for this I put it inside one column
. and the result is that of the gif.
How can I make it the default height of the snackbar? I don't want the column to continue to fill the entire screen
SnackBar(
backgroundColor: _color,
content: Container(
child: Column(
children: <Widget>[
Row(children: <Widget>[_icon]),
Row(children: <Widget>[
SizedBox(width: 10),
]),
Row(children: <Widget>[
Text(_accion_toast + ". " + mensaje),
]),
]),
),
duration: Duration(milliseconds: 1500),
);
How can I do it?
Upvotes: 2
Views: 924
Reputation: 3563
You can specify how the column should allocate the size to the children with its mainAxisSize
property.
You can pass the value MainAxisSize.min
to use only the space needed.
Check the docs here: https://api.flutter.dev/flutter/widgets/Column-class.html And https://api.flutter.dev/flutter/rendering/MainAxisSize-class.html
Upvotes: 3
Reputation: 267554
As I mentioned in comment, by default Column
takes up the entire available space, so if you want to restrict it to the minimum, you need to set
Column(
mainAxisSize: MainAxisSize.min // this property
children: [],
)
Upvotes: 0
Reputation: 27137
You have to mainAxisSize property to reduce size as below.
Column(mainAxisSize: MainAxisSize.min, children: <Widget>[
Upvotes: 0