I have been working on having two dropdown buttons that are meant for the user to easily pick the car model and its respective make. Below is the code snippet of the static lists that I have. Any feedback is highly appreciated.
final List<String> carModel = [
'Audi',
'BMW',
'Chevrolet',
'Chrysler',
'Daihatsu',
'Ford',
'Hino',
'Honda',
'Isuzu',
'Jaguar',
'Jeep',
'Landrover',
'Lexus',
'Mazda',
'Mercedes',
'Mitsubishi',
'Nissan',
'Peugeot',
'Porsche',
'Subaru',
'Suzuki',
'Toyota',
'UD',
'Volkswagen',
'Volvo'
];
final List<String> audiMake = [
'A3',
'A4',
'A5',
'A6',
'A7',
'A8',
'Q3',
'Q5',
'Q7',
'Q8',
'R8',
'TT',
];
final List<String> bmwMake = [
'1 Series',
'2 Series',
'3 Series',
'4 Series',
'5 Series',
'6 Series',
'7 Series',
'8 Series',
'M2',
'M3',
'M4',
'M5',
'M6',
'X1',
'X2',
'X3',
'X4',
'X5',
'X6',
'X7',
'Z4',
'i3',
'i8',
];
Here is the code that I have been working in bringing the functionality of the dropdown buttons to work:
DropdownButton<String>(
value: selectedCarModel,
items: carModel.map((e) {
return DropdownMenuItem<String>(
value: e,
child: Text('$e'),
);
}).toList(),
onChanged: (val) {
setState(() {
selectedCarModel = val!;
});
}),
const SizedBox(
height: 10,
),
DropdownButton<String>(
value: selectedCarMake,
items: carMake.map((e) {
return DropdownMenuItem<String>(
value: e,
child: Text('$e'),
);
}).toList(),
onChanged: (val) {
carMake = val == 'Audi' ? audiMake : bmwMake;
setState(() {
selectedCarMake = val!;
});
}),