Flutter Progress Indicators

Flutter Progress Indicators:

In this tutorial, we are going to learn some beautiful and animated progress indicator in Flutter app. for example if we charge a mobile in that it indicates some percentage the mobile is charged or if we see the network it will display network bar based on the availability of the network. In this way, these progress indicators are used in mobile app development using Flutter for both Android and IOS apps. We also noticed the when app loads then progress indicator indicates that what percentage the app is loaded.

There are different types of progress indicators, few of them are, Jumping dots, Heartbeat, Glowing, Loading, etc and also we are adding some images in this flutter progress indicators.

Adding Image to Flutter progress Indicators:

Create an asset folder in your main directory and inside this asset, folder create a images subfolder inside this subfolder you add your images.

Sample asset folder is shown in below image.

 

After adding the images to the asset folder, Now you go to your pubspec.yaml file and find the assets and uncomment it. as shown in the below image.

 

 

Below assets, you add your images ane by one with the complete path as shown in the above example image.

 

In this tutorial, we are creating all the above types of progress indicators.

Creating Progress Indicators In Flutter App:

Follow the below steps to create Progress indicators in flutter App.

Add the dependency package:

Use the below code to add dependency package to pubspec.yaml file. after adding the package run the get package method to import all the required dependencies to your Flutter app.

dependencies:
progress_indicators: ^0.1.2

Install the Package:

You can install the package from the command line using the below method.

$ flutter packages get

Importing the package:

After adding the dependency package to pubspec.yaml file, you can now import the package into your dart code. without adding the package to pubspec.yaml file if you import it will shoe package not found the error. Use the below code to import the package into your dart code. 

import 'package:progress_indicators/progress_indicators.dart';

Complete Example code for flutter Progress Indicators.

Copy and paste the below code into your main.dart  

import 'package:flutter/material.dart';
import 'package:progress_indicators/progress_indicators.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Progress Indicators',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new MyHomePage(title: 'Progress Indicators'),
);
}
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);

final String title;

@override
_MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State {
@override
Widget build(BuildContext context) {
print(Offset(0.0, -1.0).distanceSquared - Offset(0.0, 0.0).distanceSquared);
return new Scaffold(
appBar: new AppBar(
title: new Text(widget.title),
),
body: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
new Text('Jumping dots'),
JumpingDotsProgressIndicator(
fontSize: 20.0,
),
SizedBox(height: 60.0),
new Text('Heartbeat'),
SizedBox(height: 16.0),
HeartbeatProgressIndicator(
child: Icon(Icons.home),
),
SizedBox(height: 60.0),
new Text('Glowing'),
GlowingProgressIndicator(
child: Icon(Icons.home),
),
SizedBox(height: 32.0),
FadingText('Loading...'),
SizedBox(height: 32.0),
JumpingText('Loading...'),
SizedBox(height: 32.0),
ScalingText('Loading...'),
SizedBox(height: 32.0),
CollectionSlideTransition(
children: [
Icon(Icons.android),
Icon(Icons.apps),
Icon(Icons.announcement),
],
),
SizedBox(height: 32.0),
CollectionScaleTransition(
children: [
Icon(Icons.android),
Icon(Icons.apps),
Icon(Icons.announcement),
],
),
],
),
),
);
}
}

Congratulations You Have Learned Creating Progress Indicators In Flutter App….!!!

If It Is Helpful Share It With Your Friends….!!! 

Leave a Reply

Categories