Flutter: custom made dropdown button function doesn't show selected value - flutter

I'm trying to make a custom function which returns a dropdown menu. The function takes 3 arguments: menuTitle, selectedValue and list of Strings.
List<String> cities= ['Rome', 'London', 'Paris'];
String selectedCity;
String title='Select a city';
Widget _buildDropdown(
String menuTitle, String selectedItem, List<String> list) {
return Container(
width: MediaQuery.of(context).size.width * 0.8,
margin: EdgeInsets.all(10.0),
decoration: BoxDecoration(
border: Border.all(color: Colors.grey[300]),
borderRadius: BorderRadius.circular(10.0)),
child: DropdownButtonHideUnderline(
child: ButtonTheme(
alignedDropdown: true,
child: DropdownButton<String>(
isExpanded: true,
hint: Text(
menuTitle.toUpperCase(),
style: GoogleFonts.lato(
textStyle: TextStyle(
color: Colors.grey[500],
fontWeight: FontWeight.bold,
)),
),
value: selectedItem,
items: list.map((String val) {
return DropdownMenuItem(
value: val,
child: Text(
val.toUpperCase(),
style: GoogleFonts.lato(
textStyle: TextStyle(
color: Colors.grey[500],
)),
),
);
}).toList(),
onChanged: (String value) {
setState(() {
selectedItem = value;
});
},
),
),
),
);
}
Dropdown menu shows all options available, but after choosing one, I can only see the hint text and not the selected value. I would appreciate any help.

For your dropdown to reflect on your selectedValue, it should be a part of the state. So follow as shown in the code below. I have tested this code and its working for me.
class _MyAppState extends State<MyApp> {
List<String> cities= ['Rome', 'London', 'Paris'];
//Initialize your selectedItem to selectedCity
//default selectedCity
String selectedCity='Rome';
String title='Select a city';
#override
Widget build(BuildContext context) {
Color color=Colors.blueAccent;
int x=color.value;
return MaterialApp(
home: Scaffold(
body: Column(
children: <Widget>[_buildDropdown("Title","",cities)],
),
),
);
}
Widget _buildDropdown(
String menuTitle, String selectedItem, List<String> list) {
return Container(
margin: EdgeInsets.all(10.0),
decoration: BoxDecoration(
border: Border.all(color: Colors.grey[300]),
borderRadius: BorderRadius.circular(10.0)),
child: DropdownButtonHideUnderline(
child: ButtonTheme(
alignedDropdown: true,
child: DropdownButton<String>(
isExpanded: true,
hint: Text(
menuTitle.toUpperCase(),
),
value: selectedCity,
items: list.map((String val) {
return DropdownMenuItem(
value: val,
child: Text(
val.toUpperCase(),
),
);
}).toList(),
onChanged: (String value) {
setState(() {
selectedCity = value;
});
},
),
),
),
);
}
}

Related

Selected value from DropdownButton not showing in Flutter

I have a DropdownButton which displays user type.
List<String> items = ['Engineer', 'Technician', 'Sales'];
String? currentSelectedValue;
child: DropdownButtonHideUnderline(
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 20.0),
child: DropdownButton<String>(
dropdownColor: Colors.blue.shade100,
isExpanded: true,
hint: Text('Select the user Type'),
onChanged: (newValue) {
setState(() {
currentSelectedValue = newValue;
});
print(currentSelectedValue);
},
items: items.map((String value) {
return DropdownMenuItem(
value: value,
child: Text(
value,
style: TextStyle(color: Colors.black),
),
);
}).toList(),
value: currentSelectedValue,
),
),
),
I can see the list, but when I select a value, it is not displaying on the Text portion of the DropdownButton. I could see the selected value printed in the console.
Can anyone help me to find the mistake?
Make sure to put currentSelectedValue outside the build method.
class Ft extends StatefulWidget {
const Ft({super.key});
#override
State<Ft> createState() => _FtState();
}
class _FtState extends State<Ft> {
List<String> items = ['Engineer', 'Technician', 'Sales'];
String? currentSelectedValue;
#override
Widget build(BuildContext context) {
return Scaffold(
body: DropdownButtonHideUnderline(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: DropdownButton<String>(
dropdownColor: Colors.blue.shade100,
isExpanded: true,
hint: Text('Select the user Type'),
onChanged: (newValue) {
setState(() {
currentSelectedValue = newValue;
});
print(currentSelectedValue);
},
items: items.map((String value) {
return DropdownMenuItem(
value: value,
child: Text(
value,
style: TextStyle(color: Colors.black),
),
);
}).toList(),
value: currentSelectedValue,
),
),
),
);
}
}

