Skip to content

Commit

Permalink
fix close ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
shirne committed Sep 23, 2023
1 parent 7398f5a commit 5a9d609
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## [4.6.9]
* fix close ignored when not inited
## [4.6.8]
* fix loading close error
## [4.6.6]
Expand Down
16 changes: 13 additions & 3 deletions lib/src/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ abstract class DialogController<T> extends ChangeNotifier

bool get isClose;
bool _isClosed = false;
bool get isClosed => _isClosed;

AnimationConfig animate;
AnimationConfig leaveAnimate;
Expand All @@ -29,13 +30,17 @@ abstract class DialogController<T> extends ChangeNotifier
AnimationConfig.fadeAndZoomOut;

void open();
void close();

@mustCallSuper
void close() {
_isClosed = true;
}

void remove();

set value(v) {
_value = v;
if (_isClosed) return;
_isClosed = isClose;
notifyListeners();
if (isClose) {
close();
Expand Down Expand Up @@ -75,6 +80,7 @@ abstract class OverlayController<T> extends DialogController<T> {

@override
void open() {
if (isClosed) return;
entry ??= OverlayEntry(
builder: (BuildContext context) {
final animateChild = CombinedAnimation(
Expand All @@ -98,7 +104,11 @@ abstract class OverlayController<T> extends DialogController<T> {

@override
void close() {
if (!controller.isLeaved) {
super.close();

if (!controller.isEntered) {
remove();
} else if (!controller.isLeaved) {
controller.leave();
}
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: shirne_dialog
description: A flutter package to use alert, toast, popup, snack, imagePreview, loading etc. with customizable style in anywhere.
version: 4.6.8
version: 4.6.9
homepage: https://shirne.github.io/dialog/
repository: https://github.com/shirne/shirne_dialog
screenshots:
Expand Down

0 comments on commit 5a9d609

Please sign in to comment.