import 'package:flutter/cupertino.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; class FarmersTab extends Decoration { @override BoxPainter createBoxPainter([VoidCallback? onChanged]) { return _CustomBoxPainter(); } } class _CustomBoxPainter extends BoxPainter { @override void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) { ///每个Tab的宽高 Size tabSize = Size(32.w, 32.w); final Offset tabOffset = Offset(offset.dx + (((configuration.size?.width ?? 0) - 32.w) / 2), offset.dy); final Rect rect = tabOffset & tabSize; final Paint paint = Paint(); paint.color = Color(0xFFFFFFFF); paint.style = PaintingStyle.stroke; paint.strokeCap = StrokeCap.round; paint.strokeWidth = 3; ///画Tab矩形 canvas.drawArc(rect, 1, 1.2, false, paint); } }