Skip to content

Commit

Permalink
Add dot indicator class.
Browse files Browse the repository at this point in the history
  • Loading branch information
divyanshub024 committed Jun 12, 2021
1 parent 0c4cbf7 commit 4be81ec
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions lib/app/tab_bar/tab_indicator/dot_indicator.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import 'package:flutter/material.dart';

class DotIndicator extends Decoration {
const DotIndicator({
this.color = Colors.white,
this.radius = 4.0,
});

final Color color;
final double radius;

@override
BoxPainter createBoxPainter([VoidCallback? onChanged]) {
return _DotPainter(
color: color,
radius: radius,
onChange: onChanged,
);
}
}

class _DotPainter extends BoxPainter {
_DotPainter({
required this.color,
required this.radius,
VoidCallback? onChange,
}) : _paint = Paint()
..color = color
..style = PaintingStyle.fill,
super(onChange);

final Paint _paint;
final Color color;
final double radius;

@override
void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) {
assert(configuration.size != null);
final Rect rect = offset & configuration.size!;
canvas.drawCircle(
Offset(rect.bottomCenter.dx, rect.bottomCenter.dy - radius),
radius,
_paint);
}
}

0 comments on commit 4be81ec

Please sign in to comment.