Update insets when device width changes
This commit is contained in:
parent
73cf87b2b5
commit
b1f20c8b5c
|
@ -208,6 +208,9 @@ class _SwipeableState extends State<Swipeable> with TickerProviderStateMixin, Au
|
||||||
double? _minX;
|
double? _minX;
|
||||||
// Maximum global X where swipe is allowed to start
|
// Maximum global X where swipe is allowed to start
|
||||||
double? _maxX;
|
double? _maxX;
|
||||||
|
// Screen width reference that helped to compute _minX and _maxX
|
||||||
|
// used to check if insets should be updated or not
|
||||||
|
double? _widthReference;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get wantKeepAlive => _moveController.isAnimating == true;
|
bool get wantKeepAlive => _moveController.isAnimating == true;
|
||||||
|
@ -452,9 +455,10 @@ class _SwipeableState extends State<Swipeable> with TickerProviderStateMixin, Au
|
||||||
// to avoid starting a swipe in this areas
|
// to avoid starting a swipe in this areas
|
||||||
MediaQueryData? mediaQuery = MediaQuery.maybeOf(context);
|
MediaQueryData? mediaQuery = MediaQuery.maybeOf(context);
|
||||||
if (mediaQuery != null) {
|
if (mediaQuery != null) {
|
||||||
if(_minX == null || _maxX == null){
|
if(_widthReference == null || _widthReference != mediaQuery.size.width){
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
_widthReference = mediaQuery.size.width;
|
||||||
_minX = mediaQuery.systemGestureInsets.left;
|
_minX = mediaQuery.systemGestureInsets.left;
|
||||||
_maxX = mediaQuery.size.width - mediaQuery.systemGestureInsets.right;
|
_maxX = mediaQuery.size.width - mediaQuery.systemGestureInsets.right;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue