showAlertChangeLanguage method
Future
showAlertChangeLanguage({
- required BuildContext context,
- required String title,
- required String btnNegative,
Show alert to change language
Implementation
Future<dynamic> showAlertChangeLanguage(
{required BuildContext context,
required String title,
required String btnNegative}) async {
List<Map<dynamic, dynamic>> out = this.getListLanguage();
return await showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text(title),
actions: <Widget>[
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(btnNegative)),
],
content: Container(
width: MediaQuery.of(context).size.height * 0.8,
height: MediaQuery.of(context).size.height * 0.3,
child: ListView.builder(
itemCount: out.length,
itemBuilder: (BuildContext context, int index) {
return Material(
color: currentValue['config']['prefix'] ==
out[index]['prefix']
? Colors.blueAccent[700]
: Colors.transparent,
child: ListTile(
leading: CountryPickerUtils.getDefaultFlagImage(
CountryPickerUtils.getCountryByIsoCode(
out[index]['iso_code'])),
selected: currentValue['config']['prefix'] ==
out[index]['prefix'],
title: Text(
out[index]['title'].toString(),
style: TextStyle(
color: currentValue['config']['prefix'] ==
out[index]['prefix']
? Colors.white
: Colors.black),
),
onTap: () {
changeLanguage(out[index]['prefix']);
Navigator.pop(context);
},
),
);
},
),
),
));
}