From ba3193d6bedb020ac3527fc8d5c821d36551ac3e Mon Sep 17 00:00:00 2001 From: Zeeshan Ahmad <50322893+zeeshanahmad0201@users.noreply.github.com> Date: Wed, 20 Nov 2024 17:19:24 +0500 Subject: [PATCH 1/2] Update circular_notched_and_cornered_shape.dart --- lib/src/circular_notched_and_cornered_shape.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/circular_notched_and_cornered_shape.dart b/lib/src/circular_notched_and_cornered_shape.dart index f5f3806..8797c81 100644 --- a/lib/src/circular_notched_and_cornered_shape.dart +++ b/lib/src/circular_notched_and_cornered_shape.dart @@ -68,14 +68,14 @@ class CircularNotchedAndCorneredRectangle extends NotchedShape { final halfOfHostWidth = host.width ~/ 2; if (guestCenterDx == halfOfHostWidth) { - if (gapLocation == GapLocation.end) + if (gapLocation != GapLocation.center) throw GapLocationException( 'Wrong gap location in $AnimatedBottomNavigationBar towards FloatingActionButtonLocation => ' 'consider use ${GapLocation.center} instead of $gapLocation or change FloatingActionButtonLocation'); } if (guestCenterDx != halfOfHostWidth) { - if (gapLocation == GapLocation.center) + if (gapLocation != GapLocation.end) throw GapLocationException( 'Wrong gap location in $AnimatedBottomNavigationBar towards FloatingActionButtonLocation => ' 'consider use ${GapLocation.end} instead of $gapLocation or change FloatingActionButtonLocation'); From 2513945ce26ff737aa35b26709dcb75bea06117d Mon Sep 17 00:00:00 2001 From: Zeeshan Ahmad <50322893+zeeshanahmad0201@users.noreply.github.com> Date: Wed, 20 Nov 2024 17:38:56 +0500 Subject: [PATCH 2/2] Update circular_notched_and_cornered_shape.dart --- .../circular_notched_and_cornered_shape.dart | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/src/circular_notched_and_cornered_shape.dart b/lib/src/circular_notched_and_cornered_shape.dart index 8797c81..c37d689 100644 --- a/lib/src/circular_notched_and_cornered_shape.dart +++ b/lib/src/circular_notched_and_cornered_shape.dart @@ -63,22 +63,26 @@ class CircularNotchedAndCorneredRectangle extends NotchedShape { } return Path()..addRect(host); } - - final guestCenterDx = guest.center.dx.toInt(); - final halfOfHostWidth = host.width ~/ 2; - - if (guestCenterDx == halfOfHostWidth) { - if (gapLocation != GapLocation.center) - throw GapLocationException( - 'Wrong gap location in $AnimatedBottomNavigationBar towards FloatingActionButtonLocation => ' - 'consider use ${GapLocation.center} instead of $gapLocation or change FloatingActionButtonLocation'); + + final guestCenterDx = guest.center.dx; + final halfOfHostWidth = host.width / 2; + + final threshold = host.width * 0.1; // 10% tolerance + final distanceFromCenter = (guestCenterDx - halfOfHostWidth).abs(); + final isNearCenter = distanceFromCenter <= threshold; + + if (isNearCenter && gapLocation != GapLocation.center) { + throw GapLocationException( + 'Wrong gap location in $AnimatedBottomNavigationBar towards FloatingActionButtonLocation => ' + 'consider use ${GapLocation.center} instead of $gapLocation or change FloatingActionButtonLocation' + ); } - if (guestCenterDx != halfOfHostWidth) { - if (gapLocation != GapLocation.end) - throw GapLocationException( - 'Wrong gap location in $AnimatedBottomNavigationBar towards FloatingActionButtonLocation => ' - 'consider use ${GapLocation.end} instead of $gapLocation or change FloatingActionButtonLocation'); + if (!isNearCenter && gapLocation != GapLocation.end) { + throw GapLocationException( + 'Wrong gap location in $AnimatedBottomNavigationBar towards FloatingActionButtonLocation => ' + 'consider use ${GapLocation.end} instead of $gapLocation or change FloatingActionButtonLocation' + ); } // The guest's shape is a circle bounded by the guest rectangle.