Issue
I'm developing an online course app in flutter, and I need to code a progress bar depend on students completion of course, how do I do that in flutter?
Solution
This is a very broad question. Concretely, you can use a LinearProgressIndicator
to show the progress. Store the progress inside the State
of the overarching widget, and update it after a part is completed, which should update the progress bar accordingly.
https://api.flutter.dev/flutter/material/LinearProgressIndicator-class.html
You can then imagine something like this:
// In a stateful widget
double progress = 0.0;
Widget build(BuildContext context) {
return Column(children: [
LinearProgressIndicator(progress: progress),
Expanded(
child: MyCourseView(onMadeProgress: (newProgress) {
// Using setState ensures this widget rebuilds
setState(() => progress = newProgress);
}),
),
]);
}
Answered By - fravolt
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.