feat: product scroll infinity

This commit is contained in:
efrilm
2025-08-05 19:48:32 +07:00
parent bb9aef55cf
commit 3e9b20f237
6 changed files with 692 additions and 194 deletions
@@ -13,17 +13,27 @@ import 'auth_local_datasource.dart';
class ProductRemoteDatasource {
final Dio dio = DioClient.instance;
Future<Either<String, ProductResponseModel>> getProducts() async {
Future<Either<String, ProductResponseModel>> getProducts({
int page = 1,
int limit = Variables.defaultLimit,
String? categoryId,
}) async {
try {
final authData = await AuthLocalDataSource().getAuthData();
final url = '${Variables.baseUrl}/api/v1/products';
Map<String, dynamic> queryParameters = {
'page': page,
'limit': limit,
};
if (categoryId != null) {
queryParameters['category_id'] = categoryId;
}
final response = await dio.get(
url,
queryParameters: {
'page': 1,
'limit': 30,
},
queryParameters: queryParameters,
options: Options(
headers: {
'Authorization': 'Bearer ${authData.token}',