Skip to content

Commit

Permalink
Add onDismiss to AnimatedModalBarrier, update tests (flutter#100162)
Browse files Browse the repository at this point in the history
I noticed that AnimatedModalBarrier didn't have the onDismiss callback that ModalBarrier does, and so I added that, and while I was at it, I updated the unit tests to perform all of the tests that are done on ModalBarrier also on AnimatedModalBarrier. The tests are unchanged, other than using AnimatedModalBarrier instead.
  • Loading branch information
gspencergoog committed Apr 7, 2022
1 parent 548e885 commit db51873
Show file tree
Hide file tree
Showing 2 changed files with 834 additions and 354 deletions.
7 changes: 7 additions & 0 deletions packages/flutter/lib/src/widgets/modal_barrier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class ModalBarrier extends StatelessWidget {
/// [ModalBarrier] built by [ModalRoute] pages.
final bool dismissible;

/// {@template flutter.widgets.ModalBarrier.onDismiss}
/// Called when the barrier is being dismissed.
///
/// If non-null [onDismiss] will be called in place of popping the current
Expand All @@ -68,6 +69,7 @@ class ModalBarrier extends StatelessWidget {
/// If null, the ambient [Navigator]'s current route will be popped.
///
/// This field is ignored if [dismissible] is false.
/// {@endtemplate}
final VoidCallback? onDismiss;

/// Whether the modal barrier semantics are included in the semantics tree.
Expand Down Expand Up @@ -172,6 +174,7 @@ class AnimatedModalBarrier extends AnimatedWidget {
this.dismissible = true,
this.semanticsLabel,
this.barrierSemanticsDismissible,
this.onDismiss,
}) : super(key: key, listenable: color);

/// If non-null, fill the barrier with this color.
Expand Down Expand Up @@ -208,13 +211,17 @@ class AnimatedModalBarrier extends AnimatedWidget {
/// the [ModalBarrier] built by [ModalRoute] pages.
final bool? barrierSemanticsDismissible;

/// {@macro flutter.widgets.ModalBarrier.onDismiss}
final VoidCallback? onDismiss;

@override
Widget build(BuildContext context) {
return ModalBarrier(
color: color.value,
dismissible: dismissible,
semanticsLabel: semanticsLabel,
barrierSemanticsDismissible: barrierSemanticsDismissible,
onDismiss: onDismiss,
);
}
}
Expand Down
Loading

0 comments on commit db51873

Please sign in to comment.