32 lines
1.0 KiB
Dart
32 lines
1.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class RectangularNotchShape extends NotchedShape {
|
|
const RectangularNotchShape();
|
|
|
|
@override
|
|
Path getOuterPath(Rect host, Rect? guest) {
|
|
if (guest == null || !host.overlaps(guest)) {
|
|
return Path()..addRect(host);
|
|
}
|
|
|
|
var margin = 20;
|
|
|
|
return Path()
|
|
..moveTo(host.left, host.top)
|
|
..lineTo(guest.left - margin, host.top)
|
|
..quadraticBezierTo(guest.left, host.top, guest.left, host.top + margin)
|
|
..lineTo(guest.left, guest.bottom - margin)
|
|
..quadraticBezierTo(
|
|
guest.left, guest.bottom, guest.left + margin, guest.bottom)
|
|
..lineTo(guest.right - margin, guest.bottom)
|
|
..quadraticBezierTo(
|
|
guest.right, guest.bottom, guest.right, guest.bottom - margin)
|
|
..lineTo(guest.right, host.top + margin)
|
|
..quadraticBezierTo(guest.right, host.top, guest.right + margin, host.top)
|
|
..lineTo(host.right, host.top)
|
|
..lineTo(host.right, host.bottom)
|
|
..lineTo(host.left, host.bottom)
|
|
..close();
|
|
}
|
|
}
|