📱 Flutter
Intermediate
What does FutureBuilder do in Flutter?
Answer
FutureBuilder builds its UI based on the current state of an asynchronous Future. It rebuilds whenever the Future changes state. The builder receives an AsyncSnapshot with a connectionState (none, waiting, done) and the resulting data or error. You use this to show a loading spinner while data is being fetched, an error message if it fails, and the actual UI when the data is available. Important: pass a pre-created Future or the FutureBuilder will restart the future on every rebuild.