Spinkit in Flutter with Example
Last Updated :
09 Nov, 2022
Spinkit is a collection of loading indicators animated with flutter. It has huge animated loading indicators which are basically used when we are loading something. Like loading an Application, video download is in progress to indicate this we're using indicators for that particular action, loading of data from the database, saving data in the database, etc. So, In this article, we will see how to Implement Spinkit. Hope you understand what are we going to do. If not following below shows what we are going to do.
Note: We are not going to show you all. We will learn How to implement Spinkit.
Example Project
Add Dependency:
dependencies:
flutter_spinkit: ^5.1.0
Note: When you read this, the version of the plugin may change.
Import the package:
import 'package:flutter_spinkit/flutter_spinkit.dart';
How to use:
It is pretty simple to use it.
const spinkit = SpinKitRotatingCircle(
color: Colors.white,
size: 50.0,
);
Create a class stateless widget MyApp. Return the MaterialApp, call the SpinHome Class on home property.
Dart
import 'package:flutter/material.dart';
import 'package:spinkit/myHome.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
home: SpinHome(),
);
}
}
Make debugShowCheckedModeBanner to false because I personally don't like it. Now we have to create the SpinHome class or stateless widget.
Dart
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
class SpinHome extends StatelessWidget {
const SpinHome({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("Spinkit flutter")),
body:
);
}
}
Return the scaffold and give the title as you want. In body property, we use the GridView widget. And use the Spinkit Widget.
Dart
GridView.count(
crossAxisSpacing: 5,
mainAxisSpacing: 3,
crossAxisCount: 3,
children: [
SpinKitChasingDots(
color: Colors.indigo,
),
SpinKitCircle(
color: Colors.amber,
),
SpinKitDancingSquare(
color: Colors.blueAccent,
),
SpinKitDoubleBounce(
color: Colors.pink,
),
SpinKitFadingGrid(
color: Colors.orange,
),
SpinKitWanderingCubes(
color: Colors.teal,
),
SpinKitHourGlass(color: Colors.lightGreenAccent),
SpinKitDualRing(
color: Colors.cyan,
),
],
),
GridView makes all the spinkit in grid view. just like your phone homepage.
Complete Example Code:
Dart
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
class SpinHome extends StatelessWidget {
const SpinHome({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("Spinkit flutter")),
body: GridView.count(
crossAxisSpacing: 5,
mainAxisSpacing: 3,
crossAxisCount: 3,
children: [
const SpinKitChasingDots(
color: Colors.indigo,
),
const SpinKitCircle(
color: Colors.amber,
),
const SpinKitDancingSquare(
color: Colors.blueAccent,
),
SpinKitDoubleBounce(
color: Colors.pink,
),
SpinKitFaddingGrid(
color: Colors.orange,
),
SpinKitWanderingCubes(
color: Colors.teal,
),
SpinKitHourGlass(color: Colors.lightGreenAccent),
SpinKitDualRing(
color: Colors.cyan,
),
],
),
);
}
}
We have huge Spinkit indicators as shown in the above video. but, In this example, we just show you How to implement them.
Output
Similar Reads
Flutter - Loading Kit Widget with Example In every android application, you have seen the loading bars, which are used when something is loading such as loading data, loading the screen, and fetching the data. The same flutter gives you a widget Flutter loading kit. We simply use the widget and use it in our project. A sample video is given
2 min read
Flutter - Create Fortune Wheel Spin Deciding what to eat can be a daily dilemma, especially when you have a plethora of options to choose from. To make this decision-making process more exciting and interactive, in this article, we will be creating â the Lunch Spinning Wheel app.Steps to Implement Fortune Wheel in FlutterStep 1: Creat
6 min read
What are Widgets Available in Flutter? Flutter is a mobile app development framework that allows developers to create beautiful and responsive user interfaces with ease. This is made possible through the use of Flutter widgets, which are the building blocks of every Flutter application. In Flutter, widgets are the fundamental building bl
4 min read
Animated Widgets in Flutter The animations are considered hard work and take time to learn. Flutter made it easy with its packages. To animate the widgets without much effort, we can wrap them inside different defined animated widgets in the animate_do package. In this article, we will see how with the animate_do package we ca
4 min read
Flutter - Slider with Gradient In this article, we will create a slide to confirm the button using the widget in Flutter. A sample video is given below to get an idea about what we are going to do in this article. Step By Step Implementation Step 1: Create a New Project in Android Studio To set up Flutter Development on Android S
3 min read
What is Widgets in Flutter? Flutter is Google's UI toolkit for crafting beautiful, natively compiled iOS and Android apps from a single code base. To build any application we start with widgets - The building block of Flutter applications. Widgets describe what their view should look like given their current configuration and
5 min read