Set modal bottom sheet barrier color (#45067)

This commit is contained in:
Sebastian Döll
2019-12-10 19:07:32 +01:00
committed by Darren Austin
parent 5469804cdf
commit 645c32311e
2 changed files with 10 additions and 1 deletions

View File

@@ -344,6 +344,7 @@ class _ModalBottomSheetRoute<T> extends PopupRoute<T> {
this.elevation,
this.shape,
this.clipBehavior,
this.modalBarrierColor,
this.isDismissible = true,
@required this.isScrollControlled,
RouteSettings settings,
@@ -358,6 +359,7 @@ class _ModalBottomSheetRoute<T> extends PopupRoute<T> {
final double elevation;
final ShapeBorder shape;
final Clip clipBehavior;
final Color modalBarrierColor;
final bool isDismissible;
@override
@@ -370,7 +372,7 @@ class _ModalBottomSheetRoute<T> extends PopupRoute<T> {
final String barrierLabel;
@override
Color get barrierColor => Colors.black54;
Color get barrierColor => modalBarrierColor ?? Colors.black54;
AnimationController _animationController;
@@ -501,6 +503,7 @@ Future<T> showModalBottomSheet<T>({
double elevation,
ShapeBorder shape,
Clip clipBehavior,
Color barrierColor,
bool isScrollControlled = false,
bool useRootNavigator = false,
bool isDismissible = true,
@@ -523,6 +526,7 @@ Future<T> showModalBottomSheet<T>({
shape: shape,
clipBehavior: clipBehavior,
isDismissible: isDismissible,
modalBarrierColor: barrierColor
));
}

View File

@@ -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<void>(
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 {