Is there any way to dynamically expand toggle buttons to parent container width without hard coding anything. I found one answer to that which uses MediaQuery of context which only works well for full screen width. I also tried to wrap the buttons in expanded widget but that throws an error
Container(
width: 150.0, // hardcoded for testing purpose
child: ToggleButtons(
constraints:
BoxConstraints.expand(width: MediaQuery.of(context).size.width), // this doesn't work once inside container unless hard coding it
borderRadius: BorderRadius.circular(5),
children: [
ShapeToggleButton(
text: 'Option1',
),
ShapeToggleButton(
text: 'Option2',
),
],
isSelected: [true, false],
onPressed: (index) {},
),
);