C. increment() does not call setState(), so UI won't update.
D. StatefulWidget cannot have state variables.
Solution
Step 1: Check how state changes update UI
In Flutter, changing state variables must be inside setState() to trigger UI rebuild.
Step 2: Identify missing setState()
increment() changes counter but does not call setState(), so UI won't refresh.
Final Answer:
increment() does not call setState(), so UI won't update. -> Option C
Quick Check:
Missing setState() means no UI update [OK]
Hint: Always wrap state changes in setState() to update UI [OK]
Common Mistakes:
Thinking counter must be final
Believing Text can't show variables
Assuming StatefulWidget can't have state
5. You have a large app with many widgets needing shared data updates. Which state management approach best helps scale the app safely and efficiently?
hard
A. Use a global variable and update it directly everywhere.
B. Use a centralized state management solution like Provider or Riverpod.
C. Avoid state management and rebuild the whole app on every change.
D. Use setState() only in each widget independently.
Solution
Step 1: Understand challenges in large apps
Large apps need shared data to update many widgets without bugs or messy code.
Step 2: Evaluate options for scaling
Global variables cause bugs; setState() alone is hard to manage; rebuilding whole app is inefficient.
Step 3: Identify best practice
Centralized state management tools like Provider or Riverpod organize shared data and updates safely.
Final Answer:
Use a centralized state management solution like Provider or Riverpod. -> Option B
Quick Check:
Centralized state management = scalable and safe [OK]
Hint: Centralize shared data with Provider or Riverpod [OK]
Common Mistakes:
Using global variables causing bugs
Relying only on setState() in many widgets
Rebuilding entire app wastes resources
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.