BasePullDownButtonAnchor class

BasePullDownButtonAnchor - Cross-platform pull-down button with menu anchoring

Uses CNPullDownButtonAnchor (Cupertino Native) for iOS - provides native iOS pull-down button with automatic menu anchoring via UIButton with UIMenu. Uses PopupMenuButton (Material) for Android.

*** use cupertino = { forceUseMaterial: true } force use Material popup on iOS *** use material = { forceUseCupertino: true } force use CNPullDownButtonAnchor on Android

Features:

  • Native UIButton with UIMenu for authentic iOS behavior via CNPullDownButtonAnchor
  • Material Design popup menu for Android
  • Anchors pull-down menu to CNButton styles
  • Supports all CNButtonStyle options (plain, gray, tinted, filled, bordered, glass)
  • Custom tint colors for themed buttons
  • Optional menu title displayed at top of menu
  • Icon-only buttons with customizable size
  • Alignment control for menu positioning
  • Built-in liquid glass effects on iOS (no manual wrapper needed)

Example usage:

BasePullDownButtonAnchor.icon(
  buttonIcon: const CNSymbol('ellipsis.circle'),
  buttonStyle: CNButtonStyle.gray,
  items: const [
    CNPullDownMenuItem(
      label: 'Settings',
      icon: CNSymbol('gear'),
    ),
    CNPullDownMenuItem(
      label: 'Help',
      icon: CNSymbol('questionmark.circle'),
    ),
  ],
  onSelected: (index) {
    print('Selected: $index');
  },
)

Updated: 2024.10.25 - Renamed from BaseCNPullDownButtonAnchor for consistency

Inheritance

Constructors

BasePullDownButtonAnchor({Key? key, required String? buttonLabel, required List<CNPullDownMenuEntry> items, required ValueChanged<int> onSelected, Color? tint, double height = 44.0, double? width, CNButtonStyle buttonStyle = CNButtonStyle.plain, String? menuTitle, Alignment alignment = Alignment.center, BaseParam? baseParam})
Creates a text-labeled pull-down button with automatic anchoring
const
BasePullDownButtonAnchor.icon({Key? key, required CNSymbol? buttonIcon, required List<CNPullDownMenuEntry> items, required ValueChanged<int> onSelected, Color? tint, double size = 44.0, CNButtonStyle buttonStyle = CNButtonStyle.glass, String? menuTitle, Alignment alignment = Alignment.center, BaseParam? baseParam})
Creates a round, icon-only pull-down button with automatic anchoring
const

Properties

alignment → Alignment
Alignment of the button content
final
baseParam → BaseParam?
Personalization parameters, gets platform parameters first, then mode parameters
finalinherited
buttonIcon → CNSymbol?
Icon for the button (non-null in icon mode)
final
buttonLabel → String?
Text for the button (null when using icon mode)
final
buttonStyle → CNButtonStyle
Visual style to apply to the button
final
hashCode → int
The hash code for this object.
no setterinherited
height → double
Control height; icon mode uses diameter semantics
final
items → List<CNPullDownMenuEntry>
Entries that populate the pull-down menu
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
Optional title for the menu
final
onSelected → ValueChanged<int>
Called with the selected index when the user makes a selection
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
size → double
Size for icon-only button variant
final
tint → Color?
Tint color for the control
final
width → double?
Fixed width; if null, uses intrinsic width
final

Methods

beforeBuild(BuildContext context) → void
Called before build
inherited
beforeBuildByCupertino(BuildContext context) → void
Called before buildByCupertino
inherited
beforeBuildByCupertinoNative(BuildContext context) → void
Called before buildByCupertinoNative (native iOS implementation)
inherited
beforeBuildByMaterial(BuildContext context) → void
Called before buildByMaterial
inherited
build(BuildContext context) → Widget
Describes the part of the user interface represented by this widget.
inherited
buildByCupertino(BuildContext context) → Widget
build on cupertino mode (Flutter implementation)
buildByCupertinoNative(BuildContext context) → dynamic
build on cupertino mode with native iOS components (cupertino_native package) This is called when baseParam.nativeIOS = true Default implementation falls back to buildByCupertino()
inherited
buildByMaterial(BuildContext context) → Widget
build on material mode
commonBuild(BuildContext context, BaseParam? baseParam) → dynamic
inherited
createElement() → StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
getBuildMode(BaseParam? baseParam) → WidgetBuildMode
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited
valueOf(String key, dynamic value) → dynamic
inherited
valueOfBaseParam(BaseParam? baseParam, String key, dynamic value) → dynamic
No reflection available in Dart First get value from platform, then from mode, finally from value itself
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited