Menus are where Flutter apps most often feel “webby.” RawMenuAnchor is the shared primitive; Cupertino and Material both build on it.
Cupertino
CupertinoMenuAnchor (community-led, notably davidhicks980) gives iOS apps a menu that behaves like UIKit: dismiss physics, nesting, and focus that match platform expectations.
Material
MenuAnchor gains optional Material 3 animations (animated: true) and SubmenuButton.hoverOpenDelay for desktop hover behavior.
Decision table
| Target | Prefer |
|---|---|
| iOS-first product | CupertinoMenuAnchor |
| Desktop dense UI | MenuAnchor + hoverOpenDelay |
| Cross-platform brand | Adaptive wrapper choosing by platform |
Pitfalls
- Callback close order changed on RawMenuAnchor — read the breaking-change note before upgrading.
- Do not rebuild the entire menu tree on every pointer event; keep anchors stable.
Originally published on FlutterCook. Read the latest version there — that copy is the one kept up to date.
Nhận xét
Đăng nhận xét