I get a box with a card and centered text but when I decrease the size of the window my card disappears and my text overflows. I get an overflow error when the box gets smaller than the text.
I want the smallest box dimension to be 300x300 and the largest box to be 600x600 rather than shrinking indefinitely
Maybe adding a Singlechildscrollview is the best I can get. I still think there is a way to create a shrinking card up to a certain minimum dimension
class TestConstrainedBox extends StatefulWidget {
TestConstrainedBox({Key? key}) : super(key: key);
@override
State<TestConstrainedBox> createState() => _TestConstrainedBoxState();
}
class _TestConstrainedBoxState extends State<TestConstrainedBox> {
@override
Widget build(BuildContext context) {
return Scaffold(appBar: AppBar(title:Text("Test Constrained Box")),body:
SingleChildScrollView(child:
Container(
margin: const EdgeInsets.only(top:20.0, left: 20.0, right: 20.0, bottom:10.0),
child:
SizedBox.fromSize(size: const Size(450,450),
//OverflowBox(minHeight:300,minWidth:300,
//maxWidth:300, maxHeight: 300,
child:ConstrainedBox(constraints: BoxConstraints(
minWidth:300,
minHeight:300,
maxWidth:350,
maxHeight:350,
),
child:
Card(child:
Column(mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children:[
//SizedBox(width:350, height:350, child:
Text('Hello World!')
//)
]))
))
)
)
);
}
}