import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:flutter/painting.dart'; class PopmenuShape extends ShapeBorder { final double borderWidth; final BorderRadius borderRadius; final Color backgroundColor; const PopmenuShape({ this.borderWidth: 1.0, this.borderRadius: BorderRadius.zero, this.backgroundColor: Colors.white, }) : assert(borderRadius != null); @override EdgeInsetsGeometry get dimensions { return new EdgeInsets.all(borderWidth); } @override ShapeBorder scale(double t) { return PopmenuShape( borderWidth: borderWidth * (t), borderRadius: borderRadius * (t), ); } @override Path getInnerPath(Rect rect, {TextDirection? textDirection}) { return new Path() ..addRRect(borderRadius .resolve(textDirection) .toRRect(rect) .deflate(borderWidth)); } @override Path getOuterPath(Rect rect, {TextDirection? textDirection}) { return new Path() ..addRRect(borderRadius.resolve(textDirection).toRRect(rect)); } @override void paint(Canvas canvas, Rect rect, {TextDirection? textDirection}) { rect = rect.deflate(borderWidth / 2.0); final RRect borderRect = borderRadius.resolve(textDirection).toRRect(rect); Paint paint = new Paint() ..color = backgroundColor ..style = PaintingStyle.fill ..strokeWidth = borderWidth; // canvas.drawRRect(borderRect,paint); Path path = Path() ..moveTo(borderRect.width - 10, borderRect.top) ..lineTo(borderRect.width - 20, borderRect.top - 10) ..lineTo(borderRect.width - 30, borderRect.top); // path.addRRect(borderRect); // canvas.drawShadow( // path, // Color(0xffdcdcdc), // 1, // false); canvas.drawPath(path, paint); } }