I am getting this error in release mode only: "The following ArgumentError was thrown during performLayout(): Invalid argument(s): 0.0".
I have done some searching and got the explanation for this error here: https://github.com/flutter/flutter/issues/5259.
Issue 5259 is resolved in this way: "We should force developers to consider those cases. Otherwise we'll have to slow down app launch to ensure that the width and height are always available at startup."
However, I am new to Flutter and I am not finding any information on how developers need to consider these cases. Do I need to get the width and height of the device before my homepage loads? Do I have to delay page loading?
I had an animation which I disabled, but the error remains, so the problem seems to arise from rendering a simple gridview.
Here is some code sample:
Main:
void main() {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
.then((_) {
runApp(StatusStream(child: MyApp()));
});
}
class MyApp extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _MyAppState();
}
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(primarySwatch: Colors.blueGrey),
home: HomePage());
}
}
Homepage:
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Easy DND'),
),
body: GridView.count(
crossAxisCount: 2,
childAspectRatio: 1.0,
padding: const EdgeInsets.all(15.0),
mainAxisSpacing: 4.0,
crossAxisSpacing: 4.0,
children: <Widget>[
CardOne(),
CardTwo(),
CardThree(),
CardFour(),
],
),
);
}
}