feat(diary): New models for calendar and autocomplete fix

This commit is contained in:
2024-07-19 11:55:48 +03:00
parent dbe8ac0999
commit be461e4183
13 changed files with 1140 additions and 444 deletions

View File

@@ -0,0 +1,21 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'calendar_model.freezed.dart';
part 'calendar_model.g.dart';
@freezed
class CalendarModel with _$CalendarModel {
const factory CalendarModel({
required int id,
required String state,
required String image,
required String description,
@JsonKey(name: "youtube_url") required String youtubeUrl,
@JsonKey(name: "created_at") required DateTime createdAt,
@JsonKey(name: "updated_at") required DateTime updatedAt,
required String title,
}) = _CalendarModel;
factory CalendarModel.fromJson(Map<String, Object?> json) =>
_$CalendarModelFromJson(json);
}

View File

@@ -0,0 +1,309 @@
// 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 'calendar_model.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');
CalendarModel _$CalendarModelFromJson(Map<String, dynamic> json) {
return _CalendarModel.fromJson(json);
}
/// @nodoc
mixin _$CalendarModel {
int get id => throw _privateConstructorUsedError;
String get state => throw _privateConstructorUsedError;
String get image => throw _privateConstructorUsedError;
String get description => throw _privateConstructorUsedError;
@JsonKey(name: "youtube_url")
String get youtubeUrl => throw _privateConstructorUsedError;
@JsonKey(name: "created_at")
DateTime get createdAt => throw _privateConstructorUsedError;
@JsonKey(name: "updated_at")
DateTime get updatedAt => throw _privateConstructorUsedError;
String get title => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$CalendarModelCopyWith<CalendarModel> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $CalendarModelCopyWith<$Res> {
factory $CalendarModelCopyWith(
CalendarModel value, $Res Function(CalendarModel) then) =
_$CalendarModelCopyWithImpl<$Res, CalendarModel>;
@useResult
$Res call(
{int id,
String state,
String image,
String description,
@JsonKey(name: "youtube_url") String youtubeUrl,
@JsonKey(name: "created_at") DateTime createdAt,
@JsonKey(name: "updated_at") DateTime updatedAt,
String title});
}
/// @nodoc
class _$CalendarModelCopyWithImpl<$Res, $Val extends CalendarModel>
implements $CalendarModelCopyWith<$Res> {
_$CalendarModelCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? state = null,
Object? image = null,
Object? description = null,
Object? youtubeUrl = null,
Object? createdAt = null,
Object? updatedAt = null,
Object? title = null,
}) {
return _then(_value.copyWith(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
state: null == state
? _value.state
: state // ignore: cast_nullable_to_non_nullable
as String,
image: null == image
? _value.image
: image // ignore: cast_nullable_to_non_nullable
as String,
description: null == description
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String,
youtubeUrl: null == youtubeUrl
? _value.youtubeUrl
: youtubeUrl // ignore: cast_nullable_to_non_nullable
as String,
createdAt: null == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as DateTime,
updatedAt: null == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as DateTime,
title: null == title
? _value.title
: title // ignore: cast_nullable_to_non_nullable
as String,
) as $Val);
}
}
/// @nodoc
abstract class _$$CalendarModelImplCopyWith<$Res>
implements $CalendarModelCopyWith<$Res> {
factory _$$CalendarModelImplCopyWith(
_$CalendarModelImpl value, $Res Function(_$CalendarModelImpl) then) =
__$$CalendarModelImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{int id,
String state,
String image,
String description,
@JsonKey(name: "youtube_url") String youtubeUrl,
@JsonKey(name: "created_at") DateTime createdAt,
@JsonKey(name: "updated_at") DateTime updatedAt,
String title});
}
/// @nodoc
class __$$CalendarModelImplCopyWithImpl<$Res>
extends _$CalendarModelCopyWithImpl<$Res, _$CalendarModelImpl>
implements _$$CalendarModelImplCopyWith<$Res> {
__$$CalendarModelImplCopyWithImpl(
_$CalendarModelImpl _value, $Res Function(_$CalendarModelImpl) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? state = null,
Object? image = null,
Object? description = null,
Object? youtubeUrl = null,
Object? createdAt = null,
Object? updatedAt = null,
Object? title = null,
}) {
return _then(_$CalendarModelImpl(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
state: null == state
? _value.state
: state // ignore: cast_nullable_to_non_nullable
as String,
image: null == image
? _value.image
: image // ignore: cast_nullable_to_non_nullable
as String,
description: null == description
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String,
youtubeUrl: null == youtubeUrl
? _value.youtubeUrl
: youtubeUrl // ignore: cast_nullable_to_non_nullable
as String,
createdAt: null == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as DateTime,
updatedAt: null == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as DateTime,
title: null == title
? _value.title
: title // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
@JsonSerializable()
class _$CalendarModelImpl implements _CalendarModel {
const _$CalendarModelImpl(
{required this.id,
required this.state,
required this.image,
required this.description,
@JsonKey(name: "youtube_url") required this.youtubeUrl,
@JsonKey(name: "created_at") required this.createdAt,
@JsonKey(name: "updated_at") required this.updatedAt,
required this.title});
factory _$CalendarModelImpl.fromJson(Map<String, dynamic> json) =>
_$$CalendarModelImplFromJson(json);
@override
final int id;
@override
final String state;
@override
final String image;
@override
final String description;
@override
@JsonKey(name: "youtube_url")
final String youtubeUrl;
@override
@JsonKey(name: "created_at")
final DateTime createdAt;
@override
@JsonKey(name: "updated_at")
final DateTime updatedAt;
@override
final String title;
@override
String toString() {
return 'CalendarModel(id: $id, state: $state, image: $image, description: $description, youtubeUrl: $youtubeUrl, createdAt: $createdAt, updatedAt: $updatedAt, title: $title)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$CalendarModelImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.state, state) || other.state == state) &&
(identical(other.image, image) || other.image == image) &&
(identical(other.description, description) ||
other.description == description) &&
(identical(other.youtubeUrl, youtubeUrl) ||
other.youtubeUrl == youtubeUrl) &&
(identical(other.createdAt, createdAt) ||
other.createdAt == createdAt) &&
(identical(other.updatedAt, updatedAt) ||
other.updatedAt == updatedAt) &&
(identical(other.title, title) || other.title == title));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, id, state, image, description,
youtubeUrl, createdAt, updatedAt, title);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$CalendarModelImplCopyWith<_$CalendarModelImpl> get copyWith =>
__$$CalendarModelImplCopyWithImpl<_$CalendarModelImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$CalendarModelImplToJson(
this,
);
}
}
abstract class _CalendarModel implements CalendarModel {
const factory _CalendarModel(
{required final int id,
required final String state,
required final String image,
required final String description,
@JsonKey(name: "youtube_url") required final String youtubeUrl,
@JsonKey(name: "created_at") required final DateTime createdAt,
@JsonKey(name: "updated_at") required final DateTime updatedAt,
required final String title}) = _$CalendarModelImpl;
factory _CalendarModel.fromJson(Map<String, dynamic> json) =
_$CalendarModelImpl.fromJson;
@override
int get id;
@override
String get state;
@override
String get image;
@override
String get description;
@override
@JsonKey(name: "youtube_url")
String get youtubeUrl;
@override
@JsonKey(name: "created_at")
DateTime get createdAt;
@override
@JsonKey(name: "updated_at")
DateTime get updatedAt;
@override
String get title;
@override
@JsonKey(ignore: true)
_$$CalendarModelImplCopyWith<_$CalendarModelImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -0,0 +1,31 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'calendar_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$CalendarModelImpl _$$CalendarModelImplFromJson(Map<String, dynamic> json) =>
_$CalendarModelImpl(
id: (json['id'] as num).toInt(),
state: json['state'] as String,
image: json['image'] as String,
description: json['description'] as String,
youtubeUrl: json['youtube_url'] as String,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
title: json['title'] as String,
);
Map<String, dynamic> _$$CalendarModelImplToJson(_$CalendarModelImpl instance) =>
<String, dynamic>{
'id': instance.id,
'state': instance.state,
'image': instance.image,
'description': instance.description,
'youtube_url': instance.youtubeUrl,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'title': instance.title,
};

View File

@@ -0,0 +1,20 @@
import 'package:eatvio_app/core/app_export.dart';
import 'package:eatvio_app/features/calendar/presentation/bloc/calendar_state.dart';
import 'package:eatvio_app/features/calendar/repositories/calendar_repository.dart';
class CalendarCubit extends Cubit<CalendarState> {
final CalendarRepository calendarRepository;
CalendarCubit({required this.calendarRepository})
: super(const CalendarState.loading());
loadCalendarList() async {
emit(const CalendarState.loading());
try {
final calendarList = await calendarRepository.getCalendar();
emit(CalendarState.loaded(calendarList: calendarList));
} catch (e) {
emit(CalendarState.error(errorMessage: e.toString()));
}
}
}

View File

@@ -0,0 +1,19 @@
import 'package:eatvio_app/features/calendar/models/calendar_model.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'calendar_state.freezed.dart';
@freezed
abstract class CalendarState with _$CalendarState {
const factory CalendarState() = _CalendarState;
const factory CalendarState.loading() = CalendarStateLoading;
const factory CalendarState.loaded({
required List<CalendarModel> calendarList,
}) = CalendarStateLoaded;
const factory CalendarState.error({
required String errorMessage,
}) = CalendarStateError;
}

View File

@@ -0,0 +1,621 @@
// 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 'calendar_state.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');
/// @nodoc
mixin _$CalendarState {
@optionalTypeArgs
TResult when<TResult extends Object?>(
TResult Function() $default, {
required TResult Function() loading,
required TResult Function(List<CalendarModel> calendarList) loaded,
required TResult Function(String errorMessage) error,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
TResult? Function()? $default, {
TResult? Function()? loading,
TResult? Function(List<CalendarModel> calendarList)? loaded,
TResult? Function(String errorMessage)? error,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
TResult Function()? $default, {
TResult Function()? loading,
TResult Function(List<CalendarModel> calendarList)? loaded,
TResult Function(String errorMessage)? error,
required TResult orElse(),
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>(
TResult Function(_CalendarState value) $default, {
required TResult Function(CalendarStateLoading value) loading,
required TResult Function(CalendarStateLoaded value) loaded,
required TResult Function(CalendarStateError value) error,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>(
TResult? Function(_CalendarState value)? $default, {
TResult? Function(CalendarStateLoading value)? loading,
TResult? Function(CalendarStateLoaded value)? loaded,
TResult? Function(CalendarStateError value)? error,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>(
TResult Function(_CalendarState value)? $default, {
TResult Function(CalendarStateLoading value)? loading,
TResult Function(CalendarStateLoaded value)? loaded,
TResult Function(CalendarStateError value)? error,
required TResult orElse(),
}) =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $CalendarStateCopyWith<$Res> {
factory $CalendarStateCopyWith(
CalendarState value, $Res Function(CalendarState) then) =
_$CalendarStateCopyWithImpl<$Res, CalendarState>;
}
/// @nodoc
class _$CalendarStateCopyWithImpl<$Res, $Val extends CalendarState>
implements $CalendarStateCopyWith<$Res> {
_$CalendarStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
}
/// @nodoc
abstract class _$$CalendarStateImplCopyWith<$Res> {
factory _$$CalendarStateImplCopyWith(
_$CalendarStateImpl value, $Res Function(_$CalendarStateImpl) then) =
__$$CalendarStateImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$CalendarStateImplCopyWithImpl<$Res>
extends _$CalendarStateCopyWithImpl<$Res, _$CalendarStateImpl>
implements _$$CalendarStateImplCopyWith<$Res> {
__$$CalendarStateImplCopyWithImpl(
_$CalendarStateImpl _value, $Res Function(_$CalendarStateImpl) _then)
: super(_value, _then);
}
/// @nodoc
class _$CalendarStateImpl implements _CalendarState {
const _$CalendarStateImpl();
@override
String toString() {
return 'CalendarState()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$CalendarStateImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>(
TResult Function() $default, {
required TResult Function() loading,
required TResult Function(List<CalendarModel> calendarList) loaded,
required TResult Function(String errorMessage) error,
}) {
return $default();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
TResult? Function()? $default, {
TResult? Function()? loading,
TResult? Function(List<CalendarModel> calendarList)? loaded,
TResult? Function(String errorMessage)? error,
}) {
return $default?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
TResult Function()? $default, {
TResult Function()? loading,
TResult Function(List<CalendarModel> calendarList)? loaded,
TResult Function(String errorMessage)? error,
required TResult orElse(),
}) {
if ($default != null) {
return $default();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>(
TResult Function(_CalendarState value) $default, {
required TResult Function(CalendarStateLoading value) loading,
required TResult Function(CalendarStateLoaded value) loaded,
required TResult Function(CalendarStateError value) error,
}) {
return $default(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>(
TResult? Function(_CalendarState value)? $default, {
TResult? Function(CalendarStateLoading value)? loading,
TResult? Function(CalendarStateLoaded value)? loaded,
TResult? Function(CalendarStateError value)? error,
}) {
return $default?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>(
TResult Function(_CalendarState value)? $default, {
TResult Function(CalendarStateLoading value)? loading,
TResult Function(CalendarStateLoaded value)? loaded,
TResult Function(CalendarStateError value)? error,
required TResult orElse(),
}) {
if ($default != null) {
return $default(this);
}
return orElse();
}
}
abstract class _CalendarState implements CalendarState {
const factory _CalendarState() = _$CalendarStateImpl;
}
/// @nodoc
abstract class _$$CalendarStateLoadingImplCopyWith<$Res> {
factory _$$CalendarStateLoadingImplCopyWith(_$CalendarStateLoadingImpl value,
$Res Function(_$CalendarStateLoadingImpl) then) =
__$$CalendarStateLoadingImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$CalendarStateLoadingImplCopyWithImpl<$Res>
extends _$CalendarStateCopyWithImpl<$Res, _$CalendarStateLoadingImpl>
implements _$$CalendarStateLoadingImplCopyWith<$Res> {
__$$CalendarStateLoadingImplCopyWithImpl(_$CalendarStateLoadingImpl _value,
$Res Function(_$CalendarStateLoadingImpl) _then)
: super(_value, _then);
}
/// @nodoc
class _$CalendarStateLoadingImpl implements CalendarStateLoading {
const _$CalendarStateLoadingImpl();
@override
String toString() {
return 'CalendarState.loading()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$CalendarStateLoadingImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>(
TResult Function() $default, {
required TResult Function() loading,
required TResult Function(List<CalendarModel> calendarList) loaded,
required TResult Function(String errorMessage) error,
}) {
return loading();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
TResult? Function()? $default, {
TResult? Function()? loading,
TResult? Function(List<CalendarModel> calendarList)? loaded,
TResult? Function(String errorMessage)? error,
}) {
return loading?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
TResult Function()? $default, {
TResult Function()? loading,
TResult Function(List<CalendarModel> calendarList)? loaded,
TResult Function(String errorMessage)? error,
required TResult orElse(),
}) {
if (loading != null) {
return loading();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>(
TResult Function(_CalendarState value) $default, {
required TResult Function(CalendarStateLoading value) loading,
required TResult Function(CalendarStateLoaded value) loaded,
required TResult Function(CalendarStateError value) error,
}) {
return loading(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>(
TResult? Function(_CalendarState value)? $default, {
TResult? Function(CalendarStateLoading value)? loading,
TResult? Function(CalendarStateLoaded value)? loaded,
TResult? Function(CalendarStateError value)? error,
}) {
return loading?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>(
TResult Function(_CalendarState value)? $default, {
TResult Function(CalendarStateLoading value)? loading,
TResult Function(CalendarStateLoaded value)? loaded,
TResult Function(CalendarStateError value)? error,
required TResult orElse(),
}) {
if (loading != null) {
return loading(this);
}
return orElse();
}
}
abstract class CalendarStateLoading implements CalendarState {
const factory CalendarStateLoading() = _$CalendarStateLoadingImpl;
}
/// @nodoc
abstract class _$$CalendarStateLoadedImplCopyWith<$Res> {
factory _$$CalendarStateLoadedImplCopyWith(_$CalendarStateLoadedImpl value,
$Res Function(_$CalendarStateLoadedImpl) then) =
__$$CalendarStateLoadedImplCopyWithImpl<$Res>;
@useResult
$Res call({List<CalendarModel> calendarList});
}
/// @nodoc
class __$$CalendarStateLoadedImplCopyWithImpl<$Res>
extends _$CalendarStateCopyWithImpl<$Res, _$CalendarStateLoadedImpl>
implements _$$CalendarStateLoadedImplCopyWith<$Res> {
__$$CalendarStateLoadedImplCopyWithImpl(_$CalendarStateLoadedImpl _value,
$Res Function(_$CalendarStateLoadedImpl) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? calendarList = null,
}) {
return _then(_$CalendarStateLoadedImpl(
calendarList: null == calendarList
? _value._calendarList
: calendarList // ignore: cast_nullable_to_non_nullable
as List<CalendarModel>,
));
}
}
/// @nodoc
class _$CalendarStateLoadedImpl implements CalendarStateLoaded {
const _$CalendarStateLoadedImpl(
{required final List<CalendarModel> calendarList})
: _calendarList = calendarList;
final List<CalendarModel> _calendarList;
@override
List<CalendarModel> get calendarList {
if (_calendarList is EqualUnmodifiableListView) return _calendarList;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_calendarList);
}
@override
String toString() {
return 'CalendarState.loaded(calendarList: $calendarList)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$CalendarStateLoadedImpl &&
const DeepCollectionEquality()
.equals(other._calendarList, _calendarList));
}
@override
int get hashCode => Object.hash(
runtimeType, const DeepCollectionEquality().hash(_calendarList));
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$CalendarStateLoadedImplCopyWith<_$CalendarStateLoadedImpl> get copyWith =>
__$$CalendarStateLoadedImplCopyWithImpl<_$CalendarStateLoadedImpl>(
this, _$identity);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>(
TResult Function() $default, {
required TResult Function() loading,
required TResult Function(List<CalendarModel> calendarList) loaded,
required TResult Function(String errorMessage) error,
}) {
return loaded(calendarList);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
TResult? Function()? $default, {
TResult? Function()? loading,
TResult? Function(List<CalendarModel> calendarList)? loaded,
TResult? Function(String errorMessage)? error,
}) {
return loaded?.call(calendarList);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
TResult Function()? $default, {
TResult Function()? loading,
TResult Function(List<CalendarModel> calendarList)? loaded,
TResult Function(String errorMessage)? error,
required TResult orElse(),
}) {
if (loaded != null) {
return loaded(calendarList);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>(
TResult Function(_CalendarState value) $default, {
required TResult Function(CalendarStateLoading value) loading,
required TResult Function(CalendarStateLoaded value) loaded,
required TResult Function(CalendarStateError value) error,
}) {
return loaded(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>(
TResult? Function(_CalendarState value)? $default, {
TResult? Function(CalendarStateLoading value)? loading,
TResult? Function(CalendarStateLoaded value)? loaded,
TResult? Function(CalendarStateError value)? error,
}) {
return loaded?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>(
TResult Function(_CalendarState value)? $default, {
TResult Function(CalendarStateLoading value)? loading,
TResult Function(CalendarStateLoaded value)? loaded,
TResult Function(CalendarStateError value)? error,
required TResult orElse(),
}) {
if (loaded != null) {
return loaded(this);
}
return orElse();
}
}
abstract class CalendarStateLoaded implements CalendarState {
const factory CalendarStateLoaded(
{required final List<CalendarModel> calendarList}) =
_$CalendarStateLoadedImpl;
List<CalendarModel> get calendarList;
@JsonKey(ignore: true)
_$$CalendarStateLoadedImplCopyWith<_$CalendarStateLoadedImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$CalendarStateErrorImplCopyWith<$Res> {
factory _$$CalendarStateErrorImplCopyWith(_$CalendarStateErrorImpl value,
$Res Function(_$CalendarStateErrorImpl) then) =
__$$CalendarStateErrorImplCopyWithImpl<$Res>;
@useResult
$Res call({String errorMessage});
}
/// @nodoc
class __$$CalendarStateErrorImplCopyWithImpl<$Res>
extends _$CalendarStateCopyWithImpl<$Res, _$CalendarStateErrorImpl>
implements _$$CalendarStateErrorImplCopyWith<$Res> {
__$$CalendarStateErrorImplCopyWithImpl(_$CalendarStateErrorImpl _value,
$Res Function(_$CalendarStateErrorImpl) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? errorMessage = null,
}) {
return _then(_$CalendarStateErrorImpl(
errorMessage: null == errorMessage
? _value.errorMessage
: errorMessage // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
class _$CalendarStateErrorImpl implements CalendarStateError {
const _$CalendarStateErrorImpl({required this.errorMessage});
@override
final String errorMessage;
@override
String toString() {
return 'CalendarState.error(errorMessage: $errorMessage)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$CalendarStateErrorImpl &&
(identical(other.errorMessage, errorMessage) ||
other.errorMessage == errorMessage));
}
@override
int get hashCode => Object.hash(runtimeType, errorMessage);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$CalendarStateErrorImplCopyWith<_$CalendarStateErrorImpl> get copyWith =>
__$$CalendarStateErrorImplCopyWithImpl<_$CalendarStateErrorImpl>(
this, _$identity);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>(
TResult Function() $default, {
required TResult Function() loading,
required TResult Function(List<CalendarModel> calendarList) loaded,
required TResult Function(String errorMessage) error,
}) {
return error(errorMessage);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
TResult? Function()? $default, {
TResult? Function()? loading,
TResult? Function(List<CalendarModel> calendarList)? loaded,
TResult? Function(String errorMessage)? error,
}) {
return error?.call(errorMessage);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
TResult Function()? $default, {
TResult Function()? loading,
TResult Function(List<CalendarModel> calendarList)? loaded,
TResult Function(String errorMessage)? error,
required TResult orElse(),
}) {
if (error != null) {
return error(errorMessage);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>(
TResult Function(_CalendarState value) $default, {
required TResult Function(CalendarStateLoading value) loading,
required TResult Function(CalendarStateLoaded value) loaded,
required TResult Function(CalendarStateError value) error,
}) {
return error(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>(
TResult? Function(_CalendarState value)? $default, {
TResult? Function(CalendarStateLoading value)? loading,
TResult? Function(CalendarStateLoaded value)? loaded,
TResult? Function(CalendarStateError value)? error,
}) {
return error?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>(
TResult Function(_CalendarState value)? $default, {
TResult Function(CalendarStateLoading value)? loading,
TResult Function(CalendarStateLoaded value)? loaded,
TResult Function(CalendarStateError value)? error,
required TResult orElse(),
}) {
if (error != null) {
return error(this);
}
return orElse();
}
}
abstract class CalendarStateError implements CalendarState {
const factory CalendarStateError({required final String errorMessage}) =
_$CalendarStateErrorImpl;
String get errorMessage;
@JsonKey(ignore: true)
_$$CalendarStateErrorImplCopyWith<_$CalendarStateErrorImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -0,0 +1,19 @@
import 'package:eatvio_app/features/calendar/models/calendar_model.dart';
import 'package:eatvio_app/features/calendar/services/calendar_service.dart';
class CalendarRepository {
final CalendarService calendarService;
CalendarRepository({required this.calendarService});
Future<List<CalendarModel>> getCalendar() async {
try {
return (await calendarService.getCalendar())
.entries
.map((entry) => entry.value)
.toList();
} catch (e) {
rethrow;
}
}
}

View File

@@ -0,0 +1,13 @@
import 'package:dio/dio.dart';
import 'package:eatvio_app/features/calendar/models/calendar_model.dart';
import 'package:retrofit/retrofit.dart';
part 'calendar_service.g.dart';
@RestApi()
abstract class CalendarService {
factory CalendarService(Dio dio, {String baseUrl}) = _CalendarService;
@GET('/calendar/index')
Future<Map<String, CalendarModel>> getCalendar();
}

View File

@@ -0,0 +1,78 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'calendar_service.dart';
// **************************************************************************
// RetrofitGenerator
// **************************************************************************
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
class _CalendarService implements CalendarService {
_CalendarService(
this._dio, {
this.baseUrl,
});
final Dio _dio;
String? baseUrl;
@override
Future<Map<String, CalendarModel>> getCalendar() async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _result = await _dio.fetch<Map<String, dynamic>>(
_setStreamType<Map<String, CalendarModel>>(Options(
method: 'GET',
headers: _headers,
extra: _extra,
)
.compose(
_dio.options,
'/calendar/index',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
))));
var _value = _result.data!.map((k, dynamic v) =>
MapEntry(k, CalendarModel.fromJson(v as Map<String, dynamic>)));
return _value;
}
RequestOptions _setStreamType<T>(RequestOptions requestOptions) {
if (T != dynamic &&
!(requestOptions.responseType == ResponseType.bytes ||
requestOptions.responseType == ResponseType.stream)) {
if (T == String) {
requestOptions.responseType = ResponseType.plain;
} else {
requestOptions.responseType = ResponseType.json;
}
}
return requestOptions;
}
String _combineBaseUrls(
String dioBaseUrl,
String? baseUrl,
) {
if (baseUrl == null || baseUrl.trim().isEmpty) {
return dioBaseUrl;
}
final url = Uri.parse(baseUrl);
if (url.isAbsolute) {
return url.toString();
}
return Uri.parse(dioBaseUrl).resolveUri(url).toString();
}
}

View File

@@ -8,23 +8,6 @@ class Product with _$Product {
const factory Product({
required int id,
required String name,
required String image,
required int productGroupId,
required String description,
required String formulations,
required int energyOn100gr,
required double proteinsOn100gr,
required double fatsOn100gr,
required double carbohydratesOn100gr,
required int portionMassGr,
required int energyOnPortion,
required int proteinsOnPortion,
required int fatsOnPortion,
required int carbohydratesOnPortion,
required String createdAt,
required String updatedAt,
required String lastState,
String? reqjectReason,
}) = _Product;
factory Product.fromJson(Map<String, Object?> json) =>

View File

@@ -22,23 +22,6 @@ Product _$ProductFromJson(Map<String, dynamic> json) {
mixin _$Product {
int get id => throw _privateConstructorUsedError;
String get name => throw _privateConstructorUsedError;
String get image => throw _privateConstructorUsedError;
int get productGroupId => throw _privateConstructorUsedError;
String get description => throw _privateConstructorUsedError;
String get formulations => throw _privateConstructorUsedError;
int get energyOn100gr => throw _privateConstructorUsedError;
double get proteinsOn100gr => throw _privateConstructorUsedError;
double get fatsOn100gr => throw _privateConstructorUsedError;
double get carbohydratesOn100gr => throw _privateConstructorUsedError;
int get portionMassGr => throw _privateConstructorUsedError;
int get energyOnPortion => throw _privateConstructorUsedError;
int get proteinsOnPortion => throw _privateConstructorUsedError;
int get fatsOnPortion => throw _privateConstructorUsedError;
int get carbohydratesOnPortion => throw _privateConstructorUsedError;
String get createdAt => throw _privateConstructorUsedError;
String get updatedAt => throw _privateConstructorUsedError;
String get lastState => throw _privateConstructorUsedError;
String? get reqjectReason => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
@@ -50,26 +33,7 @@ abstract class $ProductCopyWith<$Res> {
factory $ProductCopyWith(Product value, $Res Function(Product) then) =
_$ProductCopyWithImpl<$Res, Product>;
@useResult
$Res call(
{int id,
String name,
String image,
int productGroupId,
String description,
String formulations,
int energyOn100gr,
double proteinsOn100gr,
double fatsOn100gr,
double carbohydratesOn100gr,
int portionMassGr,
int energyOnPortion,
int proteinsOnPortion,
int fatsOnPortion,
int carbohydratesOnPortion,
String createdAt,
String updatedAt,
String lastState,
String? reqjectReason});
$Res call({int id, String name});
}
/// @nodoc
@@ -87,23 +51,6 @@ class _$ProductCopyWithImpl<$Res, $Val extends Product>
$Res call({
Object? id = null,
Object? name = null,
Object? image = null,
Object? productGroupId = null,
Object? description = null,
Object? formulations = null,
Object? energyOn100gr = null,
Object? proteinsOn100gr = null,
Object? fatsOn100gr = null,
Object? carbohydratesOn100gr = null,
Object? portionMassGr = null,
Object? energyOnPortion = null,
Object? proteinsOnPortion = null,
Object? fatsOnPortion = null,
Object? carbohydratesOnPortion = null,
Object? createdAt = null,
Object? updatedAt = null,
Object? lastState = null,
Object? reqjectReason = freezed,
}) {
return _then(_value.copyWith(
id: null == id
@@ -114,74 +61,6 @@ class _$ProductCopyWithImpl<$Res, $Val extends Product>
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
image: null == image
? _value.image
: image // ignore: cast_nullable_to_non_nullable
as String,
productGroupId: null == productGroupId
? _value.productGroupId
: productGroupId // ignore: cast_nullable_to_non_nullable
as int,
description: null == description
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String,
formulations: null == formulations
? _value.formulations
: formulations // ignore: cast_nullable_to_non_nullable
as String,
energyOn100gr: null == energyOn100gr
? _value.energyOn100gr
: energyOn100gr // ignore: cast_nullable_to_non_nullable
as int,
proteinsOn100gr: null == proteinsOn100gr
? _value.proteinsOn100gr
: proteinsOn100gr // ignore: cast_nullable_to_non_nullable
as double,
fatsOn100gr: null == fatsOn100gr
? _value.fatsOn100gr
: fatsOn100gr // ignore: cast_nullable_to_non_nullable
as double,
carbohydratesOn100gr: null == carbohydratesOn100gr
? _value.carbohydratesOn100gr
: carbohydratesOn100gr // ignore: cast_nullable_to_non_nullable
as double,
portionMassGr: null == portionMassGr
? _value.portionMassGr
: portionMassGr // ignore: cast_nullable_to_non_nullable
as int,
energyOnPortion: null == energyOnPortion
? _value.energyOnPortion
: energyOnPortion // ignore: cast_nullable_to_non_nullable
as int,
proteinsOnPortion: null == proteinsOnPortion
? _value.proteinsOnPortion
: proteinsOnPortion // ignore: cast_nullable_to_non_nullable
as int,
fatsOnPortion: null == fatsOnPortion
? _value.fatsOnPortion
: fatsOnPortion // ignore: cast_nullable_to_non_nullable
as int,
carbohydratesOnPortion: null == carbohydratesOnPortion
? _value.carbohydratesOnPortion
: carbohydratesOnPortion // ignore: cast_nullable_to_non_nullable
as int,
createdAt: null == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as String,
updatedAt: null == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as String,
lastState: null == lastState
? _value.lastState
: lastState // ignore: cast_nullable_to_non_nullable
as String,
reqjectReason: freezed == reqjectReason
? _value.reqjectReason
: reqjectReason // ignore: cast_nullable_to_non_nullable
as String?,
) as $Val);
}
}
@@ -193,26 +72,7 @@ abstract class _$$ProductImplCopyWith<$Res> implements $ProductCopyWith<$Res> {
__$$ProductImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{int id,
String name,
String image,
int productGroupId,
String description,
String formulations,
int energyOn100gr,
double proteinsOn100gr,
double fatsOn100gr,
double carbohydratesOn100gr,
int portionMassGr,
int energyOnPortion,
int proteinsOnPortion,
int fatsOnPortion,
int carbohydratesOnPortion,
String createdAt,
String updatedAt,
String lastState,
String? reqjectReason});
$Res call({int id, String name});
}
/// @nodoc
@@ -228,23 +88,6 @@ class __$$ProductImplCopyWithImpl<$Res>
$Res call({
Object? id = null,
Object? name = null,
Object? image = null,
Object? productGroupId = null,
Object? description = null,
Object? formulations = null,
Object? energyOn100gr = null,
Object? proteinsOn100gr = null,
Object? fatsOn100gr = null,
Object? carbohydratesOn100gr = null,
Object? portionMassGr = null,
Object? energyOnPortion = null,
Object? proteinsOnPortion = null,
Object? fatsOnPortion = null,
Object? carbohydratesOnPortion = null,
Object? createdAt = null,
Object? updatedAt = null,
Object? lastState = null,
Object? reqjectReason = freezed,
}) {
return _then(_$ProductImpl(
id: null == id
@@ -255,74 +98,6 @@ class __$$ProductImplCopyWithImpl<$Res>
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
image: null == image
? _value.image
: image // ignore: cast_nullable_to_non_nullable
as String,
productGroupId: null == productGroupId
? _value.productGroupId
: productGroupId // ignore: cast_nullable_to_non_nullable
as int,
description: null == description
? _value.description
: description // ignore: cast_nullable_to_non_nullable
as String,
formulations: null == formulations
? _value.formulations
: formulations // ignore: cast_nullable_to_non_nullable
as String,
energyOn100gr: null == energyOn100gr
? _value.energyOn100gr
: energyOn100gr // ignore: cast_nullable_to_non_nullable
as int,
proteinsOn100gr: null == proteinsOn100gr
? _value.proteinsOn100gr
: proteinsOn100gr // ignore: cast_nullable_to_non_nullable
as double,
fatsOn100gr: null == fatsOn100gr
? _value.fatsOn100gr
: fatsOn100gr // ignore: cast_nullable_to_non_nullable
as double,
carbohydratesOn100gr: null == carbohydratesOn100gr
? _value.carbohydratesOn100gr
: carbohydratesOn100gr // ignore: cast_nullable_to_non_nullable
as double,
portionMassGr: null == portionMassGr
? _value.portionMassGr
: portionMassGr // ignore: cast_nullable_to_non_nullable
as int,
energyOnPortion: null == energyOnPortion
? _value.energyOnPortion
: energyOnPortion // ignore: cast_nullable_to_non_nullable
as int,
proteinsOnPortion: null == proteinsOnPortion
? _value.proteinsOnPortion
: proteinsOnPortion // ignore: cast_nullable_to_non_nullable
as int,
fatsOnPortion: null == fatsOnPortion
? _value.fatsOnPortion
: fatsOnPortion // ignore: cast_nullable_to_non_nullable
as int,
carbohydratesOnPortion: null == carbohydratesOnPortion
? _value.carbohydratesOnPortion
: carbohydratesOnPortion // ignore: cast_nullable_to_non_nullable
as int,
createdAt: null == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as String,
updatedAt: null == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as String,
lastState: null == lastState
? _value.lastState
: lastState // ignore: cast_nullable_to_non_nullable
as String,
reqjectReason: freezed == reqjectReason
? _value.reqjectReason
: reqjectReason // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
@@ -330,26 +105,7 @@ class __$$ProductImplCopyWithImpl<$Res>
/// @nodoc
@JsonSerializable()
class _$ProductImpl implements _Product {
const _$ProductImpl(
{required this.id,
required this.name,
required this.image,
required this.productGroupId,
required this.description,
required this.formulations,
required this.energyOn100gr,
required this.proteinsOn100gr,
required this.fatsOn100gr,
required this.carbohydratesOn100gr,
required this.portionMassGr,
required this.energyOnPortion,
required this.proteinsOnPortion,
required this.fatsOnPortion,
required this.carbohydratesOnPortion,
required this.createdAt,
required this.updatedAt,
required this.lastState,
this.reqjectReason});
const _$ProductImpl({required this.id, required this.name});
factory _$ProductImpl.fromJson(Map<String, dynamic> json) =>
_$$ProductImplFromJson(json);
@@ -358,44 +114,10 @@ class _$ProductImpl implements _Product {
final int id;
@override
final String name;
@override
final String image;
@override
final int productGroupId;
@override
final String description;
@override
final String formulations;
@override
final int energyOn100gr;
@override
final double proteinsOn100gr;
@override
final double fatsOn100gr;
@override
final double carbohydratesOn100gr;
@override
final int portionMassGr;
@override
final int energyOnPortion;
@override
final int proteinsOnPortion;
@override
final int fatsOnPortion;
@override
final int carbohydratesOnPortion;
@override
final String createdAt;
@override
final String updatedAt;
@override
final String lastState;
@override
final String? reqjectReason;
@override
String toString() {
return 'Product(id: $id, name: $name, image: $image, productGroupId: $productGroupId, description: $description, formulations: $formulations, energyOn100gr: $energyOn100gr, proteinsOn100gr: $proteinsOn100gr, fatsOn100gr: $fatsOn100gr, carbohydratesOn100gr: $carbohydratesOn100gr, portionMassGr: $portionMassGr, energyOnPortion: $energyOnPortion, proteinsOnPortion: $proteinsOnPortion, fatsOnPortion: $fatsOnPortion, carbohydratesOnPortion: $carbohydratesOnPortion, createdAt: $createdAt, updatedAt: $updatedAt, lastState: $lastState, reqjectReason: $reqjectReason)';
return 'Product(id: $id, name: $name)';
}
@override
@@ -404,66 +126,12 @@ class _$ProductImpl implements _Product {
(other.runtimeType == runtimeType &&
other is _$ProductImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.name, name) || other.name == name) &&
(identical(other.image, image) || other.image == image) &&
(identical(other.productGroupId, productGroupId) ||
other.productGroupId == productGroupId) &&
(identical(other.description, description) ||
other.description == description) &&
(identical(other.formulations, formulations) ||
other.formulations == formulations) &&
(identical(other.energyOn100gr, energyOn100gr) ||
other.energyOn100gr == energyOn100gr) &&
(identical(other.proteinsOn100gr, proteinsOn100gr) ||
other.proteinsOn100gr == proteinsOn100gr) &&
(identical(other.fatsOn100gr, fatsOn100gr) ||
other.fatsOn100gr == fatsOn100gr) &&
(identical(other.carbohydratesOn100gr, carbohydratesOn100gr) ||
other.carbohydratesOn100gr == carbohydratesOn100gr) &&
(identical(other.portionMassGr, portionMassGr) ||
other.portionMassGr == portionMassGr) &&
(identical(other.energyOnPortion, energyOnPortion) ||
other.energyOnPortion == energyOnPortion) &&
(identical(other.proteinsOnPortion, proteinsOnPortion) ||
other.proteinsOnPortion == proteinsOnPortion) &&
(identical(other.fatsOnPortion, fatsOnPortion) ||
other.fatsOnPortion == fatsOnPortion) &&
(identical(other.carbohydratesOnPortion, carbohydratesOnPortion) ||
other.carbohydratesOnPortion == carbohydratesOnPortion) &&
(identical(other.createdAt, createdAt) ||
other.createdAt == createdAt) &&
(identical(other.updatedAt, updatedAt) ||
other.updatedAt == updatedAt) &&
(identical(other.lastState, lastState) ||
other.lastState == lastState) &&
(identical(other.reqjectReason, reqjectReason) ||
other.reqjectReason == reqjectReason));
(identical(other.name, name) || other.name == name));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hashAll([
runtimeType,
id,
name,
image,
productGroupId,
description,
formulations,
energyOn100gr,
proteinsOn100gr,
fatsOn100gr,
carbohydratesOn100gr,
portionMassGr,
energyOnPortion,
proteinsOnPortion,
fatsOnPortion,
carbohydratesOnPortion,
createdAt,
updatedAt,
lastState,
reqjectReason
]);
int get hashCode => Object.hash(runtimeType, id, name);
@JsonKey(ignore: true)
@override
@@ -480,26 +148,8 @@ class _$ProductImpl implements _Product {
}
abstract class _Product implements Product {
const factory _Product(
{required final int id,
required final String name,
required final String image,
required final int productGroupId,
required final String description,
required final String formulations,
required final int energyOn100gr,
required final double proteinsOn100gr,
required final double fatsOn100gr,
required final double carbohydratesOn100gr,
required final int portionMassGr,
required final int energyOnPortion,
required final int proteinsOnPortion,
required final int fatsOnPortion,
required final int carbohydratesOnPortion,
required final String createdAt,
required final String updatedAt,
required final String lastState,
final String? reqjectReason}) = _$ProductImpl;
const factory _Product({required final int id, required final String name}) =
_$ProductImpl;
factory _Product.fromJson(Map<String, dynamic> json) = _$ProductImpl.fromJson;
@@ -508,40 +158,6 @@ abstract class _Product implements Product {
@override
String get name;
@override
String get image;
@override
int get productGroupId;
@override
String get description;
@override
String get formulations;
@override
int get energyOn100gr;
@override
double get proteinsOn100gr;
@override
double get fatsOn100gr;
@override
double get carbohydratesOn100gr;
@override
int get portionMassGr;
@override
int get energyOnPortion;
@override
int get proteinsOnPortion;
@override
int get fatsOnPortion;
@override
int get carbohydratesOnPortion;
@override
String get createdAt;
@override
String get updatedAt;
@override
String get lastState;
@override
String? get reqjectReason;
@override
@JsonKey(ignore: true)
_$$ProductImplCopyWith<_$ProductImpl> get copyWith =>
throw _privateConstructorUsedError;

View File

@@ -10,44 +10,10 @@ _$ProductImpl _$$ProductImplFromJson(Map<String, dynamic> json) =>
_$ProductImpl(
id: (json['id'] as num).toInt(),
name: json['name'] as String,
image: json['image'] as String,
productGroupId: (json['productGroupId'] as num).toInt(),
description: json['description'] as String,
formulations: json['formulations'] as String,
energyOn100gr: (json['energyOn100gr'] as num).toInt(),
proteinsOn100gr: (json['proteinsOn100gr'] as num).toDouble(),
fatsOn100gr: (json['fatsOn100gr'] as num).toDouble(),
carbohydratesOn100gr: (json['carbohydratesOn100gr'] as num).toDouble(),
portionMassGr: (json['portionMassGr'] as num).toInt(),
energyOnPortion: (json['energyOnPortion'] as num).toInt(),
proteinsOnPortion: (json['proteinsOnPortion'] as num).toInt(),
fatsOnPortion: (json['fatsOnPortion'] as num).toInt(),
carbohydratesOnPortion: (json['carbohydratesOnPortion'] as num).toInt(),
createdAt: json['createdAt'] as String,
updatedAt: json['updatedAt'] as String,
lastState: json['lastState'] as String,
reqjectReason: json['reqjectReason'] as String?,
);
Map<String, dynamic> _$$ProductImplToJson(_$ProductImpl instance) =>
<String, dynamic>{
'id': instance.id,
'name': instance.name,
'image': instance.image,
'productGroupId': instance.productGroupId,
'description': instance.description,
'formulations': instance.formulations,
'energyOn100gr': instance.energyOn100gr,
'proteinsOn100gr': instance.proteinsOn100gr,
'fatsOn100gr': instance.fatsOn100gr,
'carbohydratesOn100gr': instance.carbohydratesOn100gr,
'portionMassGr': instance.portionMassGr,
'energyOnPortion': instance.energyOnPortion,
'proteinsOnPortion': instance.proteinsOnPortion,
'fatsOnPortion': instance.fatsOnPortion,
'carbohydratesOnPortion': instance.carbohydratesOnPortion,
'createdAt': instance.createdAt,
'updatedAt': instance.updatedAt,
'lastState': instance.lastState,
'reqjectReason': instance.reqjectReason,
};

View File

@@ -261,9 +261,9 @@ class DiaryBloc extends Bloc<DiaryEvent, DiaryState> {
if (state is DiaryStateLoaded) {
//var currentState = state as DiaryStateLoaded;
print(await diaryRepository.inputProduct(event.input));
final Map<String, List<Product>> productNutritionalValues =
await diaryRepository.inputProduct(event.input);
print(productNutritionalValues);
// Create a new controller with the input text and update the autocomplete list
/*var updatedState = currentState.copyWith(
productNameController: TextEditingController(text: event.input),