Last active
May 22, 2018 03:46
-
-
Save vipulasri/57a4dc92956ba79ae7e69a072fd0bef8 to your computer and use it in GitHub Desktop.
Flutter: Bubble Tab Indicator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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