CircularProgressIndicator in flutter

.In Flutter, we can simply wrap the CircularProgressIndicator widget as a Container widget and specify the height and width of the container to increase and reduce the size of the CircularProgressIndicator of Mobile application.A simple video of  circularProgressIndecator  below mention.


Step-by-Step Implementation

Step 1: Create a New Project in Android Studio (File >new flutter project)


Step 2: Adding material package

Import method the runApp method in the main function call first while run the application.

 import 'package:flutter/material.dart';

 void main() {

     runApp(RunMyApp());

 }

Step 3: Creating a stateless widget 

We can create a stateless widget that contains MaterialApp widget,AppBar,etc.

 class RunMyApp extends StatelessWidget {

     const RunMyApp({super.key});  

    @override

    Widget build(BuildContext context) {

    return MaterialApp(home);

     }

 }

Step 4: Create a CircularProgressIndicator in main.dart file
 children: const [
SizedBox(
child: CircularProgressIndicator(),
height: 200.0,
width: 200.0,
)
]
Step 5: Final code of CircularProgressIndicator
 import 'package:flutter/material.dart';

void main() {
runApp(HomeScreen());
}
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
title: Text('Circular progress'),
backgroundColor: Colors.blue
),
body: Container(
child: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: const [
SizedBox(
height: 30,
),
SizedBox(
child: CircularProgressIndicator(),
height: 200.0,
width: 200.0,
),
SizedBox(
height: 30,
),
SizedBox(
child: CircularProgressIndicator(),
height: 130.0,
width: 130.0,
),
SizedBox(
height: 30,
),
],
),
),
),
),
);
}
}
Step 6: Output of above example 


Happy coding!

365Bloggy June 6, 2024
Share this post
Tags
SUBSCRIBE THIS FORM


Archive