Don't remove view insets in removePadding ctor (#13286)
This will be followed by a patch that supports independently removing padding and view insets.
This commit is contained in:
@@ -158,12 +158,7 @@ class MediaQueryData {
|
||||
right: removeRight ? 0.0 : null,
|
||||
bottom: removeBottom ? 0.0 : null,
|
||||
),
|
||||
viewInsets: viewInsets.copyWith(
|
||||
left: removeLeft ? 0.0 : null,
|
||||
top: removeTop ? 0.0 : null,
|
||||
right: removeRight ? 0.0 : null,
|
||||
bottom: removeBottom ? 0.0 : null,
|
||||
),
|
||||
viewInsets: viewInsets,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -70,4 +70,57 @@ void main() {
|
||||
expect(copied.padding, const EdgeInsets.all(9.10938));
|
||||
expect(copied.viewInsets, const EdgeInsets.all(1.67262));
|
||||
});
|
||||
|
||||
testWidgets('MediaQuery.removePadding removes specified padding', (WidgetTester tester) async {
|
||||
const Size size = const Size(2.0, 4.0);
|
||||
const double devicePixelRatio = 2.0;
|
||||
const double textScaleFactor = 1.2;
|
||||
const EdgeInsets padding = const EdgeInsets.only(
|
||||
top: 1.0,
|
||||
right: 2.0,
|
||||
left: 3.0,
|
||||
bottom: 4.0,
|
||||
);
|
||||
const EdgeInsets viewInsets = const EdgeInsets.only(
|
||||
top: 5.0,
|
||||
right: 6.0,
|
||||
left: 7.0,
|
||||
bottom: 8.0,
|
||||
);
|
||||
|
||||
MediaQueryData unpadded;
|
||||
await tester.pumpWidget(
|
||||
new MediaQuery(
|
||||
data: const MediaQueryData(
|
||||
size: size,
|
||||
devicePixelRatio: devicePixelRatio,
|
||||
textScaleFactor: textScaleFactor,
|
||||
padding: padding,
|
||||
viewInsets: viewInsets,
|
||||
),
|
||||
child: new Builder(
|
||||
builder: (BuildContext context) {
|
||||
return new MediaQuery.removePadding(
|
||||
context: context,
|
||||
removeTop: true,
|
||||
removeRight: true,
|
||||
removeLeft: true,
|
||||
removeBottom: true,
|
||||
child: new Builder(
|
||||
builder: (BuildContext context) {
|
||||
unpadded = MediaQuery.of(context);
|
||||
return new Container();
|
||||
}
|
||||
),
|
||||
);
|
||||
}),
|
||||
)
|
||||
);
|
||||
|
||||
expect(unpadded.size, size);
|
||||
expect(unpadded.devicePixelRatio, devicePixelRatio);
|
||||
expect(unpadded.textScaleFactor, textScaleFactor);
|
||||
expect(unpadded.padding, EdgeInsets.zero);
|
||||
expect(unpadded.viewInsets, viewInsets);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user