Dropdown not showing selected value

DropdownButton(
hint: Text('Select Priority Level', style: GoogleFonts.dosis() ,),
dropdownColor: Colors.blueGrey,
value: selectedValue,
onChanged: (newValue){
setState(() {
selectedValue = newValue;
priority = selectedValue;
});
},
items: listPriority.map((valueItem){
return DropdownMenuItem<String>(
value: valueItem,
child: Text(valueItem),
);
}).toList(),
)
The value selected is stored however when I select an item it does not show in the drop-down field. How can I fix this?
Here is sample code i did
initialize variable
int _selectedjobcategory;
Code
Flexible(
flex: 0,
child: Padding(
padding: EdgeInsets.only(left: 10, right: 10, top: 15),
child: Container(
width: double.infinity,
height: 60,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(5),
border: Border.all(color: Colors.blueGrey)),
child: DropdownButtonFormField(
isExpanded: true,
itemHeight: 50,
icon: Icon(Icons.arrow_drop_down),
iconSize: 40,
// underline: SizedBox(),
hint: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Select Enquiry Type",
style: TextStyle(fontSize: 15, color: Colors.black),
),
),
value: _selectedjobcategory,
onChanged: (newValues) {
setState(() {
_selectedjobcategory = newValues;
});
},
items: jobcategory.map((jobs) {
return DropdownMenuItem(
child: Padding(
padding: const EdgeInsets.all(8.0),
child:
Text(jobs.name, style: TextStyle(fontSize: 15)),
),
value: jobs.id,
);
}).toList(),
),
),
),
),
here's a custom class of dropdown you can call it anywhere
import 'package:flutter/material.dart';
// ignore: must_be_immutable
class DropDownClass extends StatelessWidget {
var _hint;
var _val;
List _list = new List();
bool _border;
Color _underLineColor, _dropDownColor;
List get list => _list;
dynamic Function(dynamic) _listener;
DropDownClass({List list,
var hint,
Color underLineColor,
Color dropDownColor,
Color textColor,
double fontSize,
bool icon,
var val,
int type,
bool border = true,
dynamic Function(dynamic) listener,})
: _list = list,
_hint = hint,
_underLineColor = underLineColor,
_dropDownColor = dropDownColor,
_val = val,
_border = border,
_listener = listener;
#override
Widget build(BuildContext context) {
return DropdownButtonHideUnderline(
child: DropdownButtonFormField<String>(
value: _val,
dropdownColor: _dropDownColor ?? Colors.white,
decoration:_border == true? InputDecoration(
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: _underLineColor ?? Theme
.of(context)
.hintColor,
width: 1.0,
),
)
):InputDecoration(
border: InputBorder.none,
fillColor: Colors.grey[400],
filled: true),
isExpanded: true,
hint: Text(_hint),
items: list.map((item) {
return DropdownMenuItem<String>(
value: item,
child: new Text(item,),
);
}).toList(),
onChanged: (value) {
_val = value;
if (_listener != null) _listener.call(value);
// return val;
},
),
);
}
}

DropdownButtonFormField dosn't show the value that selected flutter

