forked from eatvio/eatvio_app
feature(registration): fix location model
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'location_model.g.dart';
|
||||
|
||||
part 'location_model.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class LocationModel with _$LocationModel {
|
||||
const factory LocationModel({
|
||||
required Map<String, dynamic> locations,
|
||||
@JsonKey(name: 'response_body')
|
||||
required String responseBody,
|
||||
}) = _LocationModel;
|
||||
required List<String> locations,
|
||||
@JsonKey(name: 'response_body') required String responseBody,
|
||||
}) = _LocationModel;
|
||||
|
||||
factory LocationModel.fromJson(Map<String, Object?> json) => _$LocationModelFromJson(json);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ LocationModel _$LocationModelFromJson(Map<String, dynamic> json) {
|
||||
|
||||
/// @nodoc
|
||||
mixin _$LocationModel {
|
||||
Map<String, dynamic> get locations => throw _privateConstructorUsedError;
|
||||
List<String> get locations => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'response_body')
|
||||
String get responseBody => throw _privateConstructorUsedError;
|
||||
|
||||
@@ -37,7 +37,7 @@ abstract class $LocationModelCopyWith<$Res> {
|
||||
_$LocationModelCopyWithImpl<$Res, LocationModel>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{Map<String, dynamic> locations,
|
||||
{List<String> locations,
|
||||
@JsonKey(name: 'response_body') String responseBody});
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ class _$LocationModelCopyWithImpl<$Res, $Val extends LocationModel>
|
||||
locations: null == locations
|
||||
? _value.locations
|
||||
: locations // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, dynamic>,
|
||||
as List<String>,
|
||||
responseBody: null == responseBody
|
||||
? _value.responseBody
|
||||
: responseBody // ignore: cast_nullable_to_non_nullable
|
||||
@@ -79,7 +79,7 @@ abstract class _$$LocationModelImplCopyWith<$Res>
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{Map<String, dynamic> locations,
|
||||
{List<String> locations,
|
||||
@JsonKey(name: 'response_body') String responseBody});
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ class __$$LocationModelImplCopyWithImpl<$Res>
|
||||
locations: null == locations
|
||||
? _value._locations
|
||||
: locations // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, dynamic>,
|
||||
as List<String>,
|
||||
responseBody: null == responseBody
|
||||
? _value.responseBody
|
||||
: responseBody // ignore: cast_nullable_to_non_nullable
|
||||
@@ -114,19 +114,19 @@ class __$$LocationModelImplCopyWithImpl<$Res>
|
||||
@JsonSerializable()
|
||||
class _$LocationModelImpl implements _LocationModel {
|
||||
const _$LocationModelImpl(
|
||||
{required final Map<String, dynamic> locations,
|
||||
{required final List<String> locations,
|
||||
@JsonKey(name: 'response_body') required this.responseBody})
|
||||
: _locations = locations;
|
||||
|
||||
factory _$LocationModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$LocationModelImplFromJson(json);
|
||||
|
||||
final Map<String, dynamic> _locations;
|
||||
final List<String> _locations;
|
||||
@override
|
||||
Map<String, dynamic> get locations {
|
||||
if (_locations is EqualUnmodifiableMapView) return _locations;
|
||||
List<String> get locations {
|
||||
if (_locations is EqualUnmodifiableListView) return _locations;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableMapView(_locations);
|
||||
return EqualUnmodifiableListView(_locations);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -170,7 +170,7 @@ class _$LocationModelImpl implements _LocationModel {
|
||||
|
||||
abstract class _LocationModel implements LocationModel {
|
||||
const factory _LocationModel(
|
||||
{required final Map<String, dynamic> locations,
|
||||
{required final List<String> locations,
|
||||
@JsonKey(name: 'response_body') required final String responseBody}) =
|
||||
_$LocationModelImpl;
|
||||
|
||||
@@ -178,7 +178,7 @@ abstract class _LocationModel implements LocationModel {
|
||||
_$LocationModelImpl.fromJson;
|
||||
|
||||
@override
|
||||
Map<String, dynamic> get locations;
|
||||
List<String> get locations;
|
||||
@override
|
||||
@JsonKey(name: 'response_body')
|
||||
String get responseBody;
|
||||
|
||||
@@ -8,7 +8,8 @@ part of 'location_model.dart';
|
||||
|
||||
_$LocationModelImpl _$$LocationModelImplFromJson(Map<String, dynamic> json) =>
|
||||
_$LocationModelImpl(
|
||||
locations: json['locations'] as Map<String, dynamic>,
|
||||
locations:
|
||||
(json['locations'] as List<dynamic>).map((e) => e as String).toList(),
|
||||
responseBody: json['response_body'] as String,
|
||||
);
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class RegistrationCubit extends Cubit<RegistrationState> {
|
||||
try {
|
||||
final location = (await registrationRepository.getLocationsListByQuery(query));
|
||||
emit(RegistrationState(sheet: state.sheet.copyWith(responseBody: location.responseBody)));
|
||||
return location.locations.values.toList().map((e) => e.toString()).toList();
|
||||
return location.locations;
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user