From 81ed2fd8c3c34a6f0fda3c5442af4fa895beb2f8 Mon Sep 17 00:00:00 2001 From: Remy Moll Date: Mon, 29 Dec 2025 00:23:10 +0100 Subject: [PATCH] feat(wip): Update entities and adopt a proper repository workflow for trip "obtention" --- frontend/analysis_options.yaml | 7 + .../datasources/backend_trip_datasource.dart | 5 - ...source.dart => trip_local_datasource.dart} | 0 .../datasources/trip_remote_datasource.dart | 142 ++++ frontend/lib/data/models/landmark_model.dart | 6 +- .../data/models/landmark_model.freezed.dart | 589 ++++++---------- .../repositories/backend_trip_repository.dart | 182 ++--- .../local_onboarding_repository.dart | 18 + .../preferences_repository_impl.dart | 50 ++ frontend/lib/domain/README.md | 11 + frontend/lib/domain/entities/landmark.dart | 33 +- .../lib/domain/entities/landmark.freezed.dart | 654 ++++++++---------- frontend/lib/domain/entities/landmark.g.dart | 53 +- .../domain/entities/landmark_description.dart | 2 +- .../landmark_description.freezed.dart | 470 ++++++------- .../entities/landmark_description.g.dart | 10 +- .../lib/domain/entities/landmark_type.dart | 8 +- .../entities/landmark_type.freezed.dart | 442 ++++++------ .../lib/domain/entities/landmark_type.g.dart | 12 +- frontend/lib/domain/entities/preferences.dart | 15 +- .../domain/entities/preferences.freezed.dart | 491 ++++++------- .../lib/domain/entities/preferences.g.dart | 18 +- frontend/lib/domain/entities/trip.dart | 9 +- .../lib/domain/entities/trip.freezed.dart | 455 ++++++------ frontend/lib/domain/entities/trip.g.dart | 18 +- .../repositories/onboarding_repository.dart | 7 + .../repositories/preferences_repository.dart | 1 + .../domain/repositories/trip_repository.dart | 5 +- frontend/lib/presentation/pages/start.dart | 12 +- .../providers/core_providers.dart | 49 ++ .../providers/landmark_providers.dart | 16 + .../providers/onboarding_state_provider.dart | 12 +- .../presentation/providers/trip_provider.dart | 20 +- frontend/pubspec.lock | 32 +- 34 files changed, 1929 insertions(+), 1925 deletions(-) delete mode 100644 frontend/lib/data/datasources/backend_trip_datasource.dart rename frontend/lib/data/datasources/{local_trip_datasource.dart => trip_local_datasource.dart} (100%) create mode 100644 frontend/lib/data/datasources/trip_remote_datasource.dart create mode 100644 frontend/lib/data/repositories/local_onboarding_repository.dart create mode 100644 frontend/lib/data/repositories/preferences_repository_impl.dart create mode 100644 frontend/lib/domain/repositories/onboarding_repository.dart create mode 100644 frontend/lib/presentation/providers/core_providers.dart create mode 100644 frontend/lib/presentation/providers/landmark_providers.dart diff --git a/frontend/analysis_options.yaml b/frontend/analysis_options.yaml index 0d29021..c2542fc 100644 --- a/frontend/analysis_options.yaml +++ b/frontend/analysis_options.yaml @@ -24,5 +24,12 @@ linter: # avoid_print: false # Uncomment to disable the `avoid_print` rule # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule +# Exclude legacy/experimental code that is not part of the current +# refactor work. This prevents the analyzer from failing on old files +# in `lib/old` while we iterate on the new architecture in `lib/`. +analyzer: + exclude: + - lib/old/** + # Additional information about this file can be found at # https://dart.dev/guides/language/analysis-options diff --git a/frontend/lib/data/datasources/backend_trip_datasource.dart b/frontend/lib/data/datasources/backend_trip_datasource.dart deleted file mode 100644 index bbac5e7..0000000 --- a/frontend/lib/data/datasources/backend_trip_datasource.dart +++ /dev/null @@ -1,5 +0,0 @@ -import 'package:anyway/domain/entities/landmark.dart'; - -abstract class TripRemoteDataSource { - Future> fetchLandmarks(); -} diff --git a/frontend/lib/data/datasources/local_trip_datasource.dart b/frontend/lib/data/datasources/trip_local_datasource.dart similarity index 100% rename from frontend/lib/data/datasources/local_trip_datasource.dart rename to frontend/lib/data/datasources/trip_local_datasource.dart diff --git a/frontend/lib/data/datasources/trip_remote_datasource.dart b/frontend/lib/data/datasources/trip_remote_datasource.dart new file mode 100644 index 0000000..d7102c3 --- /dev/null +++ b/frontend/lib/data/datasources/trip_remote_datasource.dart @@ -0,0 +1,142 @@ +import 'dart:convert'; +import 'dart:developer'; + +import 'package:dio/dio.dart'; + +abstract class TripRemoteDataSource { + /// Fetch available landmarks for the provided preferences/start payload. + Future>> fetchLandmarks(Map body); + + /// Create a new trip using the optimizer payload (that includes landmarks). + Future> createTrip(Map body); + + /// Fetch an existing trip by UUID + Future> fetchTrip(String uuid); +} + +class TripRemoteDataSourceImpl implements TripRemoteDataSource { + final Dio dio; + + TripRemoteDataSourceImpl({required this.dio}); + + @override + Future>> fetchLandmarks(Map body) async { + final response = await dio.post('/get/landmarks', data: body); + if (response.statusCode != 200) { + throw Exception('Server error fetching landmarks: ${response.statusCode}'); + } + + if (response.data is! List) { + throw Exception('Unexpected landmarks response format'); + } + + return _normalizeLandmarks(List.from(response.data as List)); + } + + @override + Future> createTrip(Map body) async { + log('Creating trip with body: $body'); + // convert body to actual json + String bodyJson = jsonEncode(body); + log('Trip request JSON: $bodyJson'); + final response = await dio.post('/optimize/trip', data: body); + if (response.statusCode != 200) { + throw Exception('Server error: ${response.statusCode}'); + } + + if (response.data is! Map) { + throw Exception('Unexpected response format'); + } + + final Map json = Map.from(response.data as Map); + + _ensureLandmarks(json); + if (json.containsKey('landmarks') && json['landmarks'] is List) { + return json; + } + + final String? firstUuid = json['first_landmark_uuid'] as String?; + if (firstUuid == null) { + return json; + } + + final List> landmarks = []; + String? next = firstUuid; + while (next != null) { + final lm = await _fetchLandmarkByUuid(next); + landmarks.add(lm); + final dynamic nxt = lm['next_uuid']; + next = (nxt is String) ? nxt : null; + } + + json['landmarks'] = landmarks; + return json; + } + + @override + Future> fetchTrip(String uuid) async { + final response = await dio.get('/trip/$uuid'); + if (response.statusCode != 200) { + throw Exception('Server error: ${response.statusCode}'); + } + if (response.data is! Map) { + throw Exception('Unexpected response format'); + } + + final Map json = Map.from(response.data as Map); + // Normalize same as createTrip: if trip contains first_landmark_uuid, expand chain + if (json.containsKey('landmarks') && json['landmarks'] is List) { + _ensureLandmarks(json); + return json; + } + + final String? firstUuid = json['first_landmark_uuid'] as String?; + if (firstUuid == null) return json; + + final List> landmarks = []; + String? next = firstUuid; + while (next != null) { + final lm = await _fetchLandmarkByUuid(next); + landmarks.add(lm); + final dynamic nxt = lm['next_uuid']; + next = (nxt is String) ? nxt : null; + } + + json['landmarks'] = landmarks; + return json; + } + + // Fetch a single landmark by uuid via the /landmark/{landmark_uuid} endpoint + Future> _fetchLandmarkByUuid(String uuid) async { + final response = await dio.get('/landmark/$uuid'); + if (response.statusCode != 200) { + throw Exception('Failed to fetch landmark $uuid: ${response.statusCode}'); + } + if (response.data is! Map) { + throw Exception('Unexpected landmark response format'); + } + return _normalizeLandmark(Map.from(response.data as Map)); + } + + static void _ensureLandmarks(Map json) { + final raw = json['landmarks']; + if (raw is List) { + json['landmarks'] = _normalizeLandmarks(raw); + } + } + + static List> _normalizeLandmarks(List rawList) { + return rawList + .map((item) => _normalizeLandmark(Map.from(item as Map))) + .toList(); + } + + static Map _normalizeLandmark(Map source) { + final normalized = Map.from(source); + final typeValue = normalized['type']; + if (typeValue is String) { + normalized['type'] = {'type': typeValue}; + } + return normalized; + } +} diff --git a/frontend/lib/data/models/landmark_model.dart b/frontend/lib/data/models/landmark_model.dart index 3077ba7..4b1274f 100644 --- a/frontend/lib/data/models/landmark_model.dart +++ b/frontend/lib/data/models/landmark_model.dart @@ -1,3 +1,4 @@ +// TODO - I have the feeling this file is outdated and not used anymore import 'package:anyway/domain/entities/landmark.dart'; import 'package:anyway/domain/entities/landmark_description.dart'; import 'package:anyway/domain/entities/landmark_type.dart'; @@ -16,6 +17,8 @@ abstract class LandmarkModel with _$LandmarkModel { required String description, }) = _LandmarkModel; + const LandmarkModel._(); + factory LandmarkModel.fromJson(Map json) => _$LandmarkModelFromJson(json); Landmark toEntity() => Landmark( @@ -24,7 +27,6 @@ abstract class LandmarkModel with _$LandmarkModel { location: location, type: LandmarkType(type: LandmarkTypeEnum.values.firstWhere((e) => e.value == type)), isSecondary: isSecondary, - // TODO - try to set tags - description: LandmarkDescription(description: description, tags: []) + description: LandmarkDescription(description: description, tags: []), ); } diff --git a/frontend/lib/data/models/landmark_model.freezed.dart b/frontend/lib/data/models/landmark_model.freezed.dart index 2f4c21e..ac5cc64 100644 --- a/frontend/lib/data/models/landmark_model.freezed.dart +++ b/frontend/lib/data/models/landmark_model.freezed.dart @@ -14,71 +14,47 @@ T _$identity(T value) => value; /// @nodoc mixin _$LandmarkModel { - String get uuid; - String get name; - List get location; - String get type; - bool get isSecondary; - String get description; - /// Create a copy of LandmarkModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - $LandmarkModelCopyWith get copyWith => - _$LandmarkModelCopyWithImpl( - this as LandmarkModel, _$identity); + String get uuid; String get name; List get location; String get type; bool get isSecondary; String get description; +/// Create a copy of LandmarkModel +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$LandmarkModelCopyWith get copyWith => _$LandmarkModelCopyWithImpl(this as LandmarkModel, _$identity); /// Serializes this LandmarkModel to a JSON map. Map toJson(); - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is LandmarkModel && - (identical(other.uuid, uuid) || other.uuid == uuid) && - (identical(other.name, name) || other.name == name) && - const DeepCollectionEquality().equals(other.location, location) && - (identical(other.type, type) || other.type == type) && - (identical(other.isSecondary, isSecondary) || - other.isSecondary == isSecondary) && - (identical(other.description, description) || - other.description == description)); - } - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - uuid, - name, - const DeepCollectionEquality().hash(location), - type, - isSecondary, - description); +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is LandmarkModel&&(identical(other.uuid, uuid) || other.uuid == uuid)&&(identical(other.name, name) || other.name == name)&&const DeepCollectionEquality().equals(other.location, location)&&(identical(other.type, type) || other.type == type)&&(identical(other.isSecondary, isSecondary) || other.isSecondary == isSecondary)&&(identical(other.description, description) || other.description == description)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,uuid,name,const DeepCollectionEquality().hash(location),type,isSecondary,description); + +@override +String toString() { + return 'LandmarkModel(uuid: $uuid, name: $name, location: $location, type: $type, isSecondary: $isSecondary, description: $description)'; +} + - @override - String toString() { - return 'LandmarkModel(uuid: $uuid, name: $name, location: $location, type: $type, isSecondary: $isSecondary, description: $description)'; - } } /// @nodoc -abstract mixin class $LandmarkModelCopyWith<$Res> { - factory $LandmarkModelCopyWith( - LandmarkModel value, $Res Function(LandmarkModel) _then) = - _$LandmarkModelCopyWithImpl; - @useResult - $Res call( - {String uuid, - String name, - List location, - String type, - bool isSecondary, - String description}); -} +abstract mixin class $LandmarkModelCopyWith<$Res> { + factory $LandmarkModelCopyWith(LandmarkModel value, $Res Function(LandmarkModel) _then) = _$LandmarkModelCopyWithImpl; +@useResult +$Res call({ + String uuid, String name, List location, String type, bool isSecondary, String description +}); + + + +} /// @nodoc class _$LandmarkModelCopyWithImpl<$Res> implements $LandmarkModelCopyWith<$Res> { @@ -87,310 +63,213 @@ class _$LandmarkModelCopyWithImpl<$Res> final LandmarkModel _self; final $Res Function(LandmarkModel) _then; - /// Create a copy of LandmarkModel - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? uuid = null, - Object? name = null, - Object? location = null, - Object? type = null, - Object? isSecondary = null, - Object? description = null, - }) { - return _then(_self.copyWith( - uuid: null == uuid - ? _self.uuid - : uuid // ignore: cast_nullable_to_non_nullable - as String, - name: null == name - ? _self.name - : name // ignore: cast_nullable_to_non_nullable - as String, - location: null == location - ? _self.location - : location // ignore: cast_nullable_to_non_nullable - as List, - type: null == type - ? _self.type - : type // ignore: cast_nullable_to_non_nullable - as String, - isSecondary: null == isSecondary - ? _self.isSecondary - : isSecondary // ignore: cast_nullable_to_non_nullable - as bool, - description: null == description - ? _self.description - : description // ignore: cast_nullable_to_non_nullable - as String, - )); - } +/// Create a copy of LandmarkModel +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? uuid = null,Object? name = null,Object? location = null,Object? type = null,Object? isSecondary = null,Object? description = null,}) { + return _then(_self.copyWith( +uuid: null == uuid ? _self.uuid : uuid // ignore: cast_nullable_to_non_nullable +as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,location: null == location ? _self.location : location // ignore: cast_nullable_to_non_nullable +as List,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable +as String,isSecondary: null == isSecondary ? _self.isSecondary : isSecondary // ignore: cast_nullable_to_non_nullable +as bool,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable +as String, + )); } +} + + /// Adds pattern-matching-related methods to [LandmarkModel]. extension LandmarkModelPatterns on LandmarkModel { - /// A variant of `map` that fallback to returning `orElse`. - /// - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case final Subclass value: - /// return ...; - /// case _: - /// return orElse(); - /// } - /// ``` +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` - @optionalTypeArgs - TResult maybeMap( - TResult Function(_LandmarkModel value)? $default, { - required TResult orElse(), - }) { - final _that = this; - switch (_that) { - case _LandmarkModel() when $default != null: - return $default(_that); - case _: - return orElse(); - } - } +@optionalTypeArgs TResult maybeMap(TResult Function( _LandmarkModel value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _LandmarkModel() when $default != null: +return $default(_that);case _: + return orElse(); - /// A `switch`-like method, using callbacks. - /// - /// Callbacks receives the raw object, upcasted. - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case final Subclass value: - /// return ...; - /// case final Subclass2 value: - /// return ...; - /// } - /// ``` +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` - @optionalTypeArgs - TResult map( - TResult Function(_LandmarkModel value) $default, - ) { - final _that = this; - switch (_that) { - case _LandmarkModel(): - return $default(_that); - case _: - throw StateError('Unexpected subclass'); - } - } +@optionalTypeArgs TResult map(TResult Function( _LandmarkModel value) $default,){ +final _that = this; +switch (_that) { +case _LandmarkModel(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); - /// A variant of `map` that fallback to returning `null`. - /// - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case final Subclass value: - /// return ...; - /// case _: - /// return null; - /// } - /// ``` +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` - @optionalTypeArgs - TResult? mapOrNull( - TResult? Function(_LandmarkModel value)? $default, - ) { - final _that = this; - switch (_that) { - case _LandmarkModel() when $default != null: - return $default(_that); - case _: - return null; - } - } +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _LandmarkModel value)? $default,){ +final _that = this; +switch (_that) { +case _LandmarkModel() when $default != null: +return $default(_that);case _: + return null; - /// A variant of `when` that fallback to an `orElse` callback. - /// - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case Subclass(:final field): - /// return ...; - /// case _: - /// return orElse(); - /// } - /// ``` +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` - @optionalTypeArgs - TResult maybeWhen( - TResult Function(String uuid, String name, List location, - String type, bool isSecondary, String description)? - $default, { - required TResult orElse(), - }) { - final _that = this; - switch (_that) { - case _LandmarkModel() when $default != null: - return $default(_that.uuid, _that.name, _that.location, _that.type, - _that.isSecondary, _that.description); - case _: - return orElse(); - } - } +@optionalTypeArgs TResult maybeWhen(TResult Function( String uuid, String name, List location, String type, bool isSecondary, String description)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _LandmarkModel() when $default != null: +return $default(_that.uuid,_that.name,_that.location,_that.type,_that.isSecondary,_that.description);case _: + return orElse(); - /// A `switch`-like method, using callbacks. - /// - /// As opposed to `map`, this offers destructuring. - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case Subclass(:final field): - /// return ...; - /// case Subclass2(:final field2): - /// return ...; - /// } - /// ``` +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` - @optionalTypeArgs - TResult when( - TResult Function(String uuid, String name, List location, - String type, bool isSecondary, String description) - $default, - ) { - final _that = this; - switch (_that) { - case _LandmarkModel(): - return $default(_that.uuid, _that.name, _that.location, _that.type, - _that.isSecondary, _that.description); - case _: - throw StateError('Unexpected subclass'); - } - } +@optionalTypeArgs TResult when(TResult Function( String uuid, String name, List location, String type, bool isSecondary, String description) $default,) {final _that = this; +switch (_that) { +case _LandmarkModel(): +return $default(_that.uuid,_that.name,_that.location,_that.type,_that.isSecondary,_that.description);case _: + throw StateError('Unexpected subclass'); - /// A variant of `when` that fallback to returning `null` - /// - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case Subclass(:final field): - /// return ...; - /// case _: - /// return null; - /// } - /// ``` +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String uuid, String name, List location, String type, bool isSecondary, String description)? $default,) {final _that = this; +switch (_that) { +case _LandmarkModel() when $default != null: +return $default(_that.uuid,_that.name,_that.location,_that.type,_that.isSecondary,_that.description);case _: + return null; + +} +} - @optionalTypeArgs - TResult? whenOrNull( - TResult? Function(String uuid, String name, List location, - String type, bool isSecondary, String description)? - $default, - ) { - final _that = this; - switch (_that) { - case _LandmarkModel() when $default != null: - return $default(_that.uuid, _that.name, _that.location, _that.type, - _that.isSecondary, _that.description); - case _: - return null; - } - } } /// @nodoc @JsonSerializable() -class _LandmarkModel implements LandmarkModel { - const _LandmarkModel( - {required this.uuid, - required this.name, - required final List location, - required this.type, - required this.isSecondary, - required this.description}) - : _location = location; - factory _LandmarkModel.fromJson(Map json) => - _$LandmarkModelFromJson(json); - @override - final String uuid; - @override - final String name; - final List _location; - @override - List get location { - if (_location is EqualUnmodifiableListView) return _location; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_location); - } +class _LandmarkModel extends LandmarkModel { + const _LandmarkModel({required this.uuid, required this.name, required final List location, required this.type, required this.isSecondary, required this.description}): _location = location,super._(); + factory _LandmarkModel.fromJson(Map json) => _$LandmarkModelFromJson(json); - @override - final String type; - @override - final bool isSecondary; - @override - final String description; +@override final String uuid; +@override final String name; + final List _location; +@override List get location { + if (_location is EqualUnmodifiableListView) return _location; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_location); +} - /// Create a copy of LandmarkModel - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - _$LandmarkModelCopyWith<_LandmarkModel> get copyWith => - __$LandmarkModelCopyWithImpl<_LandmarkModel>(this, _$identity); +@override final String type; +@override final bool isSecondary; +@override final String description; - @override - Map toJson() { - return _$LandmarkModelToJson( - this, - ); - } +/// Create a copy of LandmarkModel +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$LandmarkModelCopyWith<_LandmarkModel> get copyWith => __$LandmarkModelCopyWithImpl<_LandmarkModel>(this, _$identity); - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _LandmarkModel && - (identical(other.uuid, uuid) || other.uuid == uuid) && - (identical(other.name, name) || other.name == name) && - const DeepCollectionEquality().equals(other._location, _location) && - (identical(other.type, type) || other.type == type) && - (identical(other.isSecondary, isSecondary) || - other.isSecondary == isSecondary) && - (identical(other.description, description) || - other.description == description)); - } +@override +Map toJson() { + return _$LandmarkModelToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _LandmarkModel&&(identical(other.uuid, uuid) || other.uuid == uuid)&&(identical(other.name, name) || other.name == name)&&const DeepCollectionEquality().equals(other._location, _location)&&(identical(other.type, type) || other.type == type)&&(identical(other.isSecondary, isSecondary) || other.isSecondary == isSecondary)&&(identical(other.description, description) || other.description == description)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,uuid,name,const DeepCollectionEquality().hash(_location),type,isSecondary,description); + +@override +String toString() { + return 'LandmarkModel(uuid: $uuid, name: $name, location: $location, type: $type, isSecondary: $isSecondary, description: $description)'; +} - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - uuid, - name, - const DeepCollectionEquality().hash(_location), - type, - isSecondary, - description); - @override - String toString() { - return 'LandmarkModel(uuid: $uuid, name: $name, location: $location, type: $type, isSecondary: $isSecondary, description: $description)'; - } } /// @nodoc -abstract mixin class _$LandmarkModelCopyWith<$Res> - implements $LandmarkModelCopyWith<$Res> { - factory _$LandmarkModelCopyWith( - _LandmarkModel value, $Res Function(_LandmarkModel) _then) = - __$LandmarkModelCopyWithImpl; - @override - @useResult - $Res call( - {String uuid, - String name, - List location, - String type, - bool isSecondary, - String description}); -} +abstract mixin class _$LandmarkModelCopyWith<$Res> implements $LandmarkModelCopyWith<$Res> { + factory _$LandmarkModelCopyWith(_LandmarkModel value, $Res Function(_LandmarkModel) _then) = __$LandmarkModelCopyWithImpl; +@override @useResult +$Res call({ + String uuid, String name, List location, String type, bool isSecondary, String description +}); + + + +} /// @nodoc class __$LandmarkModelCopyWithImpl<$Res> implements _$LandmarkModelCopyWith<$Res> { @@ -399,45 +278,21 @@ class __$LandmarkModelCopyWithImpl<$Res> final _LandmarkModel _self; final $Res Function(_LandmarkModel) _then; - /// Create a copy of LandmarkModel - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $Res call({ - Object? uuid = null, - Object? name = null, - Object? location = null, - Object? type = null, - Object? isSecondary = null, - Object? description = null, - }) { - return _then(_LandmarkModel( - uuid: null == uuid - ? _self.uuid - : uuid // ignore: cast_nullable_to_non_nullable - as String, - name: null == name - ? _self.name - : name // ignore: cast_nullable_to_non_nullable - as String, - location: null == location - ? _self._location - : location // ignore: cast_nullable_to_non_nullable - as List, - type: null == type - ? _self.type - : type // ignore: cast_nullable_to_non_nullable - as String, - isSecondary: null == isSecondary - ? _self.isSecondary - : isSecondary // ignore: cast_nullable_to_non_nullable - as bool, - description: null == description - ? _self.description - : description // ignore: cast_nullable_to_non_nullable - as String, - )); - } +/// Create a copy of LandmarkModel +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? uuid = null,Object? name = null,Object? location = null,Object? type = null,Object? isSecondary = null,Object? description = null,}) { + return _then(_LandmarkModel( +uuid: null == uuid ? _self.uuid : uuid // ignore: cast_nullable_to_non_nullable +as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,location: null == location ? _self._location : location // ignore: cast_nullable_to_non_nullable +as List,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable +as String,isSecondary: null == isSecondary ? _self.isSecondary : isSecondary // ignore: cast_nullable_to_non_nullable +as bool,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable +as String, + )); +} + + } // dart format on diff --git a/frontend/lib/data/repositories/backend_trip_repository.dart b/frontend/lib/data/repositories/backend_trip_repository.dart index db1bf34..ef8f425 100644 --- a/frontend/lib/data/repositories/backend_trip_repository.dart +++ b/frontend/lib/data/repositories/backend_trip_repository.dart @@ -1,119 +1,89 @@ -import 'dart:developer'; - +import 'package:anyway/domain/entities/landmark.dart'; import 'package:anyway/domain/entities/preferences.dart'; import 'package:anyway/domain/entities/trip.dart'; import 'package:anyway/domain/repositories/trip_repository.dart'; -import 'package:dio/dio.dart'; +import 'package:anyway/data/datasources/trip_remote_datasource.dart'; -// We can request a new trip from our backend API by passing it user preferences (which contain all the necessary data) class BackendTripRepository implements TripRepository { - final Dio dio; - - BackendTripRepository({required this.dio}); + final TripRemoteDataSource remote; + BackendTripRepository({required this.remote}); @override - Future getTrip({Preferences? preferences, String? tripUUID}) async { - Map data = { - "preferences": preferences!.toJson(), - // "start": preferences!.startPoint.location, + Future getTrip({Preferences? preferences, String? tripUUID, List? landmarks}) async { + try { + Map json; + + if (tripUUID != null) { + json = await remote.fetchTrip(tripUUID); + } else { + if (preferences == null) { + throw ArgumentError('Either preferences or tripUUID must be provided'); + } + + final Map prefsPayload = _buildPreferencesPayload(preferences); + List> landmarkBodies = landmarks != null + ? landmarks.map((lm) => lm.toJson()).toList() + : await _fetchLandmarkPayloads(prefsPayload, preferences.startLocation); + + // TODO: remove + // restrict the landmark list to 30 to iterate quickly + landmarkBodies = landmarkBodies.take(30).toList(); + // change the json key because of backend inconsistency + for (var lm in landmarkBodies) { + if (lm.containsKey('type')) { + lm['type'] = "sightseeing"; + } + lm['osm_type'] = 'node'; + lm['osm_id'] = 1; + } + + final Map body = { + 'preferences': prefsPayload, + 'landmarks': landmarkBodies, + 'start': preferences.startLocation, + }; + if (preferences.endLocation != null) { + body['end'] = preferences.endLocation; + } + if (preferences.detourToleranceMinutes != null) { + body['detour_tolerance_minute'] = preferences.detourToleranceMinutes; + } + + json = await remote.createTrip(body); + } + + return Trip.fromJson(json); + } catch (e) { + throw Exception('Failed to fetch trip: ${e.toString()}'); + } + } + + + // TODO - maybe shorten this + @override + Future> searchLandmarks(Preferences preferences) async { + final Map prefsPayload = _buildPreferencesPayload(preferences); + final List> rawLandmarks = await _fetchLandmarkPayloads(prefsPayload, preferences.startLocation); + return rawLandmarks.map((lmJson) => Landmark.fromJson(lmJson)).toList(); + } + + Future>> _fetchLandmarkPayloads( + Map prefsPayload, List startLocation) async { + final Map landmarkRequest = { + 'preferences': prefsPayload, + 'start': startLocation, }; + return await remote.fetchLandmarks(landmarkRequest); + } - late Response response; - try { - response = await dio.post( - "/trip/new", - data: data - ); - } catch (e) { - trip.updateUUID("error"); - - // Format the error message to be more user friendly - String errorDescription; - if (e is DioException) { - errorDescription = e.message ?? "Unknown error"; - } else if (e is SocketException) { - errorDescription = "No internet connection"; - } else if (e is TimeoutException) { - errorDescription = "Request timed out"; - } else { - errorDescription = "Unknown error"; - } - - String errorMessage = """ - We're sorry, the following error was generated: - - ${errorDescription.trim()} - """.trim(); - - trip.updateError(errorMessage); - log(e.toString()); - log(errorMessage); - return; - } - - // handle more specific errors - if (response.statusCode != 200) { - trip.updateUUID("error"); - String errorDescription; - if (response.data.runtimeType == String) { - errorDescription = response.data; - } else if (response.data.runtimeType == Map) { - errorDescription = response.data["detail"] ?? "Unknown error"; - } else { - errorDescription = "Unknown error"; - } - - String errorMessage = """ - We're sorry, our servers generated the following error: - - ${errorDescription.trim()} - Please try again. - """.trim(); - trip.updateError(errorMessage); - log(errorMessage); - // Actualy no need to throw an exception, we can just log the error and let the user retry - // throw Exception(errorDetail); - } else { - - // if the response data is not json, throw an error - if (response.data is! Map) { - log("${response.data.runtimeType}"); - trip.updateUUID("error"); - String errorMessage = """ - We're sorry, our servers generated the following error: - - ${response.data.trim()} - Please try again. - """.trim(); - trip.updateError(errorMessage); - log(errorMessage); - return; - } - - Map json = response.data; - - // only fill in the trip "meta" data for now - trip.loadFromJson(json); - - // now fill the trip with landmarks - // we are going to recreate ALL the landmarks from the information given by the api - trip.landmarks.remove(trip.landmarks.first); - String? nextUUID = json["first_landmark_uuid"]; - while (nextUUID != null) { - var (landmark, newUUID) = await fetchLandmark(nextUUID); - trip.addLandmark(landmark); - nextUUID = newUUID; - } - - log(response.data.toString()); - // // Also save the trip for the user's convenience - // savedTrips.addTrip(trip); - } - - - - + Map _buildPreferencesPayload(Preferences preferences) { + final Map prefsPayload = {}; + preferences.scores.forEach((type, score) { + prefsPayload[type] = {'type': type, 'score': score}; + }); + prefsPayload['max_time_minute'] = preferences.maxTimeMinutes; + return prefsPayload; } } diff --git a/frontend/lib/data/repositories/local_onboarding_repository.dart b/frontend/lib/data/repositories/local_onboarding_repository.dart new file mode 100644 index 0000000..9bae326 --- /dev/null +++ b/frontend/lib/data/repositories/local_onboarding_repository.dart @@ -0,0 +1,18 @@ +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:anyway/domain/repositories/onboarding_repository.dart'; + +class LocalOnboardingRepository implements OnboardingRepository { + static const _key = 'onboardingCompleted'; + + @override + Future isOnboarded() async { + final prefs = await SharedPreferences.getInstance(); + return prefs.getBool(_key) ?? false; + } + + @override + Future setOnboarded(bool value) async { + final prefs = await SharedPreferences.getInstance(); + await prefs.setBool(_key, value); + } +} diff --git a/frontend/lib/data/repositories/preferences_repository_impl.dart b/frontend/lib/data/repositories/preferences_repository_impl.dart new file mode 100644 index 0000000..76f6104 --- /dev/null +++ b/frontend/lib/data/repositories/preferences_repository_impl.dart @@ -0,0 +1,50 @@ +import 'dart:convert'; + +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:anyway/domain/entities/preferences.dart'; +import 'package:anyway/domain/repositories/preferences_repository.dart'; + +class PreferencesRepositoryImpl implements PreferencesRepository { + static const _key = 'userPreferences'; + + @override + Future getPreferences() async { + final prefs = await SharedPreferences.getInstance(); + final raw = prefs.getString(_key); + if (raw == null) { + // TODO - rethink this + // return a sensible default + return Preferences( + scores: { + 'sightseeing': 0, + 'shopping': 0, + 'nature': 0, + }, + maxTimeMinutes: 120, + startLocation: const [48.8575, 2.3514], + ); + } + + try { + final map = json.decode(raw) as Map; + return Preferences.fromJson(map); + } catch (_) { + return Preferences( + scores: { + 'sightseeing': 0, + 'shopping': 0, + 'nature': 0, + }, + maxTimeMinutes: 120, + startLocation: const [48.8575, 2.3514], + ); + } + } + + @override + Future savePreferences(Preferences preferences) async { + final prefs = await SharedPreferences.getInstance(); + final raw = json.encode(preferences.toJson()); + await prefs.setString(_key, raw); + } +} diff --git a/frontend/lib/domain/README.md b/frontend/lib/domain/README.md index 1746555..a8158cc 100644 --- a/frontend/lib/domain/README.md +++ b/frontend/lib/domain/README.md @@ -22,3 +22,14 @@ This is required boilerplate for all models. Then, we define the model itself us The `*.frozen.dart` and `*.g.dart` are pure boilerplate and should not be touched. Note that the description of the data will losely follow the capabilities of the backend but does not need to reflect it exactly. That is where the `data` part is for: translating api calls into flutter objects. + +To ensure the creation of the boilerplate code, run the following command in your terminal: + +```bash +flutter pub run build_runner build --delete-conflicting-outputs +``` +or interactively: +``` +dart run build_runner watch -d +``` + diff --git a/frontend/lib/domain/entities/landmark.dart b/frontend/lib/domain/entities/landmark.dart index 08b8aa0..757371e 100644 --- a/frontend/lib/domain/entities/landmark.dart +++ b/frontend/lib/domain/entities/landmark.dart @@ -12,9 +12,38 @@ abstract class Landmark with _$Landmark { required String name, required List location, required LandmarkType type, - required bool isSecondary, - required LandmarkDescription description, + @JsonKey(name: 'is_secondary') + bool? isSecondary, + + /// Optional rich description object (may be null if API returns plain string) + LandmarkDescription? description, + + @JsonKey(name: 'name_en') + String? nameEn, + + @JsonKey(name: 'website_url') + String? websiteUrl, + + @JsonKey(name: 'image_url') + String? imageUrl, + + @JsonKey(name: 'attractiveness') + int? attractiveness, + + @JsonKey(name: 'n_tags') + int? tagCount, + + + + /// Duration at landmark in minutes + @JsonKey(name: 'duration') + int? durationMinutes, + + bool? visited, + + @JsonKey(name: 'time_to_reach_next') + int? timeToReachNextMinutes, }) = _Landmark; factory Landmark.fromJson(Map json) => _$LandmarkFromJson(json); diff --git a/frontend/lib/domain/entities/landmark.freezed.dart b/frontend/lib/domain/entities/landmark.freezed.dart index 14e862b..1bf9b3a 100644 --- a/frontend/lib/domain/entities/landmark.freezed.dart +++ b/frontend/lib/domain/entities/landmark.freezed.dart @@ -14,435 +14,337 @@ T _$identity(T value) => value; /// @nodoc mixin _$Landmark { - String get uuid; - set uuid(String value); - String get name; - set name(String value); - List get location; - set location(List value); - LandmarkType get type; - set type(LandmarkType value); - bool get isSecondary; - set isSecondary(bool value); - LandmarkDescription get description; - set description(LandmarkDescription value); - /// Create a copy of Landmark - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - $LandmarkCopyWith get copyWith => - _$LandmarkCopyWithImpl(this as Landmark, _$identity); + String get uuid; set uuid(String value); String get name; set name(String value); List get location; set location(List value); LandmarkType get type; set type(LandmarkType value);@JsonKey(name: 'is_secondary') bool? get isSecondary;@JsonKey(name: 'is_secondary') set isSecondary(bool? value);/// Optional rich description object (may be null if API returns plain string) + LandmarkDescription? get description;/// Optional rich description object (may be null if API returns plain string) + set description(LandmarkDescription? value);@JsonKey(name: 'name_en') String? get nameEn;@JsonKey(name: 'name_en') set nameEn(String? value);@JsonKey(name: 'website_url') String? get websiteUrl;@JsonKey(name: 'website_url') set websiteUrl(String? value);@JsonKey(name: 'image_url') String? get imageUrl;@JsonKey(name: 'image_url') set imageUrl(String? value);@JsonKey(name: 'attractiveness') int? get attractiveness;@JsonKey(name: 'attractiveness') set attractiveness(int? value);@JsonKey(name: 'n_tags') int? get tagCount;@JsonKey(name: 'n_tags') set tagCount(int? value);/// Duration at landmark in minutes +@JsonKey(name: 'duration') int? get durationMinutes;/// Duration at landmark in minutes +@JsonKey(name: 'duration') set durationMinutes(int? value); bool? get visited; set visited(bool? value);@JsonKey(name: 'time_to_reach_next') int? get timeToReachNextMinutes;@JsonKey(name: 'time_to_reach_next') set timeToReachNextMinutes(int? value); +/// Create a copy of Landmark +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$LandmarkCopyWith get copyWith => _$LandmarkCopyWithImpl(this as Landmark, _$identity); /// Serializes this Landmark to a JSON map. Map toJson(); - @override - String toString() { - return 'Landmark(uuid: $uuid, name: $name, location: $location, type: $type, isSecondary: $isSecondary, description: $description)'; - } + + + +@override +String toString() { + return 'Landmark(uuid: $uuid, name: $name, location: $location, type: $type, isSecondary: $isSecondary, description: $description, nameEn: $nameEn, websiteUrl: $websiteUrl, imageUrl: $imageUrl, attractiveness: $attractiveness, tagCount: $tagCount, durationMinutes: $durationMinutes, visited: $visited, timeToReachNextMinutes: $timeToReachNextMinutes)'; +} + + } /// @nodoc -abstract mixin class $LandmarkCopyWith<$Res> { - factory $LandmarkCopyWith(Landmark value, $Res Function(Landmark) _then) = - _$LandmarkCopyWithImpl; - @useResult - $Res call( - {String uuid, - String name, - List location, - LandmarkType type, - bool isSecondary, - LandmarkDescription description}); +abstract mixin class $LandmarkCopyWith<$Res> { + factory $LandmarkCopyWith(Landmark value, $Res Function(Landmark) _then) = _$LandmarkCopyWithImpl; +@useResult +$Res call({ + String uuid, String name, List location, LandmarkType type,@JsonKey(name: 'is_secondary') bool? isSecondary, LandmarkDescription? description,@JsonKey(name: 'name_en') String? nameEn,@JsonKey(name: 'website_url') String? websiteUrl,@JsonKey(name: 'image_url') String? imageUrl,@JsonKey(name: 'attractiveness') int? attractiveness,@JsonKey(name: 'n_tags') int? tagCount,@JsonKey(name: 'duration') int? durationMinutes, bool? visited,@JsonKey(name: 'time_to_reach_next') int? timeToReachNextMinutes +}); + + +$LandmarkTypeCopyWith<$Res> get type;$LandmarkDescriptionCopyWith<$Res>? get description; - $LandmarkTypeCopyWith<$Res> get type; - $LandmarkDescriptionCopyWith<$Res> get description; } - /// @nodoc -class _$LandmarkCopyWithImpl<$Res> implements $LandmarkCopyWith<$Res> { +class _$LandmarkCopyWithImpl<$Res> + implements $LandmarkCopyWith<$Res> { _$LandmarkCopyWithImpl(this._self, this._then); final Landmark _self; final $Res Function(Landmark) _then; - /// Create a copy of Landmark - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? uuid = null, - Object? name = null, - Object? location = null, - Object? type = null, - Object? isSecondary = null, - Object? description = null, - }) { - return _then(_self.copyWith( - uuid: null == uuid - ? _self.uuid - : uuid // ignore: cast_nullable_to_non_nullable - as String, - name: null == name - ? _self.name - : name // ignore: cast_nullable_to_non_nullable - as String, - location: null == location - ? _self.location - : location // ignore: cast_nullable_to_non_nullable - as List, - type: null == type - ? _self.type - : type // ignore: cast_nullable_to_non_nullable - as LandmarkType, - isSecondary: null == isSecondary - ? _self.isSecondary - : isSecondary // ignore: cast_nullable_to_non_nullable - as bool, - description: null == description - ? _self.description - : description // ignore: cast_nullable_to_non_nullable - as LandmarkDescription, - )); - } - - /// Create a copy of Landmark - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $LandmarkTypeCopyWith<$Res> get type { - return $LandmarkTypeCopyWith<$Res>(_self.type, (value) { - return _then(_self.copyWith(type: value)); - }); - } - - /// Create a copy of Landmark - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $LandmarkDescriptionCopyWith<$Res> get description { - return $LandmarkDescriptionCopyWith<$Res>(_self.description, (value) { - return _then(_self.copyWith(description: value)); - }); - } +/// Create a copy of Landmark +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? uuid = null,Object? name = null,Object? location = null,Object? type = null,Object? isSecondary = freezed,Object? description = freezed,Object? nameEn = freezed,Object? websiteUrl = freezed,Object? imageUrl = freezed,Object? attractiveness = freezed,Object? tagCount = freezed,Object? durationMinutes = freezed,Object? visited = freezed,Object? timeToReachNextMinutes = freezed,}) { + return _then(_self.copyWith( +uuid: null == uuid ? _self.uuid : uuid // ignore: cast_nullable_to_non_nullable +as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,location: null == location ? _self.location : location // ignore: cast_nullable_to_non_nullable +as List,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable +as LandmarkType,isSecondary: freezed == isSecondary ? _self.isSecondary : isSecondary // ignore: cast_nullable_to_non_nullable +as bool?,description: freezed == description ? _self.description : description // ignore: cast_nullable_to_non_nullable +as LandmarkDescription?,nameEn: freezed == nameEn ? _self.nameEn : nameEn // ignore: cast_nullable_to_non_nullable +as String?,websiteUrl: freezed == websiteUrl ? _self.websiteUrl : websiteUrl // ignore: cast_nullable_to_non_nullable +as String?,imageUrl: freezed == imageUrl ? _self.imageUrl : imageUrl // ignore: cast_nullable_to_non_nullable +as String?,attractiveness: freezed == attractiveness ? _self.attractiveness : attractiveness // ignore: cast_nullable_to_non_nullable +as int?,tagCount: freezed == tagCount ? _self.tagCount : tagCount // ignore: cast_nullable_to_non_nullable +as int?,durationMinutes: freezed == durationMinutes ? _self.durationMinutes : durationMinutes // ignore: cast_nullable_to_non_nullable +as int?,visited: freezed == visited ? _self.visited : visited // ignore: cast_nullable_to_non_nullable +as bool?,timeToReachNextMinutes: freezed == timeToReachNextMinutes ? _self.timeToReachNextMinutes : timeToReachNextMinutes // ignore: cast_nullable_to_non_nullable +as int?, + )); } +/// Create a copy of Landmark +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$LandmarkTypeCopyWith<$Res> get type { + + return $LandmarkTypeCopyWith<$Res>(_self.type, (value) { + return _then(_self.copyWith(type: value)); + }); +}/// Create a copy of Landmark +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$LandmarkDescriptionCopyWith<$Res>? get description { + if (_self.description == null) { + return null; + } + + return $LandmarkDescriptionCopyWith<$Res>(_self.description!, (value) { + return _then(_self.copyWith(description: value)); + }); +} +} + /// Adds pattern-matching-related methods to [Landmark]. extension LandmarkPatterns on Landmark { - /// A variant of `map` that fallback to returning `orElse`. - /// - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case final Subclass value: - /// return ...; - /// case _: - /// return orElse(); - /// } - /// ``` +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` - @optionalTypeArgs - TResult maybeMap( - TResult Function(_Landmark value)? $default, { - required TResult orElse(), - }) { - final _that = this; - switch (_that) { - case _Landmark() when $default != null: - return $default(_that); - case _: - return orElse(); - } - } +@optionalTypeArgs TResult maybeMap(TResult Function( _Landmark value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Landmark() when $default != null: +return $default(_that);case _: + return orElse(); - /// A `switch`-like method, using callbacks. - /// - /// Callbacks receives the raw object, upcasted. - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case final Subclass value: - /// return ...; - /// case final Subclass2 value: - /// return ...; - /// } - /// ``` +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` - @optionalTypeArgs - TResult map( - TResult Function(_Landmark value) $default, - ) { - final _that = this; - switch (_that) { - case _Landmark(): - return $default(_that); - case _: - throw StateError('Unexpected subclass'); - } - } +@optionalTypeArgs TResult map(TResult Function( _Landmark value) $default,){ +final _that = this; +switch (_that) { +case _Landmark(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); - /// A variant of `map` that fallback to returning `null`. - /// - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case final Subclass value: - /// return ...; - /// case _: - /// return null; - /// } - /// ``` +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` - @optionalTypeArgs - TResult? mapOrNull( - TResult? Function(_Landmark value)? $default, - ) { - final _that = this; - switch (_that) { - case _Landmark() when $default != null: - return $default(_that); - case _: - return null; - } - } +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _Landmark value)? $default,){ +final _that = this; +switch (_that) { +case _Landmark() when $default != null: +return $default(_that);case _: + return null; - /// A variant of `when` that fallback to an `orElse` callback. - /// - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case Subclass(:final field): - /// return ...; - /// case _: - /// return orElse(); - /// } - /// ``` +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` - @optionalTypeArgs - TResult maybeWhen( - TResult Function( - String uuid, - String name, - List location, - LandmarkType type, - bool isSecondary, - LandmarkDescription description)? - $default, { - required TResult orElse(), - }) { - final _that = this; - switch (_that) { - case _Landmark() when $default != null: - return $default(_that.uuid, _that.name, _that.location, _that.type, - _that.isSecondary, _that.description); - case _: - return orElse(); - } - } +@optionalTypeArgs TResult maybeWhen(TResult Function( String uuid, String name, List location, LandmarkType type, @JsonKey(name: 'is_secondary') bool? isSecondary, LandmarkDescription? description, @JsonKey(name: 'name_en') String? nameEn, @JsonKey(name: 'website_url') String? websiteUrl, @JsonKey(name: 'image_url') String? imageUrl, @JsonKey(name: 'attractiveness') int? attractiveness, @JsonKey(name: 'n_tags') int? tagCount, @JsonKey(name: 'duration') int? durationMinutes, bool? visited, @JsonKey(name: 'time_to_reach_next') int? timeToReachNextMinutes)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Landmark() when $default != null: +return $default(_that.uuid,_that.name,_that.location,_that.type,_that.isSecondary,_that.description,_that.nameEn,_that.websiteUrl,_that.imageUrl,_that.attractiveness,_that.tagCount,_that.durationMinutes,_that.visited,_that.timeToReachNextMinutes);case _: + return orElse(); - /// A `switch`-like method, using callbacks. - /// - /// As opposed to `map`, this offers destructuring. - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case Subclass(:final field): - /// return ...; - /// case Subclass2(:final field2): - /// return ...; - /// } - /// ``` +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` - @optionalTypeArgs - TResult when( - TResult Function( - String uuid, - String name, - List location, - LandmarkType type, - bool isSecondary, - LandmarkDescription description) - $default, - ) { - final _that = this; - switch (_that) { - case _Landmark(): - return $default(_that.uuid, _that.name, _that.location, _that.type, - _that.isSecondary, _that.description); - case _: - throw StateError('Unexpected subclass'); - } - } +@optionalTypeArgs TResult when(TResult Function( String uuid, String name, List location, LandmarkType type, @JsonKey(name: 'is_secondary') bool? isSecondary, LandmarkDescription? description, @JsonKey(name: 'name_en') String? nameEn, @JsonKey(name: 'website_url') String? websiteUrl, @JsonKey(name: 'image_url') String? imageUrl, @JsonKey(name: 'attractiveness') int? attractiveness, @JsonKey(name: 'n_tags') int? tagCount, @JsonKey(name: 'duration') int? durationMinutes, bool? visited, @JsonKey(name: 'time_to_reach_next') int? timeToReachNextMinutes) $default,) {final _that = this; +switch (_that) { +case _Landmark(): +return $default(_that.uuid,_that.name,_that.location,_that.type,_that.isSecondary,_that.description,_that.nameEn,_that.websiteUrl,_that.imageUrl,_that.attractiveness,_that.tagCount,_that.durationMinutes,_that.visited,_that.timeToReachNextMinutes);case _: + throw StateError('Unexpected subclass'); - /// A variant of `when` that fallback to returning `null` - /// - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case Subclass(:final field): - /// return ...; - /// case _: - /// return null; - /// } - /// ``` +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String uuid, String name, List location, LandmarkType type, @JsonKey(name: 'is_secondary') bool? isSecondary, LandmarkDescription? description, @JsonKey(name: 'name_en') String? nameEn, @JsonKey(name: 'website_url') String? websiteUrl, @JsonKey(name: 'image_url') String? imageUrl, @JsonKey(name: 'attractiveness') int? attractiveness, @JsonKey(name: 'n_tags') int? tagCount, @JsonKey(name: 'duration') int? durationMinutes, bool? visited, @JsonKey(name: 'time_to_reach_next') int? timeToReachNextMinutes)? $default,) {final _that = this; +switch (_that) { +case _Landmark() when $default != null: +return $default(_that.uuid,_that.name,_that.location,_that.type,_that.isSecondary,_that.description,_that.nameEn,_that.websiteUrl,_that.imageUrl,_that.attractiveness,_that.tagCount,_that.durationMinutes,_that.visited,_that.timeToReachNextMinutes);case _: + return null; + +} +} - @optionalTypeArgs - TResult? whenOrNull( - TResult? Function( - String uuid, - String name, - List location, - LandmarkType type, - bool isSecondary, - LandmarkDescription description)? - $default, - ) { - final _that = this; - switch (_that) { - case _Landmark() when $default != null: - return $default(_that.uuid, _that.name, _that.location, _that.type, - _that.isSecondary, _that.description); - case _: - return null; - } - } } /// @nodoc @JsonSerializable() + class _Landmark implements Landmark { - _Landmark( - {required this.uuid, - required this.name, - required this.location, - required this.type, - required this.isSecondary, - required this.description}); - factory _Landmark.fromJson(Map json) => - _$LandmarkFromJson(json); + _Landmark({required this.uuid, required this.name, required this.location, required this.type, @JsonKey(name: 'is_secondary') this.isSecondary, this.description, @JsonKey(name: 'name_en') this.nameEn, @JsonKey(name: 'website_url') this.websiteUrl, @JsonKey(name: 'image_url') this.imageUrl, @JsonKey(name: 'attractiveness') this.attractiveness, @JsonKey(name: 'n_tags') this.tagCount, @JsonKey(name: 'duration') this.durationMinutes, this.visited, @JsonKey(name: 'time_to_reach_next') this.timeToReachNextMinutes}); + factory _Landmark.fromJson(Map json) => _$LandmarkFromJson(json); - @override - String uuid; - @override - String name; - @override - List location; - @override - LandmarkType type; - @override - bool isSecondary; - @override - LandmarkDescription description; +@override String uuid; +@override String name; +@override List location; +@override LandmarkType type; +@override@JsonKey(name: 'is_secondary') bool? isSecondary; +/// Optional rich description object (may be null if API returns plain string) +@override LandmarkDescription? description; +@override@JsonKey(name: 'name_en') String? nameEn; +@override@JsonKey(name: 'website_url') String? websiteUrl; +@override@JsonKey(name: 'image_url') String? imageUrl; +@override@JsonKey(name: 'attractiveness') int? attractiveness; +@override@JsonKey(name: 'n_tags') int? tagCount; +/// Duration at landmark in minutes +@override@JsonKey(name: 'duration') int? durationMinutes; +@override bool? visited; +@override@JsonKey(name: 'time_to_reach_next') int? timeToReachNextMinutes; - /// Create a copy of Landmark - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - _$LandmarkCopyWith<_Landmark> get copyWith => - __$LandmarkCopyWithImpl<_Landmark>(this, _$identity); +/// Create a copy of Landmark +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$LandmarkCopyWith<_Landmark> get copyWith => __$LandmarkCopyWithImpl<_Landmark>(this, _$identity); + +@override +Map toJson() { + return _$LandmarkToJson(this, ); +} + + + +@override +String toString() { + return 'Landmark(uuid: $uuid, name: $name, location: $location, type: $type, isSecondary: $isSecondary, description: $description, nameEn: $nameEn, websiteUrl: $websiteUrl, imageUrl: $imageUrl, attractiveness: $attractiveness, tagCount: $tagCount, durationMinutes: $durationMinutes, visited: $visited, timeToReachNextMinutes: $timeToReachNextMinutes)'; +} - @override - Map toJson() { - return _$LandmarkToJson( - this, - ); - } - @override - String toString() { - return 'Landmark(uuid: $uuid, name: $name, location: $location, type: $type, isSecondary: $isSecondary, description: $description)'; - } } /// @nodoc -abstract mixin class _$LandmarkCopyWith<$Res> - implements $LandmarkCopyWith<$Res> { - factory _$LandmarkCopyWith(_Landmark value, $Res Function(_Landmark) _then) = - __$LandmarkCopyWithImpl; - @override - @useResult - $Res call( - {String uuid, - String name, - List location, - LandmarkType type, - bool isSecondary, - LandmarkDescription description}); +abstract mixin class _$LandmarkCopyWith<$Res> implements $LandmarkCopyWith<$Res> { + factory _$LandmarkCopyWith(_Landmark value, $Res Function(_Landmark) _then) = __$LandmarkCopyWithImpl; +@override @useResult +$Res call({ + String uuid, String name, List location, LandmarkType type,@JsonKey(name: 'is_secondary') bool? isSecondary, LandmarkDescription? description,@JsonKey(name: 'name_en') String? nameEn,@JsonKey(name: 'website_url') String? websiteUrl,@JsonKey(name: 'image_url') String? imageUrl,@JsonKey(name: 'attractiveness') int? attractiveness,@JsonKey(name: 'n_tags') int? tagCount,@JsonKey(name: 'duration') int? durationMinutes, bool? visited,@JsonKey(name: 'time_to_reach_next') int? timeToReachNextMinutes +}); + + +@override $LandmarkTypeCopyWith<$Res> get type;@override $LandmarkDescriptionCopyWith<$Res>? get description; - @override - $LandmarkTypeCopyWith<$Res> get type; - @override - $LandmarkDescriptionCopyWith<$Res> get description; } - /// @nodoc -class __$LandmarkCopyWithImpl<$Res> implements _$LandmarkCopyWith<$Res> { +class __$LandmarkCopyWithImpl<$Res> + implements _$LandmarkCopyWith<$Res> { __$LandmarkCopyWithImpl(this._self, this._then); final _Landmark _self; final $Res Function(_Landmark) _then; - /// Create a copy of Landmark - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $Res call({ - Object? uuid = null, - Object? name = null, - Object? location = null, - Object? type = null, - Object? isSecondary = null, - Object? description = null, - }) { - return _then(_Landmark( - uuid: null == uuid - ? _self.uuid - : uuid // ignore: cast_nullable_to_non_nullable - as String, - name: null == name - ? _self.name - : name // ignore: cast_nullable_to_non_nullable - as String, - location: null == location - ? _self.location - : location // ignore: cast_nullable_to_non_nullable - as List, - type: null == type - ? _self.type - : type // ignore: cast_nullable_to_non_nullable - as LandmarkType, - isSecondary: null == isSecondary - ? _self.isSecondary - : isSecondary // ignore: cast_nullable_to_non_nullable - as bool, - description: null == description - ? _self.description - : description // ignore: cast_nullable_to_non_nullable - as LandmarkDescription, - )); +/// Create a copy of Landmark +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? uuid = null,Object? name = null,Object? location = null,Object? type = null,Object? isSecondary = freezed,Object? description = freezed,Object? nameEn = freezed,Object? websiteUrl = freezed,Object? imageUrl = freezed,Object? attractiveness = freezed,Object? tagCount = freezed,Object? durationMinutes = freezed,Object? visited = freezed,Object? timeToReachNextMinutes = freezed,}) { + return _then(_Landmark( +uuid: null == uuid ? _self.uuid : uuid // ignore: cast_nullable_to_non_nullable +as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,location: null == location ? _self.location : location // ignore: cast_nullable_to_non_nullable +as List,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable +as LandmarkType,isSecondary: freezed == isSecondary ? _self.isSecondary : isSecondary // ignore: cast_nullable_to_non_nullable +as bool?,description: freezed == description ? _self.description : description // ignore: cast_nullable_to_non_nullable +as LandmarkDescription?,nameEn: freezed == nameEn ? _self.nameEn : nameEn // ignore: cast_nullable_to_non_nullable +as String?,websiteUrl: freezed == websiteUrl ? _self.websiteUrl : websiteUrl // ignore: cast_nullable_to_non_nullable +as String?,imageUrl: freezed == imageUrl ? _self.imageUrl : imageUrl // ignore: cast_nullable_to_non_nullable +as String?,attractiveness: freezed == attractiveness ? _self.attractiveness : attractiveness // ignore: cast_nullable_to_non_nullable +as int?,tagCount: freezed == tagCount ? _self.tagCount : tagCount // ignore: cast_nullable_to_non_nullable +as int?,durationMinutes: freezed == durationMinutes ? _self.durationMinutes : durationMinutes // ignore: cast_nullable_to_non_nullable +as int?,visited: freezed == visited ? _self.visited : visited // ignore: cast_nullable_to_non_nullable +as bool?,timeToReachNextMinutes: freezed == timeToReachNextMinutes ? _self.timeToReachNextMinutes : timeToReachNextMinutes // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + +/// Create a copy of Landmark +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$LandmarkTypeCopyWith<$Res> get type { + + return $LandmarkTypeCopyWith<$Res>(_self.type, (value) { + return _then(_self.copyWith(type: value)); + }); +}/// Create a copy of Landmark +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$LandmarkDescriptionCopyWith<$Res>? get description { + if (_self.description == null) { + return null; } - /// Create a copy of Landmark - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $LandmarkTypeCopyWith<$Res> get type { - return $LandmarkTypeCopyWith<$Res>(_self.type, (value) { - return _then(_self.copyWith(type: value)); - }); - } - - /// Create a copy of Landmark - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $LandmarkDescriptionCopyWith<$Res> get description { - return $LandmarkDescriptionCopyWith<$Res>(_self.description, (value) { - return _then(_self.copyWith(description: value)); - }); - } + return $LandmarkDescriptionCopyWith<$Res>(_self.description!, (value) { + return _then(_self.copyWith(description: value)); + }); +} } // dart format on diff --git a/frontend/lib/domain/entities/landmark.g.dart b/frontend/lib/domain/entities/landmark.g.dart index 81fdc35..3983c5e 100644 --- a/frontend/lib/domain/entities/landmark.g.dart +++ b/frontend/lib/domain/entities/landmark.g.dart @@ -7,22 +7,41 @@ part of 'landmark.dart'; // ************************************************************************** _Landmark _$LandmarkFromJson(Map json) => _Landmark( - uuid: json['uuid'] as String, - name: json['name'] as String, - location: (json['location'] as List) - .map((e) => (e as num).toDouble()) - .toList(), - type: LandmarkType.fromJson(json['type'] as Map), - isSecondary: json['isSecondary'] as bool, - description: LandmarkDescription.fromJson( - json['description'] as Map), - ); + uuid: json['uuid'] as String, + name: json['name'] as String, + location: (json['location'] as List) + .map((e) => (e as num).toDouble()) + .toList(), + type: LandmarkType.fromJson(json['type'] as Map), + isSecondary: json['is_secondary'] as bool?, + description: json['description'] == null + ? null + : LandmarkDescription.fromJson( + json['description'] as Map, + ), + nameEn: json['name_en'] as String?, + websiteUrl: json['website_url'] as String?, + imageUrl: json['image_url'] as String?, + attractiveness: (json['attractiveness'] as num?)?.toInt(), + tagCount: (json['n_tags'] as num?)?.toInt(), + durationMinutes: (json['duration'] as num?)?.toInt(), + visited: json['visited'] as bool?, + timeToReachNextMinutes: (json['time_to_reach_next'] as num?)?.toInt(), +); Map _$LandmarkToJson(_Landmark instance) => { - 'uuid': instance.uuid, - 'name': instance.name, - 'location': instance.location, - 'type': instance.type, - 'isSecondary': instance.isSecondary, - 'description': instance.description, - }; + 'uuid': instance.uuid, + 'name': instance.name, + 'location': instance.location, + 'type': instance.type, + 'is_secondary': instance.isSecondary, + 'description': instance.description, + 'name_en': instance.nameEn, + 'website_url': instance.websiteUrl, + 'image_url': instance.imageUrl, + 'attractiveness': instance.attractiveness, + 'n_tags': instance.tagCount, + 'duration': instance.durationMinutes, + 'visited': instance.visited, + 'time_to_reach_next': instance.timeToReachNextMinutes, +}; diff --git a/frontend/lib/domain/entities/landmark_description.dart b/frontend/lib/domain/entities/landmark_description.dart index 4853447..0da7d11 100644 --- a/frontend/lib/domain/entities/landmark_description.dart +++ b/frontend/lib/domain/entities/landmark_description.dart @@ -3,7 +3,7 @@ part 'landmark_description.freezed.dart'; part 'landmark_description.g.dart'; -@Freezed(makeCollectionsUnmodifiable: false) +@freezed abstract class LandmarkDescription with _$LandmarkDescription { const factory LandmarkDescription({ required String description, diff --git a/frontend/lib/domain/entities/landmark_description.freezed.dart b/frontend/lib/domain/entities/landmark_description.freezed.dart index 842b41a..daf0ea9 100644 --- a/frontend/lib/domain/entities/landmark_description.freezed.dart +++ b/frontend/lib/domain/entities/landmark_description.freezed.dart @@ -14,50 +14,47 @@ T _$identity(T value) => value; /// @nodoc mixin _$LandmarkDescription { - String get description; - List get tags; - /// Create a copy of LandmarkDescription - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - $LandmarkDescriptionCopyWith get copyWith => - _$LandmarkDescriptionCopyWithImpl( - this as LandmarkDescription, _$identity); + String get description; List get tags; +/// Create a copy of LandmarkDescription +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$LandmarkDescriptionCopyWith get copyWith => _$LandmarkDescriptionCopyWithImpl(this as LandmarkDescription, _$identity); /// Serializes this LandmarkDescription to a JSON map. Map toJson(); - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is LandmarkDescription && - (identical(other.description, description) || - other.description == description) && - const DeepCollectionEquality().equals(other.tags, tags)); - } - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, description, const DeepCollectionEquality().hash(tags)); +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is LandmarkDescription&&(identical(other.description, description) || other.description == description)&&const DeepCollectionEquality().equals(other.tags, tags)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,description,const DeepCollectionEquality().hash(tags)); + +@override +String toString() { + return 'LandmarkDescription(description: $description, tags: $tags)'; +} + - @override - String toString() { - return 'LandmarkDescription(description: $description, tags: $tags)'; - } } /// @nodoc -abstract mixin class $LandmarkDescriptionCopyWith<$Res> { - factory $LandmarkDescriptionCopyWith( - LandmarkDescription value, $Res Function(LandmarkDescription) _then) = - _$LandmarkDescriptionCopyWithImpl; - @useResult - $Res call({String description, List tags}); -} +abstract mixin class $LandmarkDescriptionCopyWith<$Res> { + factory $LandmarkDescriptionCopyWith(LandmarkDescription value, $Res Function(LandmarkDescription) _then) = _$LandmarkDescriptionCopyWithImpl; +@useResult +$Res call({ + String description, List tags +}); + + + +} /// @nodoc class _$LandmarkDescriptionCopyWithImpl<$Res> implements $LandmarkDescriptionCopyWith<$Res> { @@ -66,244 +63,205 @@ class _$LandmarkDescriptionCopyWithImpl<$Res> final LandmarkDescription _self; final $Res Function(LandmarkDescription) _then; - /// Create a copy of LandmarkDescription - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? description = null, - Object? tags = null, - }) { - return _then(_self.copyWith( - description: null == description - ? _self.description - : description // ignore: cast_nullable_to_non_nullable - as String, - tags: null == tags - ? _self.tags - : tags // ignore: cast_nullable_to_non_nullable - as List, - )); - } +/// Create a copy of LandmarkDescription +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? description = null,Object? tags = null,}) { + return _then(_self.copyWith( +description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable +as String,tags: null == tags ? _self.tags : tags // ignore: cast_nullable_to_non_nullable +as List, + )); } +} + + /// Adds pattern-matching-related methods to [LandmarkDescription]. extension LandmarkDescriptionPatterns on LandmarkDescription { - /// A variant of `map` that fallback to returning `orElse`. - /// - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case final Subclass value: - /// return ...; - /// case _: - /// return orElse(); - /// } - /// ``` +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` - @optionalTypeArgs - TResult maybeMap( - TResult Function(_LandmarkDescription value)? $default, { - required TResult orElse(), - }) { - final _that = this; - switch (_that) { - case _LandmarkDescription() when $default != null: - return $default(_that); - case _: - return orElse(); - } - } +@optionalTypeArgs TResult maybeMap(TResult Function( _LandmarkDescription value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _LandmarkDescription() when $default != null: +return $default(_that);case _: + return orElse(); - /// A `switch`-like method, using callbacks. - /// - /// Callbacks receives the raw object, upcasted. - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case final Subclass value: - /// return ...; - /// case final Subclass2 value: - /// return ...; - /// } - /// ``` +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` - @optionalTypeArgs - TResult map( - TResult Function(_LandmarkDescription value) $default, - ) { - final _that = this; - switch (_that) { - case _LandmarkDescription(): - return $default(_that); - case _: - throw StateError('Unexpected subclass'); - } - } +@optionalTypeArgs TResult map(TResult Function( _LandmarkDescription value) $default,){ +final _that = this; +switch (_that) { +case _LandmarkDescription(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); - /// A variant of `map` that fallback to returning `null`. - /// - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case final Subclass value: - /// return ...; - /// case _: - /// return null; - /// } - /// ``` +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` - @optionalTypeArgs - TResult? mapOrNull( - TResult? Function(_LandmarkDescription value)? $default, - ) { - final _that = this; - switch (_that) { - case _LandmarkDescription() when $default != null: - return $default(_that); - case _: - return null; - } - } +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _LandmarkDescription value)? $default,){ +final _that = this; +switch (_that) { +case _LandmarkDescription() when $default != null: +return $default(_that);case _: + return null; - /// A variant of `when` that fallback to an `orElse` callback. - /// - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case Subclass(:final field): - /// return ...; - /// case _: - /// return orElse(); - /// } - /// ``` +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` - @optionalTypeArgs - TResult maybeWhen( - TResult Function(String description, List tags)? $default, { - required TResult orElse(), - }) { - final _that = this; - switch (_that) { - case _LandmarkDescription() when $default != null: - return $default(_that.description, _that.tags); - case _: - return orElse(); - } - } +@optionalTypeArgs TResult maybeWhen(TResult Function( String description, List tags)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _LandmarkDescription() when $default != null: +return $default(_that.description,_that.tags);case _: + return orElse(); - /// A `switch`-like method, using callbacks. - /// - /// As opposed to `map`, this offers destructuring. - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case Subclass(:final field): - /// return ...; - /// case Subclass2(:final field2): - /// return ...; - /// } - /// ``` +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` - @optionalTypeArgs - TResult when( - TResult Function(String description, List tags) $default, - ) { - final _that = this; - switch (_that) { - case _LandmarkDescription(): - return $default(_that.description, _that.tags); - case _: - throw StateError('Unexpected subclass'); - } - } +@optionalTypeArgs TResult when(TResult Function( String description, List tags) $default,) {final _that = this; +switch (_that) { +case _LandmarkDescription(): +return $default(_that.description,_that.tags);case _: + throw StateError('Unexpected subclass'); - /// A variant of `when` that fallback to returning `null` - /// - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case Subclass(:final field): - /// return ...; - /// case _: - /// return null; - /// } - /// ``` +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String description, List tags)? $default,) {final _that = this; +switch (_that) { +case _LandmarkDescription() when $default != null: +return $default(_that.description,_that.tags);case _: + return null; + +} +} - @optionalTypeArgs - TResult? whenOrNull( - TResult? Function(String description, List tags)? $default, - ) { - final _that = this; - switch (_that) { - case _LandmarkDescription() when $default != null: - return $default(_that.description, _that.tags); - case _: - return null; - } - } } /// @nodoc @JsonSerializable() + class _LandmarkDescription implements LandmarkDescription { - const _LandmarkDescription({required this.description, required this.tags}); - factory _LandmarkDescription.fromJson(Map json) => - _$LandmarkDescriptionFromJson(json); + const _LandmarkDescription({required this.description, required final List tags}): _tags = tags; + factory _LandmarkDescription.fromJson(Map json) => _$LandmarkDescriptionFromJson(json); - @override - final String description; - @override - final List tags; +@override final String description; + final List _tags; +@override List get tags { + if (_tags is EqualUnmodifiableListView) return _tags; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_tags); +} - /// Create a copy of LandmarkDescription - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - _$LandmarkDescriptionCopyWith<_LandmarkDescription> get copyWith => - __$LandmarkDescriptionCopyWithImpl<_LandmarkDescription>( - this, _$identity); - @override - Map toJson() { - return _$LandmarkDescriptionToJson( - this, - ); - } +/// Create a copy of LandmarkDescription +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$LandmarkDescriptionCopyWith<_LandmarkDescription> get copyWith => __$LandmarkDescriptionCopyWithImpl<_LandmarkDescription>(this, _$identity); - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _LandmarkDescription && - (identical(other.description, description) || - other.description == description) && - const DeepCollectionEquality().equals(other.tags, tags)); - } +@override +Map toJson() { + return _$LandmarkDescriptionToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _LandmarkDescription&&(identical(other.description, description) || other.description == description)&&const DeepCollectionEquality().equals(other._tags, _tags)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,description,const DeepCollectionEquality().hash(_tags)); + +@override +String toString() { + return 'LandmarkDescription(description: $description, tags: $tags)'; +} - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, description, const DeepCollectionEquality().hash(tags)); - @override - String toString() { - return 'LandmarkDescription(description: $description, tags: $tags)'; - } } /// @nodoc -abstract mixin class _$LandmarkDescriptionCopyWith<$Res> - implements $LandmarkDescriptionCopyWith<$Res> { - factory _$LandmarkDescriptionCopyWith(_LandmarkDescription value, - $Res Function(_LandmarkDescription) _then) = - __$LandmarkDescriptionCopyWithImpl; - @override - @useResult - $Res call({String description, List tags}); -} +abstract mixin class _$LandmarkDescriptionCopyWith<$Res> implements $LandmarkDescriptionCopyWith<$Res> { + factory _$LandmarkDescriptionCopyWith(_LandmarkDescription value, $Res Function(_LandmarkDescription) _then) = __$LandmarkDescriptionCopyWithImpl; +@override @useResult +$Res call({ + String description, List tags +}); + + + +} /// @nodoc class __$LandmarkDescriptionCopyWithImpl<$Res> implements _$LandmarkDescriptionCopyWith<$Res> { @@ -312,25 +270,17 @@ class __$LandmarkDescriptionCopyWithImpl<$Res> final _LandmarkDescription _self; final $Res Function(_LandmarkDescription) _then; - /// Create a copy of LandmarkDescription - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $Res call({ - Object? description = null, - Object? tags = null, - }) { - return _then(_LandmarkDescription( - description: null == description - ? _self.description - : description // ignore: cast_nullable_to_non_nullable - as String, - tags: null == tags - ? _self.tags - : tags // ignore: cast_nullable_to_non_nullable - as List, - )); - } +/// Create a copy of LandmarkDescription +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? description = null,Object? tags = null,}) { + return _then(_LandmarkDescription( +description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable +as String,tags: null == tags ? _self._tags : tags // ignore: cast_nullable_to_non_nullable +as List, + )); +} + + } // dart format on diff --git a/frontend/lib/domain/entities/landmark_description.g.dart b/frontend/lib/domain/entities/landmark_description.g.dart index ffc5c5e..1dca268 100644 --- a/frontend/lib/domain/entities/landmark_description.g.dart +++ b/frontend/lib/domain/entities/landmark_description.g.dart @@ -13,8 +13,8 @@ _LandmarkDescription _$LandmarkDescriptionFromJson(Map json) => ); Map _$LandmarkDescriptionToJson( - _LandmarkDescription instance) => - { - 'description': instance.description, - 'tags': instance.tags, - }; + _LandmarkDescription instance, +) => { + 'description': instance.description, + 'tags': instance.tags, +}; diff --git a/frontend/lib/domain/entities/landmark_type.dart b/frontend/lib/domain/entities/landmark_type.dart index 858cf84..e116e0f 100644 --- a/frontend/lib/domain/entities/landmark_type.dart +++ b/frontend/lib/domain/entities/landmark_type.dart @@ -14,12 +14,16 @@ abstract class LandmarkType with _$LandmarkType { @JsonEnum(alwaysCreate: true) enum LandmarkTypeEnum { - @JsonValue('culture') - culture, + @JsonValue('sightseeing') + sightseeing, @JsonValue('nature') nature, @JsonValue('shopping') shopping, + @JsonValue('start') + start, + @JsonValue('finish') + finish, } extension LandmarkTypeEnumExtension on LandmarkTypeEnum { diff --git a/frontend/lib/domain/entities/landmark_type.freezed.dart b/frontend/lib/domain/entities/landmark_type.freezed.dart index 5df1c7b..795b3ea 100644 --- a/frontend/lib/domain/entities/landmark_type.freezed.dart +++ b/frontend/lib/domain/entities/landmark_type.freezed.dart @@ -14,280 +14,246 @@ T _$identity(T value) => value; /// @nodoc mixin _$LandmarkType { - LandmarkTypeEnum get type; - /// Create a copy of LandmarkType - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - $LandmarkTypeCopyWith get copyWith => - _$LandmarkTypeCopyWithImpl( - this as LandmarkType, _$identity); + LandmarkTypeEnum get type; +/// Create a copy of LandmarkType +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$LandmarkTypeCopyWith get copyWith => _$LandmarkTypeCopyWithImpl(this as LandmarkType, _$identity); /// Serializes this LandmarkType to a JSON map. Map toJson(); - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is LandmarkType && - (identical(other.type, type) || other.type == type)); - } - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, type); +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is LandmarkType&&(identical(other.type, type) || other.type == type)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,type); + +@override +String toString() { + return 'LandmarkType(type: $type)'; +} + - @override - String toString() { - return 'LandmarkType(type: $type)'; - } } /// @nodoc -abstract mixin class $LandmarkTypeCopyWith<$Res> { - factory $LandmarkTypeCopyWith( - LandmarkType value, $Res Function(LandmarkType) _then) = - _$LandmarkTypeCopyWithImpl; - @useResult - $Res call({LandmarkTypeEnum type}); -} +abstract mixin class $LandmarkTypeCopyWith<$Res> { + factory $LandmarkTypeCopyWith(LandmarkType value, $Res Function(LandmarkType) _then) = _$LandmarkTypeCopyWithImpl; +@useResult +$Res call({ + LandmarkTypeEnum type +}); + + + +} /// @nodoc -class _$LandmarkTypeCopyWithImpl<$Res> implements $LandmarkTypeCopyWith<$Res> { +class _$LandmarkTypeCopyWithImpl<$Res> + implements $LandmarkTypeCopyWith<$Res> { _$LandmarkTypeCopyWithImpl(this._self, this._then); final LandmarkType _self; final $Res Function(LandmarkType) _then; - /// Create a copy of LandmarkType - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? type = null, - }) { - return _then(_self.copyWith( - type: null == type - ? _self.type - : type // ignore: cast_nullable_to_non_nullable - as LandmarkTypeEnum, - )); - } +/// Create a copy of LandmarkType +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? type = null,}) { + return _then(_self.copyWith( +type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable +as LandmarkTypeEnum, + )); } +} + + /// Adds pattern-matching-related methods to [LandmarkType]. extension LandmarkTypePatterns on LandmarkType { - /// A variant of `map` that fallback to returning `orElse`. - /// - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case final Subclass value: - /// return ...; - /// case _: - /// return orElse(); - /// } - /// ``` +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` - @optionalTypeArgs - TResult maybeMap( - TResult Function(_LandmarkType value)? $default, { - required TResult orElse(), - }) { - final _that = this; - switch (_that) { - case _LandmarkType() when $default != null: - return $default(_that); - case _: - return orElse(); - } - } +@optionalTypeArgs TResult maybeMap(TResult Function( _LandmarkType value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _LandmarkType() when $default != null: +return $default(_that);case _: + return orElse(); - /// A `switch`-like method, using callbacks. - /// - /// Callbacks receives the raw object, upcasted. - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case final Subclass value: - /// return ...; - /// case final Subclass2 value: - /// return ...; - /// } - /// ``` +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` - @optionalTypeArgs - TResult map( - TResult Function(_LandmarkType value) $default, - ) { - final _that = this; - switch (_that) { - case _LandmarkType(): - return $default(_that); - case _: - throw StateError('Unexpected subclass'); - } - } +@optionalTypeArgs TResult map(TResult Function( _LandmarkType value) $default,){ +final _that = this; +switch (_that) { +case _LandmarkType(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); - /// A variant of `map` that fallback to returning `null`. - /// - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case final Subclass value: - /// return ...; - /// case _: - /// return null; - /// } - /// ``` +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` - @optionalTypeArgs - TResult? mapOrNull( - TResult? Function(_LandmarkType value)? $default, - ) { - final _that = this; - switch (_that) { - case _LandmarkType() when $default != null: - return $default(_that); - case _: - return null; - } - } +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _LandmarkType value)? $default,){ +final _that = this; +switch (_that) { +case _LandmarkType() when $default != null: +return $default(_that);case _: + return null; - /// A variant of `when` that fallback to an `orElse` callback. - /// - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case Subclass(:final field): - /// return ...; - /// case _: - /// return orElse(); - /// } - /// ``` +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` - @optionalTypeArgs - TResult maybeWhen( - TResult Function(LandmarkTypeEnum type)? $default, { - required TResult orElse(), - }) { - final _that = this; - switch (_that) { - case _LandmarkType() when $default != null: - return $default(_that.type); - case _: - return orElse(); - } - } +@optionalTypeArgs TResult maybeWhen(TResult Function( LandmarkTypeEnum type)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _LandmarkType() when $default != null: +return $default(_that.type);case _: + return orElse(); - /// A `switch`-like method, using callbacks. - /// - /// As opposed to `map`, this offers destructuring. - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case Subclass(:final field): - /// return ...; - /// case Subclass2(:final field2): - /// return ...; - /// } - /// ``` +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` - @optionalTypeArgs - TResult when( - TResult Function(LandmarkTypeEnum type) $default, - ) { - final _that = this; - switch (_that) { - case _LandmarkType(): - return $default(_that.type); - case _: - throw StateError('Unexpected subclass'); - } - } +@optionalTypeArgs TResult when(TResult Function( LandmarkTypeEnum type) $default,) {final _that = this; +switch (_that) { +case _LandmarkType(): +return $default(_that.type);case _: + throw StateError('Unexpected subclass'); - /// A variant of `when` that fallback to returning `null` - /// - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case Subclass(:final field): - /// return ...; - /// case _: - /// return null; - /// } - /// ``` +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( LandmarkTypeEnum type)? $default,) {final _that = this; +switch (_that) { +case _LandmarkType() when $default != null: +return $default(_that.type);case _: + return null; + +} +} - @optionalTypeArgs - TResult? whenOrNull( - TResult? Function(LandmarkTypeEnum type)? $default, - ) { - final _that = this; - switch (_that) { - case _LandmarkType() when $default != null: - return $default(_that.type); - case _: - return null; - } - } } /// @nodoc @JsonSerializable() + class _LandmarkType implements LandmarkType { const _LandmarkType({required this.type}); - factory _LandmarkType.fromJson(Map json) => - _$LandmarkTypeFromJson(json); + factory _LandmarkType.fromJson(Map json) => _$LandmarkTypeFromJson(json); - @override - final LandmarkTypeEnum type; +@override final LandmarkTypeEnum type; - /// Create a copy of LandmarkType - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - _$LandmarkTypeCopyWith<_LandmarkType> get copyWith => - __$LandmarkTypeCopyWithImpl<_LandmarkType>(this, _$identity); +/// Create a copy of LandmarkType +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$LandmarkTypeCopyWith<_LandmarkType> get copyWith => __$LandmarkTypeCopyWithImpl<_LandmarkType>(this, _$identity); - @override - Map toJson() { - return _$LandmarkTypeToJson( - this, - ); - } +@override +Map toJson() { + return _$LandmarkTypeToJson(this, ); +} - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _LandmarkType && - (identical(other.type, type) || other.type == type)); - } +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _LandmarkType&&(identical(other.type, type) || other.type == type)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,type); + +@override +String toString() { + return 'LandmarkType(type: $type)'; +} - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, type); - @override - String toString() { - return 'LandmarkType(type: $type)'; - } } /// @nodoc -abstract mixin class _$LandmarkTypeCopyWith<$Res> - implements $LandmarkTypeCopyWith<$Res> { - factory _$LandmarkTypeCopyWith( - _LandmarkType value, $Res Function(_LandmarkType) _then) = - __$LandmarkTypeCopyWithImpl; - @override - @useResult - $Res call({LandmarkTypeEnum type}); -} +abstract mixin class _$LandmarkTypeCopyWith<$Res> implements $LandmarkTypeCopyWith<$Res> { + factory _$LandmarkTypeCopyWith(_LandmarkType value, $Res Function(_LandmarkType) _then) = __$LandmarkTypeCopyWithImpl; +@override @useResult +$Res call({ + LandmarkTypeEnum type +}); + + + +} /// @nodoc class __$LandmarkTypeCopyWithImpl<$Res> implements _$LandmarkTypeCopyWith<$Res> { @@ -296,20 +262,16 @@ class __$LandmarkTypeCopyWithImpl<$Res> final _LandmarkType _self; final $Res Function(_LandmarkType) _then; - /// Create a copy of LandmarkType - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $Res call({ - Object? type = null, - }) { - return _then(_LandmarkType( - type: null == type - ? _self.type - : type // ignore: cast_nullable_to_non_nullable - as LandmarkTypeEnum, - )); - } +/// Create a copy of LandmarkType +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? type = null,}) { + return _then(_LandmarkType( +type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable +as LandmarkTypeEnum, + )); +} + + } // dart format on diff --git a/frontend/lib/domain/entities/landmark_type.g.dart b/frontend/lib/domain/entities/landmark_type.g.dart index 4188d3d..fe483ef 100644 --- a/frontend/lib/domain/entities/landmark_type.g.dart +++ b/frontend/lib/domain/entities/landmark_type.g.dart @@ -7,17 +7,15 @@ part of 'landmark_type.dart'; // ************************************************************************** _LandmarkType _$LandmarkTypeFromJson(Map json) => - _LandmarkType( - type: $enumDecode(_$LandmarkTypeEnumEnumMap, json['type']), - ); + _LandmarkType(type: $enumDecode(_$LandmarkTypeEnumEnumMap, json['type'])); Map _$LandmarkTypeToJson(_LandmarkType instance) => - { - 'type': _$LandmarkTypeEnumEnumMap[instance.type]!, - }; + {'type': _$LandmarkTypeEnumEnumMap[instance.type]!}; const _$LandmarkTypeEnumEnumMap = { - LandmarkTypeEnum.culture: 'culture', + LandmarkTypeEnum.sightseeing: 'sightseeing', LandmarkTypeEnum.nature: 'nature', LandmarkTypeEnum.shopping: 'shopping', + LandmarkTypeEnum.start: 'start', + LandmarkTypeEnum.finish: 'finish', }; diff --git a/frontend/lib/domain/entities/preferences.dart b/frontend/lib/domain/entities/preferences.dart index d1046af..08e8e60 100644 --- a/frontend/lib/domain/entities/preferences.dart +++ b/frontend/lib/domain/entities/preferences.dart @@ -5,7 +5,20 @@ part 'preferences.g.dart'; @freezed abstract class Preferences with _$Preferences { const factory Preferences({ - required String test, + /// Scores keyed by preference type (e.g. 'sightseeing', 'shopping', 'nature') + required Map scores, + + /// Maximum trip duration in minutes + required int maxTimeMinutes, + + /// Required start location [lat, lon] + required List startLocation, + + /// Optional end location + List? endLocation, + + /// Optional detour tolerance in minutes + int? detourToleranceMinutes, }) = _Preferences; factory Preferences.fromJson(Map json) => _$PreferencesFromJson(json); diff --git a/frontend/lib/domain/entities/preferences.freezed.dart b/frontend/lib/domain/entities/preferences.freezed.dart index 56612f2..33d01c4 100644 --- a/frontend/lib/domain/entities/preferences.freezed.dart +++ b/frontend/lib/domain/entities/preferences.freezed.dart @@ -14,300 +14,309 @@ T _$identity(T value) => value; /// @nodoc mixin _$Preferences { - String get test; - /// Create a copy of Preferences - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - $PreferencesCopyWith get copyWith => - _$PreferencesCopyWithImpl(this as Preferences, _$identity); +/// Scores keyed by preference type (e.g. 'sightseeing', 'shopping', 'nature') + Map get scores;/// Maximum trip duration in minutes + int get maxTimeMinutes;/// Required start location [lat, lon] + List get startLocation;/// Optional end location + List? get endLocation;/// Optional detour tolerance in minutes + int? get detourToleranceMinutes; +/// Create a copy of Preferences +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PreferencesCopyWith get copyWith => _$PreferencesCopyWithImpl(this as Preferences, _$identity); /// Serializes this Preferences to a JSON map. Map toJson(); - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is Preferences && - (identical(other.test, test) || other.test == test)); - } - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, test); +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is Preferences&&const DeepCollectionEquality().equals(other.scores, scores)&&(identical(other.maxTimeMinutes, maxTimeMinutes) || other.maxTimeMinutes == maxTimeMinutes)&&const DeepCollectionEquality().equals(other.startLocation, startLocation)&&const DeepCollectionEquality().equals(other.endLocation, endLocation)&&(identical(other.detourToleranceMinutes, detourToleranceMinutes) || other.detourToleranceMinutes == detourToleranceMinutes)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(scores),maxTimeMinutes,const DeepCollectionEquality().hash(startLocation),const DeepCollectionEquality().hash(endLocation),detourToleranceMinutes); + +@override +String toString() { + return 'Preferences(scores: $scores, maxTimeMinutes: $maxTimeMinutes, startLocation: $startLocation, endLocation: $endLocation, detourToleranceMinutes: $detourToleranceMinutes)'; +} + - @override - String toString() { - return 'Preferences(test: $test)'; - } } /// @nodoc -abstract mixin class $PreferencesCopyWith<$Res> { - factory $PreferencesCopyWith( - Preferences value, $Res Function(Preferences) _then) = - _$PreferencesCopyWithImpl; - @useResult - $Res call({String test}); -} +abstract mixin class $PreferencesCopyWith<$Res> { + factory $PreferencesCopyWith(Preferences value, $Res Function(Preferences) _then) = _$PreferencesCopyWithImpl; +@useResult +$Res call({ + Map scores, int maxTimeMinutes, List startLocation, List? endLocation, int? detourToleranceMinutes +}); + + + +} /// @nodoc -class _$PreferencesCopyWithImpl<$Res> implements $PreferencesCopyWith<$Res> { +class _$PreferencesCopyWithImpl<$Res> + implements $PreferencesCopyWith<$Res> { _$PreferencesCopyWithImpl(this._self, this._then); final Preferences _self; final $Res Function(Preferences) _then; - /// Create a copy of Preferences - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? test = null, - }) { - return _then(_self.copyWith( - test: null == test - ? _self.test - : test // ignore: cast_nullable_to_non_nullable - as String, - )); - } +/// Create a copy of Preferences +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? scores = null,Object? maxTimeMinutes = null,Object? startLocation = null,Object? endLocation = freezed,Object? detourToleranceMinutes = freezed,}) { + return _then(_self.copyWith( +scores: null == scores ? _self.scores : scores // ignore: cast_nullable_to_non_nullable +as Map,maxTimeMinutes: null == maxTimeMinutes ? _self.maxTimeMinutes : maxTimeMinutes // ignore: cast_nullable_to_non_nullable +as int,startLocation: null == startLocation ? _self.startLocation : startLocation // ignore: cast_nullable_to_non_nullable +as List,endLocation: freezed == endLocation ? _self.endLocation : endLocation // ignore: cast_nullable_to_non_nullable +as List?,detourToleranceMinutes: freezed == detourToleranceMinutes ? _self.detourToleranceMinutes : detourToleranceMinutes // ignore: cast_nullable_to_non_nullable +as int?, + )); } +} + + /// Adds pattern-matching-related methods to [Preferences]. extension PreferencesPatterns on Preferences { - /// A variant of `map` that fallback to returning `orElse`. - /// - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case final Subclass value: - /// return ...; - /// case _: - /// return orElse(); - /// } - /// ``` +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` - @optionalTypeArgs - TResult maybeMap( - TResult Function(_Preferences value)? $default, { - required TResult orElse(), - }) { - final _that = this; - switch (_that) { - case _Preferences() when $default != null: - return $default(_that); - case _: - return orElse(); - } - } +@optionalTypeArgs TResult maybeMap(TResult Function( _Preferences value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Preferences() when $default != null: +return $default(_that);case _: + return orElse(); - /// A `switch`-like method, using callbacks. - /// - /// Callbacks receives the raw object, upcasted. - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case final Subclass value: - /// return ...; - /// case final Subclass2 value: - /// return ...; - /// } - /// ``` +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` - @optionalTypeArgs - TResult map( - TResult Function(_Preferences value) $default, - ) { - final _that = this; - switch (_that) { - case _Preferences(): - return $default(_that); - case _: - throw StateError('Unexpected subclass'); - } - } +@optionalTypeArgs TResult map(TResult Function( _Preferences value) $default,){ +final _that = this; +switch (_that) { +case _Preferences(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); - /// A variant of `map` that fallback to returning `null`. - /// - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case final Subclass value: - /// return ...; - /// case _: - /// return null; - /// } - /// ``` +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` - @optionalTypeArgs - TResult? mapOrNull( - TResult? Function(_Preferences value)? $default, - ) { - final _that = this; - switch (_that) { - case _Preferences() when $default != null: - return $default(_that); - case _: - return null; - } - } +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _Preferences value)? $default,){ +final _that = this; +switch (_that) { +case _Preferences() when $default != null: +return $default(_that);case _: + return null; - /// A variant of `when` that fallback to an `orElse` callback. - /// - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case Subclass(:final field): - /// return ...; - /// case _: - /// return orElse(); - /// } - /// ``` +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` - @optionalTypeArgs - TResult maybeWhen( - TResult Function(String test)? $default, { - required TResult orElse(), - }) { - final _that = this; - switch (_that) { - case _Preferences() when $default != null: - return $default(_that.test); - case _: - return orElse(); - } - } +@optionalTypeArgs TResult maybeWhen(TResult Function( Map scores, int maxTimeMinutes, List startLocation, List? endLocation, int? detourToleranceMinutes)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Preferences() when $default != null: +return $default(_that.scores,_that.maxTimeMinutes,_that.startLocation,_that.endLocation,_that.detourToleranceMinutes);case _: + return orElse(); - /// A `switch`-like method, using callbacks. - /// - /// As opposed to `map`, this offers destructuring. - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case Subclass(:final field): - /// return ...; - /// case Subclass2(:final field2): - /// return ...; - /// } - /// ``` +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` - @optionalTypeArgs - TResult when( - TResult Function(String test) $default, - ) { - final _that = this; - switch (_that) { - case _Preferences(): - return $default(_that.test); - case _: - throw StateError('Unexpected subclass'); - } - } +@optionalTypeArgs TResult when(TResult Function( Map scores, int maxTimeMinutes, List startLocation, List? endLocation, int? detourToleranceMinutes) $default,) {final _that = this; +switch (_that) { +case _Preferences(): +return $default(_that.scores,_that.maxTimeMinutes,_that.startLocation,_that.endLocation,_that.detourToleranceMinutes);case _: + throw StateError('Unexpected subclass'); - /// A variant of `when` that fallback to returning `null` - /// - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case Subclass(:final field): - /// return ...; - /// case _: - /// return null; - /// } - /// ``` +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( Map scores, int maxTimeMinutes, List startLocation, List? endLocation, int? detourToleranceMinutes)? $default,) {final _that = this; +switch (_that) { +case _Preferences() when $default != null: +return $default(_that.scores,_that.maxTimeMinutes,_that.startLocation,_that.endLocation,_that.detourToleranceMinutes);case _: + return null; + +} +} - @optionalTypeArgs - TResult? whenOrNull( - TResult? Function(String test)? $default, - ) { - final _that = this; - switch (_that) { - case _Preferences() when $default != null: - return $default(_that.test); - case _: - return null; - } - } } /// @nodoc @JsonSerializable() + class _Preferences implements Preferences { - const _Preferences({required this.test}); - factory _Preferences.fromJson(Map json) => - _$PreferencesFromJson(json); + const _Preferences({required final Map scores, required this.maxTimeMinutes, required final List startLocation, final List? endLocation, this.detourToleranceMinutes}): _scores = scores,_startLocation = startLocation,_endLocation = endLocation; + factory _Preferences.fromJson(Map json) => _$PreferencesFromJson(json); - @override - final String test; +/// Scores keyed by preference type (e.g. 'sightseeing', 'shopping', 'nature') + final Map _scores; +/// Scores keyed by preference type (e.g. 'sightseeing', 'shopping', 'nature') +@override Map get scores { + if (_scores is EqualUnmodifiableMapView) return _scores; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_scores); +} - /// Create a copy of Preferences - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - _$PreferencesCopyWith<_Preferences> get copyWith => - __$PreferencesCopyWithImpl<_Preferences>(this, _$identity); +/// Maximum trip duration in minutes +@override final int maxTimeMinutes; +/// Required start location [lat, lon] + final List _startLocation; +/// Required start location [lat, lon] +@override List get startLocation { + if (_startLocation is EqualUnmodifiableListView) return _startLocation; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_startLocation); +} - @override - Map toJson() { - return _$PreferencesToJson( - this, - ); - } +/// Optional end location + final List? _endLocation; +/// Optional end location +@override List? get endLocation { + final value = _endLocation; + if (value == null) return null; + if (_endLocation is EqualUnmodifiableListView) return _endLocation; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); +} - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _Preferences && - (identical(other.test, test) || other.test == test)); - } +/// Optional detour tolerance in minutes +@override final int? detourToleranceMinutes; + +/// Create a copy of Preferences +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PreferencesCopyWith<_Preferences> get copyWith => __$PreferencesCopyWithImpl<_Preferences>(this, _$identity); + +@override +Map toJson() { + return _$PreferencesToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Preferences&&const DeepCollectionEquality().equals(other._scores, _scores)&&(identical(other.maxTimeMinutes, maxTimeMinutes) || other.maxTimeMinutes == maxTimeMinutes)&&const DeepCollectionEquality().equals(other._startLocation, _startLocation)&&const DeepCollectionEquality().equals(other._endLocation, _endLocation)&&(identical(other.detourToleranceMinutes, detourToleranceMinutes) || other.detourToleranceMinutes == detourToleranceMinutes)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_scores),maxTimeMinutes,const DeepCollectionEquality().hash(_startLocation),const DeepCollectionEquality().hash(_endLocation),detourToleranceMinutes); + +@override +String toString() { + return 'Preferences(scores: $scores, maxTimeMinutes: $maxTimeMinutes, startLocation: $startLocation, endLocation: $endLocation, detourToleranceMinutes: $detourToleranceMinutes)'; +} - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, test); - @override - String toString() { - return 'Preferences(test: $test)'; - } } /// @nodoc -abstract mixin class _$PreferencesCopyWith<$Res> - implements $PreferencesCopyWith<$Res> { - factory _$PreferencesCopyWith( - _Preferences value, $Res Function(_Preferences) _then) = - __$PreferencesCopyWithImpl; - @override - @useResult - $Res call({String test}); -} +abstract mixin class _$PreferencesCopyWith<$Res> implements $PreferencesCopyWith<$Res> { + factory _$PreferencesCopyWith(_Preferences value, $Res Function(_Preferences) _then) = __$PreferencesCopyWithImpl; +@override @useResult +$Res call({ + Map scores, int maxTimeMinutes, List startLocation, List? endLocation, int? detourToleranceMinutes +}); + + + +} /// @nodoc -class __$PreferencesCopyWithImpl<$Res> implements _$PreferencesCopyWith<$Res> { +class __$PreferencesCopyWithImpl<$Res> + implements _$PreferencesCopyWith<$Res> { __$PreferencesCopyWithImpl(this._self, this._then); final _Preferences _self; final $Res Function(_Preferences) _then; - /// Create a copy of Preferences - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $Res call({ - Object? test = null, - }) { - return _then(_Preferences( - test: null == test - ? _self.test - : test // ignore: cast_nullable_to_non_nullable - as String, - )); - } +/// Create a copy of Preferences +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? scores = null,Object? maxTimeMinutes = null,Object? startLocation = null,Object? endLocation = freezed,Object? detourToleranceMinutes = freezed,}) { + return _then(_Preferences( +scores: null == scores ? _self._scores : scores // ignore: cast_nullable_to_non_nullable +as Map,maxTimeMinutes: null == maxTimeMinutes ? _self.maxTimeMinutes : maxTimeMinutes // ignore: cast_nullable_to_non_nullable +as int,startLocation: null == startLocation ? _self._startLocation : startLocation // ignore: cast_nullable_to_non_nullable +as List,endLocation: freezed == endLocation ? _self._endLocation : endLocation // ignore: cast_nullable_to_non_nullable +as List?,detourToleranceMinutes: freezed == detourToleranceMinutes ? _self.detourToleranceMinutes : detourToleranceMinutes // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + + } // dart format on diff --git a/frontend/lib/domain/entities/preferences.g.dart b/frontend/lib/domain/entities/preferences.g.dart index 0398396..798c0a2 100644 --- a/frontend/lib/domain/entities/preferences.g.dart +++ b/frontend/lib/domain/entities/preferences.g.dart @@ -7,10 +7,22 @@ part of 'preferences.dart'; // ************************************************************************** _Preferences _$PreferencesFromJson(Map json) => _Preferences( - test: json['test'] as String, - ); + scores: Map.from(json['scores'] as Map), + maxTimeMinutes: (json['maxTimeMinutes'] as num).toInt(), + startLocation: (json['startLocation'] as List) + .map((e) => (e as num).toDouble()) + .toList(), + endLocation: (json['endLocation'] as List?) + ?.map((e) => (e as num).toDouble()) + .toList(), + detourToleranceMinutes: (json['detourToleranceMinutes'] as num?)?.toInt(), +); Map _$PreferencesToJson(_Preferences instance) => { - 'test': instance.test, + 'scores': instance.scores, + 'maxTimeMinutes': instance.maxTimeMinutes, + 'startLocation': instance.startLocation, + 'endLocation': instance.endLocation, + 'detourToleranceMinutes': instance.detourToleranceMinutes, }; diff --git a/frontend/lib/domain/entities/trip.dart b/frontend/lib/domain/entities/trip.dart index ab07ea3..afac167 100644 --- a/frontend/lib/domain/entities/trip.dart +++ b/frontend/lib/domain/entities/trip.dart @@ -5,12 +5,17 @@ part 'trip.freezed.dart'; part 'trip.g.dart'; -@Freezed(makeCollectionsUnmodifiable: false) +@unfreezed abstract class Trip with _$Trip { - const factory Trip({ + factory Trip({ required String uuid, // Duration totalTime, + + /// total time in minutes + int? totalTimeMinutes, + + /// ordered list of landmarks in this trip required List landmarks, }) = _Trip; diff --git a/frontend/lib/domain/entities/trip.freezed.dart b/frontend/lib/domain/entities/trip.freezed.dart index 32a98c0..b1eda59 100644 --- a/frontend/lib/domain/entities/trip.freezed.dart +++ b/frontend/lib/domain/entities/trip.freezed.dart @@ -14,314 +14,265 @@ T _$identity(T value) => value; /// @nodoc mixin _$Trip { - String get uuid; // Duration totalTime, - List get landmarks; - /// Create a copy of Trip - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - $TripCopyWith get copyWith => - _$TripCopyWithImpl(this as Trip, _$identity); + String get uuid; set uuid(String value);// Duration totalTime, +/// total time in minutes + int? get totalTimeMinutes;// Duration totalTime, +/// total time in minutes + set totalTimeMinutes(int? value);/// ordered list of landmarks in this trip + List get landmarks;/// ordered list of landmarks in this trip + set landmarks(List value); +/// Create a copy of Trip +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$TripCopyWith get copyWith => _$TripCopyWithImpl(this as Trip, _$identity); /// Serializes this Trip to a JSON map. Map toJson(); - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is Trip && - (identical(other.uuid, uuid) || other.uuid == uuid) && - const DeepCollectionEquality().equals(other.landmarks, landmarks)); - } - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, uuid, const DeepCollectionEquality().hash(landmarks)); - @override - String toString() { - return 'Trip(uuid: $uuid, landmarks: $landmarks)'; - } + +@override +String toString() { + return 'Trip(uuid: $uuid, totalTimeMinutes: $totalTimeMinutes, landmarks: $landmarks)'; +} + + } /// @nodoc -abstract mixin class $TripCopyWith<$Res> { - factory $TripCopyWith(Trip value, $Res Function(Trip) _then) = - _$TripCopyWithImpl; - @useResult - $Res call({String uuid, List landmarks}); -} +abstract mixin class $TripCopyWith<$Res> { + factory $TripCopyWith(Trip value, $Res Function(Trip) _then) = _$TripCopyWithImpl; +@useResult +$Res call({ + String uuid, int? totalTimeMinutes, List landmarks +}); + + + +} /// @nodoc -class _$TripCopyWithImpl<$Res> implements $TripCopyWith<$Res> { +class _$TripCopyWithImpl<$Res> + implements $TripCopyWith<$Res> { _$TripCopyWithImpl(this._self, this._then); final Trip _self; final $Res Function(Trip) _then; - /// Create a copy of Trip - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? uuid = null, - Object? landmarks = null, - }) { - return _then(_self.copyWith( - uuid: null == uuid - ? _self.uuid - : uuid // ignore: cast_nullable_to_non_nullable - as String, - landmarks: null == landmarks - ? _self.landmarks - : landmarks // ignore: cast_nullable_to_non_nullable - as List, - )); - } +/// Create a copy of Trip +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? uuid = null,Object? totalTimeMinutes = freezed,Object? landmarks = null,}) { + return _then(_self.copyWith( +uuid: null == uuid ? _self.uuid : uuid // ignore: cast_nullable_to_non_nullable +as String,totalTimeMinutes: freezed == totalTimeMinutes ? _self.totalTimeMinutes : totalTimeMinutes // ignore: cast_nullable_to_non_nullable +as int?,landmarks: null == landmarks ? _self.landmarks : landmarks // ignore: cast_nullable_to_non_nullable +as List, + )); } +} + + /// Adds pattern-matching-related methods to [Trip]. extension TripPatterns on Trip { - /// A variant of `map` that fallback to returning `orElse`. - /// - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case final Subclass value: - /// return ...; - /// case _: - /// return orElse(); - /// } - /// ``` +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` - @optionalTypeArgs - TResult maybeMap( - TResult Function(_Trip value)? $default, { - required TResult orElse(), - }) { - final _that = this; - switch (_that) { - case _Trip() when $default != null: - return $default(_that); - case _: - return orElse(); - } - } +@optionalTypeArgs TResult maybeMap(TResult Function( _Trip value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Trip() when $default != null: +return $default(_that);case _: + return orElse(); - /// A `switch`-like method, using callbacks. - /// - /// Callbacks receives the raw object, upcasted. - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case final Subclass value: - /// return ...; - /// case final Subclass2 value: - /// return ...; - /// } - /// ``` +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` - @optionalTypeArgs - TResult map( - TResult Function(_Trip value) $default, - ) { - final _that = this; - switch (_that) { - case _Trip(): - return $default(_that); - case _: - throw StateError('Unexpected subclass'); - } - } +@optionalTypeArgs TResult map(TResult Function( _Trip value) $default,){ +final _that = this; +switch (_that) { +case _Trip(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); - /// A variant of `map` that fallback to returning `null`. - /// - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case final Subclass value: - /// return ...; - /// case _: - /// return null; - /// } - /// ``` +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` - @optionalTypeArgs - TResult? mapOrNull( - TResult? Function(_Trip value)? $default, - ) { - final _that = this; - switch (_that) { - case _Trip() when $default != null: - return $default(_that); - case _: - return null; - } - } +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _Trip value)? $default,){ +final _that = this; +switch (_that) { +case _Trip() when $default != null: +return $default(_that);case _: + return null; - /// A variant of `when` that fallback to an `orElse` callback. - /// - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case Subclass(:final field): - /// return ...; - /// case _: - /// return orElse(); - /// } - /// ``` +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` - @optionalTypeArgs - TResult maybeWhen( - TResult Function(String uuid, List landmarks)? $default, { - required TResult orElse(), - }) { - final _that = this; - switch (_that) { - case _Trip() when $default != null: - return $default(_that.uuid, _that.landmarks); - case _: - return orElse(); - } - } +@optionalTypeArgs TResult maybeWhen(TResult Function( String uuid, int? totalTimeMinutes, List landmarks)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Trip() when $default != null: +return $default(_that.uuid,_that.totalTimeMinutes,_that.landmarks);case _: + return orElse(); - /// A `switch`-like method, using callbacks. - /// - /// As opposed to `map`, this offers destructuring. - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case Subclass(:final field): - /// return ...; - /// case Subclass2(:final field2): - /// return ...; - /// } - /// ``` +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` - @optionalTypeArgs - TResult when( - TResult Function(String uuid, List landmarks) $default, - ) { - final _that = this; - switch (_that) { - case _Trip(): - return $default(_that.uuid, _that.landmarks); - case _: - throw StateError('Unexpected subclass'); - } - } +@optionalTypeArgs TResult when(TResult Function( String uuid, int? totalTimeMinutes, List landmarks) $default,) {final _that = this; +switch (_that) { +case _Trip(): +return $default(_that.uuid,_that.totalTimeMinutes,_that.landmarks);case _: + throw StateError('Unexpected subclass'); - /// A variant of `when` that fallback to returning `null` - /// - /// It is equivalent to doing: - /// ```dart - /// switch (sealedClass) { - /// case Subclass(:final field): - /// return ...; - /// case _: - /// return null; - /// } - /// ``` +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String uuid, int? totalTimeMinutes, List landmarks)? $default,) {final _that = this; +switch (_that) { +case _Trip() when $default != null: +return $default(_that.uuid,_that.totalTimeMinutes,_that.landmarks);case _: + return null; + +} +} - @optionalTypeArgs - TResult? whenOrNull( - TResult? Function(String uuid, List landmarks)? $default, - ) { - final _that = this; - switch (_that) { - case _Trip() when $default != null: - return $default(_that.uuid, _that.landmarks); - case _: - return null; - } - } } /// @nodoc @JsonSerializable() + class _Trip implements Trip { - const _Trip({required this.uuid, required this.landmarks}); + _Trip({required this.uuid, this.totalTimeMinutes, required this.landmarks}); factory _Trip.fromJson(Map json) => _$TripFromJson(json); - @override - final String uuid; +@override String uuid; // Duration totalTime, - @override - final List landmarks; +/// total time in minutes +@override int? totalTimeMinutes; +/// ordered list of landmarks in this trip +@override List landmarks; - /// Create a copy of Trip - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - @pragma('vm:prefer-inline') - _$TripCopyWith<_Trip> get copyWith => - __$TripCopyWithImpl<_Trip>(this, _$identity); +/// Create a copy of Trip +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$TripCopyWith<_Trip> get copyWith => __$TripCopyWithImpl<_Trip>(this, _$identity); - @override - Map toJson() { - return _$TripToJson( - this, - ); - } +@override +Map toJson() { + return _$TripToJson(this, ); +} - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _Trip && - (identical(other.uuid, uuid) || other.uuid == uuid) && - const DeepCollectionEquality().equals(other.landmarks, landmarks)); - } - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, uuid, const DeepCollectionEquality().hash(landmarks)); - @override - String toString() { - return 'Trip(uuid: $uuid, landmarks: $landmarks)'; - } +@override +String toString() { + return 'Trip(uuid: $uuid, totalTimeMinutes: $totalTimeMinutes, landmarks: $landmarks)'; +} + + } /// @nodoc abstract mixin class _$TripCopyWith<$Res> implements $TripCopyWith<$Res> { - factory _$TripCopyWith(_Trip value, $Res Function(_Trip) _then) = - __$TripCopyWithImpl; - @override - @useResult - $Res call({String uuid, List landmarks}); -} + factory _$TripCopyWith(_Trip value, $Res Function(_Trip) _then) = __$TripCopyWithImpl; +@override @useResult +$Res call({ + String uuid, int? totalTimeMinutes, List landmarks +}); + + + +} /// @nodoc -class __$TripCopyWithImpl<$Res> implements _$TripCopyWith<$Res> { +class __$TripCopyWithImpl<$Res> + implements _$TripCopyWith<$Res> { __$TripCopyWithImpl(this._self, this._then); final _Trip _self; final $Res Function(_Trip) _then; - /// Create a copy of Trip - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $Res call({ - Object? uuid = null, - Object? landmarks = null, - }) { - return _then(_Trip( - uuid: null == uuid - ? _self.uuid - : uuid // ignore: cast_nullable_to_non_nullable - as String, - landmarks: null == landmarks - ? _self.landmarks - : landmarks // ignore: cast_nullable_to_non_nullable - as List, - )); - } +/// Create a copy of Trip +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? uuid = null,Object? totalTimeMinutes = freezed,Object? landmarks = null,}) { + return _then(_Trip( +uuid: null == uuid ? _self.uuid : uuid // ignore: cast_nullable_to_non_nullable +as String,totalTimeMinutes: freezed == totalTimeMinutes ? _self.totalTimeMinutes : totalTimeMinutes // ignore: cast_nullable_to_non_nullable +as int?,landmarks: null == landmarks ? _self.landmarks : landmarks // ignore: cast_nullable_to_non_nullable +as List, + )); +} + + } // dart format on diff --git a/frontend/lib/domain/entities/trip.g.dart b/frontend/lib/domain/entities/trip.g.dart index 148cec2..d7755b4 100644 --- a/frontend/lib/domain/entities/trip.g.dart +++ b/frontend/lib/domain/entities/trip.g.dart @@ -7,13 +7,15 @@ part of 'trip.dart'; // ************************************************************************** _Trip _$TripFromJson(Map json) => _Trip( - uuid: json['uuid'] as String, - landmarks: (json['landmarks'] as List) - .map((e) => Landmark.fromJson(e as Map)) - .toList(), - ); + uuid: json['uuid'] as String, + totalTimeMinutes: (json['totalTimeMinutes'] as num?)?.toInt(), + landmarks: (json['landmarks'] as List) + .map((e) => Landmark.fromJson(e as Map)) + .toList(), +); Map _$TripToJson(_Trip instance) => { - 'uuid': instance.uuid, - 'landmarks': instance.landmarks, - }; + 'uuid': instance.uuid, + 'totalTimeMinutes': instance.totalTimeMinutes, + 'landmarks': instance.landmarks, +}; diff --git a/frontend/lib/domain/repositories/onboarding_repository.dart b/frontend/lib/domain/repositories/onboarding_repository.dart new file mode 100644 index 0000000..5e37e04 --- /dev/null +++ b/frontend/lib/domain/repositories/onboarding_repository.dart @@ -0,0 +1,7 @@ +abstract class OnboardingRepository { + /// Returns true when the user accepted the onboarding agreement + Future isOnboarded(); + + /// Sets the onboarding completion flag + Future setOnboarded(bool value); +} diff --git a/frontend/lib/domain/repositories/preferences_repository.dart b/frontend/lib/domain/repositories/preferences_repository.dart index 5bce78a..edf5bf1 100644 --- a/frontend/lib/domain/repositories/preferences_repository.dart +++ b/frontend/lib/domain/repositories/preferences_repository.dart @@ -2,4 +2,5 @@ import 'package:anyway/domain/entities/preferences.dart'; abstract class PreferencesRepository { Future getPreferences(); + Future savePreferences(Preferences preferences); } diff --git a/frontend/lib/domain/repositories/trip_repository.dart b/frontend/lib/domain/repositories/trip_repository.dart index 82f222e..a09036b 100644 --- a/frontend/lib/domain/repositories/trip_repository.dart +++ b/frontend/lib/domain/repositories/trip_repository.dart @@ -1,6 +1,9 @@ +import 'package:anyway/domain/entities/landmark.dart'; import 'package:anyway/domain/entities/preferences.dart'; import 'package:anyway/domain/entities/trip.dart'; abstract class TripRepository { - Future getTrip({Preferences? preferences, String? tripUUID}); + Future getTrip({Preferences? preferences, String? tripUUID, List? landmarks}); + + Future> searchLandmarks(Preferences preferences); } diff --git a/frontend/lib/presentation/pages/start.dart b/frontend/lib/presentation/pages/start.dart index d81fcc4..b269e70 100644 --- a/frontend/lib/presentation/pages/start.dart +++ b/frontend/lib/presentation/pages/start.dart @@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:anyway/presentation/providers/onboarding_state_provider.dart'; import 'package:anyway/presentation/pages/login.dart'; import 'package:anyway/presentation/pages/onboarding.dart'; +import 'package:anyway/presentation/pages/new_trip_preferences.dart'; // Example providers (replace these with your actual providers) // final onboardingStateProvider = Provider((ref) => true); // Replace with actual onboarding state logic @@ -80,7 +81,16 @@ class TripCreationPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - body: Center(child: Text('Trip Creation Page')), + appBar: AppBar(title: const Text('Create a Trip')), + body: Center( + child: ElevatedButton.icon( + icon: const Icon(Icons.tune), + label: const Text('Set Preferences'), + onPressed: () { + Navigator.of(context).push(MaterialPageRoute(builder: (_) => const NewTripPreferencesPage())); + }, + ), + ), ); } } diff --git a/frontend/lib/presentation/providers/core_providers.dart b/frontend/lib/presentation/providers/core_providers.dart new file mode 100644 index 0000000..8c2d603 --- /dev/null +++ b/frontend/lib/presentation/providers/core_providers.dart @@ -0,0 +1,49 @@ +import 'package:anyway/core/dio_client.dart'; +import 'package:anyway/data/repositories/local_onboarding_repository.dart'; +import 'package:anyway/domain/repositories/onboarding_repository.dart'; +import 'package:anyway/domain/repositories/trip_repository.dart'; +import 'package:anyway/data/repositories/backend_trip_repository.dart'; +import 'package:anyway/data/datasources/trip_remote_datasource.dart'; +import 'package:anyway/data/repositories/preferences_repository_impl.dart'; +import 'package:anyway/domain/repositories/preferences_repository.dart'; +import 'dart:io'; + +import 'package:dio/dio.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +/// Provide a configured Dio instance (used by data layer) +final dioProvider = Provider((ref) { + // baseUrl can be configured via environment; use a sensible default + return Dio(BaseOptions( + baseUrl: 'https://anyway.anydev.info', + connectTimeout: const Duration(seconds: 5), + receiveTimeout: const Duration(seconds: 120), + headers: { + HttpHeaders.acceptHeader: 'application/json', + HttpHeaders.contentTypeHeader: 'application/json', + }, + )); +}); + +/// Provide a simple wrapper client if needed elsewhere +final dioClientProvider = Provider((ref) { + final dio = ref.read(dioProvider); + return DioClient(baseUrl: dio.options.baseUrl); +}); + +/// Onboarding repository backed by SharedPreferences +final onboardingRepositoryProvider = Provider((ref) { + return LocalOnboardingRepository(); +}); + +/// Preferences repository (local persistence) +final preferencesRepositoryProvider = Provider((ref) { + return PreferencesRepositoryImpl(); +}); + +/// Trip repository backed by the backend +final tripRepositoryProvider = Provider((ref) { + final dio = ref.read(dioProvider); + final remote = TripRemoteDataSourceImpl(dio: dio); + return BackendTripRepository(remote: remote); +}); diff --git a/frontend/lib/presentation/providers/landmark_providers.dart b/frontend/lib/presentation/providers/landmark_providers.dart new file mode 100644 index 0000000..0950677 --- /dev/null +++ b/frontend/lib/presentation/providers/landmark_providers.dart @@ -0,0 +1,16 @@ +import 'package:anyway/domain/entities/landmark.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +class IntermediateLandmarksNotifier extends Notifier> { + @override + List build() => []; + + void setLandmarks(List landmarks) { + state = List.unmodifiable(landmarks); + } + + void clear() => state = []; +} + +final intermediateLandmarksProvider = + NotifierProvider>(IntermediateLandmarksNotifier.new); diff --git a/frontend/lib/presentation/providers/onboarding_state_provider.dart b/frontend/lib/presentation/providers/onboarding_state_provider.dart index f9ffbb0..5baf0eb 100644 --- a/frontend/lib/presentation/providers/onboarding_state_provider.dart +++ b/frontend/lib/presentation/providers/onboarding_state_provider.dart @@ -1,9 +1,10 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:shared_preferences/shared_preferences.dart'; +import 'package:anyway/domain/repositories/onboarding_repository.dart'; +import 'package:anyway/presentation/providers/core_providers.dart'; final onboardingStateProvider = FutureProvider((ref) async { - final prefs = await SharedPreferences.getInstance(); - return prefs.getBool('onboardingCompleted') ?? false; + final repo = ref.watch(onboardingRepositoryProvider); + return repo.isOnboarded(); }); @@ -16,9 +17,10 @@ class OnboardingController { OnboardingController(this.ref); Future setOnboarded(bool value) async { - final prefs = await SharedPreferences.getInstance(); - await prefs.setBool('onboardingCompleted', value); + final repo = ref.read(onboardingRepositoryProvider); + await repo.setOnboarded(value); // refresh the read provider so UI updates ref.invalidate(onboardingStateProvider); } } + diff --git a/frontend/lib/presentation/providers/trip_provider.dart b/frontend/lib/presentation/providers/trip_provider.dart index b3b0110..020f690 100644 --- a/frontend/lib/presentation/providers/trip_provider.dart +++ b/frontend/lib/presentation/providers/trip_provider.dart @@ -1,6 +1,16 @@ -// import 'package:anyway/data/repositories/trip_repository.dart'; -// import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:anyway/domain/entities/preferences.dart'; +import 'package:anyway/domain/entities/trip.dart'; +import 'package:anyway/presentation/providers/landmark_providers.dart'; -// final weatherRepositoryProvider = Provider((ref) { -// return TripRepositoryImpl(???); -// }); +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:anyway/presentation/providers/core_providers.dart'; + +// Provides a function that creates a trip given preferences. +final createTripProvider = Provider Function(Preferences)>((ref) { + return (Preferences prefs) async { + final repo = ref.read(tripRepositoryProvider); + final landmarks = await repo.searchLandmarks(prefs); + ref.read(intermediateLandmarksProvider.notifier).setLandmarks(landmarks); + return repo.getTrip(preferences: prefs, landmarks: landmarks); + }; +}); diff --git a/frontend/pubspec.lock b/frontend/pubspec.lock index 9839703..bc3b06c 100644 --- a/frontend/pubspec.lock +++ b/frontend/pubspec.lock @@ -708,26 +708,26 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0" + sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" url: "https://pub.dev" source: hosted - version: "10.0.9" + version: "11.0.2" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 + sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" url: "https://pub.dev" source: hosted - version: "3.0.9" + version: "3.0.10" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.0.2" lints: dependency: transitive description: @@ -772,10 +772,10 @@ packages: dependency: transitive description: name: meta - sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c + sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.17.0" mime: dependency: transitive description: @@ -1273,26 +1273,26 @@ packages: dependency: transitive description: name: test - sha256: "301b213cd241ca982e9ba50266bd3f5bd1ea33f1455554c5abb85d1be0e2d87e" + sha256: "75906bf273541b676716d1ca7627a17e4c4070a3a16272b7a3dc7da3b9f3f6b7" url: "https://pub.dev" source: hosted - version: "1.25.15" + version: "1.26.3" test_api: dependency: transitive description: name: test_api - sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd + sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55 url: "https://pub.dev" source: hosted - version: "0.7.4" + version: "0.7.7" test_core: dependency: transitive description: name: test_core - sha256: "84d17c3486c8dfdbe5e12a50c8ae176d15e2a771b96909a9442b40173649ccaa" + sha256: "0cc24b5ff94b38d2ae73e1eb43cc302b77964fbf67abad1e296025b78deb53d0" url: "https://pub.dev" source: hosted - version: "0.6.8" + version: "0.6.12" timing: dependency: transitive description: @@ -1409,10 +1409,10 @@ packages: dependency: transitive description: name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b url: "https://pub.dev" source: hosted - version: "2.1.4" + version: "2.2.0" vm_service: dependency: transitive description: