linear_progress_bar 1.1.2 linear_progress_bar: ^1.1.2 copied to clipboard
Flutter and Dart advanced linear progress indicator like Native Android Progress Bar
import 'package:flutter/material.dart';
import 'package:linear_progress_bar/linear_progress_bar.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int currentStep = 1;
void _incrementCounter() {
if (currentStep <= 6) {
setState(() {
currentStep++;
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.symmetric(horizontal: 40.0),
child: LinearProgressBar(
maxSteps: 6,
progressType: LinearProgressBar.progressTypeLinear,
minHeight: 16,
// Use Linear progress
currentStep: currentStep,
progressColor: Colors.red,
backgroundColor: Colors.grey,
borderRadius: BorderRadius.circular(10),
),
)
],
),
),
floatingActionButton: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
const SizedBox(height: 10),
FloatingActionButton(
onPressed: _decrementCounter,
tooltip: 'Decrement',
child: const Icon(Icons.remove),
),
const SizedBox(height: 30),
],
),
floatingActionButtonLocation: FloatingActionButtonLocation.endContained,
);
}
void _decrementCounter() {
if (currentStep > 1) {
setState(() {
currentStep--;
});
}
}
}