Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: filled field text fix #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
17 changes: 12 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
## 0.0.5

- Fixed a bug when text wasn't showing when the field was filled with a color.

## 0.0.4
* Updated package description
* formatted multiselect.dart

- Updated package description
- formatted multiselect.dart

## 0.0.3
* Matching version number in pub with github

- Matching version number in pub with github

## 0.0.2
* Updated README.md

- Updated README.md

## 0.0.1

* The first implementation of a multiselect
- The first implementation of a multiselect
63 changes: 59 additions & 4 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,79 @@ class Home extends StatefulWidget {
}

class _HomeState extends State<Home> {

List<String> selected = [];

@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Padding(
child: Container(
width: 100,
padding: const EdgeInsets.all(20.0),
child: DropDownMultiSelect(
onChanged: (List<String> x) {
setState(() {
selected =x;
selected = x;
});
},
options: ['a' , 'b' , 'c' , 'd'],
options: [
'aghfchgfch',
'bfghfgghfhhj',
'cbkjhkhbjkgb',
'djghhjghjvhgf'
],
selectedValues: selected,
whenEmpty: 'Select Something',
decoration: InputDecoration(
filled: true,
fillColor: Color(0xFFF2F5F8),
contentPadding: EdgeInsets.symmetric(
vertical: 8,
horizontal: 12,
),
border: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.transparent,
width: 1,
),
borderRadius: BorderRadius.circular(5),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.transparent,
width: 1,
),
borderRadius: BorderRadius.circular(5),
),
errorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.transparent,
width: 1,
),
borderRadius: BorderRadius.circular(5),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.transparent,
width: 1,
),
borderRadius: BorderRadius.circular(5),
),
disabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.transparent,
width: 1,
),
borderRadius: BorderRadius.circular(5),
),
focusedErrorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.transparent,
width: 1,
),
borderRadius: BorderRadius.circular(5),
),
),
),
),
));
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.0.3"
version: "0.0.5"
path:
dependency: transitive
description:
Expand Down
132 changes: 57 additions & 75 deletions lib/multiselect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ class _SelectRow extends StatelessWidget {
onChange(x!);
_theState.notify();
}),
Text(text)
SizedBox(width: 4),
Text(
text,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 13),
),
],
);
}
Expand Down Expand Up @@ -87,80 +92,57 @@ class _DropDownMultiSelectState extends State<DropDownMultiSelect> {
Widget build(BuildContext context) {
return Container(
height: 100,
child: Stack(
children: [
_theState.rebuilder(() => widget.childBuilder != null
? widget.childBuilder!(widget.selectedValues)
: Align(
child: Padding(
padding:
EdgeInsets.symmetric(vertical: 15, horizontal: 10),
child: Text(widget.selectedValues.length > 0
? widget.selectedValues
.reduce((a, b) => a + ' , ' + b)
: widget.whenEmpty ?? '')),
alignment: Alignment.centerLeft)),
Align(
alignment: Alignment.centerLeft,
child: DropdownButtonFormField<String>(
decoration: widget.decoration != null
? widget.decoration
: InputDecoration(
border: OutlineInputBorder(),
isDense: true,
contentPadding: EdgeInsets.symmetric(
vertical: 15,
horizontal: 10,
),
),
isDense: true,
onChanged: widget.enabled ? (x) {} : null,
value: null,
selectedItemBuilder: (context) {
return widget.options
.map((e) => DropdownMenuItem(
child: Container(),
))
.toList();
},
items: widget.options
.map((x) => DropdownMenuItem(
child: _theState.rebuilder(() {
return widget.menuItembuilder != null
? widget.menuItembuilder!(x)
: _SelectRow(
selected: widget.selectedValues.contains(x),
text: x,
onChange: (isSelected) {
if (isSelected) {
var ns = widget.selectedValues;
ns.add(x);
widget.onChanged(ns);
} else {
var ns = widget.selectedValues;
ns.remove(x);
widget.onChanged(ns);
}
},
);
}),
value: x,
onTap: () {
if (widget.selectedValues.contains(x)) {
var ns = widget.selectedValues;
ns.remove(x);
widget.onChanged(ns);
} else {
var ns = widget.selectedValues;
ns.add(x);
widget.onChanged(ns);
}
},
))
.toList(),
),
),
],
child: Align(
alignment: Alignment.centerLeft,
child: DropdownButtonFormField<String>(
decoration: widget.decoration != null
? widget.decoration!.copyWith(
hintText: widget.selectedValues.length > 0
? widget.selectedValues.reduce((a, b) => a + ', ' + b)
: widget.whenEmpty ?? '')
: InputDecoration(
border: OutlineInputBorder(),
isDense: true,
),
isDense: true,
onChanged: widget.enabled ? (x) {} : null,
value: null,
items: widget.options
.map((x) => DropdownMenuItem(
child: _theState.rebuilder(() {
return widget.menuItembuilder != null
? widget.menuItembuilder!(x)
: _SelectRow(
selected: widget.selectedValues.contains(x),
text: x,
onChange: (isSelected) {
if (isSelected) {
var ns = widget.selectedValues;
ns.add(x);
widget.onChanged(ns);
} else {
var ns = widget.selectedValues;
ns.remove(x);
widget.onChanged(ns);
}
},
);
}),
value: x,
onTap: () {
if (widget.selectedValues.contains(x)) {
var ns = widget.selectedValues;
ns.remove(x);
widget.onChanged(ns);
} else {
var ns = widget.selectedValues;
ns.add(x);
widget.onChanged(ns);
}
},
))
.toList(),
),
),
);
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: multiselect
description: A simple multiselect dropdown. It provide a concise way to create a Multi Selct ComboBox/SelectBox
version: 0.0.4
version: 0.0.5
homepage: https://github.com/TaimoorHassan/multiselect

environment:
Expand Down