@@ -22,10 +22,9 @@ class CreateHeadlinePage extends StatelessWidget {
22
22
// The list of all countries is fetched once and cached in the
23
23
// ContentManagementBloc. We read it here and provide it to the
24
24
// CreateHeadlineBloc.
25
- final allCountries = context
26
- .read <ContentManagementBloc >()
27
- .state
28
- .allCountries;
25
+ final contentManagementState = context.watch <ContentManagementBloc >().state;
26
+ final allCountries = contentManagementState.allCountries;
27
+
29
28
return BlocProvider (
30
29
create: (context) => CreateHeadlineBloc (
31
30
headlinesRepository: context.read <DataRepository <Headline >>(),
@@ -221,40 +220,53 @@ class _CreateHeadlineViewState extends State<_CreateHeadlineView> {
221
220
.add (CreateHeadlineTopicChanged (value)),
222
221
),
223
222
const SizedBox (height: AppSpacing .lg),
224
- DropdownButtonFormField <Country ?>(
225
- value: state.eventCountry,
226
- decoration: InputDecoration (
227
- labelText: l10n.countryName,
228
- border: const OutlineInputBorder (),
229
- ),
230
- items: [
231
- DropdownMenuItem (value: null , child: Text (l10n.none)),
232
- ...state.countries.map (
233
- (country) => DropdownMenuItem (
234
- value: country,
235
- child: Row (
236
- children: [
237
- SizedBox (
238
- width: 32 ,
239
- height: 20 ,
240
- child: Image .network (
241
- country.flagUrl,
242
- fit: BoxFit .cover,
243
- errorBuilder:
244
- (context, error, stackTrace) =>
245
- const Icon (Icons .flag),
246
- ),
223
+ BlocBuilder <ContentManagementBloc , ContentManagementState >(
224
+ builder: (context, contentState) {
225
+ final isLoading = contentState.allCountriesStatus ==
226
+ ContentManagementStatus .loading;
227
+ return DropdownButtonFormField <Country ?>(
228
+ value: state.eventCountry,
229
+ decoration: InputDecoration (
230
+ labelText: l10n.countryName,
231
+ border: const OutlineInputBorder (),
232
+ helperText:
233
+ isLoading ? l10n.loadingFullList : null ,
234
+ ),
235
+ items: [
236
+ DropdownMenuItem (
237
+ value: null ,
238
+ child: Text (l10n.none),
239
+ ),
240
+ ...state.countries.map (
241
+ (country) => DropdownMenuItem (
242
+ value: country,
243
+ child: Row (
244
+ children: [
245
+ SizedBox (
246
+ width: 32 ,
247
+ height: 20 ,
248
+ child: Image .network (
249
+ country.flagUrl,
250
+ fit: BoxFit .cover,
251
+ errorBuilder:
252
+ (context, error, stackTrace) =>
253
+ const Icon (Icons .flag),
254
+ ),
255
+ ),
256
+ const SizedBox (width: AppSpacing .md),
257
+ Text (country.name),
258
+ ],
247
259
),
248
- const SizedBox (width: AppSpacing .md),
249
- Text (country.name),
250
- ],
260
+ ),
251
261
),
252
- ),
253
- ),
254
- ],
255
- onChanged: (value) => context
256
- .read <CreateHeadlineBloc >()
257
- .add (CreateHeadlineCountryChanged (value)),
262
+ ],
263
+ onChanged: isLoading
264
+ ? null
265
+ : (value) => context
266
+ .read <CreateHeadlineBloc >()
267
+ .add (CreateHeadlineCountryChanged (value)),
268
+ );
269
+ },
258
270
),
259
271
const SizedBox (height: AppSpacing .lg),
260
272
DropdownButtonFormField <ContentStatus >(
0 commit comments