This issue occurred the first time I ran my app today. After some testing I found that the methods I call in the Widget build section only run once on the intital build or hot reload. Previously, these methods would constantly be running. For example, if I printed an integer with the value of 5 in one of the methods, the console would display:
I/flutter ( 510): 5
I/flutter ( 510): 5
I/flutter ( 510): 5
I/flutter ( 510): 5
I/flutter ( 510): 5
etc...
Now the console only prints the integer once (Until I hot reload):
I/flutter ( 510): 5
- Even with an async method it will only print once to the console.
- The same situation applies to error messages.
- It only appears to be broken on the main page.
- This issue occurs on my other apps as well.
- I have ran flutter clean in the console.
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel unknown, v1.12.13+hotfix.4, on Microsoft Windows [Version 10.0.18363.778], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
[√] Android Studio (version 3.4)
[√] VS Code (version 1.44.2)
[√] Connected device (1 available)
• No issues found!
My question would be if I was implementing code like this correctly in the first place? Is there another way I should be doing this, or is flutter broken?
Thanks, I appreciate the help!
@override
Widget build(BuildContext context) {
// This code only runs once on the inital build
createDay();
getSaveContent();
_updatePointsProgress();
printStuff();
return MaterialApp(
home: Builder(