@@ -59,26 +59,21 @@ class EditSourceBloc extends Bloc<EditSourceEvent, EditSourceState> {
5959 ) async {
6060 emit (state.copyWith (status: EditSourceStatus .loading));
6161 try {
62- final [sourceResponse, countriesPaginated, languagesPaginated] =
63- await Future .wait ([
62+ final responses = await Future .wait ([
6463 _sourcesRepository.read (id: _sourceId),
6564 _countriesRepository.readAll (
6665 sort: [const SortOption ('name' , SortOrder .asc)],
67- ) as Future < PaginatedResponse < Country >> ,
66+ ),
6867 _languagesRepository.readAll (
6968 sort: [const SortOption ('name' , SortOrder .asc)],
70- ) as Future < PaginatedResponse < Language >> ,
69+ ),
7170 ]);
7271
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 > ;
7675
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
8277 orElse: () => source.language,
8378 );
8479
0 commit comments