MBDropdownElement constructor
Initializes a dropdown element with the dictionary returned by the MBurger APIs.
- Parameters:
dictionary
: Thedictionary
returned by the APIs.
Implementation
factory MBDropdownElement({required Map<String, dynamic> dictionary}) {
String? selectedOption;
List<MBDropdownElementOption> options = [];
if (dictionary['value'] is String) {
selectedOption = dictionary['value'] as String;
}
if (dictionary['options'] is List) {
List<Map<String, dynamic>> optionsMaps =
List<Map<String, dynamic>>.from(dictionary['options'] as List);
options = optionsMaps
.map((o) => MBDropdownElementOption.fromDictionary(dictionary: o))
.toList();
}
return MBDropdownElement._(
dictionary: dictionary,
options: options,
selectedOption: selectedOption,
);
}