gesture insets fix
This commit is contained in:
parent
f16d98ba2b
commit
d5cfab6236
1 changed files with 3 additions and 10 deletions
|
@ -7,23 +7,16 @@ import 'package:provider/provider.dart';
|
|||
// - a vertically scrollable body.
|
||||
// It will prevent the body from scrolling when a user swipe from bottom to use Android Q style navigation gestures.
|
||||
class BottomGestureAreaProtector extends StatelessWidget {
|
||||
// as of Flutter v1.22.5, `systemGestureInsets` from `MediaQuery` mistakenly reports no bottom inset,
|
||||
// so we use an empirical measurement instead
|
||||
static const double systemGestureInsetsBottom = 32;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<MediaQueryData, double>(
|
||||
selector: (c, mq) => mq.effectiveBottomPadding,
|
||||
builder: (c, mqPaddingBottom, child) {
|
||||
// devices with physical navigation buttons have no bottom insets
|
||||
// we assume these devices do not use gesture navigation
|
||||
if (mqPaddingBottom == 0) return SizedBox();
|
||||
selector: (c, mq) => mq.systemGestureInsets.bottom,
|
||||
builder: (c, systemGestureBottom, child) {
|
||||
return Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
height: systemGestureInsetsBottom,
|
||||
height: systemGestureBottom,
|
||||
child: AbsorbPointer(),
|
||||
);
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue