Unverified Commit a1b22b17 authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Don't remove view insets in removePadding ctor (#13286)

This will be followed by a patch that supports independently removing
padding and view insets.
parent 5a1dcdb4
...@@ -158,12 +158,7 @@ class MediaQueryData { ...@@ -158,12 +158,7 @@ class MediaQueryData {
right: removeRight ? 0.0 : null, right: removeRight ? 0.0 : null,
bottom: removeBottom ? 0.0 : null, bottom: removeBottom ? 0.0 : null,
), ),
viewInsets: viewInsets.copyWith( viewInsets: viewInsets,
left: removeLeft ? 0.0 : null,
top: removeTop ? 0.0 : null,
right: removeRight ? 0.0 : null,
bottom: removeBottom ? 0.0 : null,
),
); );
} }
......
...@@ -70,4 +70,57 @@ void main() { ...@@ -70,4 +70,57 @@ void main() {
expect(copied.padding, const EdgeInsets.all(9.10938)); expect(copied.padding, const EdgeInsets.all(9.10938));
expect(copied.viewInsets, const EdgeInsets.all(1.67262)); 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);
});
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment