customizable_counter 1.0.4

SDKflutter
Platformandroidioswindowslinuxmacosweb

a counter widget that support different kinds of customization.

Customizable Counter

A counter widget that support different kinds of customization.

Sample Customizable Counter

Installation

From pubspec.yaml

Add the following line to pubspec.yaml:

dependencies:
  customizable_counter: <last-release>

and

flutter pub get

From cli

run following command:

flutter pub add customizable_counter

Basic setup

Complete example available here.

@override
Widget build(BuildContext context) =>
    CustomizableCounter(
      borderColor: Colors.yellow,
      borderWidth: 5,
      borderRadius: 100,
      backgroundColor: Colors.amberAccent,
      buttonText: "Add Item",
      textColor: Colors.white,
      textSize: 22,
      count: 0,
      step: 1,
      minCount: 0,
      maxCount: 10,
      incrementIcon: const Icon(
        Icons.add,
        color: Colors.white,
      ),
      decrementIcon: const Icon(
        Icons.remove,
        color: Colors.white,
      ),
      onCountChange: (count) {

      },
      onIncrement: (count) {

      },
      onDecrement: (count) {

      },
    );

Parameters

In order to customize the widget ui there are several attributes that are supported by this package:

AttributeTypeDefaultRequiredDescription
borderColorColornullNocolor of widget border
borderWidthdoublenullNowidth of widget border
borderRadiusdoublenullNoradius of widget border
backgroundColorColornullNocolor of widget background
buttonTextStringnullNotext that will shown on widget if counter value is zero.
textColorColornullNobutton title and counter text color
textSizedoublenullNobutton title and counter text size
decrementIconWidgetnullNoicon widget that will be shown on left side and by clicking this widget the counter value will de decreased.
incrementIconWidgetnullNoicon widget that will be shown on right side and by clicking this widget the counter value will de increased.
countdouble0Nothe current value of the counter.
maxCountdoubledouble.maxFiniteNothe maximum value support for counter
minCountdouble0Nothe minimum value support for counter
stepdouble1Noamount increased or decreased after clicking buttons.
showButtonTextbooltrueNodoes shown button text when counter value is zero.
onCountChangeFunction(double c)nullNocalled when the counter value change by clicking button.
onIncrementFunction(double c)nullNocalled when the counter value increment by clicking Increment button.
onCountChangeFunction(double c)nullNocalled when the counter value decrement by clicking Decrement button.