This is my code and I tried to print the value in my console to figure if it is work and it's correctly printed but it dose not show in the text Filed. When I chose the hint text disappear but no thing show also I changed the Icon (arrow) size but when I click on any part of it, no response until I click in the corner
String _medicationDesc;
List<DropdownMenuItem> getDropDownItem() {
List<DropdownMenuItem> dropDownItems = [];
for (String dose in medcationDose) {
var newItem = DropdownMenuItem(
child: Text(
dose,
style: textStyle1,
),
value: dose,
);
dropDownItems.add(newItem);
}
return dropDownItems;
}
List<String> medcationDose = [
'مرة واحدة في اليوم',
'مرتان في اليوم',
'ثلاث مرات في اليوم',
'اربعة مرات في اليوم',
'وقت الحاجة'
];
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(backgroundColor: nave),
body: SingleChildScrollView(
child: Container(
margin: EdgeInsets.fromLTRB(0.0, 30, 0, 0),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
SizedBox(
height: 50,
width: 350,
child: DropdownButtonFormField(
value: _medicationDose,
items: getDropDownItem(),
iconSize: 50,
iconEnabledColor: white,
onChanged: (value) {
setState(() {
_medicationDose = value;
});
},
decoration: InputDecoration(
hintText: 'الجرعة',
),
),
try this
List<String> languageList = ['EN', 'ES', 'FR'];
var selectedValue;
DropdownButtonHideUnderline(
child: DropdownButtonFormField<String>(
decoration: InputDecoration(
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.transparent))),
dropdownColor: CustomColors.black,
value:
selectedValue == null ? languageList[0] : selectedValue,
style: robotoStyle(
color: CustomColors.white,
fontSize: 10),
icon: Icon(
Icons.keyboard_arrow_down,
color: CustomColors.white,
),
isExpanded: true,
items: languageList.map((item) {
return DropdownMenuItem<String>(
value: item,
child: new Text(item,
style: robotoStyle(
color: CustomColors.white,
fontSize: 10)),
);
}).toList(),
onChanged: (value) {
selectedValue = value;
S.load(Locale(selectedValue));
print(selectedValue);
},
),
)
i made a class for you, you can call it anywhere may be it will help you
class DropDownClass extends StatelessWidget {
var values;
var hint;
List list = new List();
Color underLineColor;
Color dropDownColor;
Color textColor;
DropDownClass({this.values,
this.list,this.hint,this.underLineColor,this.dropDownColor,this.textColor});
#override
Widget build(BuildContext context) {
return DropdownButtonHideUnderline(
child: DropdownButtonFormField<String>(
value: values,
dropdownColor: dropDownColor??Colors.white,
decoration: InputDecoration(
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: underLineColor??Colors.grey[800],
width: 1.0,
),
)
),
style: TextStyle(
color: textColor??Colors.black,
fontWeight: FontWeight.w400,
fontSize: 15),
isExpanded: true,
icon: Icon(
Icons.keyboard_arrow_down,
color: Colors.white,
),
hint: Text(hint,
style: TextStyle(
color:Colors.white,
fontWeight: FontWeight.w400,
fontSize:15)),
items: list.map((item) {
return DropdownMenuItem<String>(
value: item,
child: new Text(item,
style: TextStyle(
color:Colors.black,
fontWeight: FontWeight.w400,
fontSize:15)),
);
}).toList(),
onChanged: (value) {
values = value;
print(values);
},
),
);
}
}

Passing data between screen but using extracted dropdown button widget

First of all, here is my condition. I'm trying to pass all the data that were filled in Dropdownbutton and Date & Time picker at the first screen (left picture) to the second screen(right picture). The problem is, I extracted the DropDownButton widget to another class, and I don't understand how to implement it.
Before that, this is the first screen Code :
class InformationDetail extends StatefulWidget {
static const String id = 'InformationDetail';
#override
_InformationDetailState createState() => _InformationDetailState();
}
class _InformationDetailState extends State<InformationDetail> {
String addressText, addNotes;
DateTime selectedDate = DateTime.now();
TimeOfDay selectedTime = TimeOfDay.now();
Future<Null> _selectDate(BuildContext context) async {
final DateTime picked = await showDatePicker(
context: context,
initialDate: selectedDate,
firstDate: DateTime(2015, 8),
lastDate: DateTime(2101));
if (picked != null && picked != selectedDate)
setState(() {
selectedDate = picked;
});
}
Future<Null> _selectTime(BuildContext context) async {
final TimeOfDay picked = await showTimePicker(
context: context,
initialTime: selectedTime,
);
if (picked != null && picked != selectedTime)
setState(() {
selectedTime = picked;
});
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: ListView(
children: <Widget>[
Container(
child: Column(
children: <Widget>[
Container(
margin: EdgeInsets.fromLTRB(25.0, 68.0, 70.0, 26.0),
child: Text(
'Information Detail',
style: TextStyle(fontSize: 35.0),
),
),
Column(
// Wrap Column
children: <Widget>[
Column(
children: <Widget>[
TitleName(
titleText: 'Grooming Type',
infoIcon: Icons.info,
),
MenuDropDown(
dropdownText: 'Grooming Type...',
type: "groomingType",
),
TitleName(
titleText: 'Cat Breeds',
),
MenuDropDown(
dropdownText: 'Cat Breeds...',
type: "catBreeds",
),
TitleName(
titleText: 'Cat Size',
infoIcon: Icons.info,
),
MenuDropDown(
dropdownText: 'Cat Size...',
type: "catSize",
),
TitleName(
titleText: 'Add-On Services',
),
MenuDropDown(
dropdownText: 'Add - On Services...',
type: "addOnServices",
),
TitleName(
titleText: 'Reservation Date',
),
Row(
children: <Widget>[
Container(
width: 130,
height: 30,
margin: EdgeInsets.fromLTRB(50.0, 0, 62, 0),
child: RaisedButton(
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
elevation: 6,
child: Text(
'Choose Date',
style: TextStyle(
fontSize: 12.0,
),
),
onPressed: () => _selectDate(context),
),
),
Text("${selectedDate.toLocal()}".split(' ')[0]),
],
),
TitleName(
titleText: 'Reservation Time',
),
Row(
children: <Widget>[
Container(
width: 130,
height: 30,
margin: EdgeInsets.fromLTRB(50.0, 0, 62, 0),
decoration: BoxDecoration(),
child: RaisedButton(
color: Colors.white,
child: Text(
'Choose Time',
style: TextStyle(
fontSize: 12.0,
),
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
elevation: 6,
onPressed: () => _selectTime(context),
),
),
Text("${selectedTime.toString()}".split(' ')[0]),
],
),
TitleName(
titleText: 'Pick Up Address',
),
Container(
width: 320,
height: 40,
child: TextFormField(
maxLines: null,
minLines: null,
expands: true,
decoration: InputDecoration(
contentPadding:
EdgeInsets.fromLTRB(35.0, 10.0, 0, 10.0),
hintText: 'Address Here...',
hintStyle: TextStyle(
fontSize: 15.0,
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15.0),
),
),
onChanged: (value) {
addressText = value;
},
),
),
TitleName(
titleText: 'Additional Notes',
infoIcon: Icons.info,
),
Container(
width: 320,
child: TextFormField(
maxLines: 4,
decoration: InputDecoration(
contentPadding:
EdgeInsets.fromLTRB(35.0, 10.0, 0, 10.0),
hintText: 'E.g. ',
hintStyle: TextStyle(
fontSize: 15.0,
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15.0),
),
),
onChanged: (value) {
addNotes = value;
},
),
),
Container(
margin: EdgeInsets.fromLTRB(0, 15.0, 0, 0),
width: 75.0,
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.rectangle,
border: Border.all(
color: Colors.black,
),
borderRadius: BorderRadius.circular(12.0),
),
child: IconButton(
icon: Icon(Icons.arrow_forward),
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => ConfirmationOrder(
addressText: addressText,
addNotes: addNotes,
)));
}),
),
],
),
],
),
],
),
),
],
)),
);
}
}
Below the first picture, there's a button to navigate to the second screen.
And here is the class where I extracted DropDownButton :
class MenuDropDown extends StatefulWidget {
final String dropdownText;
final String type;
MenuDropDown({this.dropdownText, this.type});
#override
_MenuDropDownState createState() => _MenuDropDownState();
}
class _MenuDropDownState extends State<MenuDropDown> {
String selectedItem;
List<String> dropdownItems = [];
List<String> groomingTypeList = ['Basic Grooming', 'Full Grooming'];
List<String> catBreedsList = [
'Persia',
'Anggora',
'Domestic',
'Maine Coon',
'Russian Blue',
'Slamese',
'Munchkin',
'Ragdoll',
'Scottish Fold',
];
List<String> catSizeList = [
'Small Size',
'Medium Size',
'Large Size',
'Extra Large Size',
];
List<String> addOnServicesList = [
'Spa & Massage',
'Shaving Hair / Styling',
'Injection Vitamis Skin & Coat',
'Cleaning Pet House and Environment',
'Fur Tangled Treatment',
];
List<String> getListBasedOnName(String value) {
print(value);
switch (value) {
case "groomingType":
return groomingTypeList;
break;
case "catBreeds":
return catBreedsList;
break;
case "catSize":
return catSizeList;
break;
case "addOnServices":
return addOnServicesList;
break;
}
return null;
}
#override
void initState() {
super.initState();
print(widget.type);
dropdownItems = getListBasedOnName(widget.type);
}
#override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.fromLTRB(0, 8.0, 0, 10.0),
child: Container(
width: 325.0,
height: 50.0,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.black45,
offset: Offset(2.5, 5.5),
blurRadius: 5.0,
)
],
borderRadius: BorderRadius.circular(8),
color: Colors.white,
),
child: DropdownButtonHideUnderline(
child: DropdownButton(
value: selectedItem,
hint: Padding(
padding: const EdgeInsets.fromLTRB(22.0, 0, 0, 0),
child: Text(
widget.dropdownText,
style: TextStyle(),
),
),
items: dropdownItems.map((String value) {
return new DropdownMenuItem<String>(
value: value,
child: new Text(value),
);
}).toList(),
onChanged: (value) {
setState(() {
selectedItem = value;
});
}),
),
),
);
}
}
I really got confused because the onChanged function in DropDownButton already used. I barely manage to do the normal pass data from the text widget. But from the Dropdownbutton and the date & time picker, I have no idea how to do it.
Is there any way to get the data from the first screen, because at the moment I still haven't learned about state management or Bloc. And the code still messy I haven't done the refactoring yet. I really Hope you can help with the solution, Thank you!
First, for the MenuDropDown, you're going to want to do a sort of extension for the onChanged method. Add a VoidCallback parameter to the widget's constructor like so:
typedef OnChangeCallback = void Function(dynamic value);
class MenuDropDown extends StatefulWidget {
final String dropdownText;
final String type;
final OnChangeCallback onChanged;
MenuDropDown({this.dropdownText, this.type, this.onChanged});
#override
_MenuDropDownState createState() => _MenuDropDownState();
}
and in the state, call that method as a part of DropdownButton's native onChanged callback:
onChanged: (value) {
setState(() {
selectedItem = value;
});
widget.onChanged(value);
}
And in _InformationDetailState you'll store the currently selected item for each input field and pass an onChanged function that updates the respective field for each input:
String catSize; //Declare at the top of _InformationDetailState
...
MenuDropDown(
dropdownText: 'Cat Size...',
type: "catSize",
onChanged: (value) {
catSize = value;
}
),
Now to pass the data to the next screen. It's never really absolutely necessary to use any kind of state management in your app and I've found that many people use it unnecessarily. In your case, it's absolutely not necessary for just passing data to a single other widget. You're already passing the addressText and addNotes correctly. Just extend this for each parameter you need to show on the confirmation screen. Alternatively, you could store all of the fields in a single Map instead of having a variable for each field and pass that Map to the confirmation page.

