mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Fixes [https://github.com/flutter/flutter/issues/132898](https://github.com/flutter/flutter/issues/132898) ### 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) { return MaterialApp( debugShowCheckedModeBanner: false, home: Scaffold( body: SafeArea( child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ MenuBar( children: [ SubmenuButton( menuChildren: <Widget>[ SubmenuButton( menuChildren: <Widget>[ MenuItemButton( onPressed: () {}, child: const Text('Menu '), ), ], child: const Text('SubmenuButton with default arrow icon'), ), SubmenuButton( submenuIcon: const WidgetStateProperty<Widget?>.fromMap( <WidgetStatesConstraint, Widget?>{ WidgetState.disabled: Icon(Icons.close), WidgetState.hovered: Icon(Icons.favorite), WidgetState.focused: Icon(Icons.add), WidgetState.any: Icon(Icons.arrow_forward_ios), }, ), menuChildren: <Widget>[ MenuItemButton( onPressed: () {}, child: const Text('Menu '), ), ], child: const Text('SubmenuButton with custom Icon widget'), ), SubmenuButton( submenuIcon: WidgetStatePropertyAll(Image.network( 'https://i.imgur.com/SF3mSOY.png', width: 28, height: 28)), menuChildren: <Widget>[ MenuItemButton( onPressed: () {}, child: const Text('Menu '), ), ], child: const Text('SubmenuButton with network image icon'), ), ], child: const Text('Menu'), ), ], ) ], ), ), ), ); } } ``` </details> ### Preview <img width="803" alt="Screenshot 2024-12-11 at 14 04 57" src="https://github.com/user-attachments/assets/4b330020-28c6-4af9-967b-630c0d43b01a"> ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md --------- Co-authored-by: Greg Spencer <gspencergoog@users.noreply.github.com>