该Stack
小部件可以帮助您。它可以和未对齐的孩子一样大,因此如果您不希望整个形状在其中,例如,您可以使用堆栈并用鼠标区域填充边框(例如正方形):
Stack(
children: [
const SizedBox.square(dimension: 50), //Unpositioned child
//Four sides
Positioned(
left: 0,
top: 3,
bottom: 3,
child: GestureDetector(
onScaleUpdate: (details) => debugPrint(details.toString()),
child: const MouseRegion(
cursor: SystemMouseCursors.resizeLeftRight,
child: SizedBox(width: 3),
),
),
),
Positioned(
right: 0,
top: 3,
bottom: 3,
child: GestureDetector(
onScaleUpdate: (details) => debugPrint(details.toString()),
child: const MouseRegion(
cursor: SystemMouseCursors.resizeLeftRight,
child: SizedBox(width: 3),
),
),
),
Positioned(
top: 0,
right: 3,
left: 3,
child: GestureDetector(
onScaleUpdate: (details) => debugPrint(details.toString()),
child: const MouseRegion(
cursor: SystemMouseCursors.resizeUpDown,
child: SizedBox(height: 3),
),
),
),
Positioned(
bottom: 0,
right: 3,
left: 3,
child: GestureDetector(
onScaleUpdate: (details) => debugPrint(details.toString()),
child: const MouseRegion(
cursor: SystemMouseCursors.resizeUpDown,
child: SizedBox(height: 3),
),
),
),
//Four corners
Positioned(
left: 0,
top: 0,
child: GestureDetector(
onScaleUpdate: (details) => debugPrint(details.toString()),
child: const MouseRegion(
cursor: SystemMouseCursors.resizeUpLeft,
child: SizedBox.square(dimension: 3),
),
),
),
Positioned(
right: 0,
top: 0,
child: GestureDetector(
onScaleUpdate: (details) => debugPrint(details.toString()),
child: const MouseRegion(
cursor: SystemMouseCursors.resizeUpRight,
child: SizedBox.square(dimension: 3),
),
),
),
Positioned(
bottom: 0,
left: 0,
child: GestureDetector(
onScaleUpdate: (details) => debugPrint(details.toString()),
child: const MouseRegion(
cursor: SystemMouseCursors.resizeDownLeft,
child: SizedBox.square(dimension: 3),
),
),
),
Positioned(
bottom: 0,
right: 0,
child: GestureDetector(
onScaleUpdate: (details) => debugPrint(details.toString()),
child: const MouseRegion(
cursor: SystemMouseCursors.resizeDownRight,
child: SizedBox.square(dimension: 3),
),
),
),
],
)