Dynamically created checkbox in flutter not changing the state on clicked

I am creating a checkbox field every time i press a button. but the generated checkbox is not changing the state when pressed, instead the next checkbox which is generated comes with the changed state.
I have attached the video of how it is working currently (https://imgur.com/a/75vE5cj )
my entire code goes like this :
class ToDoNotes extends StatelessWidget {
#override
Widget build(BuildContext context) {
SizeConfig().init(context);
return new MaterialApp(
title: 'notes',
theme: new ThemeData(
primarySwatch: Colors.green,
),
home: new T_notes(),
); }}
class T_notes extends StatefulWidget {
static String tag = 'T_notes';
#override
_T_notesState createState() => new _T_notesState();
}
this is my code for creating checkbox dynamically.
class _T_notesState extends State<T_notes> {
bool rememberMe = false;
void _onRememberMeChanged(bool newValue) => setState(() {
rememberMe = newValue;
});
List<Widget> _children = [];
int _count = 0;
String input;
int i=0;
void _add() {
_children = List.from(_children)
..add(
CheckboxListTile(
value: rememberMe,
onChanged: _onRememberMeChanged,
title: new Text(input,style: TextStyle(color: Colors.black)),
controlAffinity: ListTileControlAffinity.leading,
activeColor: Colors.black,
)
);
setState(() {
++_count;
});
i++;
}
inside the widget build() inside the body i have the dynamic widget as:
#override
Widget build(BuildContext context) {
return new Scaffold(
resizeToAvoidBottomPadding: false,
body: ListView(
padding: EdgeInsets.all(28.0),
children: <Widget>[
SizedBox(height: 30),
new Row(
children: <Widget>[
SizedBox(width:0.2),
new Container(
width:200,
child: new TextField(
textAlign: TextAlign.left,
decoration: InputDecoration(
border: OutlineInputBorder(borderRadius: BorderRadius.circular(138.0)),
hintText: 'Enter the text',
),
onChanged: (val) {
input = val;
}
),
),
SizedBox(width:10),
new Container(
width: 80,
child:new Material(
borderRadius: BorderRadius.circular(30.5),
shadowColor: Colors.lightBlueAccent.shade100,
elevation: 1.0,
child: new MaterialButton(
onPressed: () {
_add();
},
child: Text('ADD', style: TextStyle(color: Colors.lightGreen,fontSize: 15)),
),
),
),
],
),
new Container(
height: 390,
child: ListView(children: _children),
),
],
) ,
);
}
I want the checkbox field to change the state properly on clicked.
Ok the thing here is that you need to have a model for each CheckboxListTile to preserve the state of each of the CheckboxListTiles.
This would be the model:
class ListTileModel {
bool enabled;
String text;
ListTileModel(this.enabled,this.text);
}
Then, when a user taps a Tile, just update the state of that particular row. What you have now is a general state for all your Tiles. So instead of having an array of widgets, have an array of models representing each row. And finally, use the a map function to build all your items
class _T_notesState extends State<T_notes> {
bool rememberMe = false;
List<ListTileModel> _items = [];
String input;
int i = 0;
void _add() {
_items.add(ListTileModel(false,input));
setState(() {});
}
#override
Widget build(BuildContext context) {
return new Scaffold(
resizeToAvoidBottomPadding: false,
body: ListView(
padding: EdgeInsets.all(28.0),
children: <Widget>[
SizedBox(height: 30),
new Row(
children: <Widget>[
SizedBox(width: 0.2),
new Container(
width: 200,
child: new TextField(
textAlign: TextAlign.left,
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(138.0)),
hintText: 'Enter the text',
),
onChanged: (val) {
input = val;
}),
),
SizedBox(width: 10),
new Container(
width: 80,
child: new Material(
borderRadius: BorderRadius.circular(30.5),
shadowColor: Colors.lightBlueAccent.shade100,
elevation: 1.0,
child: new MaterialButton(
onPressed: () {
_add();
},
child: Text('ADD',
style:
TextStyle(color: Colors.lightGreen, fontSize: 15)),
),
),
),
],
),
new Container(
height: 390,
child: ListView(
children: _items
.map((item) => CheckboxListTile(
value: item.enabled,
onChanged: (enabled) {
item.enabled = enabled;
setState(() {});
},
title: new Text(item.text,
style: TextStyle(color: Colors.black)),
controlAffinity: ListTileControlAffinity.leading,
activeColor: Colors.black,
))
.toList()),
),
],
),
);
}
}