How can I implement AppTranslations
widget with checkbox?, I want to select one of the language by click on the box on the right side of the listtile
I try use CheckBoxListTilie
but without success :(
code:
class _LanguageSelectorState extends State<LanguageSelector> {
static final List<String> languagesList = application.supportedLanguages;
static final List<String> languageCodesList =
application.supportedLanguagesCodes;
final Map<dynamic, dynamic> languagesMap = {
languagesList[0]: languageCodesList[0],
languagesList[1]: languageCodesList[1],
};
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
backgroundColor: Colors.white,
iconTheme: IconThemeData(color: Colors.black),
title: Text(AppTranslations.of(context).text("settings_language"), style: TextStyle(color: Colors.black, letterSpacing: 1)),
elevation: 0.0,
centerTitle: true,
bottom: PreferredSize(child: Container(color: Colors.black, height: 0.1), preferredSize: Size.fromHeight(0.1),),
),
body: _buildLanguagesList(),
);
}
String selectedLanguage = '';
_buildLanguagesList() {
return ListView.builder(
itemCount: languagesList.length,
itemBuilder: (context, index) {
return _buildLanguageItem(languagesList[index]);
},
);
}
_buildLanguageItem(String language) {
return ListTile(
onTap: () {
selectedLanguage = language;
application.onLocaleChanged(Locale(languagesMap[language]));
},
title: Text(language),
leading: Icon(Icons.flag),
);
}
}
tight now i have only simply cenetered list :(
thanks for any help
Aucun commentaire:
Enregistrer un commentaire