@@ -17,15 +17,14 @@ import 'package:provider/provider.dart';
17
17
class CustomizationDropdownMenu <T > extends StatelessWidget {
18
18
final String label;
19
19
final List <T > options;
20
- int selectedItemIndex;
20
+ final int selectedItemIndex;
21
21
final String Function (T ) getText;
22
22
final Function (T , int ) onSelectionChange;
23
23
final List <Widget Function ()>? itemLeadingIcons;
24
- T ? selectedOption;
24
+ final T ? selectedOption;
25
+ final bool isSelected;
25
26
26
- var isSelected = false ;
27
-
28
- CustomizationDropdownMenu ({
27
+ const CustomizationDropdownMenu ({
29
28
super .key,
30
29
required this .label,
31
30
required this .options,
@@ -34,6 +33,7 @@ class CustomizationDropdownMenu<T> extends StatelessWidget {
34
33
required this .selectedOption,
35
34
this .itemLeadingIcons,
36
35
required this .getText,
36
+ this .isSelected = false ,
37
37
});
38
38
39
39
@override
@@ -67,24 +67,22 @@ class CustomizationDropdownMenu<T> extends StatelessWidget {
67
67
),
68
68
onSelected: (value) {
69
69
if (value != null ) {
70
- selectedItemIndex = options.indexOf (value);
71
- onSelectionChange (value, selectedItemIndex );
70
+ final newIndex = options.indexOf (value);
71
+ onSelectionChange (value, newIndex );
72
72
}
73
73
},
74
74
leadingIcon: itemLeadingIcons != null ? buildDropdownLeadingIcon (context, itemLeadingIcons, selectedItemIndex) : null ,
75
75
dropdownMenuEntries: List .generate (options.length, (index) {
76
- selectedOption = options[index];
77
- selectedItemIndex = index;
78
76
return DropdownMenuEntry <T >(
79
77
labelWidget: Text (getText (options[index]),
80
78
style: TextStyle (
81
79
fontSize: OudsTheme .of (context).fontTokens.sizeBodyLargeMobile,
82
80
fontWeight: OudsTheme .of (context).fontTokens.weightLabelStrong,
83
81
letterSpacing: OudsTheme .of (context).fontTokens.letterSpacingBodyLargeMobile,
84
82
)),
85
- value: selectedOption as T ,
83
+ value: options[index] ,
86
84
label: getText (options[index]),
87
- leadingIcon: itemLeadingIcons != null ? buildDropdownLeadingIcon (context, itemLeadingIcons, selectedItemIndex ) : null ,
85
+ leadingIcon: itemLeadingIcons != null ? buildDropdownLeadingIcon (context, itemLeadingIcons, index ) : null ,
88
86
);
89
87
}),
90
88
),
0 commit comments