When your app needs to load data, users often have to wait. How you handle this waiting time can make a big difference in how they feel about your app.
Option 1: Use a Basic Progress Indicator
The simplest way is to show a spinner or a loading bar. Flutter provides built-in widgets for this.
Built-in Widgets
You can use widgets like CircularProgressIndicator.adaptive()
. This widget automatically picks the right style for the platform (iOS or Android).
// Creates an indicator that is a
// [CupertinoActivityIndicator] in iOS
// [CircularProgressIndicator] in others
CircularProgressIndicator.adaptive();
Other Packages
If you want more variety or fancier animations, you can explore packages like:
- sleek_circular_slider: For customizable circular sliders.
- flutter_spinkit: Offers many different kinds of loading animations.
Option 2: Use a Skeleton Animation
A more modern approach is to show a 'skeleton' version of the content that is about to load.
What is a Skeleton Animation?
Instead of just a spinner, you show grey blocks that look like the layout of the page (where text, images, etc., will go). This gives the user an idea of what's coming.
Why Use Skeleton Animations?
They make the waiting time feel shorter. When compared to a blank screen with a spinner, users perceive skeleton screens as loading faster, even if the actual load time is the same.
Recommended Package
A popular package for creating skeleton screens is:
- better_skeleton: Makes it easier to build these loading states.
Choosing the right loading indicator helps improve the user experience while your app fetches data.