Skip to content

Instantly share code, notes, and snippets.

@vipulasri
Last active May 22, 2018 03:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vipulasri/57a4dc92956ba79ae7e69a072fd0bef8 to your computer and use it in GitHub Desktop.
Save vipulasri/57a4dc92956ba79ae7e69a072fd0bef8 to your computer and use it in GitHub Desktop.
Flutter: Bubble Tab Indicator
import 'package:flutter/widgets.dart';
import 'package:flutter/material.dart';
class CustomTabIndicator extends Decoration {
@override
_CustomPainter createBoxPainter([VoidCallback onChanged]) {
return new _CustomPainter(this, onChanged);
}
}
class _CustomPainter extends BoxPainter {
final CustomTabIndicator decoration;
_CustomPainter(this.decoration, VoidCallback onChanged)
: assert(decoration != null),
super(onChanged);
@override
void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) {
assert(configuration != null);
assert(configuration.size != null);
//offset is the position from where the decoration should be drawn.
//configuration.size tells us about the height and width of the tab.
final Rect rect = offset & configuration.size;
final Paint paint = Paint();
paint.color = Colors.blueAccent;
paint.style = PaintingStyle.fill;
canvas.drawRRect(RRect.fromRectAndRadius(rect, Radius.circular(10.0)), paint);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment