diff --git a/example/lib/gzx_dropdown_menu_test_page.dart b/example/lib/gzx_dropdown_menu_test_page.dart index b75947d..04d9cb7 100644 --- a/example/lib/gzx_dropdown_menu_test_page.dart +++ b/example/lib/gzx_dropdown_menu_test_page.dart @@ -105,7 +105,10 @@ class _GZXDropDownMenuTestPageState extends State { items: [ GZXDropDownHeaderItem(_dropDownHeaderItemStrings[0]), GZXDropDownHeaderItem(_dropDownHeaderItemStrings[1]), - GZXDropDownHeaderItem(_dropDownHeaderItemStrings[2]), + GZXDropDownHeaderItem( + _dropDownHeaderItemStrings[2], + style: TextStyle(color: Colors.yellow), + ), GZXDropDownHeaderItem(_dropDownHeaderItemStrings[3], iconData: Icons.filter_frames, iconSize: 18), ], // GZXDropDownHeader对应第一父级Stack的key @@ -194,8 +197,7 @@ class _GZXDropDownMenuTestPageState extends State { dropDownHeight: 40 * 8.0, dropDownWidget: _buildConditionListWidget(_brandSortConditions, (value) { _selectBrandSortCondition = value; - _dropDownHeaderItemStrings[1] = - _selectBrandSortCondition.name == '全部' ? '品牌' : _selectBrandSortCondition.name; + _dropDownHeaderItemStrings[1] = _selectBrandSortCondition.name == '全部' ? '品牌' : _selectBrandSortCondition.name; _dropdownMenuController.hide(); setState(() {}); })), diff --git a/lib/src/gzx_dropdown_header.dart b/lib/src/gzx_dropdown_header.dart index 1c4a4bf..739b647 100644 --- a/lib/src/gzx_dropdown_header.dart +++ b/lib/src/gzx_dropdown_header.dart @@ -140,40 +140,43 @@ class _GZXDropDownHeaderState extends State with SingleTicker setState(() {}); }, child: Container( - color: widget.color, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Expanded( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Flexible( - child: Text( + color: widget.color, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Flexible( + child: Text( item.title, maxLines: 1, overflow: TextOverflow.ellipsis, - style: _isShowDropDownItemWidget ? _dropDownStyle : widget.style, - )), - Icon( - !_isShowDropDownItemWidget - ? item.iconData ?? Icons.arrow_drop_down - : item.iconData ?? Icons.arrow_drop_up, - color: _isShowDropDownItemWidget ? _iconDropDownColor : widget.iconColor, - size: item.iconSize ?? widget.iconSize, + style: _isShowDropDownItemWidget ? _dropDownStyle : widget.style.merge(item.style), ), - ], - ), + ), + Icon( + !_isShowDropDownItemWidget ? item.iconData ?? Icons.arrow_drop_down : item.iconData ?? Icons.arrow_drop_up, + color: _isShowDropDownItemWidget ? _iconDropDownColor : item?.style?.color ?? widget.iconColor, + size: item.iconSize ?? widget.iconSize, + ), + ], ), - index == widget.items.length - 1 - ? Container() - : Container( - height: widget.dividerHeight, - decoration: - BoxDecoration(border: Border(right: BorderSide(color: widget.dividerColor, width: 1))), - ) - ], - )), + ), + index == widget.items.length - 1 + ? Container() + : Container( + height: widget.dividerHeight, + decoration: BoxDecoration( + border: Border( + right: BorderSide(color: widget.dividerColor, width: 1), + ), + ), + ) + ], + ), + ), ); } } @@ -182,10 +185,6 @@ class GZXDropDownHeaderItem { final String title; final IconData iconData; final double iconSize; - - GZXDropDownHeaderItem( - this.title, { - this.iconData, - this.iconSize, - }); + final TextStyle style; + GZXDropDownHeaderItem(this.title, {this.iconData, this.iconSize, this.style}); }