diff --git a/packages/flutter/lib/src/material/bottom_sheet.dart b/packages/flutter/lib/src/material/bottom_sheet.dart index 75d2cea4df..a461b25de3 100644 --- a/packages/flutter/lib/src/material/bottom_sheet.dart +++ b/packages/flutter/lib/src/material/bottom_sheet.dart @@ -344,6 +344,7 @@ class _ModalBottomSheetRoute extends PopupRoute { this.elevation, this.shape, this.clipBehavior, + this.modalBarrierColor, this.isDismissible = true, @required this.isScrollControlled, RouteSettings settings, @@ -358,6 +359,7 @@ class _ModalBottomSheetRoute extends PopupRoute { final double elevation; final ShapeBorder shape; final Clip clipBehavior; + final Color modalBarrierColor; final bool isDismissible; @override @@ -370,7 +372,7 @@ class _ModalBottomSheetRoute extends PopupRoute { final String barrierLabel; @override - Color get barrierColor => Colors.black54; + Color get barrierColor => modalBarrierColor ?? Colors.black54; AnimationController _animationController; @@ -501,6 +503,7 @@ Future showModalBottomSheet({ double elevation, ShapeBorder shape, Clip clipBehavior, + Color barrierColor, bool isScrollControlled = false, bool useRootNavigator = false, bool isDismissible = true, @@ -523,6 +526,7 @@ Future showModalBottomSheet({ shape: shape, clipBehavior: clipBehavior, isDismissible: isDismissible, + modalBarrierColor: barrierColor )); } diff --git a/packages/flutter/test/material/bottom_sheet_test.dart b/packages/flutter/test/material/bottom_sheet_test.dart index ae2656a8e1..afb988102f 100644 --- a/packages/flutter/test/material/bottom_sheet_test.dart +++ b/packages/flutter/test/material/bottom_sheet_test.dart @@ -342,6 +342,7 @@ void main() { const double elevation = 9.0; final ShapeBorder shape = BeveledRectangleBorder(borderRadius: BorderRadius.circular(12)); const Clip clipBehavior = Clip.antiAlias; + const Color barrierColor = Colors.red; await tester.pumpWidget(MaterialApp( home: Scaffold( @@ -353,6 +354,7 @@ void main() { showModalBottomSheet( context: scaffoldKey.currentContext, backgroundColor: color, + barrierColor: barrierColor, elevation: elevation, shape: shape, clipBehavior: clipBehavior, @@ -371,6 +373,9 @@ void main() { expect(bottomSheet.elevation, elevation); expect(bottomSheet.shape, shape); expect(bottomSheet.clipBehavior, clipBehavior); + + final ModalBarrier modalBarrier = tester.widget(find.byType(ModalBarrier).last); + expect(modalBarrier.color, barrierColor); }); testWidgets('modal BottomSheet with scrollController has semantics', (WidgetTester tester) async {