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/lib/src/popover.dart b/lib/src/popover.dart index db6ec2c..b308506 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. @@ -81,13 +85,17 @@ 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, double arrowDxOffset = 0, double arrowDyOffset = 0, double contentDyOffset = 0, + double contentDxOffset = 0, bool barrierDismissible = true, double? width, double? height, @@ -111,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), @@ -131,12 +136,13 @@ Future showPopover({ arrowDxOffset: arrowDxOffset, arrowDyOffset: arrowDyOffset, contentDyOffset: contentDyOffset, + contentDxOffset: contentDxOffset, key: key, ), ); }, barrierDismissible: barrierDismissible, - barrierLabel: barrierLabel ??= + barrierLabel: barrierLabel ?? MaterialLocalizations.of(context).modalBarrierDismissLabel, barrierColor: barrierColor, transitionDuration: transitionDuration, 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), ); } 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: