From 24780ff9b97fed0555f2ad3a3963746073e3e141 Mon Sep 17 00:00:00 2001 From: boyan Date: Wed, 22 May 2019 22:17:12 +0800 Subject: [PATCH] rename rejectKey to modalKey --- lib/src/overlay.dart | 4 ++-- lib/src/overlay_key.dart | 14 +++++++------- test/overlay_support_test.dart | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/src/overlay.dart b/lib/src/overlay.dart index 9af18ee..e4c47d2 100644 --- a/lib/src/overlay.dart +++ b/lib/src/overlay.dart @@ -41,7 +41,7 @@ typedef Widget AnimatedOverlayWidgetBuilder( /// /// if the notification1 of step1 is showing, the step2 will dismiss previous notification1. /// -/// if you want notification1' exist to reject step2, please see [RejectKey] +/// if you want notification1' exist to prevent step2, please see [ModalKey] /// /// OverlaySupportEntry showOverlay( @@ -63,7 +63,7 @@ OverlaySupportEntry showOverlay( final overlayKey = _OverlayKey(key); final supportEntry = OverlaySupportEntry._entries[overlayKey]; - if (supportEntry != null && key is RejectKey) { + if (supportEntry != null && key is ModalKey) { //do nothing for reject key return supportEntry; } diff --git a/lib/src/overlay_key.dart b/lib/src/overlay_key.dart index 7d9651d..1f63fb2 100644 --- a/lib/src/overlay_key.dart +++ b/lib/src/overlay_key.dart @@ -13,27 +13,27 @@ class _KeyedOverlay extends StatelessWidget { } } -///[showOverlay] with this key will be rejected if a overlay with the same key is being showing +///[showOverlay] with block other show with the same [ModalKey] /// /// for example /// ```dart -/// final rejectKey = RejectKey('simple'); +/// final modalKey = ModalKey('simple'); /// /// //popup a simple message on top of screen -/// showSimpleNotification(context, Text('reject example'), key: rejectKey); +/// showSimpleNotification(context, Text('modal example'), key: modalKey); /// /// //when previous notification is showing, popup again whit this key /// //this notification will be rejected. -/// showSimpleNotification(context, Text('reject example 2'), key: rejectKey); +/// showSimpleNotification(context, Text('modal example 2'), key: modalKey); /// /// ``` -class RejectKey extends ValueKey { - RejectKey(T value) : super(value); +class ModalKey extends ValueKey { + ModalKey(T value) : super(value); @override bool operator ==(other) { if (other.runtimeType != runtimeType) return false; - final RejectKey typedOther = other; + final ModalKey typedOther = other; return value == typedOther.value; } diff --git a/test/overlay_support_test.dart b/test/overlay_support_test.dart index 7104ca4..6d7c7a1 100644 --- a/test/overlay_support_test.dart +++ b/test/overlay_support_test.dart @@ -188,7 +188,7 @@ void main() { await tester.pump(const Duration(milliseconds: 1250)); }); - testWidgets('overlay with the reject key', (tester) async { + testWidgets('overlay with the modal key', (tester) async { kNotificationSlideDuration = Duration(milliseconds: 200); kNotificationDuration = const Duration(milliseconds: 1000); await tester.pumpWidget(_FakeOverlay(child: Builder(builder: (context) { @@ -197,13 +197,13 @@ void main() { FlatButton( onPressed: () { showSimpleNotification(context, Text('message'), - autoDismiss: false, key: RejectKey('hello')); + autoDismiss: false, key: ModalKey('hello')); }, child: Text('notification')), FlatButton( onPressed: () { showSimpleNotification(context, Text('message2'), - autoDismiss: false, key: RejectKey('hello')); + autoDismiss: false, key: ModalKey('hello')); }, child: Text('notification2')), ],