Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
## 1.0.0
## 3.3.10

- Allow custom content margin

* TODO: Describe initial release.
## 3.3.8

* TODO: Describe initial release.

## 1.0.0

* TODO: Describe initial release.

2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class _MyHomePageState extends State<MyHomePage> {
children: [
// example1 text
CustomPopup(
barrierColor: Colors.green.withOpacity(0.1),
barrierColor: Colors.green.withValues(alpha: 0.1),
backgroundColor: Colors.white,
content: Text('George says everything looks fine'),
child: Icon(Icons.help, color: Colors.grey),
Expand Down
44 changes: 22 additions & 22 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ packages:
dependency: transitive
description:
name: async
sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63
sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb"
url: "https://pub.dev"
source: hosted
version: "2.12.0"
version: "2.13.0"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -45,10 +45,10 @@ packages:
dependency: transitive
description:
name: fake_async
sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc"
sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44"
url: "https://pub.dev"
source: hosted
version: "1.3.2"
version: "1.3.3"
file:
dependency: transitive
description:
Expand All @@ -73,7 +73,7 @@ packages:
path: ".."
relative: true
source: path
version: "3.3.8"
version: "3.3.9"
flutter_test:
dependency: "direct dev"
description: flutter
Expand All @@ -93,26 +93,26 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec
sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de"
url: "https://pub.dev"
source: hosted
version: "10.0.8"
version: "11.0.2"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
url: "https://pub.dev"
source: hosted
version: "3.0.9"
version: "3.0.10"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
url: "https://pub.dev"
source: hosted
version: "3.0.1"
version: "3.0.2"
matcher:
dependency: transitive
description:
Expand Down Expand Up @@ -157,10 +157,10 @@ packages:
dependency: transitive
description:
name: process
sha256: "107d8be718f120bbba9dcd1e95e3bd325b1b4a4f07db64154635ba03f2567a0d"
sha256: c6248e4526673988586e8c00bb22a49210c258dc91df5227d5da9748ecf79744
url: "https://pub.dev"
source: hosted
version: "5.0.3"
version: "5.0.5"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -218,34 +218,34 @@ packages:
dependency: transitive
description:
name: test_api
sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd
sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00"
url: "https://pub.dev"
source: hosted
version: "0.7.4"
version: "0.7.6"
vector_math:
dependency: transitive
description:
name: vector_math
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
url: "https://pub.dev"
source: hosted
version: "2.1.4"
version: "2.2.0"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14"
sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60"
url: "https://pub.dev"
source: hosted
version: "14.3.1"
version: "15.0.2"
webdriver:
dependency: transitive
description:
name: webdriver
sha256: "3d773670966f02a646319410766d3b5e1037efb7f07cc68f844d5e06cd4d61c8"
sha256: "2f3a14ca026957870cfd9c635b83507e0e51d8091568e90129fbf805aba7cade"
url: "https://pub.dev"
source: hosted
version: "3.0.4"
version: "3.1.0"
sdks:
dart: ">=3.7.0-0 <4.0.0"
dart: ">=3.8.0-0 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54"
59 changes: 39 additions & 20 deletions lib/src/popup.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of flutter_popup;
part of '../flutter_popup.dart';

enum _ArrowDirection { top, bottom }

Expand All @@ -14,6 +14,7 @@ class CustomPopup extends StatefulWidget {
final Color? barrierColor;
final bool showArrow;
final EdgeInsets contentPadding;
final EdgeInsets contentMargin;
final double? contentRadius;
final BoxDecoration? contentDecoration;
final VoidCallback? onBeforePopup;
Expand All @@ -34,6 +35,7 @@ class CustomPopup extends StatefulWidget {
this.showArrow = true,
this.barrierColor,
this.contentPadding = const EdgeInsets.all(8),
this.contentMargin = const EdgeInsets.symmetric(vertical: 10),
this.contentRadius,
this.contentDecoration,
this.onBeforePopup,
Expand Down Expand Up @@ -66,6 +68,7 @@ class CustomPopupState extends State<CustomPopup> {
showArrow: widget.showArrow,
barriersColor: widget.barrierColor,
contentPadding: widget.contentPadding,
contentMargin: widget.contentMargin,
contentRadius: widget.contentRadius,
contentDecoration: widget.contentDecoration,
position: widget.position,
Expand Down Expand Up @@ -98,11 +101,11 @@ class _PopupContent extends StatelessWidget {
final Color? arrowColor;
final bool showArrow;
final EdgeInsets contentPadding;
final EdgeInsets contentMargin;
final double? contentRadius;
final BoxDecoration? contentDecoration;

const _PopupContent({
Key? key,
required this.child,
required this.childKey,
required this.arrowKey,
Expand All @@ -113,8 +116,9 @@ class _PopupContent extends StatelessWidget {
this.arrowColor,
this.contentRadius,
required this.contentPadding,
required this.contentMargin,
this.contentDecoration,
}) : super(key: key);
});

@override
Widget build(BuildContext context) {
Expand All @@ -123,7 +127,7 @@ class _PopupContent extends StatelessWidget {
Container(
key: childKey,
padding: contentPadding,
margin: const EdgeInsets.symmetric(vertical: 10).copyWith(
margin: contentMargin.copyWith(
top: arrowDirection == _ArrowDirection.bottom ? 0 : null,
bottom: arrowDirection == _ArrowDirection.top ? 0 : null,
),
Expand All @@ -134,7 +138,7 @@ class _PopupContent extends StatelessWidget {
borderRadius: BorderRadius.circular(contentRadius ?? 10),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
color: Colors.black.withValues(alpha: 0.1),
blurRadius: 10,
),
],
Expand Down Expand Up @@ -172,14 +176,32 @@ class _TrianglePainter extends CustomPainter {
paint.color = color;

path.lineTo(size.width * 0.66, size.height * 0.86);
path.cubicTo(size.width * 0.58, size.height * 1.05, size.width * 0.42,
size.height * 1.05, size.width * 0.34, size.height * 0.86);
path.cubicTo(
size.width * 0.58,
size.height * 1.05,
size.width * 0.42,
size.height * 1.05,
size.width * 0.34,
size.height * 0.86,
);
path.cubicTo(size.width * 0.34, size.height * 0.86, 0, 0, 0, 0);
path.cubicTo(0, 0, size.width, 0, size.width, 0);
path.cubicTo(size.width, 0, size.width * 0.66, size.height * 0.86,
size.width * 0.66, size.height * 0.86);
path.cubicTo(size.width * 0.66, size.height * 0.86, size.width * 0.66,
size.height * 0.86, size.width * 0.66, size.height * 0.86);
path.cubicTo(
size.width,
0,
size.width * 0.66,
size.height * 0.86,
size.width * 0.66,
size.height * 0.86,
);
path.cubicTo(
size.width * 0.66,
size.height * 0.86,
size.width * 0.66,
size.height * 0.86,
size.width * 0.66,
size.height * 0.86,
);
canvas.drawPath(path, paint);
}

Expand Down Expand Up @@ -211,6 +233,7 @@ class _PopupRoute extends PopupRoute<void> {
final bool showArrow;
final Color? barriersColor;
final EdgeInsets contentPadding;
final EdgeInsets contentMargin;
final double? contentRadius;
final BoxDecoration? contentDecoration;

Expand All @@ -225,29 +248,24 @@ class _PopupRoute extends PopupRoute<void> {
double? _right;

_PopupRoute({
RouteSettings? settings,
ImageFilter? filter,
TraversalEdgeBehavior? traversalEdgeBehavior,
required this.child,
required this.targetRect,
this.backgroundColor,
this.arrowColor,
required this.showArrow,
this.barriersColor,
required this.contentPadding,
required this.contentMargin,
this.contentRadius,
this.contentDecoration,
this.position = PopupPosition.auto,
required this.animationDuration,
this.animationCurve = Curves.easeInOut,
}) : super(
settings: settings,
filter: filter,
traversalEdgeBehavior: traversalEdgeBehavior,
);
});

@override
Color? get barrierColor => barriersColor ?? Colors.black.withOpacity(0.1);
Color? get barrierColor =>
barriersColor ?? Colors.black.withValues(alpha: 0.1);

@override
bool get barrierDismissible => true;
Expand Down Expand Up @@ -360,6 +378,7 @@ class _PopupRoute extends PopupRoute<void> {
arrowColor: arrowColor,
showArrow: showArrow,
contentPadding: contentPadding,
contentMargin: contentMargin,
contentRadius: contentRadius,
contentDecoration: contentDecoration,
child: child,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/screen.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of flutter_popup;
part of '../flutter_popup.dart';

abstract class Screen {
static MediaQueryData get mediaQuery => MediaQueryData.fromView(
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_popup
description: The flutter_popup package is a versatile tool for creating customizable popups in Flutter apps. Its highlight feature effectively guides user attention to specific areas
version: 3.3.9
version: 3.3.10
homepage: https://github.com/herowws/flutter_popup

environment:
Expand All @@ -13,7 +13,7 @@ dependencies:
dev_dependencies:
example:
path: example
flutter_lints: ^1.0.0
flutter_lints: ^6.0.0
flutter_test:
sdk: flutter

Expand Down