Fix constraints of popupmenu (#75748)
This commit is contained in:
parent
3e89f24233
commit
531870f57b
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user