import 'package:flutter/material.dart'; import 'package:userstory2translate/classes/language.dart'; import 'package:userstory2translate/localization/language_constants.dart'; import 'package:userstory2translate/main.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); MyApp.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(), )), ), ); } }