I want to show an alertbox when my progress indicator reached 100%. Is there any way to do it in flutter?
@override
Widget build(BuildContext context) {
var progressValue = (100 * controller.value).toInt();
return FittedBox(
child: CircularPercentIndicator(
percent: controller.value,
animation: true,
animationDuration: 1000,
progressColor: colorProgressIndicatorProgress,
radius: widget.radius,
center: Text("$progressValue% ${widget.centerText}",
textAlign: TextAlign.center),
),
// child: CircularProgressIndicator(),
);
}
It can done listening on onChanged
like this
class ASDA extends StatefulWidget {
const ASDA({Key? key}) : super(key: key);
@override
State<ASDA> createState() => _ASDAState();
}
class _ASDAState extends State<ASDA> {
double value = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
Slider(
value: value,
onChanged: (v) {
setState(() {
value = v;
});
if (v == 1) {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text("100%"),
),
);
}
},
)
],
),
);
}
}