Open bramp opened 12 months ago
I did notice, when I'm in profile, the main runApp widget get's built twice, for example:
void main() {
runApp(const _StoryBookApp());
}
class _StoryBookApp extends StatelessWidget {
Widget build(BuildContext context) {
print("build");
return Storybook(
...
)
}
}
When I do MediaQuery.of(context), the first context has a size of Zero, whereas the 2nd time it looks correct. I don't see this pattern when the DevTools are closed. Changing my code to:
Widget build(BuildContext context) {
if (MediaQuery.of(context).size.isEmpty) {
return const Placeholder();
}
return Storybook(...);
}
Seems to actually fix my problem! So ok, this makes me think, somewhere in Storybook something is being cached, and triggering this mess.
I spent a hour or two trying to debug this, but sadly I am no closer :(
When the Flutter DevTools Performance Tools are open, and I am running the storybook in Profile mode (e.g
flutter run --profile
), I get the following exception when I click on any Story:When I switch back to a debug build, or close the dev tools, the issue goes away.
Steps to repeat:
Visit the URL in your browser. Now click on a story, and the exception is thrown. The same occurs if using the DevTools via say VSCode. If you don't open the dev tools, then everything seems fine.