1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 13:58:47 +00:00

Flutter 3.29 beta (#2571)

This commit is contained in:
Eric Windmill
2025-02-12 18:08:01 -05:00
committed by GitHub
parent d62c784789
commit 719fd72c38
685 changed files with 76244 additions and 53721 deletions

View File

@@ -24,20 +24,14 @@ void main() {
testWidgets('should load app', (tester) async {
// Load app widget.
await tester.pumpWidget(
MultiProvider(
providers: providersLocal,
child: const MainApp(),
),
MultiProvider(providers: providersLocal, child: const MainApp()),
);
});
testWidgets('Open a booking', (tester) async {
// Load app widget with local configuration
await tester.pumpWidget(
MultiProvider(
providers: providersLocal,
child: const MainApp(),
),
MultiProvider(providers: providersLocal, child: const MainApp()),
);
await tester.pumpAndSettle();
@@ -61,10 +55,7 @@ void main() {
testWidgets('Create booking', (tester) async {
// Load app widget with local configuration
await tester.pumpWidget(
MultiProvider(
providers: providersLocal,
child: const MainApp(),
),
MultiProvider(providers: providersLocal, child: const MainApp()),
);
await tester.pumpAndSettle();
@@ -97,8 +88,10 @@ void main() {
await tester.pumpAndSettle();
// Select guests
await tester.tap(find.byKey(const ValueKey(addGuestsKey)),
warnIfMissed: false);
await tester.tap(
find.byKey(const ValueKey(addGuestsKey)),
warnIfMissed: false,
);
// Refresh screen state
await tester.pumpAndSettle();

View File

@@ -50,10 +50,7 @@ void main() {
testWidgets('should load app', (tester) async {
// Load app widget.
await tester.pumpWidget(
MultiProvider(
providers: providersRemote,
child: const MainApp(),
),
MultiProvider(providers: providersRemote, child: const MainApp()),
);
await tester.pumpAndSettle();
@@ -65,10 +62,7 @@ void main() {
testWidgets('Open a booking', (tester) async {
// Load app widget with local configuration
await tester.pumpWidget(
MultiProvider(
providers: providersRemote,
child: const MainApp(),
),
MultiProvider(providers: providersRemote, child: const MainApp()),
);
await tester.pumpAndSettle();
@@ -111,10 +105,7 @@ void main() {
testWidgets('Create booking', (tester) async {
// Load app widget with local configuration
await tester.pumpWidget(
MultiProvider(
providers: providersRemote,
child: const MainApp(),
),
MultiProvider(providers: providersRemote, child: const MainApp()),
);
await tester.pumpAndSettle();
@@ -155,8 +146,10 @@ void main() {
await tester.pumpAndSettle();
// Select guests
await tester.tap(find.byKey(const ValueKey('add_guests')),
warnIfMissed: false);
await tester.tap(
find.byKey(const ValueKey('add_guests')),
warnIfMissed: false,
);
// Refresh screen state
await tester.pumpAndSettle();

View File

@@ -36,11 +36,12 @@ import '../domain/use_cases/booking/booking_share_use_case.dart';
List<SingleChildWidget> _sharedProviders = [
Provider(
lazy: true,
create: (context) => BookingCreateUseCase(
destinationRepository: context.read(),
activityRepository: context.read(),
bookingRepository: context.read(),
),
create:
(context) => BookingCreateUseCase(
destinationRepository: context.read(),
activityRepository: context.read(),
bookingRepository: context.read(),
),
),
Provider(
lazy: true,
@@ -52,49 +53,50 @@ List<SingleChildWidget> _sharedProviders = [
/// This dependency list uses repositories that connect to a remote server.
List<SingleChildWidget> get providersRemote {
return [
Provider(
create: (context) => AuthApiClient(),
),
Provider(
create: (context) => ApiClient(),
),
Provider(
create: (context) => SharedPreferencesService(),
),
Provider(create: (context) => AuthApiClient()),
Provider(create: (context) => ApiClient()),
Provider(create: (context) => SharedPreferencesService()),
ChangeNotifierProvider(
create: (context) => AuthRepositoryRemote(
authApiClient: context.read(),
apiClient: context.read(),
sharedPreferencesService: context.read(),
) as AuthRepository,
create:
(context) =>
AuthRepositoryRemote(
authApiClient: context.read(),
apiClient: context.read(),
sharedPreferencesService: context.read(),
)
as AuthRepository,
),
Provider(
create: (context) => DestinationRepositoryRemote(
apiClient: context.read(),
) as DestinationRepository,
create:
(context) =>
DestinationRepositoryRemote(apiClient: context.read())
as DestinationRepository,
),
Provider(
create: (context) => ContinentRepositoryRemote(
apiClient: context.read(),
) as ContinentRepository,
create:
(context) =>
ContinentRepositoryRemote(apiClient: context.read())
as ContinentRepository,
),
Provider(
create: (context) => ActivityRepositoryRemote(
apiClient: context.read(),
) as ActivityRepository,
create:
(context) =>
ActivityRepositoryRemote(apiClient: context.read())
as ActivityRepository,
),
Provider.value(
value: ItineraryConfigRepositoryMemory() as ItineraryConfigRepository,
),
Provider(
create: (context) => BookingRepositoryRemote(
apiClient: context.read(),
) as BookingRepository,
create:
(context) =>
BookingRepositoryRemote(apiClient: context.read())
as BookingRepository,
),
Provider(
create: (context) => UserRepositoryRemote(
apiClient: context.read(),
) as UserRepository,
create:
(context) =>
UserRepositoryRemote(apiClient: context.read()) as UserRepository,
),
..._sharedProviders,
];
@@ -105,39 +107,40 @@ List<SingleChildWidget> get providersRemote {
/// The user is always logged in.
List<SingleChildWidget> get providersLocal {
return [
ChangeNotifierProvider.value(
value: AuthRepositoryDev() as AuthRepository,
),
Provider.value(
value: LocalDataService(),
ChangeNotifierProvider.value(value: AuthRepositoryDev() as AuthRepository),
Provider.value(value: LocalDataService()),
Provider(
create:
(context) =>
DestinationRepositoryLocal(localDataService: context.read())
as DestinationRepository,
),
Provider(
create: (context) => DestinationRepositoryLocal(
localDataService: context.read(),
) as DestinationRepository,
create:
(context) =>
ContinentRepositoryLocal(localDataService: context.read())
as ContinentRepository,
),
Provider(
create: (context) => ContinentRepositoryLocal(
localDataService: context.read(),
) as ContinentRepository,
create:
(context) =>
ActivityRepositoryLocal(localDataService: context.read())
as ActivityRepository,
),
Provider(
create: (context) => ActivityRepositoryLocal(
localDataService: context.read(),
) as ActivityRepository,
),
Provider(
create: (context) => BookingRepositoryLocal(
localDataService: context.read(),
) as BookingRepository,
create:
(context) =>
BookingRepositoryLocal(localDataService: context.read())
as BookingRepository,
),
Provider.value(
value: ItineraryConfigRepositoryMemory() as ItineraryConfigRepository,
),
Provider(
create: (context) => UserRepositoryLocal(
localDataService: context.read(),
) as UserRepository,
create:
(context) =>
UserRepositoryLocal(localDataService: context.read())
as UserRepository,
),
..._sharedProviders,
];

View File

@@ -10,18 +10,18 @@ import 'activity_repository.dart';
/// Local implementation of ActivityRepository
/// Uses data from assets folder
class ActivityRepositoryLocal implements ActivityRepository {
ActivityRepositoryLocal({
required LocalDataService localDataService,
}) : _localDataService = localDataService;
ActivityRepositoryLocal({required LocalDataService localDataService})
: _localDataService = localDataService;
final LocalDataService _localDataService;
@override
Future<Result<List<Activity>>> getByDestination(String ref) async {
try {
final activities = (await _localDataService.getActivities())
.where((activity) => activity.destinationRef == ref)
.toList();
final activities =
(await _localDataService.getActivities())
.where((activity) => activity.destinationRef == ref)
.toList();
return Result.ok(activities);
} on Exception catch (error) {

View File

@@ -11,9 +11,8 @@ import 'activity_repository.dart';
/// Implements basic local caching.
/// See: https://docs.flutter.dev/get-started/fwe/local-caching
class ActivityRepositoryRemote implements ActivityRepository {
ActivityRepositoryRemote({
required ApiClient apiClient,
}) : _apiClient = apiClient;
ActivityRepositoryRemote({required ApiClient apiClient})
: _apiClient = apiClient;
final ApiClient _apiClient;

View File

@@ -12,10 +12,7 @@ abstract class AuthRepository extends ChangeNotifier {
Future<bool> get isAuthenticated;
/// Perform login
Future<Result<void>> login({
required String email,
required String password,
});
Future<Result<void>> login({required String email, required String password});
/// Perform logout
Future<Result<void>> logout();

View File

@@ -17,9 +17,9 @@ class AuthRepositoryRemote extends AuthRepository {
required ApiClient apiClient,
required AuthApiClient authApiClient,
required SharedPreferencesService sharedPreferencesService,
}) : _apiClient = apiClient,
_authApiClient = authApiClient,
_sharedPreferencesService = sharedPreferencesService {
}) : _apiClient = apiClient,
_authApiClient = authApiClient,
_sharedPreferencesService = sharedPreferencesService {
_apiClient.authHeaderProvider = _authHeaderProvider;
}
@@ -64,10 +64,7 @@ class AuthRepositoryRemote extends AuthRepository {
}) async {
try {
final result = await _authApiClient.login(
LoginRequest(
email: email,
password: password,
),
LoginRequest(email: email, password: password),
);
switch (result) {
case Ok<LoginResponse>():

View File

@@ -14,9 +14,8 @@ import '../../services/local/local_data_service.dart';
import 'booking_repository.dart';
class BookingRepositoryLocal implements BookingRepository {
BookingRepositoryLocal({
required LocalDataService localDataService,
}) : _localDataService = localDataService;
BookingRepositoryLocal({required LocalDataService localDataService})
: _localDataService = localDataService;
// Only create default booking once
bool _isInitialized = false;
@@ -72,10 +71,11 @@ class BookingRepositoryLocal implements BookingRepository {
// create a default booking the first time
if (_bookings.isEmpty) {
final destination = (await _localDataService.getDestinations()).first;
final activities = (await _localDataService.getActivities())
.where((activity) => activity.destinationRef == destination.ref)
.take(4)
.toList();
final activities =
(await _localDataService.getActivities())
.where((activity) => activity.destinationRef == destination.ref)
.take(4)
.toList();
_bookings.add(
Booking(

View File

@@ -12,9 +12,8 @@ import '../../services/api/model/booking/booking_api_model.dart';
import 'booking_repository.dart';
class BookingRepositoryRemote implements BookingRepository {
BookingRepositoryRemote({
required ApiClient apiClient,
}) : _apiClient = apiClient;
BookingRepositoryRemote({required ApiClient apiClient})
: _apiClient = apiClient;
final ApiClient _apiClient;
@@ -62,18 +61,21 @@ class BookingRepositoryRemote implements BookingRepository {
// Get destination for booking
final destination = _cachedDestinations!.firstWhere(
(destination) => destination.ref == booking.destinationRef);
(destination) => destination.ref == booking.destinationRef,
);
final resultActivities =
await _apiClient.getActivityByDestination(destination.ref);
final resultActivities = await _apiClient.getActivityByDestination(
destination.ref,
);
switch (resultActivities) {
case Error<List<Activity>>():
return Result.error(resultActivities.error);
case Ok<List<Activity>>():
}
final activities = resultActivities.value
.where((activity) => booking.activitiesRef.contains(activity.ref))
.toList();
final activities =
resultActivities.value
.where((activity) => booking.activitiesRef.contains(activity.ref))
.toList();
return Result.ok(
Booking(
@@ -96,16 +98,18 @@ class BookingRepositoryRemote implements BookingRepository {
switch (result) {
case Ok<List<BookingApiModel>>():
final bookingsApi = result.value;
return Result.ok(bookingsApi
.map(
(bookingApi) => BookingSummary(
id: bookingApi.id!,
name: bookingApi.name,
startDate: bookingApi.startDate,
endDate: bookingApi.endDate,
),
)
.toList());
return Result.ok(
bookingsApi
.map(
(bookingApi) => BookingSummary(
id: bookingApi.id!,
name: bookingApi.name,
startDate: bookingApi.startDate,
endDate: bookingApi.endDate,
),
)
.toList(),
);
case Error<List<BookingApiModel>>():
return Result.error(result.error);
}

View File

@@ -9,9 +9,8 @@ import 'continent_repository.dart';
/// Local data source with all possible continents.
class ContinentRepositoryLocal implements ContinentRepository {
ContinentRepositoryLocal({
required LocalDataService localDataService,
}) : _localDataService = localDataService;
ContinentRepositoryLocal({required LocalDataService localDataService})
: _localDataService = localDataService;
final LocalDataService _localDataService;

View File

@@ -11,9 +11,8 @@ import 'continent_repository.dart';
/// Implements basic local caching.
/// See: https://docs.flutter.dev/get-started/fwe/local-caching
class ContinentRepositoryRemote implements ContinentRepository {
ContinentRepositoryRemote({
required ApiClient apiClient,
}) : _apiClient = apiClient;
ContinentRepositoryRemote({required ApiClient apiClient})
: _apiClient = apiClient;
final ApiClient _apiClient;

View File

@@ -10,9 +10,8 @@ import 'destination_repository.dart';
/// Local implementation of DestinationRepository
/// Uses data from assets folder
class DestinationRepositoryLocal implements DestinationRepository {
DestinationRepositoryLocal({
required LocalDataService localDataService,
}) : _localDataService = localDataService;
DestinationRepositoryLocal({required LocalDataService localDataService})
: _localDataService = localDataService;
final LocalDataService _localDataService;

View File

@@ -11,9 +11,8 @@ import 'destination_repository.dart';
/// Implements basic local caching.
/// See: https://docs.flutter.dev/get-started/fwe/local-caching
class DestinationRepositoryRemote implements DestinationRepository {
DestinationRepositoryRemote({
required ApiClient apiClient,
}) : _apiClient = apiClient;
DestinationRepositoryRemote({required ApiClient apiClient})
: _apiClient = apiClient;
final ApiClient _apiClient;

View File

@@ -8,9 +8,8 @@ import '../../services/local/local_data_service.dart';
import 'user_repository.dart';
class UserRepositoryLocal implements UserRepository {
UserRepositoryLocal({
required LocalDataService localDataService,
}) : _localDataService = localDataService;
UserRepositoryLocal({required LocalDataService localDataService})
: _localDataService = localDataService;
final LocalDataService _localDataService;

View File

@@ -9,9 +9,7 @@ import '../../services/api/model/user/user_api_model.dart';
import 'user_repository.dart';
class UserRepositoryRemote implements UserRepository {
UserRepositoryRemote({
required ApiClient apiClient,
}) : _apiClient = apiClient;
UserRepositoryRemote({required ApiClient apiClient}) : _apiClient = apiClient;
final ApiClient _apiClient;

View File

@@ -16,13 +16,10 @@ import 'model/user/user_api_model.dart';
typedef AuthHeaderProvider = String? Function();
class ApiClient {
ApiClient({
String? host,
int? port,
HttpClient Function()? clientFactory,
}) : _host = host ?? 'localhost',
_port = port ?? 8080,
_clientFactory = clientFactory ?? HttpClient.new;
ApiClient({String? host, int? port, HttpClient Function()? clientFactory})
: _host = host ?? 'localhost',
_port = port ?? 8080,
_clientFactory = clientFactory ?? HttpClient.new;
final String _host;
final int _port;
@@ -51,7 +48,8 @@ class ApiClient {
final stringData = await response.transform(utf8.decoder).join();
final json = jsonDecode(stringData) as List<dynamic>;
return Result.ok(
json.map((element) => Continent.fromJson(element)).toList());
json.map((element) => Continent.fromJson(element)).toList(),
);
} else {
return const Result.error(HttpException("Invalid response"));
}
@@ -72,7 +70,8 @@ class ApiClient {
final stringData = await response.transform(utf8.decoder).join();
final json = jsonDecode(stringData) as List<dynamic>;
return Result.ok(
json.map((element) => Destination.fromJson(element)).toList());
json.map((element) => Destination.fromJson(element)).toList(),
);
} else {
return const Result.error(HttpException("Invalid response"));
}
@@ -86,8 +85,11 @@ class ApiClient {
Future<Result<List<Activity>>> getActivityByDestination(String ref) async {
final client = _clientFactory();
try {
final request =
await client.get(_host, _port, '/destination/$ref/activity');
final request = await client.get(
_host,
_port,
'/destination/$ref/activity',
);
await _authHeader(request.headers);
final response = await request.close();
if (response.statusCode == 200) {

View File

@@ -10,13 +10,10 @@ import 'model/login_request/login_request.dart';
import 'model/login_response/login_response.dart';
class AuthApiClient {
AuthApiClient({
String? host,
int? port,
HttpClient Function()? clientFactory,
}) : _host = host ?? 'localhost',
_port = port ?? 8080,
_clientFactory = clientFactory ?? HttpClient.new;
AuthApiClient({String? host, int? port, HttpClient Function()? clientFactory})
: _host = host ?? 'localhost',
_port = port ?? 8080,
_clientFactory = clientFactory ?? HttpClient.new;
final String _host;
final int _port;

View File

@@ -12,7 +12,8 @@ part of 'booking_api_model.dart';
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');
'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',
);
BookingApiModel _$BookingApiModelFromJson(Map<String, dynamic> json) {
return _BookingApiModel.fromJson(json);
@@ -52,16 +53,18 @@ mixin _$BookingApiModel {
/// @nodoc
abstract class $BookingApiModelCopyWith<$Res> {
factory $BookingApiModelCopyWith(
BookingApiModel value, $Res Function(BookingApiModel) then) =
_$BookingApiModelCopyWithImpl<$Res, BookingApiModel>;
BookingApiModel value,
$Res Function(BookingApiModel) then,
) = _$BookingApiModelCopyWithImpl<$Res, BookingApiModel>;
@useResult
$Res call(
{int? id,
DateTime startDate,
DateTime endDate,
String name,
String destinationRef,
List<String> activitiesRef});
$Res call({
int? id,
DateTime startDate,
DateTime endDate,
String name,
String destinationRef,
List<String> activitiesRef,
});
}
/// @nodoc
@@ -86,50 +89,61 @@ class _$BookingApiModelCopyWithImpl<$Res, $Val extends BookingApiModel>
Object? destinationRef = null,
Object? activitiesRef = null,
}) {
return _then(_value.copyWith(
id: freezed == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int?,
startDate: null == startDate
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime,
endDate: null == endDate
? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable
as DateTime,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
destinationRef: null == destinationRef
? _value.destinationRef
: destinationRef // ignore: cast_nullable_to_non_nullable
as String,
activitiesRef: null == activitiesRef
? _value.activitiesRef
: activitiesRef // ignore: cast_nullable_to_non_nullable
as List<String>,
) as $Val);
return _then(
_value.copyWith(
id:
freezed == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int?,
startDate:
null == startDate
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime,
endDate:
null == endDate
? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable
as DateTime,
name:
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
destinationRef:
null == destinationRef
? _value.destinationRef
: destinationRef // ignore: cast_nullable_to_non_nullable
as String,
activitiesRef:
null == activitiesRef
? _value.activitiesRef
: activitiesRef // ignore: cast_nullable_to_non_nullable
as List<String>,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$BookingApiModelImplCopyWith<$Res>
implements $BookingApiModelCopyWith<$Res> {
factory _$$BookingApiModelImplCopyWith(_$BookingApiModelImpl value,
$Res Function(_$BookingApiModelImpl) then) =
__$$BookingApiModelImplCopyWithImpl<$Res>;
factory _$$BookingApiModelImplCopyWith(
_$BookingApiModelImpl value,
$Res Function(_$BookingApiModelImpl) then,
) = __$$BookingApiModelImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{int? id,
DateTime startDate,
DateTime endDate,
String name,
String destinationRef,
List<String> activitiesRef});
$Res call({
int? id,
DateTime startDate,
DateTime endDate,
String name,
String destinationRef,
List<String> activitiesRef,
});
}
/// @nodoc
@@ -137,8 +151,9 @@ class __$$BookingApiModelImplCopyWithImpl<$Res>
extends _$BookingApiModelCopyWithImpl<$Res, _$BookingApiModelImpl>
implements _$$BookingApiModelImplCopyWith<$Res> {
__$$BookingApiModelImplCopyWithImpl(
_$BookingApiModelImpl _value, $Res Function(_$BookingApiModelImpl) _then)
: super(_value, _then);
_$BookingApiModelImpl _value,
$Res Function(_$BookingApiModelImpl) _then,
) : super(_value, _then);
/// Create a copy of BookingApiModel
/// with the given fields replaced by the non-null parameter values.
@@ -152,46 +167,54 @@ class __$$BookingApiModelImplCopyWithImpl<$Res>
Object? destinationRef = null,
Object? activitiesRef = null,
}) {
return _then(_$BookingApiModelImpl(
id: freezed == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int?,
startDate: null == startDate
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime,
endDate: null == endDate
? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable
as DateTime,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
destinationRef: null == destinationRef
? _value.destinationRef
: destinationRef // ignore: cast_nullable_to_non_nullable
as String,
activitiesRef: null == activitiesRef
? _value._activitiesRef
: activitiesRef // ignore: cast_nullable_to_non_nullable
as List<String>,
));
return _then(
_$BookingApiModelImpl(
id:
freezed == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int?,
startDate:
null == startDate
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime,
endDate:
null == endDate
? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable
as DateTime,
name:
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
destinationRef:
null == destinationRef
? _value.destinationRef
: destinationRef // ignore: cast_nullable_to_non_nullable
as String,
activitiesRef:
null == activitiesRef
? _value._activitiesRef
: activitiesRef // ignore: cast_nullable_to_non_nullable
as List<String>,
),
);
}
}
/// @nodoc
@JsonSerializable()
class _$BookingApiModelImpl implements _BookingApiModel {
const _$BookingApiModelImpl(
{this.id,
required this.startDate,
required this.endDate,
required this.name,
required this.destinationRef,
required final List<String> activitiesRef})
: _activitiesRef = activitiesRef;
const _$BookingApiModelImpl({
this.id,
required this.startDate,
required this.endDate,
required this.name,
required this.destinationRef,
required final List<String> activitiesRef,
}) : _activitiesRef = activitiesRef;
factory _$BookingApiModelImpl.fromJson(Map<String, dynamic> json) =>
_$$BookingApiModelImplFromJson(json);
@@ -245,14 +268,23 @@ class _$BookingApiModelImpl implements _BookingApiModel {
(identical(other.name, name) || other.name == name) &&
(identical(other.destinationRef, destinationRef) ||
other.destinationRef == destinationRef) &&
const DeepCollectionEquality()
.equals(other._activitiesRef, _activitiesRef));
const DeepCollectionEquality().equals(
other._activitiesRef,
_activitiesRef,
));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, id, startDate, endDate, name,
destinationRef, const DeepCollectionEquality().hash(_activitiesRef));
int get hashCode => Object.hash(
runtimeType,
id,
startDate,
endDate,
name,
destinationRef,
const DeepCollectionEquality().hash(_activitiesRef),
);
/// Create a copy of BookingApiModel
/// with the given fields replaced by the non-null parameter values.
@@ -261,24 +293,25 @@ class _$BookingApiModelImpl implements _BookingApiModel {
@pragma('vm:prefer-inline')
_$$BookingApiModelImplCopyWith<_$BookingApiModelImpl> get copyWith =>
__$$BookingApiModelImplCopyWithImpl<_$BookingApiModelImpl>(
this, _$identity);
this,
_$identity,
);
@override
Map<String, dynamic> toJson() {
return _$$BookingApiModelImplToJson(
this,
);
return _$$BookingApiModelImplToJson(this);
}
}
abstract class _BookingApiModel implements BookingApiModel {
const factory _BookingApiModel(
{final int? id,
required final DateTime startDate,
required final DateTime endDate,
required final String name,
required final String destinationRef,
required final List<String> activitiesRef}) = _$BookingApiModelImpl;
const factory _BookingApiModel({
final int? id,
required final DateTime startDate,
required final DateTime endDate,
required final String name,
required final String destinationRef,
required final List<String> activitiesRef,
}) = _$BookingApiModelImpl;
factory _BookingApiModel.fromJson(Map<String, dynamic> json) =
_$BookingApiModelImpl.fromJson;

View File

@@ -7,25 +7,24 @@ part of 'booking_api_model.dart';
// **************************************************************************
_$BookingApiModelImpl _$$BookingApiModelImplFromJson(
Map<String, dynamic> json) =>
_$BookingApiModelImpl(
id: (json['id'] as num?)?.toInt(),
startDate: DateTime.parse(json['startDate'] as String),
endDate: DateTime.parse(json['endDate'] as String),
name: json['name'] as String,
destinationRef: json['destinationRef'] as String,
activitiesRef: (json['activitiesRef'] as List<dynamic>)
.map((e) => e as String)
.toList(),
);
Map<String, dynamic> json,
) => _$BookingApiModelImpl(
id: (json['id'] as num?)?.toInt(),
startDate: DateTime.parse(json['startDate'] as String),
endDate: DateTime.parse(json['endDate'] as String),
name: json['name'] as String,
destinationRef: json['destinationRef'] as String,
activitiesRef:
(json['activitiesRef'] as List<dynamic>).map((e) => e as String).toList(),
);
Map<String, dynamic> _$$BookingApiModelImplToJson(
_$BookingApiModelImpl instance) =>
<String, dynamic>{
'id': instance.id,
'startDate': instance.startDate.toIso8601String(),
'endDate': instance.endDate.toIso8601String(),
'name': instance.name,
'destinationRef': instance.destinationRef,
'activitiesRef': instance.activitiesRef,
};
_$BookingApiModelImpl instance,
) => <String, dynamic>{
'id': instance.id,
'startDate': instance.startDate.toIso8601String(),
'endDate': instance.endDate.toIso8601String(),
'name': instance.name,
'destinationRef': instance.destinationRef,
'activitiesRef': instance.activitiesRef,
};

View File

@@ -12,7 +12,8 @@ part of 'login_request.dart';
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');
'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);
@@ -39,8 +40,9 @@ mixin _$LoginRequest {
/// @nodoc
abstract class $LoginRequestCopyWith<$Res> {
factory $LoginRequestCopyWith(
LoginRequest value, $Res Function(LoginRequest) then) =
_$LoginRequestCopyWithImpl<$Res, LoginRequest>;
LoginRequest value,
$Res Function(LoginRequest) then,
) = _$LoginRequestCopyWithImpl<$Res, LoginRequest>;
@useResult
$Res call({String email, String password});
}
@@ -59,20 +61,22 @@ class _$LoginRequestCopyWithImpl<$Res, $Val extends 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);
$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,
);
}
}
@@ -80,8 +84,9 @@ class _$LoginRequestCopyWithImpl<$Res, $Val extends LoginRequest>
abstract class _$$LoginRequestImplCopyWith<$Res>
implements $LoginRequestCopyWith<$Res> {
factory _$$LoginRequestImplCopyWith(
_$LoginRequestImpl value, $Res Function(_$LoginRequestImpl) then) =
__$$LoginRequestImplCopyWithImpl<$Res>;
_$LoginRequestImpl value,
$Res Function(_$LoginRequestImpl) then,
) = __$$LoginRequestImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String email, String password});
@@ -92,27 +97,29 @@ class __$$LoginRequestImplCopyWithImpl<$Res>
extends _$LoginRequestCopyWithImpl<$Res, _$LoginRequestImpl>
implements _$$LoginRequestImplCopyWith<$Res> {
__$$LoginRequestImplCopyWithImpl(
_$LoginRequestImpl _value, $Res Function(_$LoginRequestImpl) _then)
: super(_value, _then);
_$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,
));
$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,
),
);
}
}
@@ -161,16 +168,15 @@ class _$LoginRequestImpl implements _LoginRequest {
@override
Map<String, dynamic> toJson() {
return _$$LoginRequestImplToJson(
this,
);
return _$$LoginRequestImplToJson(this);
}
}
abstract class _LoginRequest implements LoginRequest {
const factory _LoginRequest(
{required final String email,
required final String password}) = _$LoginRequestImpl;
const factory _LoginRequest({
required final String email,
required final String password,
}) = _$LoginRequestImpl;
factory _LoginRequest.fromJson(Map<String, dynamic> json) =
_$LoginRequestImpl.fromJson;

View File

@@ -13,7 +13,4 @@ _$LoginRequestImpl _$$LoginRequestImplFromJson(Map<String, dynamic> json) =>
);
Map<String, dynamic> _$$LoginRequestImplToJson(_$LoginRequestImpl instance) =>
<String, dynamic>{
'email': instance.email,
'password': instance.password,
};
<String, dynamic>{'email': instance.email, 'password': instance.password};

View File

@@ -12,7 +12,8 @@ part of 'login_response.dart';
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');
'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);
@@ -39,8 +40,9 @@ mixin _$LoginResponse {
/// @nodoc
abstract class $LoginResponseCopyWith<$Res> {
factory $LoginResponseCopyWith(
LoginResponse value, $Res Function(LoginResponse) then) =
_$LoginResponseCopyWithImpl<$Res, LoginResponse>;
LoginResponse value,
$Res Function(LoginResponse) then,
) = _$LoginResponseCopyWithImpl<$Res, LoginResponse>;
@useResult
$Res call({String token, String userId});
}
@@ -59,20 +61,22 @@ class _$LoginResponseCopyWithImpl<$Res, $Val extends 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);
$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,
);
}
}
@@ -80,8 +84,9 @@ class _$LoginResponseCopyWithImpl<$Res, $Val extends LoginResponse>
abstract class _$$LoginResponseImplCopyWith<$Res>
implements $LoginResponseCopyWith<$Res> {
factory _$$LoginResponseImplCopyWith(
_$LoginResponseImpl value, $Res Function(_$LoginResponseImpl) then) =
__$$LoginResponseImplCopyWithImpl<$Res>;
_$LoginResponseImpl value,
$Res Function(_$LoginResponseImpl) then,
) = __$$LoginResponseImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String token, String userId});
@@ -92,27 +97,29 @@ class __$$LoginResponseImplCopyWithImpl<$Res>
extends _$LoginResponseCopyWithImpl<$Res, _$LoginResponseImpl>
implements _$$LoginResponseImplCopyWith<$Res> {
__$$LoginResponseImplCopyWithImpl(
_$LoginResponseImpl _value, $Res Function(_$LoginResponseImpl) _then)
: super(_value, _then);
_$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,
));
$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,
),
);
}
}
@@ -160,16 +167,15 @@ class _$LoginResponseImpl implements _LoginResponse {
@override
Map<String, dynamic> toJson() {
return _$$LoginResponseImplToJson(
this,
);
return _$$LoginResponseImplToJson(this);
}
}
abstract class _LoginResponse implements LoginResponse {
const factory _LoginResponse(
{required final String token,
required final String userId}) = _$LoginResponseImpl;
const factory _LoginResponse({
required final String token,
required final String userId,
}) = _$LoginResponseImpl;
factory _LoginResponse.fromJson(Map<String, dynamic> json) =
_$LoginResponseImpl.fromJson;

View File

@@ -13,7 +13,4 @@ _$LoginResponseImpl _$$LoginResponseImplFromJson(Map<String, dynamic> json) =>
);
Map<String, dynamic> _$$LoginResponseImplToJson(_$LoginResponseImpl instance) =>
<String, dynamic>{
'token': instance.token,
'userId': instance.userId,
};
<String, dynamic>{'token': instance.token, 'userId': instance.userId};

View File

@@ -12,7 +12,8 @@ part of 'user_api_model.dart';
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');
'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',
);
UserApiModel _$UserApiModelFromJson(Map<String, dynamic> json) {
return _UserApiModel.fromJson(json);
@@ -45,8 +46,9 @@ mixin _$UserApiModel {
/// @nodoc
abstract class $UserApiModelCopyWith<$Res> {
factory $UserApiModelCopyWith(
UserApiModel value, $Res Function(UserApiModel) then) =
_$UserApiModelCopyWithImpl<$Res, UserApiModel>;
UserApiModel value,
$Res Function(UserApiModel) then,
) = _$UserApiModelCopyWithImpl<$Res, UserApiModel>;
@useResult
$Res call({String id, String name, String email, String picture});
}
@@ -71,24 +73,31 @@ class _$UserApiModelCopyWithImpl<$Res, $Val extends UserApiModel>
Object? email = null,
Object? picture = null,
}) {
return _then(_value.copyWith(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
email: null == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String,
picture: null == picture
? _value.picture
: picture // ignore: cast_nullable_to_non_nullable
as String,
) as $Val);
return _then(
_value.copyWith(
id:
null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
name:
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
email:
null == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String,
picture:
null == picture
? _value.picture
: picture // ignore: cast_nullable_to_non_nullable
as String,
)
as $Val,
);
}
}
@@ -96,8 +105,9 @@ class _$UserApiModelCopyWithImpl<$Res, $Val extends UserApiModel>
abstract class _$$UserApiModelImplCopyWith<$Res>
implements $UserApiModelCopyWith<$Res> {
factory _$$UserApiModelImplCopyWith(
_$UserApiModelImpl value, $Res Function(_$UserApiModelImpl) then) =
__$$UserApiModelImplCopyWithImpl<$Res>;
_$UserApiModelImpl value,
$Res Function(_$UserApiModelImpl) then,
) = __$$UserApiModelImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String id, String name, String email, String picture});
@@ -108,8 +118,9 @@ class __$$UserApiModelImplCopyWithImpl<$Res>
extends _$UserApiModelCopyWithImpl<$Res, _$UserApiModelImpl>
implements _$$UserApiModelImplCopyWith<$Res> {
__$$UserApiModelImplCopyWithImpl(
_$UserApiModelImpl _value, $Res Function(_$UserApiModelImpl) _then)
: super(_value, _then);
_$UserApiModelImpl _value,
$Res Function(_$UserApiModelImpl) _then,
) : super(_value, _then);
/// Create a copy of UserApiModel
/// with the given fields replaced by the non-null parameter values.
@@ -121,35 +132,42 @@ class __$$UserApiModelImplCopyWithImpl<$Res>
Object? email = null,
Object? picture = null,
}) {
return _then(_$UserApiModelImpl(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
email: null == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String,
picture: null == picture
? _value.picture
: picture // ignore: cast_nullable_to_non_nullable
as String,
));
return _then(
_$UserApiModelImpl(
id:
null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
name:
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
email:
null == email
? _value.email
: email // ignore: cast_nullable_to_non_nullable
as String,
picture:
null == picture
? _value.picture
: picture // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
@JsonSerializable()
class _$UserApiModelImpl implements _UserApiModel {
const _$UserApiModelImpl(
{required this.id,
required this.name,
required this.email,
required this.picture});
const _$UserApiModelImpl({
required this.id,
required this.name,
required this.email,
required this.picture,
});
factory _$UserApiModelImpl.fromJson(Map<String, dynamic> json) =>
_$$UserApiModelImplFromJson(json);
@@ -200,18 +218,17 @@ class _$UserApiModelImpl implements _UserApiModel {
@override
Map<String, dynamic> toJson() {
return _$$UserApiModelImplToJson(
this,
);
return _$$UserApiModelImplToJson(this);
}
}
abstract class _UserApiModel implements UserApiModel {
const factory _UserApiModel(
{required final String id,
required final String name,
required final String email,
required final String picture}) = _$UserApiModelImpl;
const factory _UserApiModel({
required final String id,
required final String name,
required final String email,
required final String picture,
}) = _$UserApiModelImpl;
factory _UserApiModel.fromJson(Map<String, dynamic> json) =
_$UserApiModelImpl.fromJson;

View File

@@ -8,13 +8,7 @@ part 'activity.freezed.dart';
part 'activity.g.dart';
enum TimeOfDay {
any,
morning,
afternoon,
evening,
night,
}
enum TimeOfDay { any, morning, afternoon, evening, night }
@freezed
class Activity with _$Activity {

View File

@@ -12,7 +12,8 @@ part of 'activity.dart';
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');
'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);
@@ -66,17 +67,18 @@ 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});
$Res call({
String name,
String description,
String locationName,
int duration,
TimeOfDay timeOfDay,
bool familyFriendly,
int price,
String destinationRef,
String ref,
String imageUrl,
});
}
/// @nodoc
@@ -105,48 +107,61 @@ class _$ActivityCopyWithImpl<$Res, $Val extends Activity>
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);
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,
);
}
}
@@ -154,21 +169,23 @@ class _$ActivityCopyWithImpl<$Res, $Val extends Activity>
abstract class _$$ActivityImplCopyWith<$Res>
implements $ActivityCopyWith<$Res> {
factory _$$ActivityImplCopyWith(
_$ActivityImpl value, $Res Function(_$ActivityImpl) then) =
__$$ActivityImplCopyWithImpl<$Res>;
_$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});
$Res call({
String name,
String description,
String locationName,
int duration,
TimeOfDay timeOfDay,
bool familyFriendly,
int price,
String destinationRef,
String ref,
String imageUrl,
});
}
/// @nodoc
@@ -176,8 +193,9 @@ class __$$ActivityImplCopyWithImpl<$Res>
extends _$ActivityCopyWithImpl<$Res, _$ActivityImpl>
implements _$$ActivityImplCopyWith<$Res> {
__$$ActivityImplCopyWithImpl(
_$ActivityImpl _value, $Res Function(_$ActivityImpl) _then)
: super(_value, _then);
_$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.
@@ -195,65 +213,78 @@ class __$$ActivityImplCopyWithImpl<$Res>
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,
));
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});
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);
@@ -331,17 +362,18 @@ class _$ActivityImpl implements _Activity {
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(
runtimeType,
name,
description,
locationName,
duration,
timeOfDay,
familyFriendly,
price,
destinationRef,
ref,
imageUrl);
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.
@@ -353,24 +385,23 @@ class _$ActivityImpl implements _Activity {
@override
Map<String, dynamic> toJson() {
return _$$ActivityImplToJson(
this,
);
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;
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;

View File

@@ -12,7 +12,8 @@ part of 'booking.dart';
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');
'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',
);
Booking _$BookingFromJson(Map<String, dynamic> json) {
return _Booking.fromJson(json);
@@ -50,12 +51,13 @@ abstract class $BookingCopyWith<$Res> {
factory $BookingCopyWith(Booking value, $Res Function(Booking) then) =
_$BookingCopyWithImpl<$Res, Booking>;
@useResult
$Res call(
{int? id,
DateTime startDate,
DateTime endDate,
Destination destination,
List<Activity> activity});
$Res call({
int? id,
DateTime startDate,
DateTime endDate,
Destination destination,
List<Activity> activity,
});
$DestinationCopyWith<$Res> get destination;
}
@@ -81,28 +83,36 @@ class _$BookingCopyWithImpl<$Res, $Val extends Booking>
Object? destination = null,
Object? activity = null,
}) {
return _then(_value.copyWith(
id: freezed == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int?,
startDate: null == startDate
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime,
endDate: null == endDate
? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable
as DateTime,
destination: null == destination
? _value.destination
: destination // ignore: cast_nullable_to_non_nullable
as Destination,
activity: null == activity
? _value.activity
: activity // ignore: cast_nullable_to_non_nullable
as List<Activity>,
) as $Val);
return _then(
_value.copyWith(
id:
freezed == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int?,
startDate:
null == startDate
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime,
endDate:
null == endDate
? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable
as DateTime,
destination:
null == destination
? _value.destination
: destination // ignore: cast_nullable_to_non_nullable
as Destination,
activity:
null == activity
? _value.activity
: activity // ignore: cast_nullable_to_non_nullable
as List<Activity>,
)
as $Val,
);
}
/// Create a copy of Booking
@@ -119,16 +129,18 @@ class _$BookingCopyWithImpl<$Res, $Val extends Booking>
/// @nodoc
abstract class _$$BookingImplCopyWith<$Res> implements $BookingCopyWith<$Res> {
factory _$$BookingImplCopyWith(
_$BookingImpl value, $Res Function(_$BookingImpl) then) =
__$$BookingImplCopyWithImpl<$Res>;
_$BookingImpl value,
$Res Function(_$BookingImpl) then,
) = __$$BookingImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{int? id,
DateTime startDate,
DateTime endDate,
Destination destination,
List<Activity> activity});
$Res call({
int? id,
DateTime startDate,
DateTime endDate,
Destination destination,
List<Activity> activity,
});
@override
$DestinationCopyWith<$Res> get destination;
@@ -139,8 +151,9 @@ class __$$BookingImplCopyWithImpl<$Res>
extends _$BookingCopyWithImpl<$Res, _$BookingImpl>
implements _$$BookingImplCopyWith<$Res> {
__$$BookingImplCopyWithImpl(
_$BookingImpl _value, $Res Function(_$BookingImpl) _then)
: super(_value, _then);
_$BookingImpl _value,
$Res Function(_$BookingImpl) _then,
) : super(_value, _then);
/// Create a copy of Booking
/// with the given fields replaced by the non-null parameter values.
@@ -153,41 +166,48 @@ class __$$BookingImplCopyWithImpl<$Res>
Object? destination = null,
Object? activity = null,
}) {
return _then(_$BookingImpl(
id: freezed == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int?,
startDate: null == startDate
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime,
endDate: null == endDate
? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable
as DateTime,
destination: null == destination
? _value.destination
: destination // ignore: cast_nullable_to_non_nullable
as Destination,
activity: null == activity
? _value._activity
: activity // ignore: cast_nullable_to_non_nullable
as List<Activity>,
));
return _then(
_$BookingImpl(
id:
freezed == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int?,
startDate:
null == startDate
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime,
endDate:
null == endDate
? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable
as DateTime,
destination:
null == destination
? _value.destination
: destination // ignore: cast_nullable_to_non_nullable
as Destination,
activity:
null == activity
? _value._activity
: activity // ignore: cast_nullable_to_non_nullable
as List<Activity>,
),
);
}
}
/// @nodoc
@JsonSerializable()
class _$BookingImpl implements _Booking {
const _$BookingImpl(
{this.id,
required this.startDate,
required this.endDate,
required this.destination,
required final List<Activity> activity})
: _activity = activity;
const _$BookingImpl({
this.id,
required this.startDate,
required this.endDate,
required this.destination,
required final List<Activity> activity,
}) : _activity = activity;
factory _$BookingImpl.fromJson(Map<String, dynamic> json) =>
_$$BookingImplFromJson(json);
@@ -241,8 +261,14 @@ class _$BookingImpl implements _Booking {
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, id, startDate, endDate,
destination, const DeepCollectionEquality().hash(_activity));
int get hashCode => Object.hash(
runtimeType,
id,
startDate,
endDate,
destination,
const DeepCollectionEquality().hash(_activity),
);
/// Create a copy of Booking
/// with the given fields replaced by the non-null parameter values.
@@ -254,19 +280,18 @@ class _$BookingImpl implements _Booking {
@override
Map<String, dynamic> toJson() {
return _$$BookingImplToJson(
this,
);
return _$$BookingImplToJson(this);
}
}
abstract class _Booking implements Booking {
const factory _Booking(
{final int? id,
required final DateTime startDate,
required final DateTime endDate,
required final Destination destination,
required final List<Activity> activity}) = _$BookingImpl;
const factory _Booking({
final int? id,
required final DateTime startDate,
required final DateTime endDate,
required final Destination destination,
required final List<Activity> activity,
}) = _$BookingImpl;
factory _Booking.fromJson(Map<String, dynamic> json) = _$BookingImpl.fromJson;

View File

@@ -11,11 +11,13 @@ _$BookingImpl _$$BookingImplFromJson(Map<String, dynamic> json) =>
id: (json['id'] as num?)?.toInt(),
startDate: DateTime.parse(json['startDate'] as String),
endDate: DateTime.parse(json['endDate'] as String),
destination:
Destination.fromJson(json['destination'] as Map<String, dynamic>),
activity: (json['activity'] as List<dynamic>)
.map((e) => Activity.fromJson(e as Map<String, dynamic>))
.toList(),
destination: Destination.fromJson(
json['destination'] as Map<String, dynamic>,
),
activity:
(json['activity'] as List<dynamic>)
.map((e) => Activity.fromJson(e as Map<String, dynamic>))
.toList(),
);
Map<String, dynamic> _$$BookingImplToJson(_$BookingImpl instance) =>

View File

@@ -12,7 +12,8 @@ part of 'booking_summary.dart';
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');
'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',
);
BookingSummary _$BookingSummaryFromJson(Map<String, dynamic> json) {
return _BookingSummary.fromJson(json);
@@ -45,8 +46,9 @@ mixin _$BookingSummary {
/// @nodoc
abstract class $BookingSummaryCopyWith<$Res> {
factory $BookingSummaryCopyWith(
BookingSummary value, $Res Function(BookingSummary) then) =
_$BookingSummaryCopyWithImpl<$Res, BookingSummary>;
BookingSummary value,
$Res Function(BookingSummary) then,
) = _$BookingSummaryCopyWithImpl<$Res, BookingSummary>;
@useResult
$Res call({int id, String name, DateTime startDate, DateTime endDate});
}
@@ -71,33 +73,41 @@ class _$BookingSummaryCopyWithImpl<$Res, $Val extends BookingSummary>
Object? startDate = null,
Object? endDate = null,
}) {
return _then(_value.copyWith(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
startDate: null == startDate
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime,
endDate: null == endDate
? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable
as DateTime,
) as $Val);
return _then(
_value.copyWith(
id:
null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
name:
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
startDate:
null == startDate
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime,
endDate:
null == endDate
? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable
as DateTime,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$BookingSummaryImplCopyWith<$Res>
implements $BookingSummaryCopyWith<$Res> {
factory _$$BookingSummaryImplCopyWith(_$BookingSummaryImpl value,
$Res Function(_$BookingSummaryImpl) then) =
__$$BookingSummaryImplCopyWithImpl<$Res>;
factory _$$BookingSummaryImplCopyWith(
_$BookingSummaryImpl value,
$Res Function(_$BookingSummaryImpl) then,
) = __$$BookingSummaryImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({int id, String name, DateTime startDate, DateTime endDate});
@@ -108,8 +118,9 @@ class __$$BookingSummaryImplCopyWithImpl<$Res>
extends _$BookingSummaryCopyWithImpl<$Res, _$BookingSummaryImpl>
implements _$$BookingSummaryImplCopyWith<$Res> {
__$$BookingSummaryImplCopyWithImpl(
_$BookingSummaryImpl _value, $Res Function(_$BookingSummaryImpl) _then)
: super(_value, _then);
_$BookingSummaryImpl _value,
$Res Function(_$BookingSummaryImpl) _then,
) : super(_value, _then);
/// Create a copy of BookingSummary
/// with the given fields replaced by the non-null parameter values.
@@ -121,35 +132,42 @@ class __$$BookingSummaryImplCopyWithImpl<$Res>
Object? startDate = null,
Object? endDate = null,
}) {
return _then(_$BookingSummaryImpl(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
startDate: null == startDate
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime,
endDate: null == endDate
? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable
as DateTime,
));
return _then(
_$BookingSummaryImpl(
id:
null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
name:
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
startDate:
null == startDate
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime,
endDate:
null == endDate
? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable
as DateTime,
),
);
}
}
/// @nodoc
@JsonSerializable()
class _$BookingSummaryImpl implements _BookingSummary {
const _$BookingSummaryImpl(
{required this.id,
required this.name,
required this.startDate,
required this.endDate});
const _$BookingSummaryImpl({
required this.id,
required this.name,
required this.startDate,
required this.endDate,
});
factory _$BookingSummaryImpl.fromJson(Map<String, dynamic> json) =>
_$$BookingSummaryImplFromJson(json);
@@ -198,22 +216,23 @@ class _$BookingSummaryImpl implements _BookingSummary {
@pragma('vm:prefer-inline')
_$$BookingSummaryImplCopyWith<_$BookingSummaryImpl> get copyWith =>
__$$BookingSummaryImplCopyWithImpl<_$BookingSummaryImpl>(
this, _$identity);
this,
_$identity,
);
@override
Map<String, dynamic> toJson() {
return _$$BookingSummaryImplToJson(
this,
);
return _$$BookingSummaryImplToJson(this);
}
}
abstract class _BookingSummary implements BookingSummary {
const factory _BookingSummary(
{required final int id,
required final String name,
required final DateTime startDate,
required final DateTime endDate}) = _$BookingSummaryImpl;
const factory _BookingSummary({
required final int id,
required final String name,
required final DateTime startDate,
required final DateTime endDate,
}) = _$BookingSummaryImpl;
factory _BookingSummary.fromJson(Map<String, dynamic> json) =
_$BookingSummaryImpl.fromJson;

View File

@@ -15,10 +15,10 @@ _$BookingSummaryImpl _$$BookingSummaryImplFromJson(Map<String, dynamic> json) =>
);
Map<String, dynamic> _$$BookingSummaryImplToJson(
_$BookingSummaryImpl instance) =>
<String, dynamic>{
'id': instance.id,
'name': instance.name,
'startDate': instance.startDate.toIso8601String(),
'endDate': instance.endDate.toIso8601String(),
};
_$BookingSummaryImpl instance,
) => <String, dynamic>{
'id': instance.id,
'name': instance.name,
'startDate': instance.startDate.toIso8601String(),
'endDate': instance.endDate.toIso8601String(),
};

View File

@@ -12,7 +12,8 @@ part of 'continent.dart';
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');
'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);
@@ -58,20 +59,22 @@ class _$ContinentCopyWithImpl<$Res, $Val extends 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);
$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,
);
}
}
@@ -79,8 +82,9 @@ class _$ContinentCopyWithImpl<$Res, $Val extends Continent>
abstract class _$$ContinentImplCopyWith<$Res>
implements $ContinentCopyWith<$Res> {
factory _$$ContinentImplCopyWith(
_$ContinentImpl value, $Res Function(_$ContinentImpl) then) =
__$$ContinentImplCopyWithImpl<$Res>;
_$ContinentImpl value,
$Res Function(_$ContinentImpl) then,
) = __$$ContinentImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String name, String imageUrl});
@@ -91,27 +95,29 @@ class __$$ContinentImplCopyWithImpl<$Res>
extends _$ContinentCopyWithImpl<$Res, _$ContinentImpl>
implements _$$ContinentImplCopyWith<$Res> {
__$$ContinentImplCopyWithImpl(
_$ContinentImpl _value, $Res Function(_$ContinentImpl) _then)
: super(_value, _then);
_$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,
));
$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,
),
);
}
}
@@ -160,16 +166,15 @@ class _$ContinentImpl implements _Continent {
@override
Map<String, dynamic> toJson() {
return _$$ContinentImplToJson(
this,
);
return _$$ContinentImplToJson(this);
}
}
abstract class _Continent implements Continent {
const factory _Continent(
{required final String name,
required final String imageUrl}) = _$ContinentImpl;
const factory _Continent({
required final String name,
required final String imageUrl,
}) = _$ContinentImpl;
factory _Continent.fromJson(Map<String, dynamic> json) =
_$ContinentImpl.fromJson;

View File

@@ -13,7 +13,4 @@ _$ContinentImpl _$$ContinentImplFromJson(Map<String, dynamic> json) =>
);
Map<String, dynamic> _$$ContinentImplToJson(_$ContinentImpl instance) =>
<String, dynamic>{
'name': instance.name,
'imageUrl': instance.imageUrl,
};
<String, dynamic>{'name': instance.name, 'imageUrl': instance.imageUrl};

View File

@@ -12,7 +12,8 @@ part of 'destination.dart';
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');
'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);
@@ -54,17 +55,19 @@ mixin _$Destination {
/// @nodoc
abstract class $DestinationCopyWith<$Res> {
factory $DestinationCopyWith(
Destination value, $Res Function(Destination) then) =
_$DestinationCopyWithImpl<$Res, Destination>;
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});
$Res call({
String ref,
String name,
String country,
String continent,
String knownFor,
List<String> tags,
String imageUrl,
});
}
/// @nodoc
@@ -90,36 +93,46 @@ class _$DestinationCopyWithImpl<$Res, $Val extends Destination>
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);
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,
);
}
}
@@ -127,18 +140,20 @@ class _$DestinationCopyWithImpl<$Res, $Val extends Destination>
abstract class _$$DestinationImplCopyWith<$Res>
implements $DestinationCopyWith<$Res> {
factory _$$DestinationImplCopyWith(
_$DestinationImpl value, $Res Function(_$DestinationImpl) then) =
__$$DestinationImplCopyWithImpl<$Res>;
_$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});
$Res call({
String ref,
String name,
String country,
String continent,
String knownFor,
List<String> tags,
String imageUrl,
});
}
/// @nodoc
@@ -146,8 +161,9 @@ class __$$DestinationImplCopyWithImpl<$Res>
extends _$DestinationCopyWithImpl<$Res, _$DestinationImpl>
implements _$$DestinationImplCopyWith<$Res> {
__$$DestinationImplCopyWithImpl(
_$DestinationImpl _value, $Res Function(_$DestinationImpl) _then)
: super(_value, _then);
_$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.
@@ -162,51 +178,60 @@ class __$$DestinationImplCopyWithImpl<$Res>
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,
));
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;
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);
@@ -270,8 +295,16 @@ class _$DestinationImpl implements _Destination {
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, ref, name, country, continent,
knownFor, const DeepCollectionEquality().hash(_tags), imageUrl);
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.
@@ -283,21 +316,20 @@ class _$DestinationImpl implements _Destination {
@override
Map<String, dynamic> toJson() {
return _$$DestinationImplToJson(
this,
);
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;
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;

View File

@@ -12,7 +12,8 @@ part of 'itinerary_config.dart';
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');
'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',
);
ItineraryConfig _$ItineraryConfigFromJson(Map<String, dynamic> json) {
return _ItineraryConfig.fromJson(json);
@@ -51,16 +52,18 @@ mixin _$ItineraryConfig {
/// @nodoc
abstract class $ItineraryConfigCopyWith<$Res> {
factory $ItineraryConfigCopyWith(
ItineraryConfig value, $Res Function(ItineraryConfig) then) =
_$ItineraryConfigCopyWithImpl<$Res, ItineraryConfig>;
ItineraryConfig value,
$Res Function(ItineraryConfig) then,
) = _$ItineraryConfigCopyWithImpl<$Res, ItineraryConfig>;
@useResult
$Res call(
{String? continent,
DateTime? startDate,
DateTime? endDate,
int? guests,
String? destination,
List<String> activities});
$Res call({
String? continent,
DateTime? startDate,
DateTime? endDate,
int? guests,
String? destination,
List<String> activities,
});
}
/// @nodoc
@@ -85,50 +88,61 @@ class _$ItineraryConfigCopyWithImpl<$Res, $Val extends ItineraryConfig>
Object? destination = freezed,
Object? activities = null,
}) {
return _then(_value.copyWith(
continent: freezed == continent
? _value.continent
: continent // ignore: cast_nullable_to_non_nullable
as String?,
startDate: freezed == startDate
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime?,
endDate: freezed == endDate
? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable
as DateTime?,
guests: freezed == guests
? _value.guests
: guests // ignore: cast_nullable_to_non_nullable
as int?,
destination: freezed == destination
? _value.destination
: destination // ignore: cast_nullable_to_non_nullable
as String?,
activities: null == activities
? _value.activities
: activities // ignore: cast_nullable_to_non_nullable
as List<String>,
) as $Val);
return _then(
_value.copyWith(
continent:
freezed == continent
? _value.continent
: continent // ignore: cast_nullable_to_non_nullable
as String?,
startDate:
freezed == startDate
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime?,
endDate:
freezed == endDate
? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable
as DateTime?,
guests:
freezed == guests
? _value.guests
: guests // ignore: cast_nullable_to_non_nullable
as int?,
destination:
freezed == destination
? _value.destination
: destination // ignore: cast_nullable_to_non_nullable
as String?,
activities:
null == activities
? _value.activities
: activities // ignore: cast_nullable_to_non_nullable
as List<String>,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$ItineraryConfigImplCopyWith<$Res>
implements $ItineraryConfigCopyWith<$Res> {
factory _$$ItineraryConfigImplCopyWith(_$ItineraryConfigImpl value,
$Res Function(_$ItineraryConfigImpl) then) =
__$$ItineraryConfigImplCopyWithImpl<$Res>;
factory _$$ItineraryConfigImplCopyWith(
_$ItineraryConfigImpl value,
$Res Function(_$ItineraryConfigImpl) then,
) = __$$ItineraryConfigImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{String? continent,
DateTime? startDate,
DateTime? endDate,
int? guests,
String? destination,
List<String> activities});
$Res call({
String? continent,
DateTime? startDate,
DateTime? endDate,
int? guests,
String? destination,
List<String> activities,
});
}
/// @nodoc
@@ -136,8 +150,9 @@ class __$$ItineraryConfigImplCopyWithImpl<$Res>
extends _$ItineraryConfigCopyWithImpl<$Res, _$ItineraryConfigImpl>
implements _$$ItineraryConfigImplCopyWith<$Res> {
__$$ItineraryConfigImplCopyWithImpl(
_$ItineraryConfigImpl _value, $Res Function(_$ItineraryConfigImpl) _then)
: super(_value, _then);
_$ItineraryConfigImpl _value,
$Res Function(_$ItineraryConfigImpl) _then,
) : super(_value, _then);
/// Create a copy of ItineraryConfig
/// with the given fields replaced by the non-null parameter values.
@@ -151,46 +166,54 @@ class __$$ItineraryConfigImplCopyWithImpl<$Res>
Object? destination = freezed,
Object? activities = null,
}) {
return _then(_$ItineraryConfigImpl(
continent: freezed == continent
? _value.continent
: continent // ignore: cast_nullable_to_non_nullable
as String?,
startDate: freezed == startDate
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime?,
endDate: freezed == endDate
? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable
as DateTime?,
guests: freezed == guests
? _value.guests
: guests // ignore: cast_nullable_to_non_nullable
as int?,
destination: freezed == destination
? _value.destination
: destination // ignore: cast_nullable_to_non_nullable
as String?,
activities: null == activities
? _value._activities
: activities // ignore: cast_nullable_to_non_nullable
as List<String>,
));
return _then(
_$ItineraryConfigImpl(
continent:
freezed == continent
? _value.continent
: continent // ignore: cast_nullable_to_non_nullable
as String?,
startDate:
freezed == startDate
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime?,
endDate:
freezed == endDate
? _value.endDate
: endDate // ignore: cast_nullable_to_non_nullable
as DateTime?,
guests:
freezed == guests
? _value.guests
: guests // ignore: cast_nullable_to_non_nullable
as int?,
destination:
freezed == destination
? _value.destination
: destination // ignore: cast_nullable_to_non_nullable
as String?,
activities:
null == activities
? _value._activities
: activities // ignore: cast_nullable_to_non_nullable
as List<String>,
),
);
}
}
/// @nodoc
@JsonSerializable()
class _$ItineraryConfigImpl implements _ItineraryConfig {
const _$ItineraryConfigImpl(
{this.continent,
this.startDate,
this.endDate,
this.guests,
this.destination,
final List<String> activities = const []})
: _activities = activities;
const _$ItineraryConfigImpl({
this.continent,
this.startDate,
this.endDate,
this.guests,
this.destination,
final List<String> activities = const [],
}) : _activities = activities;
factory _$ItineraryConfigImpl.fromJson(Map<String, dynamic> json) =>
_$$ItineraryConfigImplFromJson(json);
@@ -245,14 +268,23 @@ class _$ItineraryConfigImpl implements _ItineraryConfig {
(identical(other.guests, guests) || other.guests == guests) &&
(identical(other.destination, destination) ||
other.destination == destination) &&
const DeepCollectionEquality()
.equals(other._activities, _activities));
const DeepCollectionEquality().equals(
other._activities,
_activities,
));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, continent, startDate, endDate,
guests, destination, const DeepCollectionEquality().hash(_activities));
int get hashCode => Object.hash(
runtimeType,
continent,
startDate,
endDate,
guests,
destination,
const DeepCollectionEquality().hash(_activities),
);
/// Create a copy of ItineraryConfig
/// with the given fields replaced by the non-null parameter values.
@@ -261,24 +293,25 @@ class _$ItineraryConfigImpl implements _ItineraryConfig {
@pragma('vm:prefer-inline')
_$$ItineraryConfigImplCopyWith<_$ItineraryConfigImpl> get copyWith =>
__$$ItineraryConfigImplCopyWithImpl<_$ItineraryConfigImpl>(
this, _$identity);
this,
_$identity,
);
@override
Map<String, dynamic> toJson() {
return _$$ItineraryConfigImplToJson(
this,
);
return _$$ItineraryConfigImplToJson(this);
}
}
abstract class _ItineraryConfig implements ItineraryConfig {
const factory _ItineraryConfig(
{final String? continent,
final DateTime? startDate,
final DateTime? endDate,
final int? guests,
final String? destination,
final List<String> activities}) = _$ItineraryConfigImpl;
const factory _ItineraryConfig({
final String? continent,
final DateTime? startDate,
final DateTime? endDate,
final int? guests,
final String? destination,
final List<String> activities,
}) = _$ItineraryConfigImpl;
factory _ItineraryConfig.fromJson(Map<String, dynamic> json) =
_$ItineraryConfigImpl.fromJson;

View File

@@ -7,30 +7,33 @@ part of 'itinerary_config.dart';
// **************************************************************************
_$ItineraryConfigImpl _$$ItineraryConfigImplFromJson(
Map<String, dynamic> json) =>
_$ItineraryConfigImpl(
continent: json['continent'] as String?,
startDate: json['startDate'] == null
Map<String, dynamic> json,
) => _$ItineraryConfigImpl(
continent: json['continent'] as String?,
startDate:
json['startDate'] == null
? null
: DateTime.parse(json['startDate'] as String),
endDate: json['endDate'] == null
endDate:
json['endDate'] == null
? null
: DateTime.parse(json['endDate'] as String),
guests: (json['guests'] as num?)?.toInt(),
destination: json['destination'] as String?,
activities: (json['activities'] as List<dynamic>?)
?.map((e) => e as String)
.toList() ??
const [],
);
guests: (json['guests'] as num?)?.toInt(),
destination: json['destination'] as String?,
activities:
(json['activities'] as List<dynamic>?)
?.map((e) => e as String)
.toList() ??
const [],
);
Map<String, dynamic> _$$ItineraryConfigImplToJson(
_$ItineraryConfigImpl instance) =>
<String, dynamic>{
'continent': instance.continent,
'startDate': instance.startDate?.toIso8601String(),
'endDate': instance.endDate?.toIso8601String(),
'guests': instance.guests,
'destination': instance.destination,
'activities': instance.activities,
};
_$ItineraryConfigImpl instance,
) => <String, dynamic>{
'continent': instance.continent,
'startDate': instance.startDate?.toIso8601String(),
'endDate': instance.endDate?.toIso8601String(),
'guests': instance.guests,
'destination': instance.destination,
'activities': instance.activities,
};

View File

@@ -12,7 +12,8 @@ part of 'user.dart';
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');
'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',
);
User _$UserFromJson(Map<String, dynamic> json) {
return _User.fromJson(json);
@@ -57,28 +58,31 @@ class _$UserCopyWithImpl<$Res, $Val extends User>
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = null,
Object? picture = null,
}) {
return _then(_value.copyWith(
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
picture: null == picture
? _value.picture
: picture // ignore: cast_nullable_to_non_nullable
as String,
) as $Val);
$Res call({Object? name = null, Object? picture = null}) {
return _then(
_value.copyWith(
name:
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
picture:
null == picture
? _value.picture
: picture // ignore: cast_nullable_to_non_nullable
as String,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$UserImplCopyWith<$Res> implements $UserCopyWith<$Res> {
factory _$$UserImplCopyWith(
_$UserImpl value, $Res Function(_$UserImpl) then) =
__$$UserImplCopyWithImpl<$Res>;
_$UserImpl value,
$Res Function(_$UserImpl) then,
) = __$$UserImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String name, String picture});
@@ -89,26 +93,27 @@ class __$$UserImplCopyWithImpl<$Res>
extends _$UserCopyWithImpl<$Res, _$UserImpl>
implements _$$UserImplCopyWith<$Res> {
__$$UserImplCopyWithImpl(_$UserImpl _value, $Res Function(_$UserImpl) _then)
: super(_value, _then);
: super(_value, _then);
/// Create a copy of User
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = null,
Object? picture = null,
}) {
return _then(_$UserImpl(
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
picture: null == picture
? _value.picture
: picture // ignore: cast_nullable_to_non_nullable
as String,
));
$Res call({Object? name = null, Object? picture = null}) {
return _then(
_$UserImpl(
name:
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
picture:
null == picture
? _value.picture
: picture // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
@@ -156,15 +161,15 @@ class _$UserImpl implements _User {
@override
Map<String, dynamic> toJson() {
return _$$UserImplToJson(
this,
);
return _$$UserImplToJson(this);
}
}
abstract class _User implements User {
const factory _User(
{required final String name, required final String picture}) = _$UserImpl;
const factory _User({
required final String name,
required final String picture,
}) = _$UserImpl;
factory _User.fromJson(Map<String, dynamic> json) = _$UserImpl.fromJson;

View File

@@ -7,12 +7,9 @@ part of 'user.dart';
// **************************************************************************
_$UserImpl _$$UserImplFromJson(Map<String, dynamic> json) => _$UserImpl(
name: json['name'] as String,
picture: json['picture'] as String,
);
name: json['name'] as String,
picture: json['picture'] as String,
);
Map<String, dynamic> _$$UserImplToJson(_$UserImpl instance) =>
<String, dynamic>{
'name': instance.name,
'picture': instance.picture,
};
<String, dynamic>{'name': instance.name, 'picture': instance.picture};

View File

@@ -22,9 +22,9 @@ class BookingCreateUseCase {
required DestinationRepository destinationRepository,
required ActivityRepository activityRepository,
required BookingRepository bookingRepository,
}) : _destinationRepository = destinationRepository,
_activityRepository = activityRepository,
_bookingRepository = bookingRepository;
}) : _destinationRepository = destinationRepository,
_activityRepository = activityRepository,
_bookingRepository = bookingRepository;
final DestinationRepository _destinationRepository;
final ActivityRepository _activityRepository;
@@ -38,8 +38,9 @@ class BookingCreateUseCase {
_log.warning('Destination is not set');
return Result.error(Exception('Destination is not set'));
}
final destinationResult =
await _fetchDestination(itineraryConfig.destination!);
final destinationResult = await _fetchDestination(
itineraryConfig.destination!,
);
switch (destinationResult) {
case Ok<Destination>():
_log.fine('Destination loaded: ${destinationResult.value.ref}');
@@ -62,11 +63,12 @@ class BookingCreateUseCase {
return Result.error(activitiesResult.error);
case Ok<List<Activity>>():
}
final activities = activitiesResult.value
.where(
(activity) => itineraryConfig.activities.contains(activity.ref),
)
.toList();
final activities =
activitiesResult.value
.where(
(activity) => itineraryConfig.activities.contains(activity.ref),
)
.toList();
_log.fine('Activities loaded (${activities.length})');
// Check if dates are set
@@ -100,8 +102,9 @@ class BookingCreateUseCase {
final result = await _destinationRepository.getDestinations();
switch (result) {
case Ok<List<Destination>>():
final destination = result.value
.firstWhere((destination) => destination.ref == destinationRef);
final destination = result.value.firstWhere(
(destination) => destination.ref == destinationRef,
);
return Result.ok(destination);
case Error<List<Destination>>():
return Result.error(result.error);

View File

@@ -28,7 +28,8 @@ class BookingShareUseCase {
final _log = Logger('BookingShareUseCase');
Future<Result<void>> shareBooking(Booking booking) async {
final text = 'Trip to ${booking.destination.name}\n'
final text =
'Trip to ${booking.destination.name}\n'
'on ${dateFormatStartEnd(DateTimeRange(start: booking.startDate, end: booking.endDate))}\n'
'Activities:\n'
'${booking.activity.map((a) => ' - ${a.name}').join('\n')}.';

View File

@@ -15,10 +15,5 @@ import 'main.dart';
void main() {
Logger.root.level = Level.ALL;
runApp(
MultiProvider(
providers: providersLocal,
child: const MainApp(),
),
);
runApp(MultiProvider(providers: providersLocal, child: const MainApp()));
}

View File

@@ -15,10 +15,5 @@ import 'main.dart';
void main() {
Logger.root.level = Level.ALL;
runApp(
MultiProvider(
providers: providersRemote,
child: const MainApp(),
),
);
runApp(MultiProvider(providers: providersRemote, child: const MainApp()));
}

View File

@@ -25,72 +25,81 @@ import 'routes.dart';
///
/// Listens to changes in [AuthTokenRepository] to redirect the user
/// to /login when the user logs out.
GoRouter router(
AuthRepository authRepository,
) =>
GoRouter(
initialLocation: Routes.home,
debugLogDiagnostics: true,
redirect: _redirect,
refreshListenable: authRepository,
GoRouter router(AuthRepository authRepository) => GoRouter(
initialLocation: Routes.home,
debugLogDiagnostics: true,
redirect: _redirect,
refreshListenable: authRepository,
routes: [
GoRoute(
path: Routes.login,
builder: (context, state) {
return LoginScreen(
viewModel: LoginViewModel(authRepository: context.read()),
);
},
),
GoRoute(
path: Routes.home,
builder: (context, state) {
final viewModel = HomeViewModel(
bookingRepository: context.read(),
userRepository: context.read(),
);
return HomeScreen(viewModel: viewModel);
},
routes: [
GoRoute(
path: Routes.login,
path: Routes.searchRelative,
builder: (context, state) {
return LoginScreen(
viewModel: LoginViewModel(
authRepository: context.read(),
),
final viewModel = SearchFormViewModel(
continentRepository: context.read(),
itineraryConfigRepository: context.read(),
);
return SearchFormScreen(viewModel: viewModel);
},
),
GoRoute(
path: Routes.home,
path: Routes.resultsRelative,
builder: (context, state) {
final viewModel = HomeViewModel(
bookingRepository: context.read(),
userRepository: context.read(),
final viewModel = ResultsViewModel(
destinationRepository: context.read(),
itineraryConfigRepository: context.read(),
);
return HomeScreen(viewModel: viewModel);
return ResultsScreen(viewModel: viewModel);
},
),
GoRoute(
path: Routes.activitiesRelative,
builder: (context, state) {
final viewModel = ActivitiesViewModel(
activityRepository: context.read(),
itineraryConfigRepository: context.read(),
);
return ActivitiesScreen(viewModel: viewModel);
},
),
GoRoute(
path: Routes.bookingRelative,
builder: (context, state) {
final viewModel = BookingViewModel(
itineraryConfigRepository: context.read(),
createBookingUseCase: context.read(),
shareBookingUseCase: context.read(),
bookingRepository: context.read(),
);
// When opening the booking screen directly
// create a new booking from the stored ItineraryConfig.
viewModel.createBooking.execute();
return BookingScreen(viewModel: viewModel);
},
routes: [
GoRoute(
path: Routes.searchRelative,
builder: (context, state) {
final viewModel = SearchFormViewModel(
continentRepository: context.read(),
itineraryConfigRepository: context.read(),
);
return SearchFormScreen(viewModel: viewModel);
},
),
GoRoute(
path: Routes.resultsRelative,
builder: (context, state) {
final viewModel = ResultsViewModel(
destinationRepository: context.read(),
itineraryConfigRepository: context.read(),
);
return ResultsScreen(
viewModel: viewModel,
);
},
),
GoRoute(
path: Routes.activitiesRelative,
builder: (context, state) {
final viewModel = ActivitiesViewModel(
activityRepository: context.read(),
itineraryConfigRepository: context.read(),
);
return ActivitiesScreen(
viewModel: viewModel,
);
},
),
GoRoute(
path: Routes.bookingRelative,
path: ':id',
builder: (context, state) {
final id = int.parse(state.pathParameters['id']!);
final viewModel = BookingViewModel(
itineraryConfigRepository: context.read(),
createBookingUseCase: context.read(),
@@ -98,41 +107,19 @@ GoRouter router(
bookingRepository: context.read(),
);
// When opening the booking screen directly
// create a new booking from the stored ItineraryConfig.
viewModel.createBooking.execute();
// When opening the booking screen with an existing id
// load and display that booking.
viewModel.loadBooking.execute(id);
return BookingScreen(
viewModel: viewModel,
);
return BookingScreen(viewModel: viewModel);
},
routes: [
GoRoute(
path: ':id',
builder: (context, state) {
final id = int.parse(state.pathParameters['id']!);
final viewModel = BookingViewModel(
itineraryConfigRepository: context.read(),
createBookingUseCase: context.read(),
shareBookingUseCase: context.read(),
bookingRepository: context.read(),
);
// When opening the booking screen with an existing id
// load and display that booking.
viewModel.loadBooking.execute(id);
return BookingScreen(
viewModel: viewModel,
);
},
),
],
),
],
),
],
);
),
],
);
// From https://github.com/flutter/packages/blob/main/packages/go_router/example/lib/redirection.dart
Future<String?> _redirect(BuildContext context, GoRouterState state) async {

View File

@@ -16,8 +16,8 @@ class ActivitiesViewModel extends ChangeNotifier {
ActivitiesViewModel({
required ActivityRepository activityRepository,
required ItineraryConfigRepository itineraryConfigRepository,
}) : _activityRepository = activityRepository,
_itineraryConfigRepository = itineraryConfigRepository {
}) : _activityRepository = activityRepository,
_itineraryConfigRepository = itineraryConfigRepository {
loadActivities = Command0(_loadActivities)..execute();
saveActivities = Command0(_saveActivities);
}
@@ -48,10 +48,7 @@ class ActivitiesViewModel extends ChangeNotifier {
final result = await _itineraryConfigRepository.getItineraryConfig();
switch (result) {
case Error<ItineraryConfig>():
_log.warning(
'Failed to load stored ItineraryConfig',
result.error,
);
_log.warning('Failed to load stored ItineraryConfig', result.error);
return result;
case Ok<ItineraryConfig>():
}
@@ -64,28 +61,37 @@ class ActivitiesViewModel extends ChangeNotifier {
_selectedActivities.addAll(result.value.activities);
final resultActivities =
await _activityRepository.getByDestination(destinationRef);
final resultActivities = await _activityRepository.getByDestination(
destinationRef,
);
switch (resultActivities) {
case Ok():
{
_daytimeActivities = resultActivities.value
.where((activity) => [
TimeOfDay.any,
TimeOfDay.morning,
TimeOfDay.afternoon,
].contains(activity.timeOfDay))
.toList();
_daytimeActivities =
resultActivities.value
.where(
(activity) => [
TimeOfDay.any,
TimeOfDay.morning,
TimeOfDay.afternoon,
].contains(activity.timeOfDay),
)
.toList();
_eveningActivities = resultActivities.value
.where((activity) => [
TimeOfDay.evening,
TimeOfDay.night,
].contains(activity.timeOfDay))
.toList();
_eveningActivities =
resultActivities.value
.where(
(activity) => [
TimeOfDay.evening,
TimeOfDay.night,
].contains(activity.timeOfDay),
)
.toList();
_log.fine('Activities (daytime: ${_daytimeActivities.length}, '
'evening: ${_eveningActivities.length}) loaded');
_log.fine(
'Activities (daytime: ${_daytimeActivities.length}, '
'evening: ${_eveningActivities.length}) loaded',
);
}
case Error():
{
@@ -100,8 +106,9 @@ class ActivitiesViewModel extends ChangeNotifier {
/// Add [Activity] to selected list.
void addActivity(String activityRef) {
assert(
(_daytimeActivities + _eveningActivities)
.any((activity) => activity.ref == activityRef),
(_daytimeActivities + _eveningActivities).any(
(activity) => activity.ref == activityRef,
),
"Activity $activityRef not found",
);
_selectedActivities.add(activityRef);
@@ -112,8 +119,9 @@ class ActivitiesViewModel extends ChangeNotifier {
/// Remove [Activity] from selected list.
void removeActivity(String activityRef) {
assert(
(_daytimeActivities + _eveningActivities)
.any((activity) => activity.ref == activityRef),
(_daytimeActivities + _eveningActivities).any(
(activity) => activity.ref == activityRef,
),
"Activity $activityRef not found",
);
_selectedActivities.remove(activityRef);
@@ -135,12 +143,10 @@ class ActivitiesViewModel extends ChangeNotifier {
final itineraryConfig = resultConfig.value;
final result = await _itineraryConfigRepository.setItineraryConfig(
itineraryConfig.copyWith(activities: _selectedActivities.toList()));
itineraryConfig.copyWith(activities: _selectedActivities.toList()),
);
if (result is Error) {
_log.warning(
'Failed to store ItineraryConfig',
result.error,
);
_log.warning('Failed to store ItineraryConfig', result.error);
}
return result;
}

View File

@@ -33,28 +33,24 @@ class ActivitiesList extends StatelessWidget {
bottom: Dimens.paddingVertical,
),
sliver: SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
final activity = list[index];
return Padding(
padding:
EdgeInsets.only(bottom: index < list.length - 1 ? 20 : 0),
child: ActivityEntry(
key: ValueKey(activity.ref),
activity: activity,
selected: viewModel.selectedActivities.contains(activity.ref),
onChanged: (value) {
if (value!) {
viewModel.addActivity(activity.ref);
} else {
viewModel.removeActivity(activity.ref);
}
},
),
);
},
childCount: list.length,
),
delegate: SliverChildBuilderDelegate((context, index) {
final activity = list[index];
return Padding(
padding: EdgeInsets.only(bottom: index < list.length - 1 ? 20 : 0),
child: ActivityEntry(
key: ValueKey(activity.ref),
activity: activity,
selected: viewModel.selectedActivities.contains(activity.ref),
onChanged: (value) {
if (value!) {
viewModel.addActivity(activity.ref);
} else {
viewModel.removeActivity(activity.ref);
}
},
),
);
}, childCount: list.length),
),
);
}

View File

@@ -18,10 +18,7 @@ import 'activity_time_of_day.dart';
const String confirmButtonKey = 'confirm-button';
class ActivitiesScreen extends StatefulWidget {
const ActivitiesScreen({
super.key,
required this.viewModel,
});
const ActivitiesScreen({super.key, required this.viewModel});
final ActivitiesViewModel viewModel;
@@ -68,13 +65,16 @@ class _ActivitiesScreenState extends State<ActivitiesScreen> {
const ActivitiesHeader(),
if (widget.viewModel.loadActivities.running)
const Expanded(
child: Center(child: CircularProgressIndicator())),
child: Center(child: CircularProgressIndicator()),
),
if (widget.viewModel.loadActivities.error)
Expanded(
child: Center(
child: ErrorIndicator(
title: AppLocalization.of(context)
.errorWhileLoadingActivities,
title:
AppLocalization.of(
context,
).errorWhileLoadingActivities,
label: AppLocalization.of(context).tryAgain,
onPressed: widget.viewModel.loadActivities.execute,
),
@@ -91,9 +91,7 @@ class _ActivitiesScreenState extends State<ActivitiesScreen> {
Expanded(
child: CustomScrollView(
slivers: [
const SliverToBoxAdapter(
child: ActivitiesHeader(),
),
const SliverToBoxAdapter(child: ActivitiesHeader()),
ActivitiesTitle(
viewModel: widget.viewModel,
activityTimeOfDay: ActivityTimeOfDay.daytime,
@@ -145,9 +143,7 @@ class _ActivitiesScreenState extends State<ActivitiesScreen> {
}
class _BottomArea extends StatelessWidget {
const _BottomArea({
required this.viewModel,
});
const _BottomArea({required this.viewModel});
final ActivitiesViewModel viewModel;
@@ -168,15 +164,17 @@ class _BottomArea extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
AppLocalization.of(context)
.selected(viewModel.selectedActivities.length),
AppLocalization.of(
context,
).selected(viewModel.selectedActivities.length),
style: Theme.of(context).textTheme.labelLarge,
),
FilledButton(
key: const Key(confirmButtonKey),
onPressed: viewModel.selectedActivities.isNotEmpty
? viewModel.saveActivities.execute
: null,
onPressed:
viewModel.selectedActivities.isNotEmpty
? viewModel.saveActivities.execute
: null,
child: Text(AppLocalization.of(context).confirm),
),
],

View File

@@ -37,7 +37,7 @@ class ActivitiesTitle extends StatelessWidget {
}
String _label(BuildContext context) => switch (activityTimeOfDay) {
ActivityTimeOfDay.daytime => AppLocalization.of(context).daytime,
ActivityTimeOfDay.evening => AppLocalization.of(context).evening,
};
ActivityTimeOfDay.daytime => AppLocalization.of(context).daytime,
ActivityTimeOfDay.evening => AppLocalization.of(context).evening,
};
}

View File

@@ -60,7 +60,7 @@ class ActivityEntry extends StatelessWidget {
key: ValueKey('${activity.ref}-checkbox'),
value: selected,
onChanged: onChanged,
)
),
],
),
);

View File

@@ -9,9 +9,8 @@ import '../../../../utils/command.dart';
import '../../../../utils/result.dart';
class LoginViewModel {
LoginViewModel({
required AuthRepository authRepository,
}) : _authRepository = authRepository {
LoginViewModel({required AuthRepository authRepository})
: _authRepository = authRepository {
login = Command1<void, (String email, String password)>(_login);
}

View File

@@ -12,10 +12,7 @@ import '../view_models/login_viewmodel.dart';
import 'tilted_cards.dart';
class LoginScreen extends StatefulWidget {
const LoginScreen({
super.key,
required this.viewModel,
});
const LoginScreen({super.key, required this.viewModel});
final LoginViewModel viewModel;
@@ -24,10 +21,12 @@ class LoginScreen extends StatefulWidget {
}
class _LoginScreenState extends State<LoginScreen> {
final TextEditingController _email =
TextEditingController(text: 'email@example.com');
final TextEditingController _password =
TextEditingController(text: 'password');
final TextEditingController _email = TextEditingController(
text: 'email@example.com',
);
final TextEditingController _password = TextEditingController(
text: 'password',
);
@override
void initState() {
@@ -61,22 +60,19 @@ class _LoginScreenState extends State<LoginScreen> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
TextField(
controller: _email,
),
TextField(controller: _email),
const SizedBox(height: Dimens.paddingVertical),
TextField(
controller: _password,
obscureText: true,
),
TextField(controller: _password, obscureText: true),
const SizedBox(height: Dimens.paddingVertical),
ListenableBuilder(
listenable: widget.viewModel.login,
builder: (context, _) {
return FilledButton(
onPressed: () {
widget.viewModel.login
.execute((_email.value.text, _password.value.text));
widget.viewModel.login.execute((
_email.value.text,
_password.value.text,
));
},
child: Text(AppLocalization.of(context).login),
);
@@ -103,8 +99,11 @@ class _LoginScreenState extends State<LoginScreen> {
content: Text(AppLocalization.of(context).errorWhileLogin),
action: SnackBarAction(
label: AppLocalization.of(context).tryAgain,
onPressed: () => widget.viewModel.login
.execute((_email.value.text, _password.value.text)),
onPressed:
() => widget.viewModel.login.execute((
_email.value.text,
_password.value.text,
)),
),
),
);

View File

@@ -12,8 +12,8 @@ class LogoutViewModel {
LogoutViewModel({
required AuthRepository authRepository,
required ItineraryConfigRepository itineraryConfigRepository,
}) : _authLogoutRepository = authRepository,
_itineraryConfigRepository = itineraryConfigRepository {
}) : _authLogoutRepository = authRepository,
_itineraryConfigRepository = itineraryConfigRepository {
logout = Command0(_logout);
}
final AuthRepository _authLogoutRepository;
@@ -25,8 +25,9 @@ class LogoutViewModel {
switch (result) {
case Ok<void>():
// clear stored itinerary config
return _itineraryConfigRepository
.setItineraryConfig(const ItineraryConfig());
return _itineraryConfigRepository.setItineraryConfig(
const ItineraryConfig(),
);
case Error<void>():
return result;
}

View File

@@ -9,10 +9,7 @@ import '../../../core/themes/colors.dart';
import '../view_models/logout_viewmodel.dart';
class LogoutButton extends StatefulWidget {
const LogoutButton({
super.key,
required this.viewModel,
});
const LogoutButton({super.key, required this.viewModel});
final LogoutViewModel viewModel;

View File

@@ -20,10 +20,10 @@ class BookingViewModel extends ChangeNotifier {
required BookingShareUseCase shareBookingUseCase,
required ItineraryConfigRepository itineraryConfigRepository,
required BookingRepository bookingRepository,
}) : _createUseCase = createBookingUseCase,
_shareUseCase = shareBookingUseCase,
_itineraryConfigRepository = itineraryConfigRepository,
_bookingRepository = bookingRepository {
}) : _createUseCase = createBookingUseCase,
_shareUseCase = shareBookingUseCase,
_itineraryConfigRepository = itineraryConfigRepository,
_bookingRepository = bookingRepository {
createBooking = Command0(_createBooking);
shareBooking = Command0(() => _shareUseCase.shareBooking(_booking!));
loadBooking = Command1(_load);

View File

@@ -12,10 +12,7 @@ import '../view_models/booking_viewmodel.dart';
import 'booking_header.dart';
class BookingBody extends StatelessWidget {
const BookingBody({
super.key,
required this.viewModel,
});
const BookingBody({super.key, required this.viewModel});
final BookingViewModel viewModel;
@@ -30,13 +27,10 @@ class BookingBody extends StatelessWidget {
slivers: [
SliverToBoxAdapter(child: BookingHeader(booking: booking)),
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
final activity = booking.activity[index];
return _Activity(activity: activity);
},
childCount: booking.activity.length,
),
delegate: SliverChildBuilderDelegate((context, index) {
final activity = booking.activity[index];
return _Activity(activity: activity);
}, childCount: booking.activity.length),
),
const SliverToBoxAdapter(child: SizedBox(height: 200)),
],
@@ -47,9 +41,7 @@ class BookingBody extends StatelessWidget {
}
class _Activity extends StatelessWidget {
const _Activity({
required this.activity,
});
const _Activity({required this.activity});
final Activity activity;

View File

@@ -15,10 +15,7 @@ import '../../core/ui/home_button.dart';
import '../../core/ui/tag_chip.dart';
class BookingHeader extends StatelessWidget {
const BookingHeader({
super.key,
required this.booking,
});
const BookingHeader({super.key, required this.booking});
final Booking booking;
@@ -51,9 +48,7 @@ class BookingHeader extends StatelessWidget {
}
class _Top extends StatelessWidget {
const _Top({
required this.booking,
});
const _Top({required this.booking});
final Booking booking;
@@ -70,10 +65,7 @@ class _Top extends StatelessWidget {
Positioned(
right: Dimens.of(context).paddingScreenHorizontal,
top: Dimens.of(context).paddingScreenVertical,
child: const SafeArea(
top: true,
child: HomeButton(blur: true),
),
child: const SafeArea(top: true, child: HomeButton(blur: true)),
),
],
),
@@ -82,9 +74,7 @@ class _Top extends StatelessWidget {
}
class _Tags extends StatelessWidget {
const _Tags({
required this.booking,
});
const _Tags({required this.booking});
final Booking booking;
@@ -100,26 +90,25 @@ class _Tags extends StatelessWidget {
child: Wrap(
spacing: 6,
runSpacing: 6,
children: booking.destination.tags
.map(
(tag) => TagChip(
tag: tag,
fontSize: 16,
height: 32,
chipColor: chipColor,
onChipColor: Theme.of(context).colorScheme.onSurface,
),
)
.toList(),
children:
booking.destination.tags
.map(
(tag) => TagChip(
tag: tag,
fontSize: 16,
height: 32,
chipColor: chipColor,
onChipColor: Theme.of(context).colorScheme.onSurface,
),
)
.toList(),
),
);
}
}
class _Headline extends StatelessWidget {
const _Headline({
required this.booking,
});
const _Headline({required this.booking});
final Booking booking;
@@ -139,10 +128,7 @@ class _Headline extends StatelessWidget {
),
Text(
dateFormatStartEnd(
DateTimeRange(
start: booking.startDate,
end: booking.endDate,
),
DateTimeRange(start: booking.startDate, end: booking.endDate),
),
style: Theme.of(context).textTheme.headlineSmall,
),
@@ -154,9 +140,7 @@ class _Headline extends StatelessWidget {
}
class _HeaderImage extends StatelessWidget {
const _HeaderImage({
required this.booking,
});
const _HeaderImage({required this.booking});
final Booking booking;
@@ -180,10 +164,7 @@ class _Gradient extends StatelessWidget {
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.transparent,
Theme.of(context).colorScheme.surface,
],
colors: [Colors.transparent, Theme.of(context).colorScheme.surface],
),
),
);

View File

@@ -12,10 +12,7 @@ import '../view_models/booking_viewmodel.dart';
import 'booking_body.dart';
class BookingScreen extends StatefulWidget {
const BookingScreen({
super.key,
required this.viewModel,
});
const BookingScreen({super.key, required this.viewModel});
final BookingViewModel viewModel;
@@ -47,16 +44,18 @@ class _BookingScreenState extends State<BookingScreen> {
child: Scaffold(
floatingActionButton: ListenableBuilder(
listenable: widget.viewModel,
builder: (context, _) => FloatingActionButton.extended(
// Workaround for https://github.com/flutter/flutter/issues/115358#issuecomment-2117157419
heroTag: null,
key: const ValueKey('share-button'),
onPressed: widget.viewModel.booking != null
? widget.viewModel.shareBooking.execute
: null,
label: Text(AppLocalization.of(context).shareTrip),
icon: const Icon(Icons.share_outlined),
),
builder:
(context, _) => FloatingActionButton.extended(
// Workaround for https://github.com/flutter/flutter/issues/115358#issuecomment-2117157419
heroTag: null,
key: const ValueKey('share-button'),
onPressed:
widget.viewModel.booking != null
? widget.viewModel.shareBooking.execute
: null,
label: Text(AppLocalization.of(context).shareTrip),
icon: const Icon(Icons.share_outlined),
),
),
body: ListenableBuilder(
// Listen to changes in both commands
@@ -68,9 +67,7 @@ class _BookingScreenState extends State<BookingScreen> {
// If either command is running, show progress indicator
if (widget.viewModel.createBooking.running ||
widget.viewModel.loadBooking.running) {
return const Center(
child: CircularProgressIndicator(),
);
return const Center(child: CircularProgressIndicator());
}
// If fails to create booking, tap to try again
if (widget.viewModel.createBooking.error) {
@@ -103,13 +100,15 @@ class _BookingScreenState extends State<BookingScreen> {
void _listener() {
if (widget.viewModel.shareBooking.error) {
widget.viewModel.shareBooking.clearResult();
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(AppLocalization.of(context).errorWhileSharing),
action: SnackBarAction(
label: AppLocalization.of(context).tryAgain,
onPressed: widget.viewModel.shareBooking.execute,
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(AppLocalization.of(context).errorWhileSharing),
action: SnackBarAction(
label: AppLocalization.of(context).tryAgain,
onPressed: widget.viewModel.shareBooking.execute,
),
),
));
);
}
}
}

View File

@@ -5,8 +5,6 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
/// Simple Localizations similar to
/// https://docs.flutter.dev/ui/accessibility-and-internationalization/internationalization#an-alternative-class-for-the-apps-localized-resources
class AppLocalization {
static AppLocalization of(BuildContext context) {
return Localizations.of(context, AppLocalization);

View File

@@ -10,8 +10,9 @@ abstract final class AppColors {
static const grey1 = Color(0xFFF2F2F2);
static const grey2 = Color(0xFF4D4D4D);
static const grey3 = Color(0xFFA4A4A4);
static const whiteTransparent =
Color(0x4DFFFFFF); // Figma rgba(255, 255, 255, 0.3)
static const whiteTransparent = Color(
0x4DFFFFFF,
); // Figma rgba(255, 255, 255, 0.3)
static const blackTransparent = Color(0x4D000000);
static const red1 = Color(0xFFE74C3C);

View File

@@ -27,17 +27,20 @@ abstract final class Dimens {
/// Symmetric padding for screen edges
EdgeInsets get edgeInsetsScreenSymmetric => EdgeInsets.symmetric(
horizontal: paddingScreenHorizontal, vertical: paddingScreenVertical);
horizontal: paddingScreenHorizontal,
vertical: paddingScreenVertical,
);
static const Dimens desktop = _DimensDesktop();
static const Dimens mobile = _DimensMobile();
/// Get dimensions definition based on screen size
factory Dimens.of(BuildContext context) =>
switch (MediaQuery.sizeOf(context).width) {
> 600 => desktop,
_ => mobile,
};
factory Dimens.of(BuildContext context) => switch (MediaQuery.sizeOf(
context,
).width) {
> 600 && < 840 => desktop,
_ => mobile,
};
}
/// Mobile dimensions

View File

@@ -9,26 +9,11 @@ import 'colors.dart';
abstract final class AppTheme {
static const _textTheme = TextTheme(
headlineLarge: TextStyle(
fontSize: 32,
fontWeight: FontWeight.w500,
),
headlineSmall: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w400,
),
titleMedium: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w500,
),
bodyLarge: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w400,
),
bodyMedium: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
),
headlineLarge: TextStyle(fontSize: 32, fontWeight: FontWeight.w500),
headlineSmall: TextStyle(fontSize: 18, fontWeight: FontWeight.w400),
titleMedium: TextStyle(fontSize: 18, fontWeight: FontWeight.w500),
bodyLarge: TextStyle(fontSize: 18, fontWeight: FontWeight.w400),
bodyMedium: TextStyle(fontSize: 16, fontWeight: FontWeight.w400),
bodySmall: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w400,

View File

@@ -10,11 +10,7 @@ import 'blur_filter.dart';
/// Custom back button to pop navigation.
class CustomBackButton extends StatelessWidget {
const CustomBackButton({
super.key,
this.onTap,
this.blur = false,
});
const CustomBackButton({super.key, this.onTap, this.blur = false});
final bool blur;
final GestureTapCallback? onTap;

View File

@@ -28,9 +28,10 @@ class CustomCheckbox extends StatelessWidget {
),
child: Material(
borderRadius: BorderRadius.circular(24),
color: value
? Theme.of(context).colorScheme.primary
: Colors.transparent,
color:
value
? Theme.of(context).colorScheme.primary
: Colors.transparent,
child: SizedBox(
width: 24,
height: 24,

View File

@@ -46,9 +46,7 @@ class ErrorIndicator extends StatelessWidget {
),
),
),
const SizedBox(
height: 10,
),
const SizedBox(height: 10),
FilledButton(
onPressed: onPressed,
style: const ButtonStyle(

View File

@@ -11,10 +11,7 @@ import 'blur_filter.dart';
/// Home button to navigate back to the '/' path.
class HomeButton extends StatelessWidget {
const HomeButton({
super.key,
this.blur = false,
});
const HomeButton({super.key, this.blur = false});
final bool blur;

View File

@@ -10,8 +10,8 @@ import 'package:flutter/material.dart';
class AppCustomScrollBehavior extends MaterialScrollBehavior {
@override
Set<PointerDeviceKind> get dragDevices => {
PointerDeviceKind.touch,
// Allow to drag with mouse on Regions carousel
PointerDeviceKind.mouse,
};
PointerDeviceKind.touch,
// Allow to drag with mouse on Regions carousel
PointerDeviceKind.mouse,
};
}

View File

@@ -16,11 +16,7 @@ import 'home_button.dart';
/// Displays a search bar with the current configuration.
/// Includes [HomeButton] to navigate back to the '/' path.
class AppSearchBar extends StatelessWidget {
const AppSearchBar({
super.key,
this.config,
this.onTap,
});
const AppSearchBar({super.key, this.config, this.onTap});
final ItineraryConfig? config;
final GestureTapCallback? onTap;
@@ -59,9 +55,7 @@ class AppSearchBar extends StatelessWidget {
}
class _QueryText extends StatelessWidget {
const _QueryText({
required this.config,
});
const _QueryText({required this.config});
final ItineraryConfig? config;

View File

@@ -34,7 +34,8 @@ class TagChip extends StatelessWidget {
filter: ImageFilter.blur(sigmaX: 3, sigmaY: 3),
child: DecoratedBox(
decoration: BoxDecoration(
color: chipColor ??
color:
chipColor ??
Theme.of(context).extension<TagChipTheme>()?.chipColor ??
AppColors.whiteTransparent,
),
@@ -48,10 +49,11 @@ class TagChip extends StatelessWidget {
children: [
Icon(
_iconFrom(tag),
color: onChipColor ??
Theme.of(context)
.extension<TagChipTheme>()
?.onChipColor ??
color:
onChipColor ??
Theme.of(
context,
).extension<TagChipTheme>()?.onChipColor ??
Colors.white,
size: fontSize,
),
@@ -98,25 +100,23 @@ class TagChip extends StatelessWidget {
// Note: original Figma file uses Google Sans
// which is not available on GoogleFonts
TextStyle _textStyle(BuildContext context) => GoogleFonts.openSans(
textStyle: TextStyle(
fontWeight: FontWeight.w500,
fontSize: fontSize,
color: onChipColor ??
Theme.of(context).extension<TagChipTheme>()?.onChipColor ??
Colors.white,
textBaseline: TextBaseline.alphabetic,
),
);
textStyle: TextStyle(
fontWeight: FontWeight.w500,
fontSize: fontSize,
color:
onChipColor ??
Theme.of(context).extension<TagChipTheme>()?.onChipColor ??
Colors.white,
textBaseline: TextBaseline.alphabetic,
),
);
}
class TagChipTheme extends ThemeExtension<TagChipTheme> {
final Color chipColor;
final Color onChipColor;
TagChipTheme({
required this.chipColor,
required this.onChipColor,
});
TagChipTheme({required this.chipColor, required this.onChipColor});
@override
ThemeExtension<TagChipTheme> copyWith({

View File

@@ -18,8 +18,8 @@ class HomeViewModel extends ChangeNotifier {
HomeViewModel({
required BookingRepository bookingRepository,
required UserRepository userRepository,
}) : _bookingRepository = bookingRepository,
_userRepository = userRepository {
}) : _bookingRepository = bookingRepository,
_userRepository = userRepository {
load = Command0(_load)..execute();
deleteBooking = Command1(_deleteBooking);
}

View File

@@ -18,10 +18,7 @@ import 'home_title.dart';
const String bookingButtonKey = 'booking-button';
class HomeScreen extends StatefulWidget {
const HomeScreen({
super.key,
required this.viewModel,
});
const HomeScreen({super.key, required this.viewModel});
final HomeViewModel viewModel;
@@ -67,9 +64,7 @@ class _HomeScreenState extends State<HomeScreen> {
listenable: widget.viewModel.load,
builder: (context, child) {
if (widget.viewModel.load.running) {
return const Center(
child: CircularProgressIndicator(),
);
return const Center(child: CircularProgressIndicator());
}
if (widget.viewModel.load.error) {
@@ -98,27 +93,32 @@ class _HomeScreenState extends State<HomeScreen> {
),
SliverList.builder(
itemCount: widget.viewModel.bookings.length,
itemBuilder: (_, index) => _Booking(
key: ValueKey(widget.viewModel.bookings[index].id),
booking: widget.viewModel.bookings[index],
onTap: () => context.push(Routes.bookingWithId(
widget.viewModel.bookings[index].id)),
confirmDismiss: (_) async {
// wait for command to complete
await widget.viewModel.deleteBooking.execute(
widget.viewModel.bookings[index].id,
);
// if command completed successfully, return true
if (widget.viewModel.deleteBooking.completed) {
// removes the dismissable from the list
return true;
} else {
// the dismissable stays in the list
return false;
}
},
),
)
itemBuilder:
(_, index) => _Booking(
key: ValueKey(widget.viewModel.bookings[index].id),
booking: widget.viewModel.bookings[index],
onTap:
() => context.push(
Routes.bookingWithId(
widget.viewModel.bookings[index].id,
),
),
confirmDismiss: (_) async {
// wait for command to complete
await widget.viewModel.deleteBooking.execute(
widget.viewModel.bookings[index].id,
);
// if command completed successfully, return true
if (widget.viewModel.deleteBooking.completed) {
// removes the dismissable from the list
return true;
} else {
// the dismissable stays in the list
return false;
}
},
),
),
],
);
},
@@ -132,9 +132,7 @@ class _HomeScreenState extends State<HomeScreen> {
if (widget.viewModel.deleteBooking.completed) {
widget.viewModel.deleteBooking.clearResult();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(AppLocalization.of(context).bookingDeleted),
),
SnackBar(content: Text(AppLocalization.of(context).bookingDeleted)),
);
}
@@ -189,16 +187,10 @@ class _Booking extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
booking.name,
style: Theme.of(context).textTheme.titleLarge,
),
Text(booking.name, style: Theme.of(context).textTheme.titleLarge),
Text(
dateFormatStartEnd(
DateTimeRange(
start: booking.startDate,
end: booking.endDate,
),
DateTimeRange(start: booking.startDate, end: booking.endDate),
),
style: Theme.of(context).textTheme.bodyLarge,
),

View File

@@ -13,10 +13,7 @@ import '../../core/themes/dimens.dart';
import '../view_models/home_viewmodel.dart';
class HomeHeader extends StatelessWidget {
const HomeHeader({
super.key,
required this.viewModel,
});
const HomeHeader({super.key, required this.viewModel});
final HomeViewModel viewModel;
@@ -49,18 +46,14 @@ class HomeHeader extends StatelessWidget {
],
),
const SizedBox(height: Dimens.paddingVertical),
_Title(
text: AppLocalization.of(context).nameTrips(user.name),
),
_Title(text: AppLocalization.of(context).nameTrips(user.name)),
],
);
}
}
class _Title extends StatelessWidget {
const _Title({
required this.text,
});
const _Title({required this.text});
final String text;
@@ -68,16 +61,12 @@ class _Title extends StatelessWidget {
Widget build(BuildContext context) {
return ShaderMask(
blendMode: BlendMode.srcIn,
shaderCallback: (bounds) => RadialGradient(
center: Alignment.bottomLeft,
radius: 2,
colors: [
Colors.purple.shade700,
Colors.purple.shade400,
],
).createShader(
Rect.fromLTWH(0, 0, bounds.width, bounds.height),
),
shaderCallback:
(bounds) => RadialGradient(
center: Alignment.bottomLeft,
radius: 2,
colors: [Colors.purple.shade700, Colors.purple.shade400],
).createShader(Rect.fromLTWH(0, 0, bounds.width, bounds.height)),
child: Text(
text,
style: GoogleFonts.rubik(

View File

@@ -18,8 +18,8 @@ class ResultsViewModel extends ChangeNotifier {
ResultsViewModel({
required DestinationRepository destinationRepository,
required ItineraryConfigRepository itineraryConfigRepository,
}) : _destinationRepository = destinationRepository,
_itineraryConfigRepository = itineraryConfigRepository {
}) : _destinationRepository = destinationRepository,
_itineraryConfigRepository = itineraryConfigRepository {
updateItineraryConfig = Command1<void, String>(_updateItineraryConfig);
search = Command0(_search)..execute();
}
@@ -67,10 +67,13 @@ class ResultsViewModel extends ChangeNotifier {
case Ok():
{
// If the result is Ok, update the list of destinations
_destinations = result.value
.where((destination) =>
destination.continent == _itineraryConfig!.continent)
.toList();
_destinations =
result.value
.where(
(destination) =>
destination.continent == _itineraryConfig!.continent,
)
.toList();
_log.fine('Destinations (${_destinations.length}) loaded');
}
case Error():
@@ -99,16 +102,11 @@ class ResultsViewModel extends ChangeNotifier {
}
final itineraryConfig = resultConfig.value;
final result = await _itineraryConfigRepository
.setItineraryConfig(itineraryConfig.copyWith(
destination: destinationRef,
activities: [],
));
final result = await _itineraryConfigRepository.setItineraryConfig(
itineraryConfig.copyWith(destination: destinationRef, activities: []),
);
if (result is Error) {
_log.warning(
'Failed to store ItineraryConfig',
result.error,
);
_log.warning('Failed to store ItineraryConfig', result.error);
}
return result;
}

View File

@@ -10,11 +10,7 @@ import '../../../utils/image_error_listener.dart';
import '../../core/ui/tag_chip.dart';
class ResultCard extends StatelessWidget {
const ResultCard({
super.key,
required this.destination,
required this.onTap,
});
const ResultCard({super.key, required this.destination, required this.onTap});
final Destination destination;
final GestureTapCallback onTap;
@@ -40,13 +36,8 @@ class ResultCard extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
destination.name.toUpperCase(),
style: _cardTitleStyle,
),
const SizedBox(
height: 6,
),
Text(destination.name.toUpperCase(), style: _cardTitleStyle),
const SizedBox(height: 6),
Wrap(
spacing: 4.0,
runSpacing: 4.0,
@@ -61,9 +52,7 @@ class ResultCard extends StatelessWidget {
Positioned.fill(
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: onTap,
),
child: InkWell(onTap: onTap),
),
),
],
@@ -80,10 +69,7 @@ final _cardTitleStyle = GoogleFonts.rubik(
letterSpacing: 1,
shadows: [
// Helps to read the text a bit better
Shadow(
blurRadius: 3.0,
color: Colors.black,
)
Shadow(blurRadius: 3.0, color: Colors.black),
],
),
);

View File

@@ -14,10 +14,7 @@ import '../view_models/results_viewmodel.dart';
import 'result_card.dart';
class ResultsScreen extends StatefulWidget {
const ResultsScreen({
super.key,
required this.viewModel,
});
const ResultsScreen({super.key, required this.viewModel});
final ResultsViewModel viewModel;
@@ -64,13 +61,16 @@ class _ResultsScreenState extends State<ResultsScreen> {
_AppSearchBar(widget: widget),
if (widget.viewModel.search.running)
const Expanded(
child: Center(child: CircularProgressIndicator())),
child: Center(child: CircularProgressIndicator()),
),
if (widget.viewModel.search.error)
Expanded(
child: Center(
child: ErrorIndicator(
title: AppLocalization.of(context)
.errorWhileLoadingDestinations,
title:
AppLocalization.of(
context,
).errorWhileLoadingDestinations,
label: AppLocalization.of(context).tryAgain,
onPressed: widget.viewModel.search.execute,
),
@@ -86,9 +86,7 @@ class _ResultsScreenState extends State<ResultsScreen> {
padding: Dimens.of(context).edgeInsetsScreenHorizontal,
child: CustomScrollView(
slivers: [
SliverToBoxAdapter(
child: _AppSearchBar(widget: widget),
),
SliverToBoxAdapter(child: _AppSearchBar(widget: widget)),
_Grid(viewModel: widget.viewModel),
],
),
@@ -118,9 +116,7 @@ class _ResultsScreenState extends State<ResultsScreen> {
}
class _AppSearchBar extends StatelessWidget {
const _AppSearchBar({
required this.widget,
});
const _AppSearchBar({required this.widget});
final ResultsScreen widget;
@@ -147,9 +143,7 @@ class _AppSearchBar extends StatelessWidget {
}
class _Grid extends StatelessWidget {
const _Grid({
required this.viewModel,
});
const _Grid({required this.viewModel});
final ResultsViewModel viewModel;
@@ -162,19 +156,16 @@ class _Grid extends StatelessWidget {
mainAxisSpacing: 8.0,
childAspectRatio: 182 / 222,
),
delegate: SliverChildBuilderDelegate(
(context, index) {
final destination = viewModel.destinations[index];
return ResultCard(
key: ValueKey(destination.ref),
destination: destination,
onTap: () {
viewModel.updateItineraryConfig.execute(destination.ref);
},
);
},
childCount: viewModel.destinations.length,
),
delegate: SliverChildBuilderDelegate((context, index) {
final destination = viewModel.destinations[index];
return ResultCard(
key: ValueKey(destination.ref),
destination: destination,
onTap: () {
viewModel.updateItineraryConfig.execute(destination.ref);
},
);
}, childCount: viewModel.destinations.length),
);
}
}

View File

@@ -20,8 +20,8 @@ class SearchFormViewModel extends ChangeNotifier {
SearchFormViewModel({
required ContinentRepository continentRepository,
required ItineraryConfigRepository itineraryConfigRepository,
}) : _continentRepository = continentRepository,
_itineraryConfigRepository = itineraryConfigRepository {
}) : _continentRepository = continentRepository,
_itineraryConfigRepository = itineraryConfigRepository {
updateItineraryConfig = Command0(_updateItineraryConfig);
load = Command0(_load)..execute();
}
@@ -125,10 +125,7 @@ class SearchFormViewModel extends ChangeNotifier {
_log.fine('ItineraryConfig loaded');
notifyListeners();
case Error<ItineraryConfig>():
_log.warning(
'Failed to load stored ItineraryConfig',
result.error,
);
_log.warning('Failed to load stored ItineraryConfig', result.error);
}
return result;
}

View File

@@ -20,10 +20,7 @@ import '../view_models/search_form_viewmodel.dart';
/// Users can tap one item to select it.
/// Tapping again the same item will deselect it.
class SearchFormContinent extends StatelessWidget {
const SearchFormContinent({
super.key,
required this.viewModel,
});
const SearchFormContinent({super.key, required this.viewModel});
final SearchFormViewModel viewModel;
@@ -35,9 +32,7 @@ class SearchFormContinent extends StatelessWidget {
listenable: viewModel.load,
builder: (context, child) {
if (viewModel.load.running) {
return const Center(
child: CircularProgressIndicator(),
);
return const Center(child: CircularProgressIndicator());
}
if (viewModel.load.error) {
return Center(
@@ -110,9 +105,7 @@ class _CarouselItem extends StatelessWidget {
// NOTE: Getting "invalid image data" error for some of the images
// e.g. https://rstr.in/google/tripedia/jlbgFDrSUVE
return const DecoratedBox(
decoration: BoxDecoration(
color: AppColors.grey3,
),
decoration: BoxDecoration(color: AppColors.grey3),
child: SizedBox(width: 140, height: 140),
);
},

View File

@@ -14,10 +14,7 @@ import '../view_models/search_form_viewmodel.dart';
///
/// Opens a date range picker dialog when tapped.
class SearchFormDate extends StatelessWidget {
const SearchFormDate({
super.key,
required this.viewModel,
});
const SearchFormDate({super.key, required this.viewModel});
final SearchFormViewModel viewModel;
@@ -71,7 +68,7 @@ class SearchFormDate extends StatelessWidget {
);
}
},
)
),
],
),
),

View File

@@ -16,10 +16,7 @@ const String addGuestsKey = 'add-guests';
/// Users can tap the Plus and Minus icons to increase or decrease
/// the number of guests.
class SearchFormGuests extends StatelessWidget {
const SearchFormGuests({
super.key,
required this.viewModel,
});
const SearchFormGuests({super.key, required this.viewModel});
final SearchFormViewModel viewModel;
@@ -44,10 +41,7 @@ class SearchFormGuests extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Who',
style: Theme.of(context).textTheme.titleMedium,
),
Text('Who', style: Theme.of(context).textTheme.titleMedium),
_QuantitySelector(viewModel),
],
),
@@ -81,22 +75,21 @@ class _QuantitySelector extends StatelessWidget {
),
ListenableBuilder(
listenable: viewModel,
builder: (context, _) => Text(
viewModel.guests.toString(),
style: viewModel.guests == 0
? Theme.of(context).inputDecorationTheme.hintStyle
: Theme.of(context).textTheme.bodyMedium,
),
builder:
(context, _) => Text(
viewModel.guests.toString(),
style:
viewModel.guests == 0
? Theme.of(context).inputDecorationTheme.hintStyle
: Theme.of(context).textTheme.bodyMedium,
),
),
InkWell(
key: const ValueKey(addGuestsKey),
onTap: () {
viewModel.guests++;
},
child: const Icon(
Icons.add_circle_outline,
color: AppColors.grey3,
),
child: const Icon(Icons.add_circle_outline, color: AppColors.grey3),
),
],
),

View File

@@ -21,10 +21,7 @@ import 'search_form_submit.dart';
/// Tapping on the submit button opens the [ResultsScreen] screen
/// passing the search options as query parameters.
class SearchFormScreen extends StatelessWidget {
const SearchFormScreen({
super.key,
required this.viewModel,
});
const SearchFormScreen({super.key, required this.viewModel});
final SearchFormViewModel viewModel;

View File

@@ -19,10 +19,7 @@ const String searchFormSubmitButtonKey = 'submit-button';
/// When tapped, it navigates to the [ResultsScreen]
/// passing the search options as query parameters.
class SearchFormSubmit extends StatefulWidget {
const SearchFormSubmit({
super.key,
required this.viewModel,
});
const SearchFormSubmit({super.key, required this.viewModel});
final SearchFormViewModel viewModel;
@@ -63,16 +60,15 @@ class _SearchFormSubmitState extends State<SearchFormSubmit> {
listenable: widget.viewModel,
child: SizedBox(
height: 52,
child: Center(
child: Text(AppLocalization.of(context).search),
),
child: Center(child: Text(AppLocalization.of(context).search)),
),
builder: (context, child) {
return FilledButton(
key: const ValueKey(searchFormSubmitButtonKey),
onPressed: widget.viewModel.valid
? widget.viewModel.updateItineraryConfig.execute
: null,
onPressed:
widget.viewModel.valid
? widget.viewModel.updateItineraryConfig.execute
: null,
child: child,
);
},
@@ -88,13 +84,15 @@ class _SearchFormSubmitState extends State<SearchFormSubmit> {
if (widget.viewModel.updateItineraryConfig.error) {
widget.viewModel.updateItineraryConfig.clearResult();
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(AppLocalization.of(context).errorWhileSavingItinerary),
action: SnackBarAction(
label: AppLocalization.of(context).tryAgain,
onPressed: widget.viewModel.updateItineraryConfig.execute,
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(AppLocalization.of(context).errorWhileSavingItinerary),
action: SnackBarAction(
label: AppLocalization.of(context).tryAgain,
onPressed: widget.viewModel.updateItineraryConfig.execute,
),
),
));
);
}
}
}

View File

@@ -4,5 +4,7 @@
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>

View File

@@ -5,7 +5,7 @@ publish_to: none
version: 0.1.0
environment:
sdk: ^3.5.0
sdk: ^3.7.0-0
dependencies:
cached_network_image: ^3.4.1

View File

@@ -18,9 +18,7 @@ void main() {
setUp(() {
fakeApiClient = FakeApiClient();
bookingRepository = BookingRepositoryRemote(
apiClient: fakeApiClient,
);
bookingRepository = BookingRepositoryRemote(apiClient: fakeApiClient);
});
test('should get booking', () async {

View File

@@ -37,8 +37,9 @@ void main() {
'/destination/${kDestination1.ref}/activity',
activites,
);
final result =
await apiClient.getActivityByDestination(kDestination1.ref);
final result = await apiClient.getActivityByDestination(
kDestination1.ref,
);
expect(result.asOk.value, activites);
});

View File

@@ -21,20 +21,10 @@ void main() {
});
test('should post login', () async {
const loginResponse = LoginResponse(
token: 'TOKEN',
userId: '123',
);
mockHttpClient.mockPost(
'/login',
loginResponse,
200,
);
const loginResponse = LoginResponse(token: 'TOKEN', userId: '123');
mockHttpClient.mockPost('/login', loginResponse, 200);
final result = await apiClient.login(
const LoginRequest(
email: 'EMAIL',
password: 'PASSWORD',
),
const LoginRequest(email: 'EMAIL', password: 'PASSWORD'),
);
expect(result.asOk.value, loginResponse);
});

View File

@@ -60,8 +60,9 @@ void main() {
});
});
testWidgets('should select activity and confirm',
(WidgetTester tester) async {
testWidgets('should select activity and confirm', (
WidgetTester tester,
) async {
await mockNetworkImages(() async {
await loadScreen(tester);
// Select one activity

View File

@@ -20,9 +20,7 @@ void main() {
setUp(() {
fakeAuthRepository = FakeAuthRepository();
viewModel = LoginViewModel(
authRepository: fakeAuthRepository,
);
viewModel = LoginViewModel(authRepository: fakeAuthRepository);
goRouter = MockGoRouter();
});

View File

@@ -27,7 +27,8 @@ void main() {
fakeAuthRepository.token = 'TOKEN';
// Setup an ItineraryConfig with some data, should be cleared after logout
fakeItineraryConfigRepository = FakeItineraryConfigRepository(
itineraryConfig: const ItineraryConfig(continent: 'CONTINENT'));
itineraryConfig: const ItineraryConfig(continent: 'CONTINENT'),
);
viewModel = LogoutViewModel(
authRepository: fakeAuthRepository,
itineraryConfigRepository: fakeItineraryConfigRepository,

View File

@@ -84,8 +84,9 @@ void main() {
expect(find.text(kBooking.destination.tags.first), findsOneWidget);
});
testWidgets('should create booking from itinerary config',
(WidgetTester tester) async {
testWidgets('should create booking from itinerary config', (
WidgetTester tester,
) async {
await loadScreen(tester);
// Create a new booking from stored itinerary config

View File

@@ -62,8 +62,9 @@ void main() {
});
});
testWidgets('should tap and navigate to activities',
(WidgetTester tester) async {
testWidgets('should tap and navigate to activities', (
WidgetTester tester,
) async {
await mockNetworkImages(() async {
await loadScreen(tester);

View File

@@ -25,8 +25,9 @@ void main() {
await testApp(tester, SearchFormContinent(viewModel: viewModel));
}
testWidgets('Should load and select continent',
(WidgetTester tester) async {
testWidgets('Should load and select continent', (
WidgetTester tester,
) async {
await loadWidget(tester);
expect(find.byType(SearchFormContinent), findsOneWidget);

View File

@@ -26,8 +26,9 @@ void main() {
await testApp(tester, SearchFormDate(viewModel: viewModel));
}
testWidgets('should display date in different month',
(WidgetTester tester) async {
testWidgets('should display date in different month', (
WidgetTester tester,
) async {
await loadWidget(tester);
expect(find.byType(SearchFormDate), findsOneWidget);
@@ -36,14 +37,17 @@ void main() {
// Simulate date picker input:
viewModel.dateRange = DateTimeRange(
start: DateTime(2024, 6, 12), end: DateTime(2024, 7, 23));
start: DateTime(2024, 6, 12),
end: DateTime(2024, 7, 23),
);
await tester.pumpAndSettle();
expect(find.text('12 Jun - 23 Jul'), findsOneWidget);
});
testWidgets('should display date in same month',
(WidgetTester tester) async {
testWidgets('should display date in same month', (
WidgetTester tester,
) async {
await loadWidget(tester);
expect(find.byType(SearchFormDate), findsOneWidget);
@@ -52,7 +56,9 @@ void main() {
// Simulate date picker input:
viewModel.dateRange = DateTimeRange(
start: DateTime(2024, 6, 12), end: DateTime(2024, 6, 23));
start: DateTime(2024, 6, 12),
end: DateTime(2024, 6, 23),
);
await tester.pumpAndSettle();
expect(find.text('12 - 23 Jun'), findsOneWidget);

View File

@@ -46,8 +46,9 @@ void main() {
);
}
testWidgets('Should fill form and perform search',
(WidgetTester tester) async {
testWidgets('Should fill form and perform search', (
WidgetTester tester,
) async {
await loadWidget(tester);
expect(find.byType(SearchFormScreen), findsOneWidget);
@@ -56,7 +57,9 @@ void main() {
// Select date
viewModel.dateRange = DateTimeRange(
start: DateTime(2024, 6, 12), end: DateTime(2024, 7, 23));
start: DateTime(2024, 6, 12),
end: DateTime(2024, 7, 23),
);
// Select guests
await tester.tap(find.byKey(const ValueKey(addGuestsKey)));

View File

@@ -66,8 +66,9 @@ void main() {
});
test('should handle errors', () async {
final command =
Command0<int>(() => Future.value(Result.error(Exception('ERROR!'))));
final command = Command0<int>(
() => Future.value(Result.error(Exception('ERROR!'))),
);
await command.execute();
expect(command.error, true);
expect(command.result, isA<Error>());
@@ -90,8 +91,9 @@ void main() {
test('should complete bool command, bool argument', () async {
// Action that returns bool argument
final command =
Command1<bool, bool>((a) => Future.value(const Result.ok(true)));
final command = Command1<bool, bool>(
(a) => Future.value(const Result.ok(true)),
);
// Run action with result and argument
await command.execute(true);

View File

@@ -30,9 +30,7 @@ Future<void> testApp(
theme: AppTheme.lightTheme,
home: InheritedGoRouter(
goRouter: goRouter ?? MockGoRouter(),
child: Scaffold(
body: body,
),
child: Scaffold(body: body),
),
),
);

View File

@@ -10,10 +10,12 @@ import 'package:flutter/foundation.dart';
class FakeContinentRepository implements ContinentRepository {
@override
Future<Result<List<Continent>>> getContinents() {
return SynchronousFuture(Result.ok([
const Continent(name: 'CONTINENT', imageUrl: 'URL'),
const Continent(name: 'CONTINENT2', imageUrl: 'URL'),
const Continent(name: 'CONTINENT3', imageUrl: 'URL'),
]));
return SynchronousFuture(
Result.ok([
const Continent(name: 'CONTINENT', imageUrl: 'URL'),
const Continent(name: 'CONTINENT2', imageUrl: 'URL'),
const Continent(name: 'CONTINENT3', imageUrl: 'URL'),
]),
);
}
}

View File

@@ -15,7 +15,8 @@ class FakeItineraryConfigRepository implements ItineraryConfigRepository {
@override
Future<Result<ItineraryConfig>> getItineraryConfig() {
return SynchronousFuture(
Result.ok(itineraryConfig ?? const ItineraryConfig()));
Result.ok(itineraryConfig ?? const ItineraryConfig()),
);
}
@override

View File

@@ -31,28 +31,26 @@ class FakeApiClient implements ApiClient {
@override
Future<Result<List<Destination>>> getDestinations() async {
requestCount++;
return Result.ok(
[
const Destination(
ref: 'ref1',
name: 'name1',
country: 'country1',
continent: 'Europe',
knownFor: 'knownFor1',
tags: ['tags1'],
imageUrl: 'imageUrl1',
),
const Destination(
ref: 'ref2',
name: 'name2',
country: 'country2',
continent: 'Europe',
knownFor: 'knownFor2',
tags: ['tags2'],
imageUrl: 'imageUrl2',
),
],
);
return Result.ok([
const Destination(
ref: 'ref1',
name: 'name1',
country: 'country1',
continent: 'Europe',
knownFor: 'knownFor1',
tags: ['tags1'],
imageUrl: 'imageUrl1',
),
const Destination(
ref: 'ref2',
name: 'name2',
country: 'country2',
continent: 'Europe',
knownFor: 'knownFor2',
tags: ['tags2'],
imageUrl: 'imageUrl2',
),
]);
}
@override

View File

@@ -26,8 +26,9 @@ extension HttpMethodMocks on MockHttpClient {
when(() => request.close()).thenAnswer((_) => Future.value(response));
when(() => request.headers).thenReturn(MockHttpHeaders());
when(() => response.statusCode).thenReturn(200);
when(() => response.transform(utf8.decoder))
.thenAnswer((_) => Stream.value(jsonEncode(object)));
when(
() => response.transform(utf8.decoder),
).thenAnswer((_) => Stream.value(jsonEncode(object)));
return Future.value(request);
});
}
@@ -39,8 +40,9 @@ extension HttpMethodMocks on MockHttpClient {
when(() => request.close()).thenAnswer((_) => Future.value(response));
when(() => request.headers).thenReturn(MockHttpHeaders());
when(() => response.statusCode).thenReturn(statusCode);
when(() => response.transform(utf8.decoder))
.thenAnswer((_) => Stream.value(jsonEncode(object)));
when(
() => response.transform(utf8.decoder),
).thenAnswer((_) => Stream.value(jsonEncode(object)));
return Future.value(request);
});
}

View File

@@ -12,7 +12,4 @@ const userApiModel = UserApiModel(
picture: 'assets/user.jpg',
);
const user = User(
name: 'NAME',
picture: 'assets/user.jpg',
);
const user = User(name: 'NAME', picture: 'assets/user.jpg');

View File

@@ -15,12 +15,13 @@ import 'package:shelf/shelf_io.dart';
import 'package:shelf_router/shelf_router.dart';
// Configure routes.
final _router = Router()
..get('/continent', continentHandler)
..mount('/destination', DestinationApi().router.call)
..mount('/booking', BookingApi().router.call)
..mount('/user', UserApi().router.call)
..mount('/login', LoginApi().router.call);
final _router =
Router()
..get('/continent', continentHandler)
..mount('/destination', DestinationApi().router.call)
..mount('/booking', BookingApi().router.call)
..mount('/user', UserApi().router.call)
..mount('/login', LoginApi().router.call);
void main(List<String> args) async {
// Use any available host or container IP (usually `0.0.0.0`).

View File

@@ -17,14 +17,14 @@ import '../config/constants.dart';
///
/// This token does not expire and is not secure.
Middleware authRequests() => (innerHandler) {
return (Request request) async {
if (request.url.path != 'login' &&
request.headers['Authorization'] != 'Bearer ${Constants.token}') {
// If the request is not a login request and the token is not present,
// return a 401 Unauthorized response.
return Response.unauthorized('Unauthorized');
}
return (Request request) async {
if (request.url.path != 'login' &&
request.headers['Authorization'] != 'Bearer ${Constants.token}') {
// If the request is not a login request and the token is not present,
// return a 401 Unauthorized response.
return Response.unauthorized('Unauthorized');
}
return innerHandler(request);
};
};
return innerHandler(request);
};
};

Some files were not shown because too many files have changed in this diff Show More