Giter Site home page Giter Site logo

dwikyhardi / simple_circular_progress_bar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nulllix/simple_circular_progress_bar

0.0 0.0 0.0 4.81 MB

Open source Flutter package, simple circular progress bar.

Home Page: https://pub.dev/packages/simple_circular_progress_bar

License: MIT License

Objective-C 0.06% Kotlin 0.22% Dart 93.26% Swift 0.59% HTML 5.87%

simple_circular_progress_bar's Introduction

Simple circular progress bar

Open source Flutter package, simple circular progress bar.

Getting Started

Installing

Add in pubspec.yaml:

dependencies:
  flutter:
    sdk: flutter
  simple_circular_progress_bar: ^2.0.0

Now in your code, you can import:

import 'package:simple_circular_progress_bar/simple_circular_progress_bar.dart';

Basic examples

See the full example here. Most of the examples are in the rows_in_progress_bar_example folder.

Example numbers correspond to their numbers in the code. To quickly find examples in the repository, look in the code: 'EXAMPLE CODE'.

Colors

Example 01, 02, 03

Dart code
// Example 1
SimpleCircularProgressBar(
    progressColors: const [Colors.cyan],
)

// Example 2
SimpleCircularProgressBar(
    progressColors: const [Colors.cyan, Colors.purple],
),

// Example 3
SimpleCircularProgressBar(
    progressColors: const [
        Colors.cyan,
        Colors.green,
        Colors.amberAccent,
        Colors.redAccent,
        Colors.purpleAccent
    ],
    backColor: Colors.blueGrey,
),

Start angle

Example 04, 05, 06

Dart code
// Example 4
SimpleCircularProgressBar(
    startAngle: 45,
),

// Example 5
SimpleCircularProgressBar(
    startAngle: 90,
),

// Example 6
SimpleCircularProgressBar(
    startAngle: -180,
),
ย 

Thickness of the lines

Example 07, 08, 09

Dart code
// Example 7
SimpleCircularProgressBar(
    size: 80,
    progressStrokeWidth: 25,
    backStrokeWidth: 25,
),

// Example 8
SimpleCircularProgressBar(
    progressStrokeWidth: 20,
    backStrokeWidth: 10,
),

// Example 9
SimpleCircularProgressBar(
    backStrokeWidth: 0,
),

Merge mode

Example 10, 11, 12

Dart code
// Example 10
SimpleCircularProgressBar(
    progressColors: const [Colors.cyan],
    mergeMode: true,
),

// Example 11
SimpleCircularProgressBar(
    progressColors: const [Colors.cyan],
    fullProgressColor: Colors.deepOrangeAccent,
    mergeMode: true,
),

// Example 12
SimpleCircularProgressBar(
    progressColors: const [Colors.cyan, Colors.purpleAccent],
    mergeMode: true,
),

Animation time

Example 13, 14, 15

If you don't need animation, set animationDuration = 0.

Dart code
// Example 13
SimpleCircularProgressBar(
    mergeMode: true,
    animationDuration: const Duration(milliseconds: 500),
),

// Example 14
SimpleCircularProgressBar(
    mergeMode: true,
    animationDuration: const Duration(seconds: 3),
),

// Example 15
SimpleCircularProgressBar(
    mergeMode: true,
    animationDuration: const Duration(minutes: 1),
),

Text Or Image

Example 16, 17, 18

Dart code
// Example 16
SimpleCircularProgressBar(
  valueNotifier: valueNotifier,
  mergeMode: true,
  centerChild: (double value, double maxValue) {
    TextStyle centerTextStyle = TextStyle(
      fontSize: 16,
      fontWeight: FontWeight.bold,
      color: Colors.greenAccent.withOpacity(value * 0.01),
    );

    return Row(
      children: [
        Icon(
          value == maxValue
          ? Icons.download_done
          : Icons.downloading,
          color: Colors.greenAccent.withOpacity(value * 0.01),
        ),
        const SizedBox(width: 4),
        Text(
          '${value.toInt()}%',
          style: centerTextStyle,
        ),
      ],
    );
  },
),

// Example 17
SimpleCircularProgressBar(
    valueNotifier: valueNotifier,
    mergeMode: true,
    onGetText: (double value, double maxValue) {
        return Text(
            '${value.toInt()}',
            style: const TextStyle(
                fontSize: 30,
                fontWeight: FontWeight.bold,
                color: Colors.white,
            ),
        );
    },
),

// Example 18
SimpleCircularProgressBar(
    valueNotifier: valueNotifier,
    mergeMode: true,
    onGetText: (double value, double maxValue) {
        TextStyle centerTextStyle = TextStyle(
            fontSize: 30,
            fontWeight: FontWeight.bold,
            color: Colors.greenAccent.withOpacity(value * 0.01),
        );
        
        return Text(
            '${value.toInt()}',
            style: centerTextStyle,
        );
    },
),

Value Notifier Example

Example value notifier

You can read about how ValueNotifier works here.

The source code of the example can be found here.

Parameters description

Parameter Default Description
size
double
100 Widget size.
maxValue
double
100 The maximum value of the progress bar. The values will vary from 0 to [maxValue].
startAngle
double
0 The angle from which the countdown of progress begins.
progressStrokeWidth
double
15 Thickness of the progress line.
backStrokeWidth
double
15 Line thickness of the background circle. If you don't need a background circle, set this parameter to 0.
progressColors
List
Progress bar can be either with or without a gradient. For a gradient, specify more than one color in the [progressColors] field and if a gradient is not needed specify only one color.
fullProgressColor
Color
The color of the circle at 100% value. It only works when [mergeMode] equal to true.
backColor
Color
The color of the background circle.
animationDuration
int
Duration(seconds: 6) Animation duration. If you don't need animation, set this parameter to zero Duration.
mergeMode
bool
false When this mode is enabled the progress bar with a 100% value forms a full circle with [fullProgressColor]. If no [fullProgressColor] is specified, the last color from [progressColors] is taken.
valueNotifier
ValueNotifier
The object designed to update the value of the progress bar. By default, creates a ValueNotifier with the maximum value.
onGetText
Text Function(double, double)
Callback to generate a new Text widget located in the center of the progress bar. The callback input is the current value and the maxValue of the progress bar.
centerChild
Text Function(double, double)
Widget located in the center of the progress bar. The callback input is the current value and the max value of the progress.

YouTube video

You can see how the application works from the example in this video.

simple_circular_progress_bar's People

Contributors

dwikyhardi avatar nulllix avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.