@@ -4,6 +4,7 @@ class _DropdownRoute<T> extends PopupRoute<_DropdownRouteResult<T>> {
44 _DropdownRoute ({
55 required this .items,
66 required this .buttonRect,
7+ required this .buttonBorderRadius,
78 required this .selectedIndex,
89 required this .isNoSelectedItem,
910 required this .onChanged,
@@ -25,6 +26,7 @@ class _DropdownRoute<T> extends PopupRoute<_DropdownRouteResult<T>> {
2526
2627 final List <DropdownItem <T >> items;
2728 final ValueNotifier <Rect ?> buttonRect;
29+ final BorderRadius ? buttonBorderRadius;
2830 final int selectedIndex;
2931 final bool isNoSelectedItem;
3032 final ValueChanged <T ?>? onChanged;
@@ -89,10 +91,11 @@ class _DropdownRoute<T> extends PopupRoute<_DropdownRouteResult<T>> {
8991 return barrierCoversButton
9092 ? routePage
9193 : _CustomModalBarrier (
92- animation: animation,
9394 barrierColor: _altBarrierColor,
95+ animation: animation,
9496 barrierCurve: barrierCurve,
9597 buttonRect: rect,
98+ buttonBorderRadius: buttonBorderRadius ?? BorderRadius .zero,
9699 child: routePage,
97100 );
98101 },
@@ -458,18 +461,20 @@ class _DropdownRouteResult<T> {
458461/// It's used instead of the route barrier when `barrierCoversButton` is set to false.
459462class _CustomModalBarrier extends StatefulWidget {
460463 const _CustomModalBarrier ({
461- this .animation ,
462- this .barrierColor ,
464+ required this .barrierColor ,
465+ required this .animation ,
463466 required this .barrierCurve,
467+ required this .buttonRect,
468+ required this .buttonBorderRadius,
464469 required this .child,
465- this .buttonRect,
466470 });
467471
468- final Animation <double >? animation;
469472 final Color ? barrierColor;
473+ final Animation <double >? animation;
470474 final Curve barrierCurve;
475+ final Rect buttonRect;
476+ final BorderRadius buttonBorderRadius;
471477 final Widget child;
472- final Rect ? buttonRect;
473478
474479 @override
475480 State <_CustomModalBarrier > createState () => _CustomModalBarrierState ();
@@ -503,8 +508,9 @@ class _CustomModalBarrierState extends State<_CustomModalBarrier> {
503508 builder: (BuildContext context, Color ? value, Widget ? child) {
504509 return CustomPaint (
505510 painter: _DropdownBarrierPainter (
506- buttonRect: widget.buttonRect,
507511 barrierColor: value,
512+ buttonRect: widget.buttonRect,
513+ buttonBorderRadius: widget.buttonBorderRadius,
508514 pageSize: size,
509515 ),
510516 );
@@ -518,29 +524,47 @@ class _CustomModalBarrierState extends State<_CustomModalBarrier> {
518524
519525class _DropdownBarrierPainter extends CustomPainter {
520526 const _DropdownBarrierPainter ({
521- this .buttonRect,
522- this .barrierColor,
527+ required this .barrierColor,
528+ required this .buttonRect,
529+ required this .buttonBorderRadius,
523530 required this .pageSize,
524531 });
525532
526- final Rect ? buttonRect;
527533 final Color ? barrierColor;
534+ final Rect buttonRect;
535+ final BorderRadius buttonBorderRadius;
528536 final Size pageSize;
529537
530538 @override
531539 void paint (Canvas canvas, Size size) {
532- if (barrierColor != null && buttonRect != null ) {
533- final Rect rect =
534- Rect .fromLTRB (- buttonRect! .left, - buttonRect! .top, pageSize.width, pageSize.height);
540+ if (barrierColor != null ) {
541+ final Rect rect = Rect .fromLTRB (
542+ - buttonRect.left,
543+ - buttonRect.top,
544+ pageSize.width,
545+ pageSize.height,
546+ );
547+
535548 canvas.saveLayer (rect, Paint ());
536549 canvas.drawRect (rect, Paint ()..color = barrierColor! );
537- canvas.drawRect (buttonRect! , Paint ()..blendMode = BlendMode .clear);
550+
551+ final RRect buttonRRect = RRect .fromRectAndCorners (
552+ buttonRect,
553+ topLeft: buttonBorderRadius.topLeft,
554+ topRight: buttonBorderRadius.topRight,
555+ bottomLeft: buttonBorderRadius.bottomLeft,
556+ bottomRight: buttonBorderRadius.bottomRight,
557+ );
558+
559+ canvas.drawRRect (buttonRRect, Paint ()..blendMode = BlendMode .clear);
538560 canvas.restore ();
539561 }
540562 }
541563
542564 @override
543565 bool shouldRepaint (_DropdownBarrierPainter oldPainter) {
544- return oldPainter.buttonRect != buttonRect || oldPainter.barrierColor != barrierColor;
566+ return oldPainter.buttonRect != buttonRect ||
567+ oldPainter.barrierColor != barrierColor ||
568+ oldPainter.buttonBorderRadius != buttonBorderRadius;
545569 }
546570}
0 commit comments