PickerDataAdapter<T> class

A picker adapter for array-based and hierarchical data structures.

PickerDataAdapter is the most commonly used adapter that supports both simple arrays and complex hierarchical data. It can handle:

  • Simple lists: ['Option 1', 'Option 2', 'Option 3']
  • Multi-dimensional arrays for independent columns
  • Hierarchical maps for linked columns: {'Category': ['Item1', 'Item2']}
  • Mixed data types with custom PickerItem objects

Simple Array Example

final adapter = PickerDataAdapter<String>(
  pickerData: ['Apple', 'Banana', 'Orange'],
);

Multi-Column Array Example (Independent Columns)

final adapter = PickerDataAdapter<String>(
  pickerData: [
    ['Red', 'Green', 'Blue'],     // Column 1: Colors
    ['Small', 'Medium', 'Large'], // Column 2: Sizes
  ],
  isArray: true,
);

Hierarchical Example (Linked Columns)

final adapter = PickerDataAdapter<String>(
  pickerData: [
    {
      'Fruits': ['Apple', 'Banana', 'Orange'],
      'Vegetables': ['Carrot', 'Broccoli', 'Spinach'],
    }
  ],
);

Custom PickerItem Example

final adapter = PickerDataAdapter<String>(
  data: [
    PickerItem<String>(
      text: Row(children: [Icon(Icons.apple), Text('Apple')]),
      value: 'apple',
    ),
    PickerItem<String>(
      text: Row(children: [Icon(Icons.android), Text('Banana')]),
      value: 'banana', 
    ),
  ],
);
Inheritance

Constructors

PickerDataAdapter.new({List? pickerData, List<PickerItem<T>>? data, bool isArray = false})

Properties

data List<PickerItem<T>>
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
isArray bool
final
isLinkage bool
no setterinherited
length int
Content length of current column
no setterinherited
maxLevel int
no setterinherited
picker Picker?
Reference to the picker widget using this adapter.
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
text String
no setterinherited

Methods

buildItem(BuildContext context, int index) Widget
Builds the widget for a specific item in the current column.
override
doSelect(int column, int index) → void
inherited
doShow() → void
inherited
getColumnFlex(int column) int
inherited
getIsLinkage() bool
override
getLength() int
Returns the number of items in the current column.
override
getMaxLevel() int
Returns the maximum number of columns (levels) this adapter supports.
override
getSelectedValues() List<T>
override
getText() String
inherited
initSelects() → void
Initializes the selected indices for all columns.
override
makeText(Widget? child, String? text, bool isSel) Widget
inherited
makeTextEx(Widget? child, String text, Widget? postfix, Widget? suffix, bool isSel) Widget
inherited
needUpdatePrev(int curIndex) bool
Need to update previous columns
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyDataChanged() → void
Notify adapter of data changes
inherited
setColumn(int index) → void
Sets the active column for subsequent operations.
override
toString() String
A string representation of this object.
inherited

Operators

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