task_progress_indicator 0.0.1 copy "task_progress_indicator: ^0.0.1" to clipboard
task_progress_indicator: ^0.0.1 copied to clipboard

A customizable Flutter widget that visually tracks and displays the progress of task completion, updating dynamically as tasks are accomplished.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:task_progress_indicator/task_progress_indicator.dart';
import 'package:task_progress_indicator/task_progress.dart';
import 'package:task_progress_indicator/task_progress_indicator_model.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Task Progress Indicator Example',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Task Progress Indicator Example'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final TaskProgress _taskProgress = TaskProgress();
  late TaskProgressIndicator _progress;

  @override
  void initState() {
    super.initState();
    _loadProgress();
  }

  Future<void> _loadProgress() async {
    final saved = await _taskProgress.loadProgress();
    setState(() {
      _progress = saved ?? TaskProgressIndicator(completed: 0, total: 5);
    });
  }

  Future<void> _updateProgress(int completed) async {
    await _taskProgress.updateProgress(
      completed: completed,
      total: 5,
    );
    setState(() {
      _progress = TaskProgressIndicator(
        completed: completed,
        total: 5,
      );
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'Task Progress:',
              style: TextStyle(fontSize: 20),
            ),
            const SizedBox(height: 20),
            TaskProgressBar(
              progress: _progress,
              height: 20,
              showText: true,
              textStyle: const TextStyle(
                color: Colors.white,
                fontWeight: FontWeight.bold,
              ),
            ),
            const SizedBox(height: 20),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: [
                for (int i = 0; i <= 5; i++)
                  ElevatedButton(
                    onPressed: () => _updateProgress(i),
                    child: Text('$i/5'),
                  ),
              ],
            ),
            const SizedBox(height: 20),
            ElevatedButton(
              onPressed: () {
                _updateProgress(0);
              },
              child: const Text('Reset Progress'),
            ),
          ],
        ),
      ),
    );
  }
}
1
likes
0
points
29
downloads

Publisher

verified publisherhery.website

Weekly Downloads

A customizable Flutter widget that visually tracks and displays the progress of task completion, updating dynamically as tasks are accomplished.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

cupertino_icons, flutter, plugin_platform_interface

More

Packages that depend on task_progress_indicator