@@ -59,26 +59,21 @@ class EditSourceBloc extends Bloc<EditSourceEvent, EditSourceState> {
59
59
) async {
60
60
emit (state.copyWith (status: EditSourceStatus .loading));
61
61
try {
62
- final [sourceResponse, countriesPaginated, languagesPaginated] =
63
- await Future .wait ([
62
+ final responses = await Future .wait ([
64
63
_sourcesRepository.read (id: _sourceId),
65
64
_countriesRepository.readAll (
66
65
sort: [const SortOption ('name' , SortOrder .asc)],
67
- ) as Future < PaginatedResponse < Country >> ,
66
+ ),
68
67
_languagesRepository.readAll (
69
68
sort: [const SortOption ('name' , SortOrder .asc)],
70
- ) as Future < PaginatedResponse < Language >> ,
69
+ ),
71
70
]);
72
71
73
- final source = sourceResponse as Source ;
74
- final countries = countriesPaginated.items ;
75
- final languages = languagesPaginated.items ;
72
+ final source = responses[ 0 ] as Source ;
73
+ final countriesPaginated = responses[ 1 ] as PaginatedResponse < Country > ;
74
+ final languagesPaginated = responses[ 2 ] as PaginatedResponse < Language > ;
76
75
77
- // The source contains a Language object. We need to find the equivalent
78
- // object in the full list of languages to ensure the DropdownButton
79
- // can correctly identify and display the initial selection by reference.
80
- final selectedLanguage = languages.firstWhere (
81
- (listLanguage) => listLanguage == source.language,
76
+ final selectedLanguage = languagesPaginated.items
82
77
orElse: () => source.language,
83
78
);
84
79
0 commit comments