Unverified Commit 531870f5 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Fix constraints of popupmenu (#75748)

parent 3e89f242
......@@ -623,9 +623,7 @@ class _PopupMenuRouteLayout extends SingleChildLayoutDelegate {
BoxConstraints getConstraintsForChild(BoxConstraints constraints) {
// The menu can be at most the size of the overlay minus 8.0 pixels in each
// direction.
return BoxConstraints.loose(
constraints.biggest - const Offset(_kMenuScreenPadding * 2.0, _kMenuScreenPadding * 2.0) as Size,
);
return BoxConstraints.loose(constraints.biggest).deflate(const EdgeInsets.all(_kMenuScreenPadding));
}
@override
......
......@@ -1915,6 +1915,46 @@ void main() {
await buildFrame(iconSize: 50);
expect(tester.widget<IconButton>(find.byType(IconButton)).iconSize, 50);
});
testWidgets('does not crash in small overlay', (WidgetTester tester) async {
final GlobalKey navigator = GlobalKey();
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Column(
children: <Widget>[
OutlinedButton(
onPressed: () {
showMenu<void>(
context: navigator.currentContext!,
position: const RelativeRect.fromLTRB(0, 0, 0, 0),
items: const <PopupMenuItem<void>>[
PopupMenuItem<void>(child: Text('foo')),
],
);
},
child: const Text('press'),
),
SizedBox(
height: 10,
width: 10,
child: Navigator(
key: navigator,
onGenerateRoute: (RouteSettings settings) => MaterialPageRoute<void>(
builder: (BuildContext context) => Container(color: Colors.red),
),
),
),
],
),
),
),
);
await tester.tap(find.text('press'));
await tester.pumpAndSettle();
expect(find.text('foo'), findsOneWidget);
});
}
class TestApp extends StatefulWidget {
......
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