radial_progress 0.1.0 copy "radial_progress: ^0.1.0" to clipboard
radial_progress: ^0.1.0 copied to clipboard

A Flutter library for displaying progress as a circle chart with the ability to dynamize the percentage of progress and personalization

example/radial_progress_example.dart

import 'package:flutter/material.dart';
import 'package:radial_progress/radial_progress.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Radial Progress Demo',
      theme: ThemeData(
        primarySwatch: Colors.cyan,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

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

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Radial Progress Demo'),
        centerTitle: true,
      ),
      body: SafeArea(
        child: Column(
          children: [
            const SizedBox(height: 24),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: [
                const RadialSample1(),
                RadialProgressWidget(
                  percent: 0.73,
                  diameter: 85,
                  progressLineWidth: 40,
                  startAngle: StartAngle.bottom,
                  enableAnimation: true,
                  animationDuration: const Duration(seconds: 2),
                  centerChild: const Text(
                    '-',
                    maxLines: 1,
                    style: TextStyle(
                      fontSize: 28,
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                ),
              ],
            ),
            const SizedBox(height: 24),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: [
                RadialProgressWidget(
                  percent: 0.23,
                  diameter: 100,
                  progressLineWidth: 24,
                  startAngle: StartAngle.start,
                  enableAnimation: true,
                  animationDuration: const Duration(seconds: 2),
                  progressLineColors: const [
                    Colors.lightBlueAccent,
                    Colors.lightBlue,
                    Colors.blue,
                  ],
                  centerChild: const Text(
                    '23 %',
                    maxLines: 1,
                    style: TextStyle(
                      fontSize: 22,
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                ),
                RadialProgressWidget(
                  percent: 0.73,
                  diameter: 95,
                  progressLineWidth: 12,
                  startAngle: StartAngle.end,
                  enableAnimation: true,
                  animationDuration: const Duration(seconds: 2),
                  centerChild: Container(),
                ),
              ],
            ),
            const SizedBox(height: 24),
            const Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                RadialSample2(),
              ],
            ),
          ],
        ),
      ),
    );
  }
}

// sample widget 1
class RadialSample1 extends StatefulWidget {
  const RadialSample1({super.key});

  @override
  State<RadialSample1> createState() => _RadialSample1State();
}

class _RadialSample1State extends State<RadialSample1> {
  double _value = 0.0;

  @override
  Widget build(BuildContext context) {
    return RadialProgressWidget(
      percent: 0.92,
      diameter: 185,
      progressLineWidth: 32,
      startAngle: StartAngle.top,
      enableAnimation: true,
      animationDuration: const Duration(seconds: 4),
      progressLineColors: const [
        Colors.purple,
        Colors.purpleAccent,
        Colors.red,
        Colors.orange,
        Colors.yellow,
        Colors.lightGreenAccent,
        Colors.lightGreen,
        Colors.green,
      ],
      centerChild: Text(
        '${(_value * 100).toInt()} %',
        maxLines: 1,
        style: const TextStyle(
          fontSize: 28,
          fontWeight: FontWeight.bold,
        ),
      ),
      callback: (value) {
        setState(() {
          _value = value;
        });
      },
    );
  }
}

// sample widget 2
class RadialSample2 extends StatefulWidget {
  const RadialSample2({super.key});

  @override
  State<RadialSample2> createState() => _RadialSample2State();
}

class _RadialSample2State extends State<RadialSample2> {
  double _value = 0.0;

  @override
  Widget build(BuildContext context) {
    return RadialProgressWidget(
      percent: 0.57,
      diameter: 300,
      progressLineWidth: 24,
      startAngle: StartAngle.top,
      enableAnimation: true,
      animationDuration: const Duration(seconds: 5),
      progressLineColors: [
        Colors.grey.shade600,
      ],
      centerChild: Text(
        (_value < 0.2)
            ? 'line 1\nsome description in line 2\nor each widget\n${(_value * 100).toInt()} %'
            : (_value < 0.3)
                ? '🙂'
                : (_value < 0.3)
                    ? '🙃'
                    : (_value < 0.4)
                        ? '😉'
                        : (_value < 0.5)
                            ? '😌'
                            : '🤩',
        textAlign: TextAlign.center,
        style: TextStyle(
          fontSize: (_value < 0.2) ? 20 : 100,
          fontWeight: FontWeight.bold,
        ),
      ),
      callback: (value) {
        setState(() {
          _value = value;
        });
      },
    );
  }
}
9
likes
150
points
145
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter library for displaying progress as a circle chart with the ability to dynamize the percentage of progress and personalization

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on radial_progress