forked from eatvio/eatvio_app
internet connection handling
This commit is contained in:
@@ -11,14 +11,14 @@ class Recipes with _$Recipes {
|
||||
required String image,
|
||||
required String state,
|
||||
@JsonKey(name: 'cooking_time') required int cookingTime,
|
||||
required List<Ingredient> ingredients,
|
||||
required List<Ingredient>? ingredients,
|
||||
required String description,
|
||||
required List<Step> steps,
|
||||
@JsonKey(name: 'video_url') required String videoUrl,
|
||||
required List<Step>? steps,
|
||||
@JsonKey(name: 'video_url') required String? videoUrl,
|
||||
@JsonKey(name: 'created_at') required DateTime createdAt,
|
||||
@JsonKey(name: 'updated_at') required DateTime updatedAt,
|
||||
required String title,
|
||||
required String type,
|
||||
required String? title,
|
||||
required String? type,
|
||||
required String slug,
|
||||
@JsonKey(name: 'total_comments') required int commentsCount,
|
||||
@JsonKey(name: 'was_liked_by_me') required bool wasLikedByMe,
|
||||
|
||||
@@ -25,17 +25,17 @@ mixin _$Recipes {
|
||||
String get state => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'cooking_time')
|
||||
int get cookingTime => throw _privateConstructorUsedError;
|
||||
List<Ingredient> get ingredients => throw _privateConstructorUsedError;
|
||||
List<Ingredient>? get ingredients => throw _privateConstructorUsedError;
|
||||
String get description => throw _privateConstructorUsedError;
|
||||
List<Step> get steps => throw _privateConstructorUsedError;
|
||||
List<Step>? get steps => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'video_url')
|
||||
String get videoUrl => throw _privateConstructorUsedError;
|
||||
String? get videoUrl => 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;
|
||||
String get type => throw _privateConstructorUsedError;
|
||||
String? get title => throw _privateConstructorUsedError;
|
||||
String? get type => throw _privateConstructorUsedError;
|
||||
String get slug => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'total_comments')
|
||||
int get commentsCount => throw _privateConstructorUsedError;
|
||||
@@ -68,14 +68,14 @@ abstract class $RecipesCopyWith<$Res> {
|
||||
String image,
|
||||
String state,
|
||||
@JsonKey(name: 'cooking_time') int cookingTime,
|
||||
List<Ingredient> ingredients,
|
||||
List<Ingredient>? ingredients,
|
||||
String description,
|
||||
List<Step> steps,
|
||||
@JsonKey(name: 'video_url') String videoUrl,
|
||||
List<Step>? steps,
|
||||
@JsonKey(name: 'video_url') String? videoUrl,
|
||||
@JsonKey(name: 'created_at') DateTime createdAt,
|
||||
@JsonKey(name: 'updated_at') DateTime updatedAt,
|
||||
String title,
|
||||
String type,
|
||||
String? title,
|
||||
String? type,
|
||||
String slug,
|
||||
@JsonKey(name: 'total_comments') int commentsCount,
|
||||
@JsonKey(name: 'was_liked_by_me') bool wasLikedByMe,
|
||||
@@ -106,14 +106,14 @@ class _$RecipesCopyWithImpl<$Res, $Val extends Recipes>
|
||||
Object? image = null,
|
||||
Object? state = null,
|
||||
Object? cookingTime = null,
|
||||
Object? ingredients = null,
|
||||
Object? ingredients = freezed,
|
||||
Object? description = null,
|
||||
Object? steps = null,
|
||||
Object? videoUrl = null,
|
||||
Object? steps = freezed,
|
||||
Object? videoUrl = freezed,
|
||||
Object? createdAt = null,
|
||||
Object? updatedAt = null,
|
||||
Object? title = null,
|
||||
Object? type = null,
|
||||
Object? title = freezed,
|
||||
Object? type = freezed,
|
||||
Object? slug = null,
|
||||
Object? commentsCount = null,
|
||||
Object? wasLikedByMe = null,
|
||||
@@ -139,22 +139,22 @@ class _$RecipesCopyWithImpl<$Res, $Val extends Recipes>
|
||||
? _value.cookingTime
|
||||
: cookingTime // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
ingredients: null == ingredients
|
||||
ingredients: freezed == ingredients
|
||||
? _value.ingredients
|
||||
: ingredients // ignore: cast_nullable_to_non_nullable
|
||||
as List<Ingredient>,
|
||||
as List<Ingredient>?,
|
||||
description: null == description
|
||||
? _value.description
|
||||
: description // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
steps: null == steps
|
||||
steps: freezed == steps
|
||||
? _value.steps
|
||||
: steps // ignore: cast_nullable_to_non_nullable
|
||||
as List<Step>,
|
||||
videoUrl: null == videoUrl
|
||||
as List<Step>?,
|
||||
videoUrl: freezed == videoUrl
|
||||
? _value.videoUrl
|
||||
: videoUrl // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
as String?,
|
||||
createdAt: null == createdAt
|
||||
? _value.createdAt
|
||||
: createdAt // ignore: cast_nullable_to_non_nullable
|
||||
@@ -163,14 +163,14 @@ class _$RecipesCopyWithImpl<$Res, $Val extends Recipes>
|
||||
? _value.updatedAt
|
||||
: updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
title: null == title
|
||||
title: freezed == title
|
||||
? _value.title
|
||||
: title // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
type: null == type
|
||||
as String?,
|
||||
type: freezed == type
|
||||
? _value.type
|
||||
: type // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
as String?,
|
||||
slug: null == slug
|
||||
? _value.slug
|
||||
: slug // ignore: cast_nullable_to_non_nullable
|
||||
@@ -225,14 +225,14 @@ abstract class _$$RecipesImplCopyWith<$Res> implements $RecipesCopyWith<$Res> {
|
||||
String image,
|
||||
String state,
|
||||
@JsonKey(name: 'cooking_time') int cookingTime,
|
||||
List<Ingredient> ingredients,
|
||||
List<Ingredient>? ingredients,
|
||||
String description,
|
||||
List<Step> steps,
|
||||
@JsonKey(name: 'video_url') String videoUrl,
|
||||
List<Step>? steps,
|
||||
@JsonKey(name: 'video_url') String? videoUrl,
|
||||
@JsonKey(name: 'created_at') DateTime createdAt,
|
||||
@JsonKey(name: 'updated_at') DateTime updatedAt,
|
||||
String title,
|
||||
String type,
|
||||
String? title,
|
||||
String? type,
|
||||
String slug,
|
||||
@JsonKey(name: 'total_comments') int commentsCount,
|
||||
@JsonKey(name: 'was_liked_by_me') bool wasLikedByMe,
|
||||
@@ -262,14 +262,14 @@ class __$$RecipesImplCopyWithImpl<$Res>
|
||||
Object? image = null,
|
||||
Object? state = null,
|
||||
Object? cookingTime = null,
|
||||
Object? ingredients = null,
|
||||
Object? ingredients = freezed,
|
||||
Object? description = null,
|
||||
Object? steps = null,
|
||||
Object? videoUrl = null,
|
||||
Object? steps = freezed,
|
||||
Object? videoUrl = freezed,
|
||||
Object? createdAt = null,
|
||||
Object? updatedAt = null,
|
||||
Object? title = null,
|
||||
Object? type = null,
|
||||
Object? title = freezed,
|
||||
Object? type = freezed,
|
||||
Object? slug = null,
|
||||
Object? commentsCount = null,
|
||||
Object? wasLikedByMe = null,
|
||||
@@ -295,22 +295,22 @@ class __$$RecipesImplCopyWithImpl<$Res>
|
||||
? _value.cookingTime
|
||||
: cookingTime // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
ingredients: null == ingredients
|
||||
ingredients: freezed == ingredients
|
||||
? _value._ingredients
|
||||
: ingredients // ignore: cast_nullable_to_non_nullable
|
||||
as List<Ingredient>,
|
||||
as List<Ingredient>?,
|
||||
description: null == description
|
||||
? _value.description
|
||||
: description // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
steps: null == steps
|
||||
steps: freezed == steps
|
||||
? _value._steps
|
||||
: steps // ignore: cast_nullable_to_non_nullable
|
||||
as List<Step>,
|
||||
videoUrl: null == videoUrl
|
||||
as List<Step>?,
|
||||
videoUrl: freezed == videoUrl
|
||||
? _value.videoUrl
|
||||
: videoUrl // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
as String?,
|
||||
createdAt: null == createdAt
|
||||
? _value.createdAt
|
||||
: createdAt // ignore: cast_nullable_to_non_nullable
|
||||
@@ -319,14 +319,14 @@ class __$$RecipesImplCopyWithImpl<$Res>
|
||||
? _value.updatedAt
|
||||
: updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
title: null == title
|
||||
title: freezed == title
|
||||
? _value.title
|
||||
: title // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
type: null == type
|
||||
as String?,
|
||||
type: freezed == type
|
||||
? _value.type
|
||||
: type // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
as String?,
|
||||
slug: null == slug
|
||||
? _value.slug
|
||||
: slug // ignore: cast_nullable_to_non_nullable
|
||||
@@ -367,9 +367,9 @@ class _$RecipesImpl implements _Recipes {
|
||||
required this.image,
|
||||
required this.state,
|
||||
@JsonKey(name: 'cooking_time') required this.cookingTime,
|
||||
required final List<Ingredient> ingredients,
|
||||
required final List<Ingredient>? ingredients,
|
||||
required this.description,
|
||||
required final List<Step> steps,
|
||||
required final List<Step>? steps,
|
||||
@JsonKey(name: 'video_url') required this.videoUrl,
|
||||
@JsonKey(name: 'created_at') required this.createdAt,
|
||||
@JsonKey(name: 'updated_at') required this.updatedAt,
|
||||
@@ -397,27 +397,31 @@ class _$RecipesImpl implements _Recipes {
|
||||
@override
|
||||
@JsonKey(name: 'cooking_time')
|
||||
final int cookingTime;
|
||||
final List<Ingredient> _ingredients;
|
||||
final List<Ingredient>? _ingredients;
|
||||
@override
|
||||
List<Ingredient> get ingredients {
|
||||
List<Ingredient>? get ingredients {
|
||||
final value = _ingredients;
|
||||
if (value == null) return null;
|
||||
if (_ingredients is EqualUnmodifiableListView) return _ingredients;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_ingredients);
|
||||
return EqualUnmodifiableListView(value);
|
||||
}
|
||||
|
||||
@override
|
||||
final String description;
|
||||
final List<Step> _steps;
|
||||
final List<Step>? _steps;
|
||||
@override
|
||||
List<Step> get steps {
|
||||
List<Step>? get steps {
|
||||
final value = _steps;
|
||||
if (value == null) return null;
|
||||
if (_steps is EqualUnmodifiableListView) return _steps;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_steps);
|
||||
return EqualUnmodifiableListView(value);
|
||||
}
|
||||
|
||||
@override
|
||||
@JsonKey(name: 'video_url')
|
||||
final String videoUrl;
|
||||
final String? videoUrl;
|
||||
@override
|
||||
@JsonKey(name: 'created_at')
|
||||
final DateTime createdAt;
|
||||
@@ -425,9 +429,9 @@ class _$RecipesImpl implements _Recipes {
|
||||
@JsonKey(name: 'updated_at')
|
||||
final DateTime updatedAt;
|
||||
@override
|
||||
final String title;
|
||||
final String? title;
|
||||
@override
|
||||
final String type;
|
||||
final String? type;
|
||||
@override
|
||||
final String slug;
|
||||
@override
|
||||
@@ -537,14 +541,14 @@ abstract class _Recipes implements Recipes {
|
||||
required final String image,
|
||||
required final String state,
|
||||
@JsonKey(name: 'cooking_time') required final int cookingTime,
|
||||
required final List<Ingredient> ingredients,
|
||||
required final List<Ingredient>? ingredients,
|
||||
required final String description,
|
||||
required final List<Step> steps,
|
||||
@JsonKey(name: 'video_url') required final String videoUrl,
|
||||
required final List<Step>? steps,
|
||||
@JsonKey(name: 'video_url') required final String? videoUrl,
|
||||
@JsonKey(name: 'created_at') required final DateTime createdAt,
|
||||
@JsonKey(name: 'updated_at') required final DateTime updatedAt,
|
||||
required final String title,
|
||||
required final String type,
|
||||
required final String? title,
|
||||
required final String? type,
|
||||
required final String slug,
|
||||
@JsonKey(name: 'total_comments') required final int commentsCount,
|
||||
@JsonKey(name: 'was_liked_by_me') required final bool wasLikedByMe,
|
||||
@@ -565,14 +569,14 @@ abstract class _Recipes implements Recipes {
|
||||
@JsonKey(name: 'cooking_time')
|
||||
int get cookingTime;
|
||||
@override
|
||||
List<Ingredient> get ingredients;
|
||||
List<Ingredient>? get ingredients;
|
||||
@override
|
||||
String get description;
|
||||
@override
|
||||
List<Step> get steps;
|
||||
List<Step>? get steps;
|
||||
@override
|
||||
@JsonKey(name: 'video_url')
|
||||
String get videoUrl;
|
||||
String? get videoUrl;
|
||||
@override
|
||||
@JsonKey(name: 'created_at')
|
||||
DateTime get createdAt;
|
||||
@@ -580,9 +584,9 @@ abstract class _Recipes implements Recipes {
|
||||
@JsonKey(name: 'updated_at')
|
||||
DateTime get updatedAt;
|
||||
@override
|
||||
String get title;
|
||||
String? get title;
|
||||
@override
|
||||
String get type;
|
||||
String? get type;
|
||||
@override
|
||||
String get slug;
|
||||
@override
|
||||
|
||||
@@ -12,18 +12,18 @@ _$RecipesImpl _$$RecipesImplFromJson(Map<String, dynamic> json) =>
|
||||
image: json['image'] as String,
|
||||
state: json['state'] as String,
|
||||
cookingTime: (json['cooking_time'] as num).toInt(),
|
||||
ingredients: (json['ingredients'] as List<dynamic>)
|
||||
.map((e) => Ingredient.fromJson(e as Map<String, dynamic>))
|
||||
ingredients: (json['ingredients'] as List<dynamic>?)
|
||||
?.map((e) => Ingredient.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
description: json['description'] as String,
|
||||
steps: (json['steps'] as List<dynamic>)
|
||||
.map((e) => Step.fromJson(e as Map<String, dynamic>))
|
||||
steps: (json['steps'] as List<dynamic>?)
|
||||
?.map((e) => Step.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
videoUrl: json['video_url'] as String,
|
||||
videoUrl: json['video_url'] as String?,
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
title: json['title'] as String,
|
||||
type: json['type'] as String,
|
||||
title: json['title'] as String?,
|
||||
type: json['type'] as String?,
|
||||
slug: json['slug'] as String,
|
||||
commentsCount: (json['total_comments'] as num).toInt(),
|
||||
wasLikedByMe: json['was_liked_by_me'] as bool,
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:eatvio_app/features/feed/repositories/feed_repository.dart';
|
||||
import 'package:eatvio_app/features/recipes/models/recipe_tag_model.dart';
|
||||
import 'package:eatvio_app/features/recipes/reporitories/recipe_repository.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'dart:developer';
|
||||
|
||||
class RecipesCubit extends Cubit<RecipesState> {
|
||||
final FeedRepository feedRepository;
|
||||
@@ -38,7 +39,8 @@ class RecipesCubit extends Cubit<RecipesState> {
|
||||
),
|
||||
);
|
||||
lastPage = currentPage;
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
log(e.toString(), stackTrace: st);
|
||||
emit(RecipesState.error(errorMessage: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,4 +47,4 @@ class Recipes extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ class _RecipesWidgetState extends State<RecipesWidget> {
|
||||
children: [
|
||||
_iconButton('assets/icons/clock.svg', widget.recipes.cookingTime.toString() + ' минут'),
|
||||
SizedBox(width: 8),
|
||||
_iconButton('assets/icons/steps.svg', widget.recipes.steps.length.toString() + ' этапов'),
|
||||
_iconButton('assets/icons/steps.svg', '${widget.recipes.steps?.length ?? 0}' + ' этапов'),
|
||||
SizedBox(width: 8),
|
||||
_iconButton('assets/icons/calories.svg', '139.9 ккал'),
|
||||
],
|
||||
@@ -73,7 +73,7 @@ class _RecipesWidgetState extends State<RecipesWidget> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Text(
|
||||
widget.recipes.title,
|
||||
widget.recipes.title.toString(),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.black87,
|
||||
|
||||
Reference in New Issue
Block a user