import 'package:flutter/material.dart'; import '../classes/language.dart'; import '../localization/language_constants.dart'; import '../routes/translation.dart'; class SettingsPage extends StatefulWidget { SettingsPage({Key key}) : super(key: key); @override _SettingsPageState createState() => _SettingsPageState(); } class _SettingsPageState extends State { void _changeLanguage(Language language) async { Locale _locale = await setLocale(language.languageCode); translation.setLocale(context, _locale); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(getTranslated(context, 'settings')), ), body: Container( child: Center( child: DropdownButton( iconSize: 30, hint: Text(getTranslated(context, 'change_language')), onChanged: (Language language) { _changeLanguage(language); }, items: Language.languageList() .map>( (e) => DropdownMenuItem( value: e, child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Text( e.flag, style: TextStyle(fontSize: 30), ), Text(e.name) ], ), ), ) .toList(), )), ), ); } }