refactor: cache supportedLocales in left_menu in initState()
This commit is contained in:
parent
0490c83790
commit
d53d7b1177
|
|
@ -16,11 +16,15 @@ class LeftMenu extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _LeftMenuState extends State<LeftMenu> with PreferencesMixin {
|
class _LeftMenuState extends State<LeftMenu> with PreferencesMixin {
|
||||||
|
List<DropdownMenuItem<String>> _dropdownMenuItems = [];
|
||||||
late String currentLocale;
|
late String currentLocale;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
_dropdownMenuItems = supportedLocales
|
||||||
|
.map((e) => DropdownMenuItem(child: Text(e), value: e))
|
||||||
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -93,10 +97,7 @@ class _LeftMenuState extends State<LeftMenu> with PreferencesMixin {
|
||||||
),
|
),
|
||||||
DropdownButton<String>(
|
DropdownButton<String>(
|
||||||
value: currentLocale,
|
value: currentLocale,
|
||||||
items: supportedLocales
|
items: _dropdownMenuItems,
|
||||||
.map(
|
|
||||||
(e) => DropdownMenuItem(child: Text(e), value: e))
|
|
||||||
.toList(),
|
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
currentLocale = value!;
|
currentLocale = value!;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue