Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class _TestPageState extends State<TestPage> {
DropDownTextField(
// initialValue: "name4",
controller: _cnt,

clearOption: true,
enableSearch: true,
clearIconProperty: IconProperty(color: Colors.green),
Expand All @@ -86,7 +87,7 @@ class _TestPageState extends State<TestPage> {
}
},
dropDownItemCount: 6,

dropDownItemTextAlignment: Alignment.centerLeft,
dropDownList: const [
DropDownValueModel(name: 'name1', value: "value1"),
DropDownValueModel(
Expand Down
23 changes: 18 additions & 5 deletions lib/dropdown_textfield.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class DropDownTextField extends StatefulWidget {
this.textFieldDecoration,
this.dropDownIconProperty,
this.dropDownItemCount = 6,
this.dropDownItemTextAlignment = Alignment.centerLeft,
this.searchFocusNode,
this.textFieldFocusNode,
this.searchAutofocus = false,
Expand Down Expand Up @@ -113,6 +114,7 @@ class DropDownTextField extends StatefulWidget {
this.dropDownIconProperty,
this.textFieldDecoration,
this.dropDownItemCount = 6,
this.dropDownItemTextAlignment = Alignment.centerLeft,
this.searchFocusNode,
this.textFieldFocusNode,
this.listSpace = 0,
Expand Down Expand Up @@ -244,6 +246,9 @@ class DropDownTextField extends StatefulWidget {
///customize checkbox property
final CheckBoxProperty? checkBoxProperty;

///dropdown list text alignment
final Alignment? dropDownItemTextAlignment;

@override
_DropDownTextFieldState createState() => _DropDownTextFieldState();
}
Expand Down Expand Up @@ -445,7 +450,7 @@ class _DropDownTextFieldState extends State<DropDownTextField>
}

_listTileTextStyle =
(widget.listTextStyle ?? Theme.of(context).textTheme.subtitle1)!;
(widget.listTextStyle ?? Theme.of(context).textTheme.titleMedium)!;
_listTileHeight =
_textWidgetSize("dummy Text", _listTileTextStyle).height +
_listPadding.top +
Expand Down Expand Up @@ -665,7 +670,7 @@ class _DropDownTextFieldState extends State<DropDownTextField>
builder: buildOverlay,
))),
);
overlay?.insert(_isScrollPadding ? _entry2! : _entry!);
overlay.insert(_isScrollPadding ? _entry2! : _entry!);
}

_openOutSideClickOverlay(BuildContext context) {
Expand All @@ -683,7 +688,7 @@ class _DropDownTextFieldState extends State<DropDownTextField>
),
);
});
overlay2?.insert(_barrierOverlay!);
overlay2.insert(_barrierOverlay!);
}

void hideOverlay() {
Expand Down Expand Up @@ -770,6 +775,8 @@ class _DropDownTextFieldState extends State<DropDownTextField>
enableSearch: widget.enableSearch,
height: _height,
listTileHeight: _listTileHeight,
listTileTextAlignment: widget.dropDownItemTextAlignment ??
Alignment.centerLeft,
dropDownList: _dropDownList,
listTextStyle: _listTileTextStyle,
onChanged: (item) {
Expand Down Expand Up @@ -815,6 +822,8 @@ class _DropDownTextFieldState extends State<DropDownTextField>
buttonColor: widget.submitButtonColor,
height: _height,
listTileHeight: _listTileHeight,
listTileTextAlignment: widget.dropDownItemTextAlignment ??
Alignment.centerLeft,
list: _multiSelectionValue,
dropDownList: _dropDownList,
listTextStyle: _listTileTextStyle,
Expand Down Expand Up @@ -878,6 +887,7 @@ class SingleSelection extends StatefulWidget {
required this.mainController,
required this.autoSort,
required this.listTileHeight,
this.listTileTextAlignment = Alignment.centerLeft,
this.onSearchTap,
this.onSearchSubmit,
this.listTextStyle,
Expand All @@ -889,6 +899,7 @@ class SingleSelection extends StatefulWidget {
final ValueSetter onChanged;
final double height;
final double listTileHeight;
final Alignment listTileTextAlignment;
final bool enableSearch;
final double searchHeight;
final FocusNode searchFocusNode;
Expand Down Expand Up @@ -1022,7 +1033,7 @@ class _SingleSelectionState extends State<SingleSelection> {
bottom: widget.listPadding.bottom,
top: widget.listPadding.top),
child: Align(
alignment: Alignment.centerLeft,
alignment: widget.listTileTextAlignment,
child: FittedBox(
fit: BoxFit.fitHeight,
child: Text(newDropDownList[index].name,
Expand Down Expand Up @@ -1052,6 +1063,7 @@ class MultiSelection extends StatefulWidget {
this.buttonTextStyle,
required this.listTileHeight,
required this.listPadding,
this.listTileTextAlignment = Alignment.centerLeft,
this.listTextStyle,
this.checkBoxProperty})
: super(key: key);
Expand All @@ -1063,6 +1075,7 @@ class MultiSelection extends StatefulWidget {
final String? buttonText;
final TextStyle? buttonTextStyle;
final double listTileHeight;
final Alignment listTileTextAlignment;
final TextStyle? listTextStyle;
final ListPadding listPadding;
final CheckBoxProperty? checkBoxProperty;
Expand Down Expand Up @@ -1104,7 +1117,7 @@ class _MultiSelectionState extends State<MultiSelection> {
padding:
const EdgeInsets.symmetric(horizontal: 10),
child: Align(
alignment: Alignment.centerLeft,
alignment: widget.listTileTextAlignment,
child: Row(
children: [
Expanded(
Expand Down