@@ -25,10 +25,9 @@ class EditHeadlinePage extends StatelessWidget {
25
25
// The list of all countries is fetched once and cached in the
26
26
// ContentManagementBloc. We read it here and provide it to the
27
27
// EditHeadlineBloc.
28
- final allCountries = context
29
- .read <ContentManagementBloc >()
30
- .state
31
- .allCountries;
28
+ final contentManagementState = context.watch <ContentManagementBloc >().state;
29
+ final allCountries = contentManagementState.allCountries;
30
+
32
31
return BlocProvider (
33
32
create: (context) => EditHeadlineBloc (
34
33
headlinesRepository: context.read <DataRepository <Headline >>(),
@@ -289,40 +288,53 @@ class _EditHeadlineViewState extends State<_EditHeadlineView> {
289
288
.add (EditHeadlineTopicChanged (value)),
290
289
),
291
290
const SizedBox (height: AppSpacing .lg),
292
- DropdownButtonFormField <Country ?>(
293
- value: selectedCountry,
294
- decoration: InputDecoration (
295
- labelText: l10n.countryName,
296
- border: const OutlineInputBorder (),
297
- ),
298
- items: [
299
- DropdownMenuItem (value: null , child: Text (l10n.none)),
300
- ...state.countries.map (
301
- (country) => DropdownMenuItem (
302
- value: country,
303
- child: Row (
304
- children: [
305
- SizedBox (
306
- width: 32 ,
307
- height: 20 ,
308
- child: Image .network (
309
- country.flagUrl,
310
- fit: BoxFit .cover,
311
- errorBuilder:
312
- (context, error, stackTrace) =>
313
- const Icon (Icons .flag),
314
- ),
291
+ BlocBuilder <ContentManagementBloc , ContentManagementState >(
292
+ builder: (context, contentState) {
293
+ final isLoading = contentState.allCountriesStatus ==
294
+ ContentManagementStatus .loading;
295
+ return DropdownButtonFormField <Country ?>(
296
+ value: selectedCountry,
297
+ decoration: InputDecoration (
298
+ labelText: l10n.countryName,
299
+ border: const OutlineInputBorder (),
300
+ helperText:
301
+ isLoading ? l10n.loadingFullList : null ,
302
+ ),
303
+ items: [
304
+ DropdownMenuItem (
305
+ value: null ,
306
+ child: Text (l10n.none),
307
+ ),
308
+ ...state.countries.map (
309
+ (country) => DropdownMenuItem (
310
+ value: country,
311
+ child: Row (
312
+ children: [
313
+ SizedBox (
314
+ width: 32 ,
315
+ height: 20 ,
316
+ child: Image .network (
317
+ country.flagUrl,
318
+ fit: BoxFit .cover,
319
+ errorBuilder:
320
+ (context, error, stackTrace) =>
321
+ const Icon (Icons .flag),
322
+ ),
323
+ ),
324
+ const SizedBox (width: AppSpacing .md),
325
+ Text (country.name),
326
+ ],
315
327
),
316
- const SizedBox (width: AppSpacing .md),
317
- Text (country.name),
318
- ],
328
+ ),
319
329
),
320
- ),
321
- ),
322
- ],
323
- onChanged: (value) => context
324
- .read <EditHeadlineBloc >()
325
- .add (EditHeadlineCountryChanged (value)),
330
+ ],
331
+ onChanged: isLoading
332
+ ? null
333
+ : (value) => context
334
+ .read <EditHeadlineBloc >()
335
+ .add (EditHeadlineCountryChanged (value)),
336
+ );
337
+ },
326
338
),
327
339
const SizedBox (height: AppSpacing .lg),
328
340
DropdownButtonFormField <ContentStatus >(
0 commit comments