mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Fixes [DropdownMenu can not be center aligned when using expandedInsets ](https://github.com/flutter/flutter/issues/155581) ### Code sample <details> <summary>expand to view the code sample</summary> ```dart import 'package:flutter/material.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { final List<DropdownMenuEntry<ShortMenu>> shortMenuItems = <DropdownMenuEntry<ShortMenu>>[]; for (final ShortMenu value in ShortMenu.values) { final DropdownMenuEntry<ShortMenu> entry = DropdownMenuEntry<ShortMenu>(value: value, label: value.label); shortMenuItems.add(entry); } return MaterialApp( home: Scaffold( body: Row( children: <Widget>[ Expanded( child: Center( child: DropdownMenu<ShortMenu>( expandedInsets: const EdgeInsets.all(16), initialSelection: ShortMenu.item0, dropdownMenuEntries: shortMenuItems, label: const Text('With expandedInsets'), ), ), ), Expanded( child: Center( child: DropdownMenu<ShortMenu>( initialSelection: ShortMenu.item0, dropdownMenuEntries: shortMenuItems, label: const Text('Without expandedInsets'), ), ), ), ], ), ), ); } } enum ShortMenu { item0('Menu 0'), item1('Menu 1'), item2('Menu 2'); const ShortMenu(this.label); final String label; } ``` </details> ### Before (`DropdownMenu` without `expandedInsets` cannot be centered) <img width="770" alt="Screenshot 2024-10-04 at 14 13 58" src="https://github.com/user-attachments/assets/c7520c12-d16a-4867-8fae-38b75dbc4225"> ### After (`DropdownMenu` with `expandedInsets` be centered) <img width="770" alt="Screenshot 2024-10-04 at 14 13 49" src="https://github.com/user-attachments/assets/82e0b81e-5c85-4e59-99b8-df329459773b">
Flutter
Flutter is a new way to build high-performance, cross-platform mobile, web, and desktop apps. Flutter is optimized for today's — and tomorrow's — mobile and desktop devices. We are focused on low-latency input and high frame rates on all platforms.
See the getting started guide for information about using Flutter.