Import flutter_spinkit
masterTo use the loading indicators, import the package at the top of your Dart file:
import 'package:flutter_spinkit/flutter_spinkit.dart';repository·master·Indexed 25 days ago
https://github.com/jogboms/flutter_spinkitA collection of animated loading indicators for Flutter applications inspired by Tobias Ahlin's SpinKit. The library provides various widgets such as SpinKitRotatingCircle, SpinKitFadingCircle, SpinKitChasingDots, SpinKitCircle, SpinKitPianoWave, SpinKitPumpingHeart, SpinKitRing, SpinKitSpinningLines, SpinKitWaveSpinner, and SpinKitWave. Most indicators support customization of color, size, duration, and AnimationController, with some offering an itemBuilder for custom widget rendering.
To use the loading indicators, import the package at the top of your Dart file:
import 'package:flutter_spinkit/flutter_spinkit.dart';You can use various SpinKit widgets to display animated loading indicators. Most widgets accept color and size properties. Some widgets also support an itemBuilder for custom styling or a controller for manual animation control.
const spinkit = SpinKitRotatingCircle(
color: Colors.white,
size: 50.0,
);Some indicators allow you to define how individual items are built:
final spinkit = SpinKitFadingCircle(
itemBuilder: (BuildContext context, int index) {
return DecoratedBox(
decoration: BoxDecoration(
color: index.isEven ? Colors.red : Colors.green,
),
);
},
);For fine-grained control over the animation, you can provide your own AnimationController:
final spinkit = SpinKitSquareCircle(
color: Colors.white,
size: 50.0,
controller: AnimationController(vsync: this, duration: const Duration(milliseconds: 1200)),
);example/ios/Runner/Assets.xcassets/LaunchImage.imageset/ directory or use Xcode to manage the assets.Add flutter_spinkit to your pubspec.yaml dependencies to use the collection of animated loading indicators in your Flutter project.
dependencies:
flutter_spinkit: ^5.2.2If you want to use something other than simple colored boxes for the wave items, use the itemBuilder property. This allows you to return any widget for each index in the wave.
Note: When using itemBuilder, do not provide a color property, as this will trigger an assertion error.
The SpinKitWaveSpinner constructor accepts the following parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
color | Color | Required | The color of the moving arc. |
trackColor | Color | Color(0x68757575) | The color of the background track. |
waveColor | Color | Color(0x68757575) | The color of the wave effect. |
size | double | 50 | The overall size of the spinner. |
duration | Duration | Duration(milliseconds: 3000) | The duration of the animation cycle. |
curve | Curve | Curves.decelerate | The animation curve used. |
child | Widget? | null | An optional widget to display in the center. |
controller | AnimationController? | null | An optional external controller to manage the animation. |
The SpinKitWave widget displays a wave-like loading animation consisting of multiple items. You must provide either a color or an itemBuilder to define how the items look.
color (Color?): The color of the wave items. Required if itemBuilder is null.itemCount (int): The number of items in the wave. Must be at least 2. Defaults to 5.size (double): The base size of the indicator. Defaults to 50.0.type (SpinKitWaveType): Determines the direction/pattern of the wave animation. Defaults to SpinKitWaveType.start.duration (Duration): The duration of the animation cycle. Defaults to 1200 milliseconds.itemBuilder (IndexedWidgetBuilder?): A builder function to create custom widgets for each item in the wave. If provided, color is ignored.controller (AnimationController?): An optional external controller to manage the animation state.The SpinKitPianoWave widget displays a piano-wave style loading animation. You must provide either a color or an itemBuilder to define how the individual bars look.
color (Color?): The color of the bars if using the default itemBuilder.itemCount (int): The number of bars in the animation. Must be at least 2. Defaults to 5.size (double): The base size of the indicator. Defaults to 50.0.duration (Duration): The duration of the animation cycle. Defaults to 1200 milliseconds.type (SpinKitPianoWaveType): Determines the direction/pattern of the wave. Options are start, end, or center.itemBuilder (IndexedWidgetBuilder?): A builder function to create custom widgets for each bar. If provided, the color parameter is ignored.controller (AnimationController?): An optional external controller to manage the animation state.The SpinKitRing widget displays a circular loading animation. You can customize its appearance using the following parameters:
color: The color of the ring (required).lineWidth: The thickness of the ring stroke. Defaults to 7.0.size: The diameter of the indicator. Defaults to 50.0.duration: The duration of one animation cycle. Defaults to Duration(milliseconds: 1200).controller: An optional AnimationController to manage the animation manually. If provided, the widget will use your controller instead of creating its own.The SpinKitChasingDots widget provides a loading animation of chasing dots. You can customize its appearance using either a color or a custom itemBuilder to define how each dot is rendered.
Constraints:
itemBuilder or a color. You cannot leave both null.itemBuilder that is an IndexedWidgetBuilder, you should not also provide a color.Properties:
color: The color of the dots (used if itemBuilder is null).size: The total size of the widget (defaults to 50.0).itemBuilder: A builder function to customize the dots. It receives the BuildContext and the dot index (0 or 1).duration: The duration of the animation cycle (defaults to 2000 milliseconds).The SpinKitPumpingHeart widget accepts the following configuration properties:
| Property | Type | Description |
|---|---|---|
color | Color? | The color of the heart icon (used if itemBuilder is null). |
size | double | The size of the heart icon. Defaults to 50.0. |
itemBuilder | IndexedWidgetBuilder? | A builder that returns a custom widget to be animated. If provided, color is ignored. |
duration | Duration | The duration of one animation cycle. Defaults to Duration(milliseconds: 2400). |
controller | AnimationController? | An external controller to manage the animation. If provided, the widget will not create its own controller and will not dispose of it. |
The SpinKitPianoWaveType enum allows you to control the animation flow of the piano wave:
SpinKitPianoWaveType.start: Animation starts from one side.SpinKitPianoWaveType.end: Animation starts from the opposite side.SpinKitPianoWaveType.center: Animation radiates from the center.enum SpinKitPianoWaveType { start, end, center }