complete category issue
This commit is contained in:
@@ -7,6 +7,7 @@ import 'package:geolocator/geolocator.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:grocery_app/src/core/network_services/service_locator.dart';
|
||||
import 'package:grocery_app/src/core/routes/routes.dart';
|
||||
import 'package:grocery_app/src/data/ProductCategoryModel.dart';
|
||||
import 'package:grocery_app/src/data/allProduct_model.dart';
|
||||
import 'package:grocery_app/src/data/all_cart_items.dart';
|
||||
import 'package:grocery_app/src/data/banners.dart';
|
||||
@@ -186,7 +187,7 @@ class ProductProvider extends ChangeNotifier {
|
||||
);
|
||||
}
|
||||
|
||||
List<Datum> categoryList = [];
|
||||
List<DatumCategory> categoryList = [];
|
||||
|
||||
bool iscategroyloading = true;
|
||||
Future<void> getAllcategory(BuildContext context) async {
|
||||
@@ -201,6 +202,7 @@ class ProductProvider extends ChangeNotifier {
|
||||
},
|
||||
(response) {
|
||||
print("jdshfjghdhfjhgjd");
|
||||
|
||||
categoryList = response.data!;
|
||||
iscategroyloading = false;
|
||||
notifyListeners();
|
||||
@@ -208,6 +210,60 @@ class ProductProvider extends ChangeNotifier {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getSubcategory(BuildContext context, String? id) async {
|
||||
var data = {"parentId": id};
|
||||
|
||||
print("kdjhgkjfkjgkj ${id}");
|
||||
|
||||
var result = await _homeRepo.getSubcategory(data, context);
|
||||
return result.fold(
|
||||
(error) {
|
||||
print("djhgfjdfhjg ${error}");
|
||||
iscategroyloading = false;
|
||||
notifyListeners();
|
||||
},
|
||||
(response) {
|
||||
print("dsfdgdfgfhfghjghjghjghjhkghj");
|
||||
categoryList = response!;
|
||||
iscategroyloading = false;
|
||||
notifyListeners();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
List<ProductCategoryModel> categoriesss = [];
|
||||
|
||||
ProductCategoryModel? selectedCategory;
|
||||
|
||||
Future<void> getCategoryByLevel() async {
|
||||
categoriesss.clear();
|
||||
|
||||
final result = await _homeRepo.getCategoryByLevel({});
|
||||
|
||||
result.fold(
|
||||
(error) {
|
||||
print("Error fetching categories: $error");
|
||||
notifyListeners();
|
||||
},
|
||||
(categoryList) {
|
||||
if (categoryList.isNotEmpty) {
|
||||
final categories = [ProductCategoryModel(id: "all", name: "ALL")];
|
||||
categories.addAll(categoryList.cast<ProductCategoryModel>());
|
||||
|
||||
categoriesss = categories;
|
||||
} else {
|
||||
print("No categories found.");
|
||||
}
|
||||
notifyListeners(); // Notify UI after update
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void setSelectedCategory(ProductCategoryModel category) {
|
||||
selectedCategory = category;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
//similarProduct
|
||||
|
||||
List<BannerData> banner = [];
|
||||
@@ -809,8 +865,7 @@ class ProductProvider extends ChangeNotifier {
|
||||
(error) {
|
||||
notifyListeners();
|
||||
},
|
||||
(response)
|
||||
{
|
||||
(response) {
|
||||
print("lkdfjglkfdglkh ${response.data}");
|
||||
_suggestions.addAll(response.data as Iterable<Product>);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user