Skip to content

A widget that makes it easy to have a custom painted and animated widget in Flutter

Notifications You must be signed in to change notification settings

adamfuller/custom_widget

Repository files navigation

Custom Widget v0.1.1

A CustomPainter and CustomPaint wrapper that simplifies and streamlines the process of creating unique widgets in Flutter.

How to install

Add the following to pubspec.yaml

dependencies:
  custom_widget:
    git:
      url: git://github.com/adamfuller/custom_widget.git
      ref: 0.1.1

How to use

Import the CustomWidget package

import 'package:custom_widget/custom_widget.dart' as cw;

Use CustomWidget as you would any other widget. The only major difference is its onPaint parameter.

cw.CustomWidget(
    duration: Duration(seconds: 5),
    size: Size.square(50),
    onPaint: (canvas, size, progress) {
        Paint p = Paint();
        p.color = Colors.white;
        p.strokeWidth = 5.0;
        p.style = PaintingStyle.stroke;

        Rect rect = Rect.fromCircle(center: Offset(size.width / 2, size.height / 2), radius: 10);

        canvas.drawArc(
            rect,
            2 * progress * 3.14159265,
            3.14159265 / 2,
            false,
            p,
        );
    },
)

Produces the following with a transparent background instead of a black one

About

A widget that makes it easy to have a custom painted and animated widget in Flutter

Resources

Stars

Watchers

Forks

Packages

No packages published