Add onDismiss to AnimatedModalBarrier, update tests (#100162)

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.
This commit is contained in:
Greg Spencer 2022-04-06 18:39:14 -07:00 committed by GitHub
parent 548e8853e6
commit db51873250
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 874 additions and 394 deletions

View File

@ -60,6 +60,7 @@ class ModalBarrier extends StatelessWidget {
/// [ModalBarrier] built by [ModalRoute] pages. /// [ModalBarrier] built by [ModalRoute] pages.
final bool dismissible; final bool dismissible;
/// {@template flutter.widgets.ModalBarrier.onDismiss}
/// Called when the barrier is being dismissed. /// Called when the barrier is being dismissed.
/// ///
/// If non-null [onDismiss] will be called in place of popping the current /// If non-null [onDismiss] will be called in place of popping the current
@ -68,6 +69,7 @@ class ModalBarrier extends StatelessWidget {
/// If null, the ambient [Navigator]'s current route will be popped. /// If null, the ambient [Navigator]'s current route will be popped.
/// ///
/// This field is ignored if [dismissible] is false. /// This field is ignored if [dismissible] is false.
/// {@endtemplate}
final VoidCallback? onDismiss; final VoidCallback? onDismiss;
/// Whether the modal barrier semantics are included in the semantics tree. /// Whether the modal barrier semantics are included in the semantics tree.
@ -172,6 +174,7 @@ class AnimatedModalBarrier extends AnimatedWidget {
this.dismissible = true, this.dismissible = true,
this.semanticsLabel, this.semanticsLabel,
this.barrierSemanticsDismissible, this.barrierSemanticsDismissible,
this.onDismiss,
}) : super(key: key, listenable: color); }) : super(key: key, listenable: color);
/// If non-null, fill the barrier with this color. /// If non-null, fill the barrier with this color.
@ -208,6 +211,9 @@ class AnimatedModalBarrier extends AnimatedWidget {
/// the [ModalBarrier] built by [ModalRoute] pages. /// the [ModalBarrier] built by [ModalRoute] pages.
final bool? barrierSemanticsDismissible; final bool? barrierSemanticsDismissible;
/// {@macro flutter.widgets.ModalBarrier.onDismiss}
final VoidCallback? onDismiss;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ModalBarrier( return ModalBarrier(
@ -215,6 +221,7 @@ class AnimatedModalBarrier extends AnimatedWidget {
dismissible: dismissible, dismissible: dismissible,
semanticsLabel: semanticsLabel, semanticsLabel: semanticsLabel,
barrierSemanticsDismissible: barrierSemanticsDismissible, barrierSemanticsDismissible: barrierSemanticsDismissible,
onDismiss: onDismiss,
); );
} }
} }

File diff suppressed because it is too large Load Diff