Chuyển đến nội dung chính

Bài đăng

Hiển thị các bài đăng có nhãn Menus

CupertinoMenuAnchor và menu Flutter hiện đại

Menu là nơi app Flutter hay “mở web” nhất. RawMenuAnchor là primitive chung; Cupertino và Material đều xây trên đó. Cupertino CupertinoMenuAnchor (community dẫn dắt, nổi bật davidhicks980) cho app iOS menu đúng kiểu UIKit: dismiss physics, nesting và focus khớp kỳ vọng nền tảng. Material MenuAnchor có animation Material 3 tùy chọn ( animated: true ) và SubmenuButton.hoverOpenDelay cho hover desktop. Bảng quyết định Mục tiêu Ưu tiên Sản phẩm iOS-first CupertinoMenuAnchor UI dày đặc desktop MenuAnchor + hoverOpenDelay Brand đa nền tảng Wrapper adaptive chọn theo platform Cạm bẫy Thứ tự callback close của RawMenuAnchor đã đổi — đọc breaking change trước khi upgrade. Đừng rebuild cả cây menu mỗi pointer event; giữ anchor ổn định. Bài viết gốc đăng tại FlutterCook . Bản trên đó là bản được cập nhật mới nhất.

CupertinoMenuAnchor and modern Flutter menus

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.