12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- 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);
- }
- }
|