-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Description
Setting the height property on a PopupMenuItem does not work correctly. Looks like the vertical start position is misaligned.
import 'package:flutter_web/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatelessWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
Widget build(BuildContext context) {
// This works fine if it is set to the default value of 48
final double itemHeight = 20;
List<PopupMenuItem<int>> dropDownItems = List<PopupMenuItem<int>>();
for(int i = 0; i < 10; ++i) {
dropDownItems.add(PopupMenuItem<int>(
height:itemHeight,
value:0,
child:SizedBox(
child:Text(i.toString()),
height:itemHeight)
),);
}
return Scaffold(
appBar: AppBar(
title: Text(title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
GestureDetector(
child:Text('Click me'),
onTapDown:(TapDownDetails tapDownDetails) async {
await showMenu<int>(
context: context,
initialValue: 0,
position: RelativeRect.fromLTRB(
tapDownDetails.globalPosition.dx,
tapDownDetails.globalPosition.dy,
tapDownDetails.globalPosition.dx + 100,
tapDownDetails.globalPosition.dx + 100),
items: dropDownItems,
);
},
),
],
),
),
);
}
}
Metadata
Metadata
Assignees
Labels
No labels
