Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion packages/flutter/lib/src/material/dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,18 @@ class _DialogRoute<T> extends PopupRoute<T> {

@override
Widget buildPage(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
return theme != null ? new Theme(data: theme, child: child) : child;
return new MediaQuery.removePadding(
context: context,
removeTop: true,
removeBottom: true,
removeLeft: true,
removeRight: true,
child: new Builder(
builder: (BuildContext context) {
return theme != null ? new Theme(data: theme, child: child) : child;
}
),
);
}

@override
Expand Down
25 changes: 18 additions & 7 deletions packages/flutter/lib/src/material/dropdown.dart
Original file line number Diff line number Diff line change
Expand Up @@ -335,14 +335,25 @@ class _DropdownRoute<T> extends PopupRoute<_DropdownRouteResult<T>> {
if (theme != null)
menu = new Theme(data: theme, child: menu);

return new CustomSingleChildLayout(
delegate: new _DropdownMenuRouteLayout<T>(
buttonRect: buttonRect,
menuTop: menuTop,
menuHeight: menuHeight,
textDirection: Directionality.of(context),
return new MediaQuery.removePadding(
context: context,
removeTop: true,
removeBottom: true,
removeLeft: true,
removeRight: true,
child: new Builder(
builder: (BuildContext context) {
return new CustomSingleChildLayout(
delegate: new _DropdownMenuRouteLayout<T>(
buttonRect: buttonRect,
menuTop: menuTop,
menuHeight: menuHeight,
textDirection: Directionality.of(context),
),
child: menu,
);
},
),
child: menu,
);
}

Expand Down
29 changes: 18 additions & 11 deletions packages/flutter/lib/src/material/popup_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -591,17 +591,24 @@ class _PopupMenuRoute<T> extends PopupRoute<T> {
if (theme != null)
menu = new Theme(data: theme, child: menu);

return new Builder(
builder: (BuildContext context) {
return new CustomSingleChildLayout(
delegate: new _PopupMenuRouteLayout(
position,
selectedItemOffset,
Directionality.of(context),
),
child: menu,
);
},
return new MediaQuery.removePadding(
context: context,
removeTop: true,
removeBottom: true,
removeLeft: true,
removeRight: true,
child: new Builder(
builder: (BuildContext context) {
return new CustomSingleChildLayout(
delegate: new _PopupMenuRouteLayout(
position,
selectedItemOffset,
Directionality.of(context),
),
child: menu,
);
},
),
);
}
}
Expand Down
36 changes: 36 additions & 0 deletions packages/flutter/test/material/dialog_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,40 @@ void main() {

semantics.dispose();
});

testWidgets('Dialogs removes MediaQuery padding', (WidgetTester tester) async {
BuildContext scaffoldContext;
BuildContext dialogContext;

await tester.pumpWidget(new MaterialApp(
home: new MediaQuery(
data: const MediaQueryData(
padding: const EdgeInsets.all(50.0),
),
child: new Builder(
builder: (BuildContext context) {
scaffoldContext = context;
return new Container();
}
),
)
));

await tester.pump();

showDialog<Null>(
context: scaffoldContext,
barrierDismissible: false,
child: new Builder(
builder: (BuildContext context) {
dialogContext = context;
return new Container();
},
),
);

await tester.pump();

expect(MediaQuery.of(dialogContext).padding, EdgeInsets.zero);
});
}
42 changes: 42 additions & 0 deletions packages/flutter/test/material/persistent_bottom_sheet_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,46 @@ void main() {
expect(buildCount, equals(1));
});

testWidgets('Scaffold removes top MediaQuery padding', (WidgetTester tester) async {
BuildContext scaffoldContext;
BuildContext bottomSheetContext;

await tester.pumpWidget(new MaterialApp(
home: new MediaQuery(
data: const MediaQueryData(
padding: const EdgeInsets.all(50.0),
),
child: new Scaffold(
resizeToAvoidBottomPadding: false,
body: new Builder(
builder: (BuildContext context) {
scaffoldContext = context;
return new Container();
}
),
),
)
));

await tester.pump();

showBottomSheet<Null>(
context: scaffoldContext,
builder: (BuildContext context) {
bottomSheetContext = context;
return new Container();
},
);

await tester.pump();

expect(
MediaQuery.of(bottomSheetContext).padding,
const EdgeInsets.only(
bottom: 50.0,
left: 50.0,
right: 50.0,
),
);
});
}
41 changes: 41 additions & 0 deletions packages/flutter/test/material/popup_menu_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,47 @@ void main() {
await testPositioningDownThenUp(tester, TextDirection.ltr, Alignment.bottomCenter, TextDirection.ltr, new Rect.fromLTWH(350.0, 500.0, 0.0, 0.0));
await testPositioningDownThenUp(tester, TextDirection.rtl, Alignment.bottomCenter, TextDirection.rtl, new Rect.fromLTWH(450.0, 500.0, 0.0, 0.0));
});

testWidgets('PopupMenu removes MediaQuery padding', (WidgetTester tester) async {
BuildContext popupContext;

await tester.pumpWidget(new MaterialApp(
home: new MediaQuery(
data: const MediaQueryData(
padding: const EdgeInsets.all(50.0),
),
child: new Material(
child: new PopupMenuButton<int>(
itemBuilder: (BuildContext context) {
popupContext = context;
return <PopupMenuItem<int>>[
new PopupMenuItem<int>(
value: 1,
child: new Builder(
builder: (BuildContext context) {
popupContext = context;
return const Text('AAA');
},
),
),
];
},
child: const SizedBox(
height: 100.0,
width: 100.0,
child: const Text('XXX'),
),
),
),
)
));

await tester.tap(find.text('XXX'));

await tester.pump();

expect(MediaQuery.of(popupContext).padding, EdgeInsets.zero);
});
}

class TestApp extends StatefulWidget {
Expand Down