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:
@@ -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`).
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
@@ -53,13 +54,14 @@ abstract class $BookingCopyWith<$Res> {
|
||||
factory $BookingCopyWith(Booking value, $Res Function(Booking) then) =
|
||||
_$BookingCopyWithImpl<$Res, Booking>;
|
||||
@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
|
||||
@@ -84,49 +86,60 @@ class _$BookingCopyWithImpl<$Res, $Val extends Booking>
|
||||
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 _$$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,
|
||||
String name,
|
||||
String destinationRef,
|
||||
List<String> activitiesRef});
|
||||
$Res call({
|
||||
int? id,
|
||||
DateTime startDate,
|
||||
DateTime endDate,
|
||||
String name,
|
||||
String destinationRef,
|
||||
List<String> activitiesRef,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -134,8 +147,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.
|
||||
@@ -149,46 +163,54 @@ class __$$BookingImplCopyWithImpl<$Res>
|
||||
Object? destinationRef = null,
|
||||
Object? activitiesRef = 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,
|
||||
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(
|
||||
_$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,
|
||||
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 _$BookingImpl implements _Booking {
|
||||
const _$BookingImpl(
|
||||
{this.id,
|
||||
required this.startDate,
|
||||
required this.endDate,
|
||||
required this.name,
|
||||
required this.destinationRef,
|
||||
required final List<String> activitiesRef})
|
||||
: _activitiesRef = activitiesRef;
|
||||
const _$BookingImpl({
|
||||
this.id,
|
||||
required this.startDate,
|
||||
required this.endDate,
|
||||
required this.name,
|
||||
required this.destinationRef,
|
||||
required final List<String> activitiesRef,
|
||||
}) : _activitiesRef = activitiesRef;
|
||||
|
||||
factory _$BookingImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$BookingImplFromJson(json);
|
||||
@@ -242,14 +264,23 @@ class _$BookingImpl implements _Booking {
|
||||
(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 Booking
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -261,20 +292,19 @@ 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 String name,
|
||||
required final String destinationRef,
|
||||
required final List<String> activitiesRef}) = _$BookingImpl;
|
||||
const factory _Booking({
|
||||
final int? id,
|
||||
required final DateTime startDate,
|
||||
required final DateTime endDate,
|
||||
required final String name,
|
||||
required final String destinationRef,
|
||||
required final List<String> activitiesRef,
|
||||
}) = _$BookingImpl;
|
||||
|
||||
factory _Booking.fromJson(Map<String, dynamic> json) = _$BookingImpl.fromJson;
|
||||
|
||||
|
||||
@@ -13,9 +13,10 @@ _$BookingImpl _$$BookingImplFromJson(Map<String, dynamic> json) =>
|
||||
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(),
|
||||
activitiesRef:
|
||||
(json['activitiesRef'] as List<dynamic>)
|
||||
.map((e) => e as String)
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$BookingImplToJson(_$BookingImpl instance) =>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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);
|
||||
@@ -69,32 +70,40 @@ class _$UserCopyWithImpl<$Res, $Val extends User>
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @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 id, String name, String email, String picture});
|
||||
@@ -105,7 +114,7 @@ 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.
|
||||
@@ -117,35 +126,42 @@ class __$$UserImplCopyWithImpl<$Res>
|
||||
Object? email = null,
|
||||
Object? picture = null,
|
||||
}) {
|
||||
return _then(_$UserImpl(
|
||||
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(
|
||||
_$UserImpl(
|
||||
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 _$UserImpl implements _User {
|
||||
const _$UserImpl(
|
||||
{required this.id,
|
||||
required this.name,
|
||||
required this.email,
|
||||
required this.picture});
|
||||
const _$UserImpl({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.email,
|
||||
required this.picture,
|
||||
});
|
||||
|
||||
factory _$UserImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$UserImplFromJson(json);
|
||||
@@ -196,18 +212,17 @@ 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 id,
|
||||
required final String name,
|
||||
required final String email,
|
||||
required final String picture}) = _$UserImpl;
|
||||
const factory _User({
|
||||
required final String id,
|
||||
required final String name,
|
||||
required final String email,
|
||||
required final String picture,
|
||||
}) = _$UserImpl;
|
||||
|
||||
factory _User.fromJson(Map<String, dynamic> json) = _$UserImpl.fromJson;
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ part of 'user.dart';
|
||||
// **************************************************************************
|
||||
|
||||
_$UserImpl _$$UserImplFromJson(Map<String, dynamic> json) => _$UserImpl(
|
||||
id: json['id'] as String,
|
||||
name: json['name'] as String,
|
||||
email: json['email'] as String,
|
||||
picture: json['picture'] as String,
|
||||
);
|
||||
id: json['id'] as String,
|
||||
name: json['name'] as String,
|
||||
email: json['email'] as String,
|
||||
picture: json['picture'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$UserImplToJson(_$UserImpl instance) =>
|
||||
<String, dynamic>{
|
||||
|
||||
@@ -23,10 +23,11 @@ class BookingApi {
|
||||
BookingApi() {
|
||||
// Create a default booking
|
||||
final destination = Assets.destinations.first;
|
||||
final activitiesRef = Assets.activities
|
||||
.where((activity) => activity.destinationRef == destination.ref)
|
||||
.map((activity) => activity.ref)
|
||||
.toList();
|
||||
final activitiesRef =
|
||||
Assets.activities
|
||||
.where((activity) => activity.destinationRef == destination.ref)
|
||||
.map((activity) => activity.ref)
|
||||
.toList();
|
||||
_bookings.add(
|
||||
Booking(
|
||||
id: _sequentialId++,
|
||||
@@ -60,8 +61,9 @@ class BookingApi {
|
||||
// Get a booking by id
|
||||
router.get('/<id>', (Request request, String id) {
|
||||
final bookingId = int.parse(id);
|
||||
final booking =
|
||||
_bookings.firstWhereOrNull((booking) => booking.id == bookingId);
|
||||
final booking = _bookings.firstWhereOrNull(
|
||||
(booking) => booking.id == bookingId,
|
||||
);
|
||||
|
||||
if (booking == null) {
|
||||
return Response.notFound('Invalid id');
|
||||
@@ -81,7 +83,8 @@ class BookingApi {
|
||||
if (booking.id != null) {
|
||||
// POST endpoint only allows newly created bookings
|
||||
return Response.badRequest(
|
||||
body: 'Booking already has id, use PUT instead.');
|
||||
body: 'Booking already has id, use PUT instead.',
|
||||
);
|
||||
}
|
||||
|
||||
// Add ID to new booking
|
||||
@@ -101,8 +104,9 @@ class BookingApi {
|
||||
// Delete booking
|
||||
router.delete('/<id>', (Request request, String id) async {
|
||||
final bookingId = int.parse(id);
|
||||
final booking =
|
||||
_bookings.firstWhereOrNull((booking) => booking.id == bookingId);
|
||||
final booking = _bookings.firstWhereOrNull(
|
||||
(booking) => booking.id == bookingId,
|
||||
);
|
||||
if (booking == null) {
|
||||
return Response.notFound('Invalid id');
|
||||
}
|
||||
|
||||
@@ -21,9 +21,10 @@ class DestinationApi {
|
||||
});
|
||||
|
||||
router.get('/<id>/activity', (Request request, String id) {
|
||||
final list = Assets.activities
|
||||
.where((activity) => activity.destinationRef == id)
|
||||
.toList();
|
||||
final list =
|
||||
Assets.activities
|
||||
.where((activity) => activity.destinationRef == id)
|
||||
.toList();
|
||||
return Response.ok(
|
||||
json.encode(list),
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
|
||||
@@ -33,10 +33,7 @@ class LoginApi {
|
||||
loginRequest.password == Constants.password) {
|
||||
return Response.ok(
|
||||
json.encode(
|
||||
LoginResponse(
|
||||
token: Constants.token,
|
||||
userId: Constants.userId,
|
||||
),
|
||||
LoginResponse(token: Constants.token, userId: Constants.userId),
|
||||
),
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
);
|
||||
|
||||
@@ -4,7 +4,7 @@ publish_to: 'none'
|
||||
version: 1.0.0
|
||||
|
||||
environment:
|
||||
sdk: ^3.5.0
|
||||
sdk: ^3.7.0-0
|
||||
|
||||
dependencies:
|
||||
args: ^2.4.0
|
||||
|
||||
@@ -21,9 +21,7 @@ void main() {
|
||||
final host = 'http://127.0.0.1:$port';
|
||||
late Process p;
|
||||
|
||||
final headers = {
|
||||
'Authorization': 'Bearer ${Constants.token}',
|
||||
};
|
||||
final headers = {'Authorization': 'Bearer ${Constants.token}'};
|
||||
|
||||
setUp(() async {
|
||||
p = await Process.start(
|
||||
@@ -39,10 +37,7 @@ void main() {
|
||||
|
||||
test('Get Continent end-point', () async {
|
||||
// Query /continent end-point
|
||||
final response = await get(
|
||||
Uri.parse('$host/continent'),
|
||||
headers: headers,
|
||||
);
|
||||
final response = await get(Uri.parse('$host/continent'), headers: headers);
|
||||
|
||||
expect(response.statusCode, 200);
|
||||
// Parse json response list
|
||||
@@ -84,10 +79,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('Get bookings end-point', () async {
|
||||
final response = await get(
|
||||
Uri.parse('$host/booking'),
|
||||
headers: headers,
|
||||
);
|
||||
final response = await get(Uri.parse('$host/booking'), headers: headers);
|
||||
expect(response.statusCode, 200);
|
||||
// Parse json response list
|
||||
final list = jsonDecode(response.body) as List<dynamic>;
|
||||
@@ -98,10 +90,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('Get booking with id 0', () async {
|
||||
final response = await get(
|
||||
Uri.parse('$host/booking/0'),
|
||||
headers: headers,
|
||||
);
|
||||
final response = await get(Uri.parse('$host/booking/0'), headers: headers);
|
||||
|
||||
expect(response.statusCode, 200);
|
||||
final booking = Booking.fromJson(jsonDecode(response.body));
|
||||
@@ -169,10 +158,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('Get user', () async {
|
||||
final response = await get(
|
||||
Uri.parse('$host/user'),
|
||||
headers: headers,
|
||||
);
|
||||
final response = await get(Uri.parse('$host/user'), headers: headers);
|
||||
|
||||
expect(response.statusCode, 200);
|
||||
final user = User.fromJson(jsonDecode(response.body));
|
||||
@@ -182,10 +168,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('404', () async {
|
||||
final response = await get(
|
||||
Uri.parse('$host/foobar'),
|
||||
headers: headers,
|
||||
);
|
||||
final response = await get(Uri.parse('$host/foobar'), headers: headers);
|
||||
expect(response.statusCode, 404);
|
||||
});
|
||||
|
||||
@@ -193,10 +176,7 @@ void main() {
|
||||
final response = await post(
|
||||
Uri.parse('$host/login'),
|
||||
body: jsonEncode(
|
||||
LoginRequest(
|
||||
email: Constants.email,
|
||||
password: Constants.password,
|
||||
),
|
||||
LoginRequest(email: Constants.email, password: Constants.password),
|
||||
),
|
||||
);
|
||||
expect(response.statusCode, 200);
|
||||
@@ -208,12 +188,7 @@ void main() {
|
||||
test('Login with wrong credentials', () async {
|
||||
final response = await post(
|
||||
Uri.parse('$host/login'),
|
||||
body: jsonEncode(
|
||||
LoginRequest(
|
||||
email: 'INVALID',
|
||||
password: 'INVALID',
|
||||
),
|
||||
),
|
||||
body: jsonEncode(LoginRequest(email: 'INVALID', password: 'INVALID')),
|
||||
);
|
||||
expect(response.statusCode, 401);
|
||||
});
|
||||
@@ -221,9 +196,7 @@ void main() {
|
||||
test('Unauthorized request', () async {
|
||||
// Query /continent end-point
|
||||
// No auth headers
|
||||
final response = await get(
|
||||
Uri.parse('$host/continent'),
|
||||
);
|
||||
final response = await get(Uri.parse('$host/continent'));
|
||||
|
||||
expect(response.statusCode, 401);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user