I have the following flutter code,
class ReportDisasterPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Column(
children: <Widget>[
Container(
width: double.infinity,
margin: EdgeInsets.only(top: 10),
child: FractionallySizedBox(
widthFactor: 0.7,
alignment: Alignment.center,
child: Card(
color: Colors.red.withAlpha(125),
elevation: 6,
child: Text(
'Choose Disaster Type',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 35,
fontWeight: FontWeight.w500,
color: Colors.black87,
),
),
),
),
),
Container(
child: GridView.count(crossAxisCount: 2), <---------------------------------- This line of code
),
],
),
),
);
}
}
In the above code, as soon as I added that line of code which I have pointed with an arrow, my app crashes and I can not figure out why. If I remove that line of code everything works fine. (I am running the app on a physical device in debug mode.)
On the screen of the phone I get,
"Unexpected error occurred in application. Error report is ready to send to support team. Please click accept to send error report or Cancel to dismiss report"
It would be really helpful if someone could point out to me why adding that line crashes the app and how to find a way around crashing.
Thank you.