CoolDropdown constructor
CoolDropdown({
- required List dropdownList,
- required Function onChange,
- dynamic resultIcon,
- dynamic placeholderTS,
- bool dropdownItemReverse = false,
- bool resultReverse = false,
- bool resultIconRotation = true,
- bool isTriangle = true,
- bool isResultLabel = true,
- String placeholder = '',
- double resultWidth = 220,
- double resultHeight = 50,
- double dropdownWidth = 200,
- double dropdownHeight = 300,
- double dropdownItemHeight = 50,
- Alignment resultAlign = Alignment.centerLeft,
- String dropdownAlign = 'center',
- String triangleAlign = 'center',
- Alignment dropdownItemAlign = Alignment.centerLeft,
- MainAxisAlignment dropdownItemMainAxis = MainAxisAlignment.spaceBetween,
- MainAxisAlignment resultMainAxis = MainAxisAlignment.spaceBetween,
- EdgeInsets resultPadding = const EdgeInsets.only(left: 10, right: 10),
- EdgeInsets dropdownItemPadding = const EdgeInsets.only(left: 10, right: 10),
- EdgeInsets dropdownPadding = const EdgeInsets.only(left: 10, right: 10),
- EdgeInsets selectedItemPadding = const EdgeInsets.only(left: 10, right: 10),
- dynamic resultBD,
- dynamic dropdownBD,
- dynamic selectedItemBD,
- dynamic selectedItemTS,
- dynamic unselectedItemTS,
- dynamic resultTS,
- double labelIconGap = 10,
- double dropdownItemGap = 5,
- double dropdownItemTopGap = 10,
- double dropdownItemBottomGap = 10,
- double resultIconLeftGap = 10,
- double gap = 30,
- double triangleWidth = 20,
- double triangleHeight = 20,
- double triangleLeft = 0,
- bool isAnimation = true,
- bool isResultIconLabel = true,
- double resultIconRotationValue = 0.5,
- bool isDropdownLabel = true,
- dynamic defaultValue,
- required Key key,
Implementation
CoolDropdown({
required this.dropdownList,
required this.onChange,
resultIcon,
placeholderTS,
this.dropdownItemReverse = false,
this.resultReverse = false,
this.resultIconRotation = true,
this.isTriangle = true,
this.isResultLabel = true,
this.placeholder = '',
this.resultWidth = 220,
this.resultHeight = 50,
this.dropdownWidth = 200,
this.dropdownHeight = 300,
this.dropdownItemHeight = 50,
this.resultAlign = Alignment.centerLeft,
this.dropdownAlign = 'center',
this.triangleAlign = 'center',
this.dropdownItemAlign = Alignment.centerLeft,
this.dropdownItemMainAxis = MainAxisAlignment.spaceBetween,
this.resultMainAxis = MainAxisAlignment.spaceBetween,
this.resultPadding = const EdgeInsets.only(left: 10, right: 10),
this.dropdownItemPadding = const EdgeInsets.only(left: 10, right: 10),
this.dropdownPadding = const EdgeInsets.only(left: 10, right: 10),
this.selectedItemPadding = const EdgeInsets.only(left: 10, right: 10),
resultBD,
dropdownBD,
selectedItemBD,
selectedItemTS,
unselectedItemTS,
resultTS,
this.labelIconGap = 10,
this.dropdownItemGap = 5,
this.dropdownItemTopGap = 10,
this.dropdownItemBottomGap = 10,
this.resultIconLeftGap = 10,
this.gap = 30,
this.triangleWidth = 20,
this.triangleHeight = 20,
this.triangleLeft = 0,
this.isAnimation = true,
this.isResultIconLabel = true,
this.resultIconRotationValue = 0.5,
this.isDropdownLabel = true,
defaultValue,
required this.key,
}) {
// 기본값 셋팅
if (defaultValue != null) {
this.defaultValue = defaultValue;
} else {
this.defaultValue = {};
}
// label unique 체크
for (var i = 0; i < dropdownList.length; i++) {
if (dropdownList[i]['label'] == null) {
throw '"label" must be initialized.';
}
for (var j = 0; j < dropdownList.length; j++) {
if (i != j) {
if (dropdownList[i]['label'] == dropdownList[j]['label']) {
throw 'label is duplicated. Labels have to be unique.';
}
}
}
}
// box decoration 셋팅
this.resultBD = resultBD ??
BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.1),
spreadRadius: 1,
blurRadius: 10,
offset: Offset(0, 1), // changes position of shadow
),
],
);
this.dropdownBD = dropdownBD ??
BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.1),
spreadRadius: 1,
blurRadius: 10,
offset: Offset(0, 1),
),
],
);
this.selectedItemBD = selectedItemBD ??
BoxDecoration(
color: Color(0XFFEFFAF0),
borderRadius: BorderRadius.circular(10),
);
// text style 셋팅
this.selectedItemTS =
selectedItemTS ?? TextStyle(color: Color(0xFF6FCC76), fontSize: 20);
this.unselectedItemTS = unselectedItemTS != null
? unselectedItemTS
: TextStyle(
fontSize: 20,
color: Colors.black,
);
this.resultTS = resultTS ??
TextStyle(
fontSize: 20,
color: Colors.black,
);
this.placeholderTS = placeholderTS ??
TextStyle(color: Colors.grey.withOpacity(0.7), fontSize: 20);
// Icon Container 셋팅
this.resultIcon = resultIcon ?? Container();
}