Use Stack() and have a container that will fill the entire screen behind your reaction bar. Use GestureDetector to detect the tap on that container.
Stack(
children: [
GestureDetector(
onTap: () {
print("tapped outside");
},
child: Container(color: Colors.red),
),
// put your reaction bar here
],
),
Another solution to allow user to click or drag on objects outside the reaction bar:
Widget build(BuildContext context) {
return Scaffold(
body: GestureDetector(
onTapDown: (_details) {
Rect tapRect = Rect.fromCircle(
center: Offset(
_details.globalPosition.dx, _details.globalPosition.dy),
radius: 1);
RenderBox reactionBox =
_keyReactionBar.currentContext?.findRenderObject() as RenderBox;
final reactionBottomRight = Offset(
reactionBox.localToGlobal(Offset.zero).dx + reactionBox.size.width,
reactionBox.localToGlobal(Offset.zero).dy + reactionBox.size.height,
);
print(reactionBottomRight);
Rect reactionRect = Rect.fromPoints(
reactionBox.localToGlobal(Offset.zero), reactionBottomRight);
if (!reactionRect.overlaps(tapRect)) {
print("tapped outside reactionsBar");
}
},
child: Column(
children: [
GestureDetector(
onTap: () {
print("hello");
},
child: SizedBox(
width: 200,
height: 200,
child: Container(
color: Colors.red,
),
),
),
GestureDetector(
onTap: () {
print("tapped on reactionsBar");
},
child: SizedBox(
key: _keyReactionBar,
width: 200,
height: 200,
child: Container(
color: Colors.blue,
),
),
)
],
),
),
);
}
I'm wrapping the entire screen/body with GestureDetector and used onTapDown to get where the tap has been happened. Then, I will check if it is within the area of reaction bar or not.