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.
|
// - a vertically scrollable body.
|
||||||
// It will prevent the body from scrolling when a user swipe from bottom to use Android Q style navigation gestures.
|
// It will prevent the body from scrolling when a user swipe from bottom to use Android Q style navigation gestures.
|
||||||
class BottomGestureAreaProtector extends StatelessWidget {
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Selector<MediaQueryData, double>(
|
return Selector<MediaQueryData, double>(
|
||||||
selector: (c, mq) => mq.effectiveBottomPadding,
|
selector: (c, mq) => mq.systemGestureInsets.bottom,
|
||||||
builder: (c, mqPaddingBottom, child) {
|
builder: (c, systemGestureBottom, child) {
|
||||||
// devices with physical navigation buttons have no bottom insets
|
|
||||||
// we assume these devices do not use gesture navigation
|
|
||||||
if (mqPaddingBottom == 0) return SizedBox();
|
|
||||||
return Positioned(
|
return Positioned(
|
||||||
left: 0,
|
left: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
height: systemGestureInsetsBottom,
|
height: systemGestureBottom,
|
||||||
child: AbsorbPointer(),
|
child: AbsorbPointer(),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue