[Compass App] Refactor model (#2431)

This PR removes the `compass_model` subproject and moves each data model
class to the respective `app` or `server` project.

Although this leads to code duplication, this is a more realistic
implementation where clients and servers have their own respective data
model class implementations.

The model classes for the server are located in `server/lib/model`.

Model classes for the app are located in two places:

- API-only model: `app/lib/data/services/api/model`.
- Domain model: `app/lib/domain/model`.

In general, models located under the domain are used across the app,
while the API-only models are only used for interacting with the API
client.

Tests have been updated.

## Pre-launch Checklist

- [x] I read the [Flutter Style Guide] _recently_, and have followed its
advice.
- [x] I signed the [CLA].
- [x] I read the [Contributors Guide].
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-devrel
channel on [Discord].

<!-- Links -->
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md
[CLA]: https://cla.developers.google.com/
[Discord]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Chat.md
[Contributors Guide]:
https://github.com/flutter/samples/blob/main/CONTRIBUTING.md
pull/2435/head
Miguel Beltran 4 months ago committed by GitHub
parent fb869e729e
commit 93b86b86f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,5 +1,4 @@
import 'package:compass_model/model.dart';
import '../../../domain/models/activity/activity.dart';
import '../../../utils/result.dart';
/// Data source for activities.

@ -1,5 +1,4 @@
import 'package:compass_model/model.dart';
import '../../../domain/models/activity/activity.dart';
import '../../../utils/result.dart';
import '../../services/local/local_data_service.dart';
import 'activity_repository.dart';

@ -1,5 +1,4 @@
import 'package:compass_model/model.dart';
import '../../../domain/models/activity/activity.dart';
import '../../../utils/result.dart';
import '../../services/api/api_client.dart';
import 'activity_repository.dart';

@ -1,9 +1,10 @@
import 'package:compass_model/model.dart';
import 'package:logging/logging.dart';
import '../../../utils/result.dart';
import '../../services/api/api_client.dart';
import '../../services/api/auth_api_client.dart';
import '../../services/api/model/login_request/login_request.dart';
import '../../services/api/model/login_response/login_response.dart';
import '../../services/shared_preferences_service.dart';
import 'auth_repository.dart';

@ -1,5 +1,4 @@
import 'package:compass_model/model.dart';
import '../../../domain/models/booking/booking.dart';
import '../../../domain/models/booking/booking_summary.dart';
import '../../../utils/result.dart';

@ -1,7 +1,7 @@
import 'dart:async';
import 'package:compass_model/model.dart';
import 'package:collection/collection.dart';
import '../../../domain/models/booking/booking.dart';
import '../../../domain/models/booking/booking_summary.dart';
import '../../../utils/result.dart';

@ -1,6 +1,7 @@
import 'package:compass_model/model.dart';
import '../../../domain/models/activity/activity.dart';
import '../../../domain/models/booking/booking.dart';
import '../../../domain/models/booking/booking_summary.dart';
import '../../../domain/models/destination/destination.dart';
import '../../../utils/result.dart';
import '../../services/api/api_client.dart';
import '../../services/api/model/booking/booking_api_model.dart';

@ -1,5 +1,4 @@
import 'package:compass_model/model.dart';
import '../../../domain/models/continent/continent.dart';
import '../../../utils/result.dart';
/// Data source with all possible continents.

@ -1,5 +1,4 @@
import 'package:compass_model/model.dart';
import '../../../domain/models/continent/continent.dart';
import '../../../utils/result.dart';
import '../../services/local/local_data_service.dart';
import 'continent_repository.dart';

@ -1,5 +1,4 @@
import 'package:compass_model/model.dart';
import '../../../domain/models/continent/continent.dart';
import '../../../utils/result.dart';
import '../../services/api/api_client.dart';
import 'continent_repository.dart';

@ -1,5 +1,4 @@
import 'package:compass_model/model.dart';
import '../../../domain/models/destination/destination.dart';
import '../../../utils/result.dart';
/// Data source with all possible destinations

@ -1,5 +1,4 @@
import 'package:compass_model/model.dart';
import '../../../domain/models/destination/destination.dart';
import '../../../utils/result.dart';
import '../../services/local/local_data_service.dart';
import 'destination_repository.dart';

@ -1,5 +1,4 @@
import 'package:compass_model/model.dart';
import '../../../domain/models/destination/destination.dart';
import '../../../utils/result.dart';
import '../../services/api/api_client.dart';
import 'destination_repository.dart';

@ -1,5 +1,4 @@
import 'package:compass_model/model.dart';
import '../../../domain/models/itinerary_config/itinerary_config.dart';
import '../../../utils/result.dart';
/// Data source for the current [ItineraryConfig]

@ -1,7 +1,6 @@
import 'dart:async';
import 'package:compass_model/model.dart';
import '../../../domain/models/itinerary_config/itinerary_config.dart';
import '../../../utils/result.dart';
import 'itinerary_config_repository.dart';

@ -1,7 +1,9 @@
import 'dart:convert';
import 'dart:io';
import 'package:compass_model/model.dart';
import '../../../domain/models/activity/activity.dart';
import '../../../domain/models/continent/continent.dart';
import '../../../domain/models/destination/destination.dart';
import '../../../utils/result.dart';
import 'model/booking/booking_api_model.dart';

@ -1,11 +1,11 @@
// TODO: Configurable baseurl/host/port
import 'dart:convert';
import 'dart:io';
import 'package:compass_model/model.dart';
import '../../../utils/result.dart';
import 'model/login_request/login_request.dart';
import 'model/login_response/login_response.dart';
// TODO: Configurable baseurl/host/port
class AuthApiClient {
Future<Result<LoginResponse>> login(LoginRequest loginRequest) async {
final client = HttpClient();

@ -1,9 +1,11 @@
import 'dart:convert';
import 'package:compass_model/model.dart';
import 'package:flutter/services.dart';
import '../../../config/assets.dart';
import '../../../domain/models/activity/activity.dart';
import '../../../domain/models/continent/continent.dart';
import '../../../domain/models/destination/destination.dart';
class LocalDataService {
List<Continent> getContinents() {

@ -1,10 +1,13 @@
import 'package:compass_model/model.dart';
import 'package:logging/logging.dart';
import '../../../data/repositories/activity/activity_repository.dart';
import '../../../data/repositories/booking/booking_repository.dart';
import '../../../data/repositories/destination/destination_repository.dart';
import '../../../utils/result.dart';
import '../../models/activity/activity.dart';
import '../../models/booking/booking.dart';
import '../../models/destination/destination.dart';
import '../../models/itinerary_config/itinerary_config.dart';
/// Component for creating [Booking] objects from [ItineraryConfig].
///

@ -1,10 +1,10 @@
import 'package:compass_model/model.dart';
import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
import 'package:share_plus/share_plus.dart';
import '../../../utils/result.dart';
import '../../../ui/core/ui/date_format_start_end.dart';
import '../../models/booking/booking.dart';
typedef ShareFunction = Future<void> Function(String text);

@ -1,6 +1,8 @@
import 'package:compass_model/model.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import '../activity/activity.dart';
import '../destination/destination.dart';
part 'booking.freezed.dart';
part 'booking.g.dart';

@ -1,9 +1,9 @@
import 'package:compass_model/model.dart';
import 'package:flutter/foundation.dart';
import 'package:logging/logging.dart';
import '../../../data/repositories/activity/activity_repository.dart';
import '../../../data/repositories/itinerary_config/itinerary_config_repository.dart';
import '../../../domain/models/activity/activity.dart';
import '../../../utils/command.dart';
import '../../../utils/result.dart';

@ -1,7 +1,7 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:compass_model/model.dart';
import 'package:flutter/material.dart';
import '../../../domain/models/activity/activity.dart';
import '../../../utils/image_error_listener.dart';
import '../../core/ui/custom_checkbox.dart';

@ -1,7 +1,6 @@
import 'package:compass_model/model.dart';
import '../../../../data/repositories/auth/auth_repository.dart';
import '../../../../data/repositories/itinerary_config/itinerary_config_repository.dart';
import '../../../../domain/models/itinerary_config/itinerary_config.dart';
import '../../../../utils/command.dart';
import '../../../../utils/result.dart';

@ -1,9 +1,10 @@
import 'package:compass_model/model.dart';
import 'package:flutter/foundation.dart';
import 'package:logging/logging.dart';
import '../../../data/repositories/booking/booking_repository.dart';
import '../../../data/repositories/itinerary_config/itinerary_config_repository.dart';
import '../../../domain/models/booking/booking.dart';
import '../../../domain/models/itinerary_config/itinerary_config.dart';
import '../../../utils/command.dart';
import '../../../utils/result.dart';
import '../../../domain/components/booking/booking_create_component.dart';

@ -1,7 +1,7 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:compass_model/model.dart';
import 'package:flutter/material.dart';
import '../../../domain/models/activity/activity.dart';
import '../../../utils/image_error_listener.dart';
import '../../core/themes/dimens.dart';
import '../view_models/booking_viewmodel.dart';

@ -1,7 +1,7 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:compass_model/model.dart';
import 'package:flutter/material.dart';
import '../../../domain/models/booking/booking.dart';
import '../../../utils/image_error_listener.dart';
import '../../core/localization/applocalization.dart';
import '../../core/themes/colors.dart';

@ -1,6 +1,6 @@
import 'package:compass_model/model.dart';
import 'package:flutter/material.dart';
import '../../../domain/models/itinerary_config/itinerary_config.dart';
import '../localization/applocalization.dart';
import '../themes/colors.dart';
import '../themes/dimens.dart';

@ -1,8 +1,9 @@
import 'package:compass_model/model.dart';
import 'package:logging/logging.dart';
import '../../../data/repositories/destination/destination_repository.dart';
import '../../../data/repositories/itinerary_config/itinerary_config_repository.dart';
import '../../../domain/models/destination/destination.dart';
import '../../../domain/models/itinerary_config/itinerary_config.dart';
import '../../../utils/command.dart';
import '../../../utils/result.dart';
import 'package:flutter/cupertino.dart';

@ -1,7 +1,6 @@
import 'package:compass_model/model.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import '../../../domain/models/destination/destination.dart';
import '../../../utils/image_error_listener.dart';
import '../../core/themes/text_styles.dart';
import '../../core/ui/tag_chip.dart';

@ -1,9 +1,10 @@
import 'package:flutter/material.dart';
import 'package:compass_model/model.dart';
import 'package:logging/logging.dart';
import '../../../data/repositories/continent/continent_repository.dart';
import '../../../data/repositories/itinerary_config/itinerary_config_repository.dart';
import '../../../domain/models/continent/continent.dart';
import '../../../domain/models/itinerary_config/itinerary_config.dart';
import '../../../utils/command.dart';
import '../../../utils/result.dart';

@ -1,8 +1,8 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:compass_model/model.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import '../../../domain/models/continent/continent.dart';
import '../../../utils/image_error_listener.dart';
import '../../core/localization/applocalization.dart';
import '../../core/themes/colors.dart';

@ -9,8 +9,6 @@ environment:
dependencies:
cached_network_image: ^3.3.1
collection: ^1.18.0
compass_model:
path: ../model
flutter:
sdk: flutter
flutter_localizations:

@ -1,5 +1,5 @@
import 'package:compass_app/domain/components/booking/booking_create_component.dart';
import 'package:compass_model/model.dart';
import 'package:compass_app/domain/models/itinerary_config/itinerary_config.dart';
import 'package:flutter_test/flutter_test.dart';
import '../../../../testing/fakes/repositories/fake_activities_repository.dart';

@ -1,5 +1,5 @@
import 'package:compass_app/domain/components/booking/booking_share_component.dart';
import 'package:compass_model/model.dart';
import 'package:compass_app/domain/models/booking/booking.dart';
import 'package:flutter_test/flutter_test.dart';
import '../../../../testing/models/activity.dart';

@ -1,7 +1,7 @@
import 'package:compass_app/domain/models/itinerary_config/itinerary_config.dart';
import 'package:compass_app/ui/activities/view_models/activities_viewmodel.dart';
import 'package:compass_app/ui/activities/widgets/activities_screen.dart';
import 'package:compass_app/ui/activities/widgets/activity_entry.dart';
import 'package:compass_model/model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mocktail/mocktail.dart';

@ -1,6 +1,6 @@
import 'package:compass_app/domain/models/itinerary_config/itinerary_config.dart';
import 'package:compass_app/ui/auth/logout/view_models/logout_viewmodel.dart';
import 'package:compass_app/ui/auth/logout/widgets/logout_button.dart';
import 'package:compass_model/model.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mocktail_image_network/mocktail_image_network.dart';

@ -1,8 +1,8 @@
import 'package:compass_app/domain/components/booking/booking_create_component.dart';
import 'package:compass_app/domain/components/booking/booking_share_component.dart';
import 'package:compass_app/domain/models/itinerary_config/itinerary_config.dart';
import 'package:compass_app/ui/booking/view_models/booking_viewmodel.dart';
import 'package:compass_app/ui/booking/widgets/booking_screen.dart';
import 'package:compass_model/model.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart';

@ -1,6 +1,6 @@
import 'package:compass_app/domain/models/itinerary_config/itinerary_config.dart';
import 'package:compass_app/ui/results/view_models/results_viewmodel.dart';
import 'package:compass_app/ui/results/widgets/results_screen.dart';
import 'package:compass_model/model.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mocktail/mocktail.dart';
import 'package:mocktail_image_network/mocktail_image_network.dart';

@ -1,5 +1,5 @@
import 'package:compass_app/domain/models/itinerary_config/itinerary_config.dart';
import 'package:compass_app/ui/results/view_models/results_viewmodel.dart';
import 'package:compass_model/model.dart';
import 'package:flutter_test/flutter_test.dart';
import '../../../testing/fakes/repositories/fake_destination_repository.dart';

@ -1,6 +1,6 @@
import 'package:compass_app/data/repositories/activity/activity_repository.dart';
import 'package:compass_app/domain/models/activity/activity.dart';
import 'package:compass_app/utils/result.dart';
import 'package:compass_model/src/model/activity/activity.dart';
import 'package:flutter/foundation.dart';
import '../../models/activity.dart';

@ -1,8 +1,8 @@
import 'package:collection/collection.dart';
import 'package:compass_app/data/repositories/booking/booking_repository.dart';
import 'package:compass_app/domain/models/booking/booking.dart';
import 'package:compass_app/domain/models/booking/booking_summary.dart';
import 'package:compass_app/utils/result.dart';
import 'package:compass_model/src/model/booking/booking.dart';
class FakeBookingRepository implements BookingRepository {
List<Booking> bookings = List.empty(growable: true);

@ -1,5 +1,5 @@
import 'package:compass_model/model.dart';
import 'package:compass_app/data/repositories/continent/continent_repository.dart';
import 'package:compass_app/domain/models/continent/continent.dart';
import 'package:compass_app/utils/result.dart';
import 'package:flutter/foundation.dart';

@ -1,5 +1,5 @@
import 'package:compass_model/model.dart';
import 'package:compass_app/data/repositories/destination/destination_repository.dart';
import 'package:compass_app/domain/models/destination/destination.dart';
import 'package:compass_app/utils/result.dart';
import 'package:flutter/foundation.dart';

@ -1,6 +1,6 @@
import 'package:compass_app/data/repositories/itinerary_config/itinerary_config_repository.dart';
import 'package:compass_app/domain/models/itinerary_config/itinerary_config.dart';
import 'package:compass_app/utils/result.dart';
import 'package:compass_model/src/model/itinerary_config/itinerary_config.dart';
import 'package:flutter/foundation.dart';
class FakeItineraryConfigRepository implements ItineraryConfigRepository {

@ -1,7 +1,9 @@
import 'package:compass_app/data/services/api/api_client.dart';
import 'package:compass_app/data/services/api/model/booking/booking_api_model.dart';
import 'package:compass_app/domain/models/activity/activity.dart';
import 'package:compass_app/domain/models/continent/continent.dart';
import 'package:compass_app/domain/models/destination/destination.dart';
import 'package:compass_app/utils/result.dart';
import 'package:compass_model/model.dart';
import '../../models/activity.dart';
import '../../models/booking.dart';

@ -1,7 +1,7 @@
import 'package:compass_app/data/services/api/auth_api_client.dart';
import 'package:compass_app/data/services/api/model/login_request/login_request.dart';
import 'package:compass_app/data/services/api/model/login_response/login_response.dart';
import 'package:compass_app/utils/result.dart';
import 'package:compass_model/src/model/auth/login_request/login_request.dart';
import 'package:compass_model/src/model/auth/login_response/login_response.dart';
class FakeAuthApiClient implements AuthApiClient {
@override

@ -1,4 +1,4 @@
import 'package:compass_model/model.dart';
import 'package:compass_app/domain/models/activity/activity.dart';
const kActivity = Activity(
description: 'DESCRIPTION',

@ -1,6 +1,6 @@
import 'package:compass_app/data/services/api/model/booking/booking_api_model.dart';
import 'package:compass_app/domain/models/booking/booking.dart';
import 'package:compass_app/domain/models/booking/booking_summary.dart';
import 'package:compass_model/model.dart';
import 'activity.dart';
import 'destination.dart';

@ -1,4 +1,4 @@
import 'package:compass_model/model.dart';
import 'package:compass_app/domain/models/destination/destination.dart';
const kDestination1 = Destination(
ref: 'ref1',

@ -1,7 +0,0 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/
# Avoid committing pubspec.lock for library packages; see
# https://dart.dev/guides/libraries/private-files#pubspeclock.
pubspec.lock

@ -1,3 +0,0 @@
# compass_model
Shared Data Model for the `compass_app` example.

@ -1,30 +0,0 @@
# This file configures the static analysis results for your project (errors,
# warnings, and lints).
#
# This enables the 'recommended' set of lints from `package:lints`.
# This set helps identify many issues that may lead to problems when running
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
# style and format.
#
# If you want a smaller set of lints you can change this to specify
# 'package:lints/core.yaml'. These are just the most critical lints
# (the recommended set includes the core lints).
# The core lints are also what is used by pub.dev for scoring packages.
include: package:lints/recommended.yaml
# Uncomment the following section to specify additional rules.
# linter:
# rules:
# - camel_case_types
# analyzer:
# exclude:
# - path/to/excluded/files/**
# For more information about the core and recommended set of lints, see
# https://dart.dev/go/core-lints
# For additional information about configuring this file, see
# https://dart.dev/guides/language/analysis-options

@ -1,9 +0,0 @@
library;
export 'src/model/activity/activity.dart';
export 'src/model/auth/login_request/login_request.dart';
export 'src/model/auth/login_response/login_response.dart';
export 'src/model/booking/booking.dart';
export 'src/model/continent/continent.dart';
export 'src/model/destination/destination.dart';
export 'src/model/itinerary_config/itinerary_config.dart';

@ -1,17 +0,0 @@
name: compass_model
description: Compass App Data Model
publish_to: 'none'
version: 1.0.0
environment:
sdk: ^3.4.3
dev_dependencies:
build_runner: ^2.4.11
freezed: ^2.5.7
json_serializable: ^6.8.0
lints: ^3.0.0
test: ^1.24.0
dependencies:
freezed_annotation: ^2.4.4
json_annotation: ^4.9.0

@ -1,7 +1,8 @@
import 'dart:convert';
import 'dart:io';
import 'package:compass_model/model.dart';
import '../model/activity/activity.dart';
import '../model/destination/destination.dart';
class Assets {
static const _activities = '../app/assets/activities.json';

@ -0,0 +1,52 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'activity.freezed.dart';
part 'activity.g.dart';
enum TimeOfDay {
any,
morning,
afternoon,
evening,
night,
}
@freezed
class Activity with _$Activity {
const factory Activity({
/// e.g. 'Glacier Trekking and Ice Climbing'
required String name,
/// e.g. 'Embark on a thrilling adventure exploring the awe-inspiring glaciers of Alaska. Hike across the icy terrain, marvel at the deep blue crevasses, and even try your hand at ice climbing for an unforgettable experience.'
required String description,
/// e.g. 'Matanuska Glacier or Mendenhall Glacier'
required String locationName,
/// Duration in days.
/// e.g. 8
required int duration,
/// e.g. 'morning'
required TimeOfDay timeOfDay,
/// e.g. false
required bool familyFriendly,
/// e.g. 4
required int price,
/// e.g. 'alaska'
required String destinationRef,
/// e.g. 'glacier-trekking-and-ice-climbing'
required String ref,
/// e.g. 'https://storage.googleapis.com/tripedia-images/activities/alaska_glacier-trekking-and-ice-climbing.jpg'
required String imageUrl,
}) = _Activity;
factory Activity.fromJson(Map<String, Object?> json) =>
_$ActivityFromJson(json);
}

@ -0,0 +1,425 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'activity.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
Activity _$ActivityFromJson(Map<String, dynamic> json) {
return _Activity.fromJson(json);
}
/// @nodoc
mixin _$Activity {
/// e.g. 'Glacier Trekking and Ice Climbing'
String get name => throw _privateConstructorUsedError;
/// e.g. 'Embark on a thrilling adventure exploring the awe-inspiring glaciers of Alaska. Hike across the icy terrain, marvel at the deep blue crevasses, and even try your hand at ice climbing for an unforgettable experience.'
String get description => throw _privateConstructorUsedError;
/// e.g. 'Matanuska Glacier or Mendenhall Glacier'
String get locationName => throw _privateConstructorUsedError;
/// Duration in days.
/// e.g. 8
int get duration => throw _privateConstructorUsedError;
/// e.g. 'morning'
TimeOfDay get timeOfDay => throw _privateConstructorUsedError;
/// e.g. false
bool get familyFriendly => throw _privateConstructorUsedError;
/// e.g. 4
int get price => throw _privateConstructorUsedError;
/// e.g. 'alaska'
String get destinationRef => throw _privateConstructorUsedError;
/// e.g. 'glacier-trekking-and-ice-climbing'
String get ref => throw _privateConstructorUsedError;
/// e.g. 'https://storage.googleapis.com/tripedia-images/activities/alaska_glacier-trekking-and-ice-climbing.jpg'
String get imageUrl => throw _privateConstructorUsedError;
/// Serializes this Activity to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of Activity
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$ActivityCopyWith<Activity> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ActivityCopyWith<$Res> {
factory $ActivityCopyWith(Activity value, $Res Function(Activity) then) =
_$ActivityCopyWithImpl<$Res, Activity>;
@useResult
$Res call(
{String name,
String description,
String locationName,
int duration,
TimeOfDay timeOfDay,
bool familyFriendly,
int price,
String destinationRef,
String ref,
String imageUrl});
}
/// @nodoc
class _$ActivityCopyWithImpl<$Res, $Val extends Activity>
implements $ActivityCopyWith<$Res> {
_$ActivityCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of Activity
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = null,
Object? description = null,
Object? locationName = null,
Object? duration = null,
Object? timeOfDay = null,
Object? familyFriendly = null,
Object? price = null,
Object? destinationRef = null,
Object? ref = null,
Object? imageUrl = null,
}) {
return _then(_value.copyWith(
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
description: null == description
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String,
locationName: null == locationName
? _value.locationName
: locationName // ignore: cast_nullable_to_non_nullable
as String,
duration: null == duration
? _value.duration
: duration // ignore: cast_nullable_to_non_nullable
as int,
timeOfDay: null == timeOfDay
? _value.timeOfDay
: timeOfDay // ignore: cast_nullable_to_non_nullable
as TimeOfDay,
familyFriendly: null == familyFriendly
? _value.familyFriendly
: familyFriendly // ignore: cast_nullable_to_non_nullable
as bool,
price: null == price
? _value.price
: price // ignore: cast_nullable_to_non_nullable
as int,
destinationRef: null == destinationRef
? _value.destinationRef
: destinationRef // ignore: cast_nullable_to_non_nullable
as String,
ref: null == ref
? _value.ref
: ref // ignore: cast_nullable_to_non_nullable
as String,
imageUrl: null == imageUrl
? _value.imageUrl
: imageUrl // ignore: cast_nullable_to_non_nullable
as String,
) as $Val);
}
}
/// @nodoc
abstract class _$$ActivityImplCopyWith<$Res>
implements $ActivityCopyWith<$Res> {
factory _$$ActivityImplCopyWith(
_$ActivityImpl value, $Res Function(_$ActivityImpl) then) =
__$$ActivityImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{String name,
String description,
String locationName,
int duration,
TimeOfDay timeOfDay,
bool familyFriendly,
int price,
String destinationRef,
String ref,
String imageUrl});
}
/// @nodoc
class __$$ActivityImplCopyWithImpl<$Res>
extends _$ActivityCopyWithImpl<$Res, _$ActivityImpl>
implements _$$ActivityImplCopyWith<$Res> {
__$$ActivityImplCopyWithImpl(
_$ActivityImpl _value, $Res Function(_$ActivityImpl) _then)
: super(_value, _then);
/// Create a copy of Activity
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = null,
Object? description = null,
Object? locationName = null,
Object? duration = null,
Object? timeOfDay = null,
Object? familyFriendly = null,
Object? price = null,
Object? destinationRef = null,
Object? ref = null,
Object? imageUrl = null,
}) {
return _then(_$ActivityImpl(
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
description: null == description
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String,
locationName: null == locationName
? _value.locationName
: locationName // ignore: cast_nullable_to_non_nullable
as String,
duration: null == duration
? _value.duration
: duration // ignore: cast_nullable_to_non_nullable
as int,
timeOfDay: null == timeOfDay
? _value.timeOfDay
: timeOfDay // ignore: cast_nullable_to_non_nullable
as TimeOfDay,
familyFriendly: null == familyFriendly
? _value.familyFriendly
: familyFriendly // ignore: cast_nullable_to_non_nullable
as bool,
price: null == price
? _value.price
: price // ignore: cast_nullable_to_non_nullable
as int,
destinationRef: null == destinationRef
? _value.destinationRef
: destinationRef // ignore: cast_nullable_to_non_nullable
as String,
ref: null == ref
? _value.ref
: ref // ignore: cast_nullable_to_non_nullable
as String,
imageUrl: null == imageUrl
? _value.imageUrl
: imageUrl // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
@JsonSerializable()
class _$ActivityImpl implements _Activity {
const _$ActivityImpl(
{required this.name,
required this.description,
required this.locationName,
required this.duration,
required this.timeOfDay,
required this.familyFriendly,
required this.price,
required this.destinationRef,
required this.ref,
required this.imageUrl});
factory _$ActivityImpl.fromJson(Map<String, dynamic> json) =>
_$$ActivityImplFromJson(json);
/// e.g. 'Glacier Trekking and Ice Climbing'
@override
final String name;
/// e.g. 'Embark on a thrilling adventure exploring the awe-inspiring glaciers of Alaska. Hike across the icy terrain, marvel at the deep blue crevasses, and even try your hand at ice climbing for an unforgettable experience.'
@override
final String description;
/// e.g. 'Matanuska Glacier or Mendenhall Glacier'
@override
final String locationName;
/// Duration in days.
/// e.g. 8
@override
final int duration;
/// e.g. 'morning'
@override
final TimeOfDay timeOfDay;
/// e.g. false
@override
final bool familyFriendly;
/// e.g. 4
@override
final int price;
/// e.g. 'alaska'
@override
final String destinationRef;
/// e.g. 'glacier-trekking-and-ice-climbing'
@override
final String ref;
/// e.g. 'https://storage.googleapis.com/tripedia-images/activities/alaska_glacier-trekking-and-ice-climbing.jpg'
@override
final String imageUrl;
@override
String toString() {
return 'Activity(name: $name, description: $description, locationName: $locationName, duration: $duration, timeOfDay: $timeOfDay, familyFriendly: $familyFriendly, price: $price, destinationRef: $destinationRef, ref: $ref, imageUrl: $imageUrl)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ActivityImpl &&
(identical(other.name, name) || other.name == name) &&
(identical(other.description, description) ||
other.description == description) &&
(identical(other.locationName, locationName) ||
other.locationName == locationName) &&
(identical(other.duration, duration) ||
other.duration == duration) &&
(identical(other.timeOfDay, timeOfDay) ||
other.timeOfDay == timeOfDay) &&
(identical(other.familyFriendly, familyFriendly) ||
other.familyFriendly == familyFriendly) &&
(identical(other.price, price) || other.price == price) &&
(identical(other.destinationRef, destinationRef) ||
other.destinationRef == destinationRef) &&
(identical(other.ref, ref) || other.ref == ref) &&
(identical(other.imageUrl, imageUrl) ||
other.imageUrl == imageUrl));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(
runtimeType,
name,
description,
locationName,
duration,
timeOfDay,
familyFriendly,
price,
destinationRef,
ref,
imageUrl);
/// Create a copy of Activity
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ActivityImplCopyWith<_$ActivityImpl> get copyWith =>
__$$ActivityImplCopyWithImpl<_$ActivityImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$ActivityImplToJson(
this,
);
}
}
abstract class _Activity implements Activity {
const factory _Activity(
{required final String name,
required final String description,
required final String locationName,
required final int duration,
required final TimeOfDay timeOfDay,
required final bool familyFriendly,
required final int price,
required final String destinationRef,
required final String ref,
required final String imageUrl}) = _$ActivityImpl;
factory _Activity.fromJson(Map<String, dynamic> json) =
_$ActivityImpl.fromJson;
/// e.g. 'Glacier Trekking and Ice Climbing'
@override
String get name;
/// e.g. 'Embark on a thrilling adventure exploring the awe-inspiring glaciers of Alaska. Hike across the icy terrain, marvel at the deep blue crevasses, and even try your hand at ice climbing for an unforgettable experience.'
@override
String get description;
/// e.g. 'Matanuska Glacier or Mendenhall Glacier'
@override
String get locationName;
/// Duration in days.
/// e.g. 8
@override
int get duration;
/// e.g. 'morning'
@override
TimeOfDay get timeOfDay;
/// e.g. false
@override
bool get familyFriendly;
/// e.g. 4
@override
int get price;
/// e.g. 'alaska'
@override
String get destinationRef;
/// e.g. 'glacier-trekking-and-ice-climbing'
@override
String get ref;
/// e.g. 'https://storage.googleapis.com/tripedia-images/activities/alaska_glacier-trekking-and-ice-climbing.jpg'
@override
String get imageUrl;
/// Create a copy of Activity
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ActivityImplCopyWith<_$ActivityImpl> get copyWith =>
throw _privateConstructorUsedError;
}

@ -0,0 +1,43 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'activity.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$ActivityImpl _$$ActivityImplFromJson(Map<String, dynamic> json) =>
_$ActivityImpl(
name: json['name'] as String,
description: json['description'] as String,
locationName: json['locationName'] as String,
duration: (json['duration'] as num).toInt(),
timeOfDay: $enumDecode(_$TimeOfDayEnumMap, json['timeOfDay']),
familyFriendly: json['familyFriendly'] as bool,
price: (json['price'] as num).toInt(),
destinationRef: json['destinationRef'] as String,
ref: json['ref'] as String,
imageUrl: json['imageUrl'] as String,
);
Map<String, dynamic> _$$ActivityImplToJson(_$ActivityImpl instance) =>
<String, dynamic>{
'name': instance.name,
'description': instance.description,
'locationName': instance.locationName,
'duration': instance.duration,
'timeOfDay': _$TimeOfDayEnumMap[instance.timeOfDay]!,
'familyFriendly': instance.familyFriendly,
'price': instance.price,
'destinationRef': instance.destinationRef,
'ref': instance.ref,
'imageUrl': instance.imageUrl,
};
const _$TimeOfDayEnumMap = {
TimeOfDay.any: 'any',
TimeOfDay.morning: 'morning',
TimeOfDay.afternoon: 'afternoon',
TimeOfDay.evening: 'evening',
TimeOfDay.night: 'night',
};

@ -0,0 +1,19 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'continent.freezed.dart';
part 'continent.g.dart';
@freezed
class Continent with _$Continent {
const factory Continent({
/// e.g. 'Europe'
required String name,
/// e.g. 'https://rstr.in/google/tripedia/TmR12QdlVTT'
required String imageUrl,
}) = _Continent;
factory Continent.fromJson(Map<String, Object?> json) =>
_$ContinentFromJson(json);
}

@ -0,0 +1,191 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'continent.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
Continent _$ContinentFromJson(Map<String, dynamic> json) {
return _Continent.fromJson(json);
}
/// @nodoc
mixin _$Continent {
/// e.g. 'Europe'
String get name => throw _privateConstructorUsedError;
/// e.g. 'https://rstr.in/google/tripedia/TmR12QdlVTT'
String get imageUrl => throw _privateConstructorUsedError;
/// Serializes this Continent to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of Continent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$ContinentCopyWith<Continent> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ContinentCopyWith<$Res> {
factory $ContinentCopyWith(Continent value, $Res Function(Continent) then) =
_$ContinentCopyWithImpl<$Res, Continent>;
@useResult
$Res call({String name, String imageUrl});
}
/// @nodoc
class _$ContinentCopyWithImpl<$Res, $Val extends Continent>
implements $ContinentCopyWith<$Res> {
_$ContinentCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of Continent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = null,
Object? imageUrl = null,
}) {
return _then(_value.copyWith(
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
imageUrl: null == imageUrl
? _value.imageUrl
: imageUrl // ignore: cast_nullable_to_non_nullable
as String,
) as $Val);
}
}
/// @nodoc
abstract class _$$ContinentImplCopyWith<$Res>
implements $ContinentCopyWith<$Res> {
factory _$$ContinentImplCopyWith(
_$ContinentImpl value, $Res Function(_$ContinentImpl) then) =
__$$ContinentImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String name, String imageUrl});
}
/// @nodoc
class __$$ContinentImplCopyWithImpl<$Res>
extends _$ContinentCopyWithImpl<$Res, _$ContinentImpl>
implements _$$ContinentImplCopyWith<$Res> {
__$$ContinentImplCopyWithImpl(
_$ContinentImpl _value, $Res Function(_$ContinentImpl) _then)
: super(_value, _then);
/// Create a copy of Continent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = null,
Object? imageUrl = null,
}) {
return _then(_$ContinentImpl(
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
imageUrl: null == imageUrl
? _value.imageUrl
: imageUrl // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
@JsonSerializable()
class _$ContinentImpl implements _Continent {
const _$ContinentImpl({required this.name, required this.imageUrl});
factory _$ContinentImpl.fromJson(Map<String, dynamic> json) =>
_$$ContinentImplFromJson(json);
/// e.g. 'Europe'
@override
final String name;
/// e.g. 'https://rstr.in/google/tripedia/TmR12QdlVTT'
@override
final String imageUrl;
@override
String toString() {
return 'Continent(name: $name, imageUrl: $imageUrl)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ContinentImpl &&
(identical(other.name, name) || other.name == name) &&
(identical(other.imageUrl, imageUrl) ||
other.imageUrl == imageUrl));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, name, imageUrl);
/// Create a copy of Continent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ContinentImplCopyWith<_$ContinentImpl> get copyWith =>
__$$ContinentImplCopyWithImpl<_$ContinentImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$ContinentImplToJson(
this,
);
}
}
abstract class _Continent implements Continent {
const factory _Continent(
{required final String name,
required final String imageUrl}) = _$ContinentImpl;
factory _Continent.fromJson(Map<String, dynamic> json) =
_$ContinentImpl.fromJson;
/// e.g. 'Europe'
@override
String get name;
/// e.g. 'https://rstr.in/google/tripedia/TmR12QdlVTT'
@override
String get imageUrl;
/// Create a copy of Continent
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ContinentImplCopyWith<_$ContinentImpl> get copyWith =>
throw _privateConstructorUsedError;
}

@ -0,0 +1,19 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'continent.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$ContinentImpl _$$ContinentImplFromJson(Map<String, dynamic> json) =>
_$ContinentImpl(
name: json['name'] as String,
imageUrl: json['imageUrl'] as String,
);
Map<String, dynamic> _$$ContinentImplToJson(_$ContinentImpl instance) =>
<String, dynamic>{
'name': instance.name,
'imageUrl': instance.imageUrl,
};

@ -0,0 +1,34 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'destination.freezed.dart';
part 'destination.g.dart';
@freezed
class Destination with _$Destination {
const factory Destination({
/// e.g. 'alaska'
required String ref,
/// e.g. 'Alaska'
required String name,
/// e.g. 'United States'
required String country,
/// e.g. 'North America'
required String continent,
/// e.g. 'Alaska is a haven for outdoor enthusiasts ...'
required String knownFor,
/// e.g. ['Mountain', 'Off-the-beaten-path', 'Wildlife watching']
required List<String> tags,
/// e.g. 'https://storage.googleapis.com/tripedia-images/destinations/alaska.jpg'
required String imageUrl,
}) = _Destination;
factory Destination.fromJson(Map<String, Object?> json) =>
_$DestinationFromJson(json);
}

@ -0,0 +1,339 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'destination.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
Destination _$DestinationFromJson(Map<String, dynamic> json) {
return _Destination.fromJson(json);
}
/// @nodoc
mixin _$Destination {
/// e.g. 'alaska'
String get ref => throw _privateConstructorUsedError;
/// e.g. 'Alaska'
String get name => throw _privateConstructorUsedError;
/// e.g. 'United States'
String get country => throw _privateConstructorUsedError;
/// e.g. 'North America'
String get continent => throw _privateConstructorUsedError;
/// e.g. 'Alaska is a haven for outdoor enthusiasts ...'
String get knownFor => throw _privateConstructorUsedError;
/// e.g. ['Mountain', 'Off-the-beaten-path', 'Wildlife watching']
List<String> get tags => throw _privateConstructorUsedError;
/// e.g. 'https://storage.googleapis.com/tripedia-images/destinations/alaska.jpg'
String get imageUrl => throw _privateConstructorUsedError;
/// Serializes this Destination to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of Destination
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$DestinationCopyWith<Destination> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $DestinationCopyWith<$Res> {
factory $DestinationCopyWith(
Destination value, $Res Function(Destination) then) =
_$DestinationCopyWithImpl<$Res, Destination>;
@useResult
$Res call(
{String ref,
String name,
String country,
String continent,
String knownFor,
List<String> tags,
String imageUrl});
}
/// @nodoc
class _$DestinationCopyWithImpl<$Res, $Val extends Destination>
implements $DestinationCopyWith<$Res> {
_$DestinationCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of Destination
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? ref = null,
Object? name = null,
Object? country = null,
Object? continent = null,
Object? knownFor = null,
Object? tags = null,
Object? imageUrl = null,
}) {
return _then(_value.copyWith(
ref: null == ref
? _value.ref
: ref // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
country: null == country
? _value.country
: country // ignore: cast_nullable_to_non_nullable
as String,
continent: null == continent
? _value.continent
: continent // ignore: cast_nullable_to_non_nullable
as String,
knownFor: null == knownFor
? _value.knownFor
: knownFor // ignore: cast_nullable_to_non_nullable
as String,
tags: null == tags
? _value.tags
: tags // ignore: cast_nullable_to_non_nullable
as List<String>,
imageUrl: null == imageUrl
? _value.imageUrl
: imageUrl // ignore: cast_nullable_to_non_nullable
as String,
) as $Val);
}
}
/// @nodoc
abstract class _$$DestinationImplCopyWith<$Res>
implements $DestinationCopyWith<$Res> {
factory _$$DestinationImplCopyWith(
_$DestinationImpl value, $Res Function(_$DestinationImpl) then) =
__$$DestinationImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{String ref,
String name,
String country,
String continent,
String knownFor,
List<String> tags,
String imageUrl});
}
/// @nodoc
class __$$DestinationImplCopyWithImpl<$Res>
extends _$DestinationCopyWithImpl<$Res, _$DestinationImpl>
implements _$$DestinationImplCopyWith<$Res> {
__$$DestinationImplCopyWithImpl(
_$DestinationImpl _value, $Res Function(_$DestinationImpl) _then)
: super(_value, _then);
/// Create a copy of Destination
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? ref = null,
Object? name = null,
Object? country = null,
Object? continent = null,
Object? knownFor = null,
Object? tags = null,
Object? imageUrl = null,
}) {
return _then(_$DestinationImpl(
ref: null == ref
? _value.ref
: ref // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
country: null == country
? _value.country
: country // ignore: cast_nullable_to_non_nullable
as String,
continent: null == continent
? _value.continent
: continent // ignore: cast_nullable_to_non_nullable
as String,
knownFor: null == knownFor
? _value.knownFor
: knownFor // ignore: cast_nullable_to_non_nullable
as String,
tags: null == tags
? _value._tags
: tags // ignore: cast_nullable_to_non_nullable
as List<String>,
imageUrl: null == imageUrl
? _value.imageUrl
: imageUrl // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
@JsonSerializable()
class _$DestinationImpl implements _Destination {
const _$DestinationImpl(
{required this.ref,
required this.name,
required this.country,
required this.continent,
required this.knownFor,
required final List<String> tags,
required this.imageUrl})
: _tags = tags;
factory _$DestinationImpl.fromJson(Map<String, dynamic> json) =>
_$$DestinationImplFromJson(json);
/// e.g. 'alaska'
@override
final String ref;
/// e.g. 'Alaska'
@override
final String name;
/// e.g. 'United States'
@override
final String country;
/// e.g. 'North America'
@override
final String continent;
/// e.g. 'Alaska is a haven for outdoor enthusiasts ...'
@override
final String knownFor;
/// e.g. ['Mountain', 'Off-the-beaten-path', 'Wildlife watching']
final List<String> _tags;
/// e.g. ['Mountain', 'Off-the-beaten-path', 'Wildlife watching']
@override
List<String> get tags {
if (_tags is EqualUnmodifiableListView) return _tags;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_tags);
}
/// e.g. 'https://storage.googleapis.com/tripedia-images/destinations/alaska.jpg'
@override
final String imageUrl;
@override
String toString() {
return 'Destination(ref: $ref, name: $name, country: $country, continent: $continent, knownFor: $knownFor, tags: $tags, imageUrl: $imageUrl)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$DestinationImpl &&
(identical(other.ref, ref) || other.ref == ref) &&
(identical(other.name, name) || other.name == name) &&
(identical(other.country, country) || other.country == country) &&
(identical(other.continent, continent) ||
other.continent == continent) &&
(identical(other.knownFor, knownFor) ||
other.knownFor == knownFor) &&
const DeepCollectionEquality().equals(other._tags, _tags) &&
(identical(other.imageUrl, imageUrl) ||
other.imageUrl == imageUrl));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, ref, name, country, continent,
knownFor, const DeepCollectionEquality().hash(_tags), imageUrl);
/// Create a copy of Destination
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$DestinationImplCopyWith<_$DestinationImpl> get copyWith =>
__$$DestinationImplCopyWithImpl<_$DestinationImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$DestinationImplToJson(
this,
);
}
}
abstract class _Destination implements Destination {
const factory _Destination(
{required final String ref,
required final String name,
required final String country,
required final String continent,
required final String knownFor,
required final List<String> tags,
required final String imageUrl}) = _$DestinationImpl;
factory _Destination.fromJson(Map<String, dynamic> json) =
_$DestinationImpl.fromJson;
/// e.g. 'alaska'
@override
String get ref;
/// e.g. 'Alaska'
@override
String get name;
/// e.g. 'United States'
@override
String get country;
/// e.g. 'North America'
@override
String get continent;
/// e.g. 'Alaska is a haven for outdoor enthusiasts ...'
@override
String get knownFor;
/// e.g. ['Mountain', 'Off-the-beaten-path', 'Wildlife watching']
@override
List<String> get tags;
/// e.g. 'https://storage.googleapis.com/tripedia-images/destinations/alaska.jpg'
@override
String get imageUrl;
/// Create a copy of Destination
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$DestinationImplCopyWith<_$DestinationImpl> get copyWith =>
throw _privateConstructorUsedError;
}

@ -0,0 +1,29 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'destination.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$DestinationImpl _$$DestinationImplFromJson(Map<String, dynamic> json) =>
_$DestinationImpl(
ref: json['ref'] as String,
name: json['name'] as String,
country: json['country'] as String,
continent: json['continent'] as String,
knownFor: json['knownFor'] as String,
tags: (json['tags'] as List<dynamic>).map((e) => e as String).toList(),
imageUrl: json['imageUrl'] as String,
);
Map<String, dynamic> _$$DestinationImplToJson(_$DestinationImpl instance) =>
<String, dynamic>{
'ref': instance.ref,
'name': instance.name,
'country': instance.country,
'continent': instance.continent,
'knownFor': instance.knownFor,
'tags': instance.tags,
'imageUrl': instance.imageUrl,
};

@ -0,0 +1,20 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'login_request.freezed.dart';
part 'login_request.g.dart';
/// Simple data class to hold login request data.
@freezed
class LoginRequest with _$LoginRequest {
const factory LoginRequest({
/// Email address.
required String email,
/// Plain text password.
required String password,
}) = _LoginRequest;
factory LoginRequest.fromJson(Map<String, Object?> json) =>
_$LoginRequestFromJson(json);
}

@ -0,0 +1,192 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'login_request.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
LoginRequest _$LoginRequestFromJson(Map<String, dynamic> json) {
return _LoginRequest.fromJson(json);
}
/// @nodoc
mixin _$LoginRequest {
/// Email address.
String get email => throw _privateConstructorUsedError;
/// Plain text password.
String get password => throw _privateConstructorUsedError;
/// Serializes this LoginRequest to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of LoginRequest
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$LoginRequestCopyWith<LoginRequest> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $LoginRequestCopyWith<$Res> {
factory $LoginRequestCopyWith(
LoginRequest value, $Res Function(LoginRequest) then) =
_$LoginRequestCopyWithImpl<$Res, LoginRequest>;
@useResult
$Res call({String email, String password});
}
/// @nodoc
class _$LoginRequestCopyWithImpl<$Res, $Val extends LoginRequest>
implements $LoginRequestCopyWith<$Res> {
_$LoginRequestCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of LoginRequest
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? email = null,
Object? password = null,
}) {
return _then(_value.copyWith(
email: null == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String,
password: null == password
? _value.password
: password // ignore: cast_nullable_to_non_nullable
as String,
) as $Val);
}
}
/// @nodoc
abstract class _$$LoginRequestImplCopyWith<$Res>
implements $LoginRequestCopyWith<$Res> {
factory _$$LoginRequestImplCopyWith(
_$LoginRequestImpl value, $Res Function(_$LoginRequestImpl) then) =
__$$LoginRequestImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String email, String password});
}
/// @nodoc
class __$$LoginRequestImplCopyWithImpl<$Res>
extends _$LoginRequestCopyWithImpl<$Res, _$LoginRequestImpl>
implements _$$LoginRequestImplCopyWith<$Res> {
__$$LoginRequestImplCopyWithImpl(
_$LoginRequestImpl _value, $Res Function(_$LoginRequestImpl) _then)
: super(_value, _then);
/// Create a copy of LoginRequest
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? email = null,
Object? password = null,
}) {
return _then(_$LoginRequestImpl(
email: null == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String,
password: null == password
? _value.password
: password // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
@JsonSerializable()
class _$LoginRequestImpl implements _LoginRequest {
const _$LoginRequestImpl({required this.email, required this.password});
factory _$LoginRequestImpl.fromJson(Map<String, dynamic> json) =>
_$$LoginRequestImplFromJson(json);
/// Email address.
@override
final String email;
/// Plain text password.
@override
final String password;
@override
String toString() {
return 'LoginRequest(email: $email, password: $password)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$LoginRequestImpl &&
(identical(other.email, email) || other.email == email) &&
(identical(other.password, password) ||
other.password == password));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, email, password);
/// Create a copy of LoginRequest
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$LoginRequestImplCopyWith<_$LoginRequestImpl> get copyWith =>
__$$LoginRequestImplCopyWithImpl<_$LoginRequestImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$LoginRequestImplToJson(
this,
);
}
}
abstract class _LoginRequest implements LoginRequest {
const factory _LoginRequest(
{required final String email,
required final String password}) = _$LoginRequestImpl;
factory _LoginRequest.fromJson(Map<String, dynamic> json) =
_$LoginRequestImpl.fromJson;
/// Email address.
@override
String get email;
/// Plain text password.
@override
String get password;
/// Create a copy of LoginRequest
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$LoginRequestImplCopyWith<_$LoginRequestImpl> get copyWith =>
throw _privateConstructorUsedError;
}

@ -0,0 +1,19 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'login_request.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$LoginRequestImpl _$$LoginRequestImplFromJson(Map<String, dynamic> json) =>
_$LoginRequestImpl(
email: json['email'] as String,
password: json['password'] as String,
);
Map<String, dynamic> _$$LoginRequestImplToJson(_$LoginRequestImpl instance) =>
<String, dynamic>{
'email': instance.email,
'password': instance.password,
};

@ -0,0 +1,20 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'login_response.freezed.dart';
part 'login_response.g.dart';
/// LoginResponse model.
@freezed
class LoginResponse with _$LoginResponse {
const factory LoginResponse({
/// The token to be used for authentication.
required String token,
/// The user id.
required String userId,
}) = _LoginResponse;
factory LoginResponse.fromJson(Map<String, Object?> json) =>
_$LoginResponseFromJson(json);
}

@ -0,0 +1,191 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'login_response.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
LoginResponse _$LoginResponseFromJson(Map<String, dynamic> json) {
return _LoginResponse.fromJson(json);
}
/// @nodoc
mixin _$LoginResponse {
/// The token to be used for authentication.
String get token => throw _privateConstructorUsedError;
/// The user id.
String get userId => throw _privateConstructorUsedError;
/// Serializes this LoginResponse to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of LoginResponse
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$LoginResponseCopyWith<LoginResponse> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $LoginResponseCopyWith<$Res> {
factory $LoginResponseCopyWith(
LoginResponse value, $Res Function(LoginResponse) then) =
_$LoginResponseCopyWithImpl<$Res, LoginResponse>;
@useResult
$Res call({String token, String userId});
}
/// @nodoc
class _$LoginResponseCopyWithImpl<$Res, $Val extends LoginResponse>
implements $LoginResponseCopyWith<$Res> {
_$LoginResponseCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of LoginResponse
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? token = null,
Object? userId = null,
}) {
return _then(_value.copyWith(
token: null == token
? _value.token
: token // ignore: cast_nullable_to_non_nullable
as String,
userId: null == userId
? _value.userId
: userId // ignore: cast_nullable_to_non_nullable
as String,
) as $Val);
}
}
/// @nodoc
abstract class _$$LoginResponseImplCopyWith<$Res>
implements $LoginResponseCopyWith<$Res> {
factory _$$LoginResponseImplCopyWith(
_$LoginResponseImpl value, $Res Function(_$LoginResponseImpl) then) =
__$$LoginResponseImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String token, String userId});
}
/// @nodoc
class __$$LoginResponseImplCopyWithImpl<$Res>
extends _$LoginResponseCopyWithImpl<$Res, _$LoginResponseImpl>
implements _$$LoginResponseImplCopyWith<$Res> {
__$$LoginResponseImplCopyWithImpl(
_$LoginResponseImpl _value, $Res Function(_$LoginResponseImpl) _then)
: super(_value, _then);
/// Create a copy of LoginResponse
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? token = null,
Object? userId = null,
}) {
return _then(_$LoginResponseImpl(
token: null == token
? _value.token
: token // ignore: cast_nullable_to_non_nullable
as String,
userId: null == userId
? _value.userId
: userId // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
@JsonSerializable()
class _$LoginResponseImpl implements _LoginResponse {
const _$LoginResponseImpl({required this.token, required this.userId});
factory _$LoginResponseImpl.fromJson(Map<String, dynamic> json) =>
_$$LoginResponseImplFromJson(json);
/// The token to be used for authentication.
@override
final String token;
/// The user id.
@override
final String userId;
@override
String toString() {
return 'LoginResponse(token: $token, userId: $userId)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$LoginResponseImpl &&
(identical(other.token, token) || other.token == token) &&
(identical(other.userId, userId) || other.userId == userId));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, token, userId);
/// Create a copy of LoginResponse
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$LoginResponseImplCopyWith<_$LoginResponseImpl> get copyWith =>
__$$LoginResponseImplCopyWithImpl<_$LoginResponseImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$LoginResponseImplToJson(
this,
);
}
}
abstract class _LoginResponse implements LoginResponse {
const factory _LoginResponse(
{required final String token,
required final String userId}) = _$LoginResponseImpl;
factory _LoginResponse.fromJson(Map<String, dynamic> json) =
_$LoginResponseImpl.fromJson;
/// The token to be used for authentication.
@override
String get token;
/// The user id.
@override
String get userId;
/// Create a copy of LoginResponse
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$LoginResponseImplCopyWith<_$LoginResponseImpl> get copyWith =>
throw _privateConstructorUsedError;
}

@ -0,0 +1,19 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'login_response.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$LoginResponseImpl _$$LoginResponseImplFromJson(Map<String, dynamic> json) =>
_$LoginResponseImpl(
token: json['token'] as String,
userId: json['userId'] as String,
);
Map<String, dynamic> _$$LoginResponseImplToJson(_$LoginResponseImpl instance) =>
<String, dynamic>{
'token': instance.token,
'userId': instance.userId,
};

@ -1,7 +1,8 @@
import 'dart:convert';
import 'package:shelf/shelf.dart';
import 'package:compass_model/model.dart';
import '../model/continent/continent.dart';
final _continents = [
Continent(

@ -1,10 +1,12 @@
import 'dart:convert';
import 'package:compass_model/model.dart';
import 'package:compass_server/config/constants.dart';
import 'package:shelf/shelf.dart';
import 'package:shelf_router/shelf_router.dart';
import '../model/login_request/login_request.dart';
import '../model/login_response/login_response.dart';
/// Implements a simple login API.
///
/// This is provided as an example for Flutter architectural purposes only

@ -12,8 +12,6 @@ dependencies:
shelf_router: ^1.1.0
freezed_annotation: ^2.4.4
json_annotation: ^4.9.0
compass_model:
path: ../model
dev_dependencies:
http: ^1.1.0

@ -2,9 +2,13 @@ import 'dart:convert';
import 'dart:io';
// TODO: Remove the compass_model and replace by a server-side model
import 'package:compass_model/model.dart' hide Booking;
import 'package:compass_server/config/constants.dart';
import 'package:compass_server/model/activity/activity.dart';
import 'package:compass_server/model/booking/booking.dart';
import 'package:compass_server/model/continent/continent.dart';
import 'package:compass_server/model/destination/destination.dart';
import 'package:compass_server/model/login_request/login_request.dart';
import 'package:compass_server/model/login_response/login_response.dart';
import 'package:http/http.dart';
import 'package:test/test.dart';

Loading…
Cancel
Save