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 below to get an idea about what we are going to do in this article.
How to Use?
FlutterLoading( isLoading: true, child: Text('Welcome Geeks'), color: Colors.green), ),
Step By Step Implementation
Step 1: Create a New Project in Android Studio
To set up Flutter Development on Android Studio please refer to Android Studio Setup for Flutter Development, and then create a new project in Android Studio please refer to Creating a Simple Application in Flutter.
Step 2: Import the material package
Adding material package that gives us the important functions and calls the runApp method in the main function that will call our application.
import 'package:flutter/material.dart'; void main() { runApp(RunMyApp()); }
Step 3: Creating Stateless Widget
Now we have to make a stateless widget because our application does not go to change its state and then return the MaterialApp widget which allows us the set the title and theme and many more.
class RunMyApp extends StatelessWidget { const RunMyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp(); } }
Step 4: Creating Scaffold Widget
Give the home property and there can be a scaffold widget that has the property of AppBar and body. AppBar allows us to give the title of AppBar, color, leading, and trailing icon.
home: Scaffold( appBar: AppBar( title: Text('Flutter Loading'), ), body: ),
Step 5: In the body, we have a Centered Flutter Loading Widget that allows setting the child, color, and Isloading. Child can any further widgets such as you can set the icon, text, and image. Color takes the material color that is set to the loading bar.
Center( child: FlutterLoading( isLoading: true, child: Text('Welcome Geeks'), color: Colors.green), ),
Final Code:
Dart
import 'package:flutter/material.dart' ; import 'package:loadingkit_flutter/loadingkit_flutter.dart' ; void main() { runApp(RunMyApp()); } class RunMyApp extends StatelessWidget { const RunMyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false , theme: ThemeData(primarySwatch: Colors.green), home: Scaffold( appBar: AppBar( title: Text( 'Flutter Loading' ), ), body: Center( child: FlutterLoading( isLoading: true , child: Text( 'Welcome Geeks' ), color: Colors.green), ), ), ); } } |
Please Login to comment...