34 lines
1.1 KiB
Dart
34 lines
1.1 KiB
Dart
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
|
/* Copyright (C) 2024 Marco Groß <mgross@sw-gross.de> */
|
|
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();
|
|
}
|
|
}
|