Skip to content

Commit

Permalink
working on dropdown
Browse files Browse the repository at this point in the history
#40
problem with the overlay that doesn't scroll along with the parent page.
  • Loading branch information
lcuis committed Jul 10, 2021
1 parent 44cd4b0 commit 3986eb3
Show file tree
Hide file tree
Showing 2 changed files with 460 additions and 197 deletions.
60 changes: 54 additions & 6 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class MyApp extends StatefulWidget {
class _MyAppState extends State<MyApp> {
bool asTabs = false;
String? selectedValueSingleDialog;
String? selectedValueSingleDropdown;
String? selectedValueSingleDoneButtonDialog;
String? selectedValueSingleMenu;
String? selectedValueSingleDialogCustomKeyboard;
Expand All @@ -78,6 +79,7 @@ class _MyAppState extends State<MyApp> {
List<int> selectedItemsMultiDialogSelectAllNoneWoClear = [];
List<int> editableSelectedItems = [];
List<DropdownMenuItem> items = [];
List<DropdownMenuItem> dropdownItems = [];
List<DropdownMenuItem> editableItems = [];
List<DropdownMenuItem> futureItems = [];
final _formKey = GlobalKey<FormState>();
Expand Down Expand Up @@ -125,6 +127,43 @@ class _MyAppState extends State<MyApp> {
wordPair = "";
}
});
wordPair = "";
loremIpsum
.toLowerCase()
.replaceAll(",", "")
.replaceAll(".", "")
.split(" ")
.forEach((word) {
if (wordPair.isEmpty) {
wordPair = word + " ";
} else {
wordPair += word;
if (dropdownItems.indexWhere((item) {
return (item.value == wordPair);
}) ==
-1) {
dropdownItems.add(DropdownMenuItem(
child:
Card(
color: Colors.blue.shade50,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
side: BorderSide(
color: Colors.brown,
width: 0.5,
),
),
margin: EdgeInsets.all(12),
child: Padding(
padding: const EdgeInsets.all(8),
child: Text(wordPair,style:TextStyle(fontSize: 16,color: Colors.black,fontFamily: "roboto",fontStyle: FontStyle.normal,fontWeight: FontWeight.normal,decoration: TextDecoration.none,),),
)),
value: wordPair,
));
}
wordPair = "";
}
});
input = TextFormField(
validator: (value) {
return ((value?.length ?? 0) < 6
Expand Down Expand Up @@ -233,6 +272,18 @@ class _MyAppState extends State<MyApp> {
},
isExpanded: true,
),
"Single dropdown": SearchChoices.single(
items: dropdownItems,
value: selectedValueSingleDropdown,
hint: "Select one",
onChanged: (value) {
setState(() {
selectedValueSingleDropdown = value;
});
},
mode:SearchChoicesMode.dropdown,
isExpanded: true,
),
"Single done button dialog": SearchChoices.single(
items: items,
value: selectedValueSingleDoneButtonDialog,
Expand Down Expand Up @@ -1472,6 +1523,7 @@ class _MyAppState extends State<MyApp> {
? DefaultTabController(
length: widgets.length,
child: Scaffold(
resizeToAvoidBottomInset: true,
appBar: AppBar(
title: const Text(appTitle),
actions: appBarActions,
Expand Down Expand Up @@ -1511,6 +1563,7 @@ class _MyAppState extends State<MyApp> {
),
)
: Scaffold(
resizeToAvoidBottomInset: true,
appBar: AppBar(
title: const Text(appTitle),
actions: appBarActions,
Expand All @@ -1519,7 +1572,6 @@ class _MyAppState extends State<MyApp> {
scrollDirection: Axis.vertical,
child: Column(
children:
// [
widgets
.map((k, v) {
return (MapEntry(
Expand All @@ -1545,11 +1597,7 @@ class _MyAppState extends State<MyApp> {
)))));
})
.values
.toList()
// .last
// ]
// .first]
,
.toList(),
),
),
),
Expand Down
Loading

0 comments on commit 3986eb3

Please sign in to comment.