popmenu_bg.dart 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import 'dart:ui';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/painting.dart';
  4. class PopmenuShape extends ShapeBorder{
  5. final double borderWidth;
  6. final BorderRadius borderRadius;
  7. const PopmenuShape({
  8. this.borderWidth: 1.0,this.borderRadius: BorderRadius.zero,})
  9. : assert(borderRadius != null);
  10. @override
  11. EdgeInsetsGeometry get dimensions {
  12. return new EdgeInsets.all(borderWidth);
  13. }
  14. @override
  15. ShapeBorder scale(double t) {
  16. return PopmenuShape(
  17. borderWidth: borderWidth * (t),borderRadius: borderRadius * (t),);
  18. }
  19. @override
  20. Path getInnerPath(Rect rect,{ TextDirection textDirection }) {
  21. return new Path()
  22. ..addRRect(borderRadius.resolve(textDirection).toRRect(rect).deflate(
  23. borderWidth));
  24. }
  25. @override
  26. Path getOuterPath(Rect rect,{ TextDirection textDirection }) {
  27. return new Path()
  28. ..addRRect(borderRadius.resolve(textDirection).toRRect(rect));
  29. }
  30. @override
  31. void paint(Canvas canvas,Rect rect,{ TextDirection textDirection }) {
  32. rect = rect.deflate(borderWidth / 2.0);
  33. Paint paint;
  34. final RRect borderRect = borderRadius.resolve(textDirection).toRRect(rect);
  35. paint = new Paint()
  36. ..color = Colors.white
  37. ..style = PaintingStyle.fill
  38. ..strokeWidth = borderWidth;
  39. // canvas.drawRRect(borderRect,paint);
  40. Path path = Path()..moveTo(borderRect.width - 10, borderRect.top +2 )..lineTo(borderRect.width - 20, borderRect.top - 10)..lineTo(borderRect.width - 30, borderRect.top+2);
  41. // canvas.drawShadow(
  42. // path,
  43. // Color(0xffdcdcdc),
  44. // 1,
  45. // false);
  46. canvas.drawPath(path, paint);
  47. }
  48. }