From 18d35381f21d9230fd9f3e06a1eea0062b949606 Mon Sep 17 00:00:00 2001 From: RasitAyaz Date: Sat, 23 Oct 2021 15:47:58 +0300 Subject: [PATCH] Fix menu toggle callback related issue --- CHANGELOG.md | 6 +++++- example/pubspec.lock | 2 +- lib/src/displayed_canvas.dart | 20 ++++++++++---------- pubspec.yaml | 2 +- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93d016a..a74c636 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ +## 0.0.5 + +* Fixed `onMenuToggle` callback of `PieMenu` is not being called when the canvas callback is null. + ## 0.0.4 -* `onMenuToggle` callback at the `PieCanvas` also added for the `PieMenu`. +* `onMenuToggle` callback at `PieCanvas` also added for `PieMenu`. ## 0.0.3 diff --git a/example/pubspec.lock b/example/pubspec.lock index c0e6b2b..1f104bf 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -120,7 +120,7 @@ packages: path: ".." relative: true source: path - version: "0.0.4" + version: "0.0.5" plugin_platform_interface: dependency: transitive description: diff --git a/lib/src/displayed_canvas.dart b/lib/src/displayed_canvas.dart index 0671efc..7519d69 100644 --- a/lib/src/displayed_canvas.dart +++ b/lib/src/displayed_canvas.dart @@ -341,18 +341,18 @@ class DisplayedCanvasState extends State } void toggleMenu(bool menuVisible) { + if (_onActiveMenuToggle != null) { + _onActiveMenuToggle!(menuVisible); + } if (widget.onMenuToggle != null) { - if (_onActiveMenuToggle != null) { - _onActiveMenuToggle!(menuVisible); - } widget.onMenuToggle!(menuVisible); - if (menuVisible) { - WidgetsBinding.instance!.addPostFrameCallback((duration) { - /// This rebuild prevents menu child being displayed - /// in the wrong offset when the scrollable swiped fast. - setState(() {}); - }); - } + } + if (menuVisible) { + WidgetsBinding.instance!.addPostFrameCallback((duration) { + /// This rebuild prevents menu child being displayed + /// in the wrong offset when the scrollable swiped fast. + setState(() {}); + }); } } diff --git a/pubspec.yaml b/pubspec.yaml index f1f7dd7..e85af3d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: pie_menu description: A customizable Flutter library that provides a circular context menu. -version: 0.0.4 +version: 0.0.5 homepage: https://github.com/RasitAyaz/flutter-pie-menu environment: