I have got a Dropdown Button that shows app languages when pressed, and when anyone is selected the app language is changed. Now I need to convert this Dropdown Button to listview. builder so that the languages are shown as a list instead of a dropdown, but could not do that. I will appreciate it if someone can help.
This is my code:
Languages class
class Language {
final int id;
final String flag;
final String name;
final String languageCode;
Language(this.id, this.flag, this.name, this.languageCode);
static List<Language> languageList() {
return <Language>[
Language(1, "🇺🇸", "English", "en"),
Language(2, "🇫🇷", "français", "fr"),
];
}
}
Dropdown Button
DropdownButton<Language>(
underline: SizedBox(),
icon: Icon(
Icons.language,
color: Colors.blue,
),
onChanged: (Language language) {
_changeLanguage(language);
},
items: Language.languageList().map<DropdownMenuItem<Language>>(
(e) => DropdownMenuItem<Language>(
value: e,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Text(
e.flag,
style: TextStyle(fontSize: 30),
),
Text(e.name)
],),
),
).toList(),
),