From eb056162c996f0b56e3e4ed466354e660cb2a929 Mon Sep 17 00:00:00 2001 From: Dzmitry Kasianiuk Date: Mon, 27 Nov 2023 11:06:36 +0300 Subject: [PATCH 1/5] added contentdxOffset --- lib/src/popover.dart | 6 ++++++ lib/src/popover_item.dart | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/src/popover.dart b/lib/src/popover.dart index db6ec2c..b634269 100644 --- a/lib/src/popover.dart +++ b/lib/src/popover.dart @@ -53,6 +53,10 @@ import 'utils/popover_utils.dart'; /// position on Y axis. It can be positive or negative number. /// This argument defaults to 0. /// +/// The`contentDxOffset` offsets [Popover]s content +/// position on X axis. It can be positive or negative number. +/// This argument defaults to 0. +/// /// The `barrierDismissible` argument is used to determine whether this route /// can be dismissed by tapping the modal barrier. This argument defaults /// to true. @@ -88,6 +92,7 @@ Future showPopover({ double arrowDxOffset = 0, double arrowDyOffset = 0, double contentDyOffset = 0, + double contentDxOffset = 0, bool barrierDismissible = true, double? width, double? height, @@ -131,6 +136,7 @@ Future showPopover({ arrowDxOffset: arrowDxOffset, arrowDyOffset: arrowDyOffset, contentDyOffset: contentDyOffset, + contentDxOffset: contentDxOffset, key: key, ), ); diff --git a/lib/src/popover_item.dart b/lib/src/popover_item.dart index 6791732..fe8fab8 100644 --- a/lib/src/popover_item.dart +++ b/lib/src/popover_item.dart @@ -19,6 +19,7 @@ class PopoverItem extends StatefulWidget { final double arrowDxOffset; final double arrowDyOffset; final double contentDyOffset; + final double contentDxOffset; final PopoverTransition transition; const PopoverItem({ @@ -36,6 +37,7 @@ class PopoverItem extends StatefulWidget { this.arrowDxOffset = 0, this.arrowDyOffset = 0, this.contentDyOffset = 0, + this.contentDxOffset = 0, super.key, }); @@ -142,7 +144,7 @@ class _PopoverItemState extends State { _attachRect = Rect.fromLTWH( offset.dx + (widget.arrowDxOffset), offset.dy + (widget.arrowDyOffset), - bounds.width, + bounds.width + (widget.contentDxOffset), bounds.height + (widget.contentDyOffset), ); } From b38d815cc74ba4dff20d99db6f125cea5bcb51b8 Mon Sep 17 00:00:00 2001 From: Dzmitry Kasianiuk Date: Mon, 27 Nov 2023 12:03:17 +0300 Subject: [PATCH 2/5] updated code by new flutter version --- lib/src/popover.dart | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/src/popover.dart b/lib/src/popover.dart index b634269..7ae4cfc 100644 --- a/lib/src/popover.dart +++ b/lib/src/popover.dart @@ -85,7 +85,10 @@ Future showPopover({ Duration transitionDuration = const Duration(milliseconds: 200), double radius = 8, List shadow = const [ - BoxShadow(color: Color(0x1F000000), blurRadius: 5) + BoxShadow( + color: Color(0x1F000000), + blurRadius: 5, + ) ], double arrowWidth = 24, double arrowHeight = 12, @@ -116,11 +119,8 @@ Future showPopover({ return Navigator.of(context, rootNavigator: true).push( RawDialogRoute( pageBuilder: (_, animation, __) { - return WillPopScope( - onWillPop: () { - onPop?.call(); - return Future.value(true); - }, + return PopScope( + onPopInvoked: (_) => onPop?.call(), child: PopoverItem( transition: transition, child: Builder(builder: bodyBuilder), @@ -142,8 +142,8 @@ Future showPopover({ ); }, barrierDismissible: barrierDismissible, - barrierLabel: barrierLabel ??= - MaterialLocalizations.of(context).modalBarrierDismissLabel, + // ignore: lines_longer_than_80_chars + barrierLabel: barrierLabel ??= MaterialLocalizations.of(context).modalBarrierDismissLabel, barrierColor: barrierColor, transitionDuration: transitionDuration, settings: routeSettings, From d419f58ee800fd627810addd92462c96364d1f87 Mon Sep 17 00:00:00 2001 From: kasyanyukd1995 <38073125+kasyanyukd1995@users.noreply.github.com> Date: Mon, 27 Nov 2023 12:06:44 +0300 Subject: [PATCH 3/5] Update lib/src/popover.dart Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- lib/src/popover.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/popover.dart b/lib/src/popover.dart index 7ae4cfc..ffe26c9 100644 --- a/lib/src/popover.dart +++ b/lib/src/popover.dart @@ -143,7 +143,7 @@ Future showPopover({ }, barrierDismissible: barrierDismissible, // ignore: lines_longer_than_80_chars - barrierLabel: barrierLabel ??= MaterialLocalizations.of(context).modalBarrierDismissLabel, + barrierLabel: barrierLabel ?? MaterialLocalizations.of(context).modalBarrierDismissLabel, barrierColor: barrierColor, transitionDuration: transitionDuration, settings: routeSettings, From 0cca23ff215b2a7eb90701c2f551f433dfac235a Mon Sep 17 00:00:00 2001 From: Dzmitry Kasianiuk Date: Mon, 27 Nov 2023 13:13:31 +0300 Subject: [PATCH 4/5] refactoring --- lib/src/popover.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/popover.dart b/lib/src/popover.dart index ffe26c9..b308506 100644 --- a/lib/src/popover.dart +++ b/lib/src/popover.dart @@ -142,8 +142,8 @@ Future showPopover({ ); }, barrierDismissible: barrierDismissible, - // ignore: lines_longer_than_80_chars - barrierLabel: barrierLabel ?? MaterialLocalizations.of(context).modalBarrierDismissLabel, + barrierLabel: barrierLabel ?? + MaterialLocalizations.of(context).modalBarrierDismissLabel, barrierColor: barrierColor, transitionDuration: transitionDuration, settings: routeSettings, From 9605af44e2dbb1b69e38edc96d76c02109c4b6cf Mon Sep 17 00:00:00 2001 From: Dzmitry Kasianiuk Date: Wed, 29 Nov 2023 09:44:46 +0300 Subject: [PATCH 5/5] up flutter ver --- example/pubspec.yaml | 4 ++-- pubspec.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 25b3999..e8f7c2f 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -4,8 +4,8 @@ version: 0.1.0 publish_to: none environment: - sdk: '>=2.19.0 <3.0.0' - flutter: '>=3.3.0' + sdk: '>=3.2.1 <4.0.0' + flutter: '>=3.16.1' dependencies: flutter: diff --git a/pubspec.yaml b/pubspec.yaml index 80b86a2..d63a6a7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,8 +4,8 @@ version: 0.3.0 homepage: https://github.com/minikin/popover environment: - sdk: '>=3.1.2 <4.0.0' - flutter: '>=3.13.5' + sdk: '>=3.2.1 <4.0.0' + flutter: '>=3.16.1' dependencies: flutter: