BasePopupButton class

BasePopupButton - Cross-platform popup button with native iOS support

Uses CNPopupButton (Cupertino Native) for iOS - provides true native iOS popup button (UIButton with popup menu) with built-in liquid glass effects and native rendering. Uses PopupMenuButton (Material) for Android and other platforms.

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

Features:

  • Native iOS popup button via CNPopupButton (cupertino_native package)
  • Material Design popup menu for Android
  • Displays selected option on button label
  • Supports all CNButtonStyle options (plain, gray, tinted, filled, bordered)
  • Optional prefix text (e.g., "Show:", "Filter:")
  • Custom dimensions (width and height)
  • Custom tint colors for themed buttons
  • Divider support between options
  • Built-in liquid glass effects on iOS (no manual wrapper needed)

Example usage:

BasePopupButton(
  options: ['All', 'Images', 'Videos', 'Documents'],
  selectedIndex: 0,
  onSelected: (index) {
    print('Selected: $index');
  },
  buttonStyle: CNButtonStyle.tinted,
  tint: CupertinoColors.systemBlue,
  prefix: 'Filter:',
)

Updated: 2024.10.25 - Renamed from BaseCNPopupButton for consistency

Inheritance

Constructors

BasePopupButton({Key? key, required List<String> options, int selectedIndex = 0, required void onSelected(int), Color? tint, double height = 32.0, double? width, CNButtonStyle buttonStyle = CNButtonStyle.plain, String? prefix, List<int> dividerIndices = const [], BaseParam? baseParam})
Creates a base popup button wrapper
const

Properties

baseParam → BaseParam?
Personalization parameters, gets platform parameters first, then mode parameters
finalinherited
buttonStyle → CNButtonStyle
Button style from CNButtonStyle
final
dividerIndices → List<int>
Indices where dividers should be inserted
final
hashCode → int
The hash code for this object.
no setterinherited
height → double
Height of the button
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onSelected → void Function(int)
Called when an option is selected
final
options → List<String>
List of options to display in the popup menu
final
prefix → String?
Optional prefix text displayed before the selected option (e.g., "Show:", "Filter:")
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
selectedIndex → int
Currently selected index
final
tint → Color?
Custom tint color for the button
final
width → double?
Width of the button (optional, defaults to auto-sizing)
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