|
1 | 1 | import 'package:core/core.dart';
|
2 |
| -import 'package:country_picker/country_picker.dart' as picker; |
3 | 2 | import 'package:data_repository/data_repository.dart';
|
4 | 3 | import 'package:flutter/material.dart';
|
5 | 4 | import 'package:flutter_bloc/flutter_bloc.dart';
|
@@ -179,6 +178,17 @@ class _EditHeadlineViewState extends State<_EditHeadlineView> {
|
179 | 178 | }
|
180 | 179 | }
|
181 | 180 |
|
| 181 | + Country? selectedCountry; |
| 182 | + if (state.eventCountry != null) { |
| 183 | + try { |
| 184 | + selectedCountry = state.countries.firstWhere( |
| 185 | + (c) => c.id == state.eventCountry!.id, |
| 186 | + ); |
| 187 | + } catch (_) { |
| 188 | + selectedCountry = null; |
| 189 | + } |
| 190 | + } |
| 191 | + |
182 | 192 | return SingleChildScrollView(
|
183 | 193 | child: Padding(
|
184 | 194 | padding: const EdgeInsets.all(AppSpacing.lg),
|
@@ -272,18 +282,13 @@ class _EditHeadlineViewState extends State<_EditHeadlineView> {
|
272 | 282 | .add(EditHeadlineTopicChanged(value)),
|
273 | 283 | ),
|
274 | 284 | const SizedBox(height: AppSpacing.lg),
|
275 |
| - CountryPickerFormField( |
| 285 | + CountryDropdownFormField( |
276 | 286 | labelText: l10n.countryName,
|
277 |
| - initialValue: state.eventCountry != null |
278 |
| - ? adaptCoreCountryToPackageCountry( |
279 |
| - state.eventCountry!, |
280 |
| - ) |
281 |
| - : null, |
282 |
| - onChanged: (picker.Country country) { |
283 |
| - context.read<EditHeadlineBloc>().add( |
284 |
| - EditHeadlineCountryChanged(country), |
285 |
| - ); |
286 |
| - }, |
| 287 | + countries: state.countries, |
| 288 | + initialValue: selectedCountry, |
| 289 | + onChanged: (value) => context |
| 290 | + .read<EditHeadlineBloc>() |
| 291 | + .add(EditHeadlineCountryChanged(value)), |
287 | 292 | ),
|
288 | 293 | const SizedBox(height: AppSpacing.lg),
|
289 | 294 | DropdownButtonFormField<ContentStatus>(
|
|
0 commit comments