I have this dropdown menu that other dropdown menus are dependent on. How do I give "selectedBusLine1" a default value that is stored in "'M${widget.busline1}'" so that "selectedBusLine1" is already populated instead of waiting for the onChanged. and if the user wanted to they can still choose a option in the dropdown list that will trigger the onChanged and overwrite the default value. Right now the "selectedBusLine1" is waiting to be populated by the on changed. Thanks a lot!
ListTileTheme(
tileColor: Colors.white,
child: ListTile(
title: Container(
decoration: BoxDecoration(
color: Colors.blueGrey[300],
border: Border.all(color: Colors.blueGrey),
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
color: Colors.grey,
blurRadius: 4,
offset: Offset(4, 8), // changes position of shadow
),
],
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: DropdownButtonHideUnderline(
child: DropdownButton<String>(
value: valueChoose_f13 ?? 'M${widget.busline1}',
isExpanded: true,
onChanged: (newValue){
valueChoose_f14 = null;
valueChoose_f15 = null;
selectedBusLine1 = newValue == 'M100007'
? businessLine2_01
: newValue == 'M100005'
? businessLine2_02
: newValue == 'M100015'
? businessLine2_03
: newValue == 'M100023'
? businessLine2_04
: newValue == 'M100012'
? businessLine2_05
: newValue == 'M100020'
? businessLine2_06
: newValue == 'M100000'
? businessLine2_07
: businessLine2_08;
setState(() {
valueChoose_f13 = newValue;
});
},
items: businessLine1.map((map) {
return DropdownMenuItem<String>(
value: map['value'],
child: Text(map['name']),
);
}).toList(),
),
),
),
),
),
),