title: Flutter: StatelessWidget.build called multiple times
body: <p>I always put code in my questions here, but this time it's not possible since the bug could be anywhere in a thousand lines of code. However:</p>
  
  <p>I noticed that the build method of my main screen (<code>StatelessWidget</code>), which is a descendant of a <code>MaterialApp</code> (home property), get's as usual called once while in debug mode but three times when in release mode.</p>
  
  <p>Under which circumstances could such a thing happen? I already tried reproducing multiple times, but failed.</p>
  
  <p>EDIT: </p>
  
  <p>The problem is that I am storing the screen size that I get from a media query as a global variable, so that I can access it from anywhere. Now I need to access that variable inside the init method of a stateful widget further down the tree. Seems to be no problem in debug mode, but in release mode the build method of the widget that makes the media query (must be inside build) weirdly gets called one time, the result of the media query being a Size(0.0, 0.0), then the init method of the widget further down the tree gets called and then the build method with the media query gets called another two times (this time with the correct screen size). The result is that I don't have he correct screen size inside the init method.</p>