1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-14 11:28:36 +00:00

Compass app (#2446)

This commit is contained in:
Eric Windmill
2024-09-27 18:49:27 -04:00
committed by GitHub
parent fcf2552cda
commit 46b5a26b26
326 changed files with 53272 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
// Copyright 2024 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:freezed_annotation/freezed_annotation.dart';
import '../activity/activity.dart';
import '../destination/destination.dart';
part 'booking.freezed.dart';
part 'booking.g.dart';
@freezed
class Booking with _$Booking {
const factory Booking({
/// Optional ID of the booking.
/// May be null if the booking is not yet stored.
int? id,
/// Start date of the trip
required DateTime startDate,
/// End date of the trip
required DateTime endDate,
/// Destination of the trip
required Destination destination,
/// List of chosen activities
required List<Activity> activity,
}) = _Booking;
factory Booking.fromJson(Map<String, Object?> json) =>
_$BookingFromJson(json);
}

View File

@@ -0,0 +1,300 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'booking.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
Booking _$BookingFromJson(Map<String, dynamic> json) {
return _Booking.fromJson(json);
}
/// @nodoc
mixin _$Booking {
/// Optional ID of the booking.
/// May be null if the booking is not yet stored.
int? get id => throw _privateConstructorUsedError;
/// Start date of the trip
DateTime get startDate => throw _privateConstructorUsedError;
/// End date of the trip
DateTime get endDate => throw _privateConstructorUsedError;
/// Destination of the trip
Destination get destination => throw _privateConstructorUsedError;
/// List of chosen activities
List<Activity> get activity => throw _privateConstructorUsedError;
/// Serializes this Booking to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of Booking
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$BookingCopyWith<Booking> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
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});
$DestinationCopyWith<$Res> get destination;
}
/// @nodoc
class _$BookingCopyWithImpl<$Res, $Val extends Booking>
implements $BookingCopyWith<$Res> {
_$BookingCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of Booking
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = freezed,
Object? startDate = null,
Object? endDate = null,
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);
}
/// Create a copy of Booking
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$DestinationCopyWith<$Res> get destination {
return $DestinationCopyWith<$Res>(_value.destination, (value) {
return _then(_value.copyWith(destination: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$BookingImplCopyWith<$Res> implements $BookingCopyWith<$Res> {
factory _$$BookingImplCopyWith(
_$BookingImpl value, $Res Function(_$BookingImpl) then) =
__$$BookingImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{int? id,
DateTime startDate,
DateTime endDate,
Destination destination,
List<Activity> activity});
@override
$DestinationCopyWith<$Res> get destination;
}
/// @nodoc
class __$$BookingImplCopyWithImpl<$Res>
extends _$BookingCopyWithImpl<$Res, _$BookingImpl>
implements _$$BookingImplCopyWith<$Res> {
__$$BookingImplCopyWithImpl(
_$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.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = freezed,
Object? startDate = null,
Object? endDate = null,
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>,
));
}
}
/// @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;
factory _$BookingImpl.fromJson(Map<String, dynamic> json) =>
_$$BookingImplFromJson(json);
/// Optional ID of the booking.
/// May be null if the booking is not yet stored.
@override
final int? id;
/// Start date of the trip
@override
final DateTime startDate;
/// End date of the trip
@override
final DateTime endDate;
/// Destination of the trip
@override
final Destination destination;
/// List of chosen activities
final List<Activity> _activity;
/// List of chosen activities
@override
List<Activity> get activity {
if (_activity is EqualUnmodifiableListView) return _activity;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_activity);
}
@override
String toString() {
return 'Booking(id: $id, startDate: $startDate, endDate: $endDate, destination: $destination, activity: $activity)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$BookingImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.startDate, startDate) ||
other.startDate == startDate) &&
(identical(other.endDate, endDate) || other.endDate == endDate) &&
(identical(other.destination, destination) ||
other.destination == destination) &&
const DeepCollectionEquality().equals(other._activity, _activity));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
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.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$BookingImplCopyWith<_$BookingImpl> get copyWith =>
__$$BookingImplCopyWithImpl<_$BookingImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
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;
factory _Booking.fromJson(Map<String, dynamic> json) = _$BookingImpl.fromJson;
/// Optional ID of the booking.
/// May be null if the booking is not yet stored.
@override
int? get id;
/// Start date of the trip
@override
DateTime get startDate;
/// End date of the trip
@override
DateTime get endDate;
/// Destination of the trip
@override
Destination get destination;
/// List of chosen activities
@override
List<Activity> get activity;
/// Create a copy of Booking
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$BookingImplCopyWith<_$BookingImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -0,0 +1,28 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'booking.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$BookingImpl _$$BookingImplFromJson(Map<String, dynamic> json) =>
_$BookingImpl(
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(),
);
Map<String, dynamic> _$$BookingImplToJson(_$BookingImpl instance) =>
<String, dynamic>{
'id': instance.id,
'startDate': instance.startDate.toIso8601String(),
'endDate': instance.endDate.toIso8601String(),
'destination': instance.destination,
'activity': instance.activity,
};

View File

@@ -0,0 +1,34 @@
// Copyright 2024 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:freezed_annotation/freezed_annotation.dart';
part 'booking_summary.freezed.dart';
part 'booking_summary.g.dart';
/// BookingSummary contains the necessary data to display a booking
/// in the user home screen, but lacks the rest of the booking data
/// like activitities or destination.
///
/// Use the [BookingRepository] to obtain a full [Booking]
/// using the [BookingSummary.id].
@freezed
class BookingSummary with _$BookingSummary {
const factory BookingSummary({
/// Booking id
required int id,
/// Name to be displayed
required String name,
/// Start date of the booking
required DateTime startDate,
/// End date of the booking
required DateTime endDate,
}) = _BookingSummary;
factory BookingSummary.fromJson(Map<String, Object?> json) =>
_$BookingSummaryFromJson(json);
}

View File

@@ -0,0 +1,243 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'booking_summary.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
BookingSummary _$BookingSummaryFromJson(Map<String, dynamic> json) {
return _BookingSummary.fromJson(json);
}
/// @nodoc
mixin _$BookingSummary {
/// Booking id
int get id => throw _privateConstructorUsedError;
/// Name to be displayed
String get name => throw _privateConstructorUsedError;
/// Start date of the booking
DateTime get startDate => throw _privateConstructorUsedError;
/// End date of the booking
DateTime get endDate => throw _privateConstructorUsedError;
/// Serializes this BookingSummary to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of BookingSummary
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$BookingSummaryCopyWith<BookingSummary> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $BookingSummaryCopyWith<$Res> {
factory $BookingSummaryCopyWith(
BookingSummary value, $Res Function(BookingSummary) then) =
_$BookingSummaryCopyWithImpl<$Res, BookingSummary>;
@useResult
$Res call({int id, String name, DateTime startDate, DateTime endDate});
}
/// @nodoc
class _$BookingSummaryCopyWithImpl<$Res, $Val extends BookingSummary>
implements $BookingSummaryCopyWith<$Res> {
_$BookingSummaryCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of BookingSummary
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? name = null,
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);
}
}
/// @nodoc
abstract class _$$BookingSummaryImplCopyWith<$Res>
implements $BookingSummaryCopyWith<$Res> {
factory _$$BookingSummaryImplCopyWith(_$BookingSummaryImpl value,
$Res Function(_$BookingSummaryImpl) then) =
__$$BookingSummaryImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({int id, String name, DateTime startDate, DateTime endDate});
}
/// @nodoc
class __$$BookingSummaryImplCopyWithImpl<$Res>
extends _$BookingSummaryCopyWithImpl<$Res, _$BookingSummaryImpl>
implements _$$BookingSummaryImplCopyWith<$Res> {
__$$BookingSummaryImplCopyWithImpl(
_$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.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? name = null,
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,
));
}
}
/// @nodoc
@JsonSerializable()
class _$BookingSummaryImpl implements _BookingSummary {
const _$BookingSummaryImpl(
{required this.id,
required this.name,
required this.startDate,
required this.endDate});
factory _$BookingSummaryImpl.fromJson(Map<String, dynamic> json) =>
_$$BookingSummaryImplFromJson(json);
/// Booking id
@override
final int id;
/// Name to be displayed
@override
final String name;
/// Start date of the booking
@override
final DateTime startDate;
/// End date of the booking
@override
final DateTime endDate;
@override
String toString() {
return 'BookingSummary(id: $id, name: $name, startDate: $startDate, endDate: $endDate)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$BookingSummaryImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.name, name) || other.name == name) &&
(identical(other.startDate, startDate) ||
other.startDate == startDate) &&
(identical(other.endDate, endDate) || other.endDate == endDate));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, id, name, startDate, endDate);
/// Create a copy of BookingSummary
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$BookingSummaryImplCopyWith<_$BookingSummaryImpl> get copyWith =>
__$$BookingSummaryImplCopyWithImpl<_$BookingSummaryImpl>(
this, _$identity);
@override
Map<String, dynamic> toJson() {
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;
factory _BookingSummary.fromJson(Map<String, dynamic> json) =
_$BookingSummaryImpl.fromJson;
/// Booking id
@override
int get id;
/// Name to be displayed
@override
String get name;
/// Start date of the booking
@override
DateTime get startDate;
/// End date of the booking
@override
DateTime get endDate;
/// Create a copy of BookingSummary
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$BookingSummaryImplCopyWith<_$BookingSummaryImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -0,0 +1,24 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'booking_summary.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$BookingSummaryImpl _$$BookingSummaryImplFromJson(Map<String, dynamic> json) =>
_$BookingSummaryImpl(
id: (json['id'] as num).toInt(),
name: json['name'] as String,
startDate: DateTime.parse(json['startDate'] as String),
endDate: DateTime.parse(json['endDate'] as String),
);
Map<String, dynamic> _$$BookingSummaryImplToJson(
_$BookingSummaryImpl instance) =>
<String, dynamic>{
'id': instance.id,
'name': instance.name,
'startDate': instance.startDate.toIso8601String(),
'endDate': instance.endDate.toIso8601String(),
};