CkStateDropDown class
A dropdown widget for selecting states/provinces of a country.
Automatically provides full state name (property.stateName) and abbreviation (property.abbreviation)
to callbacks and builders via CkStateDropDownItemProperty.
Supports passing either full state name or state abbreviation in initialState.
Example:
CkStateDropDown(
countryName: 'United States',
initialState: 'CA', // Accepts state name ('California') or abbreviation ('CA')
onChanged: (property) {
print(property?.stateName); // California
print(property?.abbreviation); // CA
},
selectedItemBuilder: (property) => CkText(
text: property.stateName,
),
nameBuilder: (property) => CkText(
text: '${property.stateName}${property.abbreviation != null ? " (${property.abbreviation})" : ""}',
),
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- CkStateDropDown
- Available extensions
Constructors
-
CkStateDropDown({Key? key, String hint = 'State', Widget? prefix, required String countryName, required void onChanged(CkStateDropDownItemProperty?), MapEntry<
String, String> ? initialValue, String? initialState, bool isRequired = false, FontStyle fontStyle = FontStyle.normal, Color? backgroundColor, Color? borderColor, TextStyle? textStyle, bool isLoading = false, double borderRadius = 8, bool enableInitalSelection = false, EdgeInsets? contentPadding, Widget? suffixIcon, dynamic nameBuilder(CkStateDropDownItemProperty property)?, Map<String, String> ? customAbbreviationMap, bool showAbbreviationInMenu = false, bool isSeparated = false, EdgeInsets? itemPadding, Widget selectedItemBuilder(CkStateDropDownItemProperty property)?, TextStyle? hintStyle, CkBorderType borderType = CkBorderType.outline, double borderWidth = 1.2, CkDropDownType dropDownType = CkDropDownType.menu, }) -
const
Properties
- backgroundColor → Color?
-
final
- borderColor → Color?
-
final
- borderRadius → double
-
final
- borderType → CkBorderType
-
final
- borderWidth → double
-
final
- center → Widget
-
Available on Widget, provided by the Alignments extension
no setter - contentPadding → EdgeInsets?
-
final
- countryName → String
-
final
-
customAbbreviationMap
→ Map<
String, String> ? -
Optional custom mapping for state abbreviations (e.g.
{'California': 'CA'}).final - dropDownType → CkDropDownType
-
final
- enableInitalSelection → bool
-
final
- end → Widget
-
Available on Widget, provided by the Alignments extension
no setter - fontStyle → FontStyle
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hint → String
-
final
- hintStyle → TextStyle?
-
final
- initialState → String?
-
Optional initial state specified as state name or abbreviation (e.g.
'California'or'CA'). Takes precedence over initialValue when provided.final -
initialValue
→ MapEntry<
String, String> ? -
final
- isLoading → bool
-
final
- isRequired → bool
-
final
- isSeparated → bool
-
final
- itemPadding → EdgeInsets?
-
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- marginZero → Widget
-
Available on Widget, provided by the WidgetMarginX extension
no setter -
final
-
final
-
final
-
final
-
final
- nameBuilder → dynamic Function(CkStateDropDownItemProperty property)?
-
final
- onChanged → void Function(CkStateDropDownItemProperty?)
-
Callback when state selection changes.
final
- paddingZero → Widget
-
Available on Widget, provided by the WidgetPaddingX extension
no setter - prefix → Widget?
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selectedItemBuilder → Widget Function(CkStateDropDownItemProperty property)?
-
final
- showAbbreviationInMenu → bool
-
Whether to show the abbreviation in the menu items (e.g. "California (CA)").
final
- sliverBox → Widget
-
Available on Widget, provided by the WidgetSliverBoxX extension
no setter - start → Widget
-
Available on Widget, provided by the Alignments extension
no setter - suffixIcon → Widget?
-
final
- textStyle → TextStyle?
-
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
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
-
getStates(
{required String country}) → List< String> -
marginAll(
double margin) → Widget -
Available on Widget, provided by the WidgetMarginX extension
-
marginOnly(
{double left = 0.0, double top = 0.0, double right = 0.0, double bottom = 0.0}) → Widget -
Available on Widget, provided by the WidgetMarginX extension
-
marginSymmetric(
{double horizontal = 0.0, double vertical = 0.0}) → Widget -
Available on Widget, provided by the WidgetMarginX extension
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
paddingAll(
double padding) → Widget -
Available on Widget, provided by the WidgetPaddingX extension
-
paddingOnly(
{double left = 0.0, double top = 0.0, double right = 0.0, double bottom = 0.0}) → Widget -
Available on Widget, provided by the WidgetPaddingX extension
-
paddingSymmetric(
{double horizontal = 0.0, double vertical = 0.0}) → Widget -
Available on Widget, provided by the WidgetPaddingX extension
-
toAr(
num width, num height) → Widget -
Available on Widget, provided by the WidgetAspectRatio extension
-
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
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited