feat: search product and fix product

This commit is contained in:
efrilm
2025-08-07 12:19:25 +07:00
parent 5575596bfc
commit fe92082ceb
9 changed files with 349 additions and 118 deletions
@@ -18,22 +18,22 @@ final _privateConstructorUsedError = UnsupportedError(
mixin _$ProductLoaderEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String? categoryId) getProduct,
required TResult Function(String? categoryId) loadMore,
required TResult Function(String? categoryId, String? search) getProduct,
required TResult Function(String? categoryId, String? search) loadMore,
required TResult Function() refresh,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String? categoryId)? getProduct,
TResult? Function(String? categoryId)? loadMore,
TResult? Function(String? categoryId, String? search)? getProduct,
TResult? Function(String? categoryId, String? search)? loadMore,
TResult? Function()? refresh,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String? categoryId)? getProduct,
TResult Function(String? categoryId)? loadMore,
TResult Function(String? categoryId, String? search)? getProduct,
TResult Function(String? categoryId, String? search)? loadMore,
TResult Function()? refresh,
required TResult orElse(),
}) =>
@@ -89,7 +89,7 @@ abstract class _$$GetProductImplCopyWith<$Res> {
_$GetProductImpl value, $Res Function(_$GetProductImpl) then) =
__$$GetProductImplCopyWithImpl<$Res>;
@useResult
$Res call({String? categoryId});
$Res call({String? categoryId, String? search});
}
/// @nodoc
@@ -106,12 +106,17 @@ class __$$GetProductImplCopyWithImpl<$Res>
@override
$Res call({
Object? categoryId = freezed,
Object? search = freezed,
}) {
return _then(_$GetProductImpl(
categoryId: freezed == categoryId
? _value.categoryId
: categoryId // ignore: cast_nullable_to_non_nullable
as String?,
search: freezed == search
? _value.search
: search // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
@@ -119,14 +124,16 @@ class __$$GetProductImplCopyWithImpl<$Res>
/// @nodoc
class _$GetProductImpl implements _GetProduct {
const _$GetProductImpl({this.categoryId});
const _$GetProductImpl({this.categoryId, this.search});
@override
final String? categoryId;
@override
final String? search;
@override
String toString() {
return 'ProductLoaderEvent.getProduct(categoryId: $categoryId)';
return 'ProductLoaderEvent.getProduct(categoryId: $categoryId, search: $search)';
}
@override
@@ -135,11 +142,12 @@ class _$GetProductImpl implements _GetProduct {
(other.runtimeType == runtimeType &&
other is _$GetProductImpl &&
(identical(other.categoryId, categoryId) ||
other.categoryId == categoryId));
other.categoryId == categoryId) &&
(identical(other.search, search) || other.search == search));
}
@override
int get hashCode => Object.hash(runtimeType, categoryId);
int get hashCode => Object.hash(runtimeType, categoryId, search);
/// Create a copy of ProductLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@@ -152,33 +160,33 @@ class _$GetProductImpl implements _GetProduct {
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String? categoryId) getProduct,
required TResult Function(String? categoryId) loadMore,
required TResult Function(String? categoryId, String? search) getProduct,
required TResult Function(String? categoryId, String? search) loadMore,
required TResult Function() refresh,
}) {
return getProduct(categoryId);
return getProduct(categoryId, search);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String? categoryId)? getProduct,
TResult? Function(String? categoryId)? loadMore,
TResult? Function(String? categoryId, String? search)? getProduct,
TResult? Function(String? categoryId, String? search)? loadMore,
TResult? Function()? refresh,
}) {
return getProduct?.call(categoryId);
return getProduct?.call(categoryId, search);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String? categoryId)? getProduct,
TResult Function(String? categoryId)? loadMore,
TResult Function(String? categoryId, String? search)? getProduct,
TResult Function(String? categoryId, String? search)? loadMore,
TResult Function()? refresh,
required TResult orElse(),
}) {
if (getProduct != null) {
return getProduct(categoryId);
return getProduct(categoryId, search);
}
return orElse();
}
@@ -219,9 +227,11 @@ class _$GetProductImpl implements _GetProduct {
}
abstract class _GetProduct implements ProductLoaderEvent {
const factory _GetProduct({final String? categoryId}) = _$GetProductImpl;
const factory _GetProduct({final String? categoryId, final String? search}) =
_$GetProductImpl;
String? get categoryId;
String? get search;
/// Create a copy of ProductLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@@ -236,7 +246,7 @@ abstract class _$$LoadMoreImplCopyWith<$Res> {
_$LoadMoreImpl value, $Res Function(_$LoadMoreImpl) then) =
__$$LoadMoreImplCopyWithImpl<$Res>;
@useResult
$Res call({String? categoryId});
$Res call({String? categoryId, String? search});
}
/// @nodoc
@@ -253,12 +263,17 @@ class __$$LoadMoreImplCopyWithImpl<$Res>
@override
$Res call({
Object? categoryId = freezed,
Object? search = freezed,
}) {
return _then(_$LoadMoreImpl(
categoryId: freezed == categoryId
? _value.categoryId
: categoryId // ignore: cast_nullable_to_non_nullable
as String?,
search: freezed == search
? _value.search
: search // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
@@ -266,14 +281,16 @@ class __$$LoadMoreImplCopyWithImpl<$Res>
/// @nodoc
class _$LoadMoreImpl implements _LoadMore {
const _$LoadMoreImpl({this.categoryId});
const _$LoadMoreImpl({this.categoryId, this.search});
@override
final String? categoryId;
@override
final String? search;
@override
String toString() {
return 'ProductLoaderEvent.loadMore(categoryId: $categoryId)';
return 'ProductLoaderEvent.loadMore(categoryId: $categoryId, search: $search)';
}
@override
@@ -282,11 +299,12 @@ class _$LoadMoreImpl implements _LoadMore {
(other.runtimeType == runtimeType &&
other is _$LoadMoreImpl &&
(identical(other.categoryId, categoryId) ||
other.categoryId == categoryId));
other.categoryId == categoryId) &&
(identical(other.search, search) || other.search == search));
}
@override
int get hashCode => Object.hash(runtimeType, categoryId);
int get hashCode => Object.hash(runtimeType, categoryId, search);
/// Create a copy of ProductLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@@ -299,33 +317,33 @@ class _$LoadMoreImpl implements _LoadMore {
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String? categoryId) getProduct,
required TResult Function(String? categoryId) loadMore,
required TResult Function(String? categoryId, String? search) getProduct,
required TResult Function(String? categoryId, String? search) loadMore,
required TResult Function() refresh,
}) {
return loadMore(categoryId);
return loadMore(categoryId, search);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String? categoryId)? getProduct,
TResult? Function(String? categoryId)? loadMore,
TResult? Function(String? categoryId, String? search)? getProduct,
TResult? Function(String? categoryId, String? search)? loadMore,
TResult? Function()? refresh,
}) {
return loadMore?.call(categoryId);
return loadMore?.call(categoryId, search);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String? categoryId)? getProduct,
TResult Function(String? categoryId)? loadMore,
TResult Function(String? categoryId, String? search)? getProduct,
TResult Function(String? categoryId, String? search)? loadMore,
TResult Function()? refresh,
required TResult orElse(),
}) {
if (loadMore != null) {
return loadMore(categoryId);
return loadMore(categoryId, search);
}
return orElse();
}
@@ -366,9 +384,11 @@ class _$LoadMoreImpl implements _LoadMore {
}
abstract class _LoadMore implements ProductLoaderEvent {
const factory _LoadMore({final String? categoryId}) = _$LoadMoreImpl;
const factory _LoadMore({final String? categoryId, final String? search}) =
_$LoadMoreImpl;
String? get categoryId;
String? get search;
/// Create a copy of ProductLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@@ -418,8 +438,8 @@ class _$RefreshImpl implements _Refresh {
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String? categoryId) getProduct,
required TResult Function(String? categoryId) loadMore,
required TResult Function(String? categoryId, String? search) getProduct,
required TResult Function(String? categoryId, String? search) loadMore,
required TResult Function() refresh,
}) {
return refresh();
@@ -428,8 +448,8 @@ class _$RefreshImpl implements _Refresh {
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String? categoryId)? getProduct,
TResult? Function(String? categoryId)? loadMore,
TResult? Function(String? categoryId, String? search)? getProduct,
TResult? Function(String? categoryId, String? search)? loadMore,
TResult? Function()? refresh,
}) {
return refresh?.call();
@@ -438,8 +458,8 @@ class _$RefreshImpl implements _Refresh {
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String? categoryId)? getProduct,
TResult Function(String? categoryId)? loadMore,
TResult Function(String? categoryId, String? search)? getProduct,
TResult Function(String? categoryId, String? search)? loadMore,
TResult Function()? refresh,
required TResult orElse(),
}) {
@@ -2,8 +2,9 @@ part of 'product_loader_bloc.dart';
@freezed
class ProductLoaderEvent with _$ProductLoaderEvent {
const factory ProductLoaderEvent.getProduct({String? categoryId}) =
_GetProduct;
const factory ProductLoaderEvent.loadMore({String? categoryId}) = _LoadMore;
const factory ProductLoaderEvent.getProduct(
{String? categoryId, String? search}) = _GetProduct;
const factory ProductLoaderEvent.loadMore(
{String? categoryId, String? search}) = _LoadMore;
const factory ProductLoaderEvent.refresh() = _Refresh;
}