complete category issue
This commit is contained in:
@@ -37,6 +37,12 @@
|
|||||||
"packageUri": "lib/",
|
"packageUri": "lib/",
|
||||||
"languageVersion": "3.2"
|
"languageVersion": "3.2"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "blur",
|
||||||
|
"rootUri": "file:///Users/rajeevsingh/.pub-cache/hosted/pub.dev/blur-4.0.0",
|
||||||
|
"packageUri": "lib/",
|
||||||
|
"languageVersion": "3.4"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "boolean_selector",
|
"name": "boolean_selector",
|
||||||
"rootUri": "file:///Users/rajeevsingh/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1",
|
"rootUri": "file:///Users/rajeevsingh/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1",
|
||||||
@@ -998,7 +1004,7 @@
|
|||||||
"languageVersion": "3.4"
|
"languageVersion": "3.4"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"generated": "2025-03-18T13:17:38.535876Z",
|
"generated": "2025-03-20T12:51:19.355653Z",
|
||||||
"generator": "pub",
|
"generator": "pub",
|
||||||
"generatorVersion": "3.4.4",
|
"generatorVersion": "3.4.4",
|
||||||
"flutterRoot": "file:///Users/rajeevsingh/Documents/allSoftwares/flutter",
|
"flutterRoot": "file:///Users/rajeevsingh/Documents/allSoftwares/flutter",
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ back_button_interceptor
|
|||||||
3.2
|
3.2
|
||||||
file:///Users/rajeevsingh/.pub-cache/hosted/pub.dev/back_button_interceptor-8.0.4/
|
file:///Users/rajeevsingh/.pub-cache/hosted/pub.dev/back_button_interceptor-8.0.4/
|
||||||
file:///Users/rajeevsingh/.pub-cache/hosted/pub.dev/back_button_interceptor-8.0.4/lib/
|
file:///Users/rajeevsingh/.pub-cache/hosted/pub.dev/back_button_interceptor-8.0.4/lib/
|
||||||
|
blur
|
||||||
|
3.4
|
||||||
|
file:///Users/rajeevsingh/.pub-cache/hosted/pub.dev/blur-4.0.0/
|
||||||
|
file:///Users/rajeevsingh/.pub-cache/hosted/pub.dev/blur-4.0.0/lib/
|
||||||
boolean_selector
|
boolean_selector
|
||||||
2.17
|
2.17
|
||||||
file:///Users/rajeevsingh/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1/
|
file:///Users/rajeevsingh/.pub-cache/hosted/pub.dev/boolean_selector-2.1.1/
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -12,6 +12,7 @@ class APIURL {
|
|||||||
static const String getBestDealProduct = "${BASE_URL}products/best-deals";
|
static const String getBestDealProduct = "${BASE_URL}products/best-deals";
|
||||||
static const String getAllcategory = "${BASE_URL}categories";
|
static const String getAllcategory = "${BASE_URL}categories";
|
||||||
static const String addToWish = "${BASE_URL}carts/wishlist/items";
|
static const String addToWish = "${BASE_URL}carts/wishlist/items";
|
||||||
|
static const String getSubcategory = "${BASE_URL}categories/by-level/2";
|
||||||
static const String deleteToWish = "${BASE_URL}carts/wishlist/items";
|
static const String deleteToWish = "${BASE_URL}carts/wishlist/items";
|
||||||
static const String addToCart = "${BASE_URL}carts/items";
|
static const String addToCart = "${BASE_URL}carts/items";
|
||||||
static const String gettAllWishList = "${BASE_URL}carts/wishlist";
|
static const String gettAllWishList = "${BASE_URL}carts/wishlist";
|
||||||
@@ -31,8 +32,7 @@ class APIURL {
|
|||||||
static const String offerCoupon = "${BASE_URL}coupons";
|
static const String offerCoupon = "${BASE_URL}coupons";
|
||||||
static const String applyCoupon = "${BASE_URL}coupons/validate";
|
static const String applyCoupon = "${BASE_URL}coupons/validate";
|
||||||
static const String forgetPassword = "${BASE_URL}auth/forgot-password/vendor";
|
static const String forgetPassword = "${BASE_URL}auth/forgot-password/vendor";
|
||||||
static const String verifyForgetPassword =
|
static const String verifyForgetPassword = "${BASE_URL}auth/forgot-password-verify-otp/vendor";
|
||||||
"${BASE_URL}auth/forgot-password-verify-otp/vendor";
|
|
||||||
static const String reset_password = "${BASE_URL}auth/reset-password/vendor";
|
static const String reset_password = "${BASE_URL}auth/reset-password/vendor";
|
||||||
|
|
||||||
static const String getProduct = "${BASE_URL}products";
|
static const String getProduct = "${BASE_URL}products";
|
||||||
@@ -45,8 +45,9 @@ class APIURL {
|
|||||||
static const String updateProduct = "${BASE_URL}products/";
|
static const String updateProduct = "${BASE_URL}products/";
|
||||||
|
|
||||||
|
|
||||||
static const String getAssignedOtp =
|
static const String getAssignedOtp ="${BASE_URL}delivery/customer-otp";
|
||||||
"${BASE_URL}delivery/customer-otp";
|
|
||||||
|
|
||||||
static const String updateStatus = "${BASE_URL}orders/items/";
|
static const String updateStatus = "${BASE_URL}orders/items/";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,84 +1,15 @@
|
|||||||
import 'package:dio/dio.dart';
|
// import 'package:dio/dio.dart';
|
||||||
|
|
||||||
import 'package:dio/dio.dart';
|
|
||||||
|
|
||||||
import 'package:dio/dio.dart';
|
|
||||||
import 'package:grocery_app/src/core/utils/response_type_def.dart';
|
|
||||||
|
|
||||||
class CustomDioExceptions implements Exception {
|
|
||||||
late String message;
|
|
||||||
|
|
||||||
CustomDioExceptions.fromDioException(DioException dioException) {
|
|
||||||
switch (dioException.type) {
|
|
||||||
case DioExceptionType.cancel:
|
|
||||||
message = "Request to API server was cancelled";
|
|
||||||
break;
|
|
||||||
case DioExceptionType.connectionTimeout:
|
|
||||||
message = "Connection timeout with API server";
|
|
||||||
break;
|
|
||||||
case DioExceptionType.receiveTimeout:
|
|
||||||
message = "Receive timeout in connection with API server";
|
|
||||||
break;
|
|
||||||
case DioExceptionType.badResponse:
|
|
||||||
message = _handleStatusError(
|
|
||||||
dioException.response?.statusCode,
|
|
||||||
dioException.response?.data,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case DioExceptionType.sendTimeout:
|
|
||||||
message = "Send timeout in connection with API server";
|
|
||||||
break;
|
|
||||||
case DioExceptionType.unknown:
|
|
||||||
message = "Unexpected error occurred";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
message = "Something went wrong";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String _handleStatusError(int? statusCode, dynamic error) {
|
|
||||||
switch (statusCode) {
|
|
||||||
case 400:
|
|
||||||
return error["message"] ?? 'Bad request';
|
|
||||||
case 401:
|
|
||||||
return error["message"] ?? 'Unauthorized';
|
|
||||||
case 403:
|
|
||||||
return error["message"] ?? 'Forbidden';
|
|
||||||
case 404:
|
|
||||||
return error["message"] ?? 'Not Found';
|
|
||||||
case 422:
|
|
||||||
return error["message"] ?? 'Cannot proceed with the data provided.';
|
|
||||||
case 406:
|
|
||||||
return error["message"] ?? 'Input Mismatched';
|
|
||||||
case 500:
|
|
||||||
return error["message"] ?? 'Internal server error';
|
|
||||||
case 502:
|
|
||||||
return error["message"] ?? 'Bad gateway';
|
|
||||||
default:
|
|
||||||
return error["message"] ?? 'Oops something went wrong';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Handle the error and return a `CustomError`
|
|
||||||
static CustomError handleError(DioException e) {
|
|
||||||
final errorMessage = CustomDioExceptions.fromDioException(e).toString();
|
|
||||||
return CustomError(errorMessage, e.response?.statusCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() => message;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
// import 'package:dio/dio.dart';
|
||||||
|
|
||||||
|
// import 'package:dio/dio.dart';
|
||||||
|
// import 'package:grocery_app/src/core/utils/response_type_def.dart';
|
||||||
|
|
||||||
// class CustomDioExceptions implements Exception {
|
// class CustomDioExceptions implements Exception {
|
||||||
// late String message;
|
// late String message;
|
||||||
|
|
||||||
// CustomDioExceptions.fromDioException(DioException dioException) {
|
// CustomDioExceptions.fromDioException(DioException dioException) {
|
||||||
// switch (dioException.type)
|
// switch (dioException.type) {
|
||||||
// {
|
|
||||||
// case DioExceptionType.cancel:
|
// case DioExceptionType.cancel:
|
||||||
// message = "Request to API server was cancelled";
|
// message = "Request to API server was cancelled";
|
||||||
// break;
|
// break;
|
||||||
@@ -129,14 +60,242 @@ class CustomDioExceptions implements Exception {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// /// call this method from api repo to handle the error
|
// /// Handle the error and return a `CustomError`
|
||||||
// static CustomError handleError(DioException e)
|
// static CustomError handleError(DioException e) {
|
||||||
// {
|
|
||||||
// final errorMessage = CustomDioExceptions.fromDioException(e).toString();
|
// final errorMessage = CustomDioExceptions.fromDioException(e).toString();
|
||||||
|
|
||||||
// return CustomError(errorMessage, e.response?.statusCode);
|
// return CustomError(errorMessage, e.response?.statusCode);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// @override
|
// @override
|
||||||
// String toString() => message;
|
// String toString() => message;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// import 'package:dio/dio.dart';
|
||||||
|
// import 'package:vendor_app/src/core/utiils_lib/response_type_def.dart';
|
||||||
|
// import 'package:dio/dio.dart';
|
||||||
|
|
||||||
|
// import 'package:dio/dio.dart';
|
||||||
|
|
||||||
|
// class CustomDioExceptions implements Exception {
|
||||||
|
// late String message;
|
||||||
|
|
||||||
|
// CustomDioExceptions.fromDioException(DioException dioException) {
|
||||||
|
// switch (dioException.type) {
|
||||||
|
// case DioExceptionType.cancel:
|
||||||
|
// message = "Request to API server was cancelled";
|
||||||
|
// break;
|
||||||
|
// case DioExceptionType.connectionTimeout:
|
||||||
|
// message = "Connection timeout with API server";
|
||||||
|
// break;
|
||||||
|
// case DioExceptionType.receiveTimeout:
|
||||||
|
// message = "Receive timeout in connection with API server";
|
||||||
|
// break;
|
||||||
|
// case DioExceptionType.badResponse:
|
||||||
|
// message = _handleStatusError(
|
||||||
|
// dioException.response?.statusCode,
|
||||||
|
// dioException.response?.data,
|
||||||
|
// );
|
||||||
|
// break;
|
||||||
|
// case DioExceptionType.sendTimeout:
|
||||||
|
// message = "Send timeout in connection with API server";
|
||||||
|
// break;
|
||||||
|
// case DioExceptionType.unknown:
|
||||||
|
// message = "Unexpected error occurred";
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// message = "Something went wrong";
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// String _handleStatusError(int? statusCode, dynamic error)
|
||||||
|
// {
|
||||||
|
// switch (statusCode) {
|
||||||
|
// case 400:
|
||||||
|
// return error["message"] ?? 'Bad request';
|
||||||
|
// case 401:
|
||||||
|
// return error["message"] ?? 'Unauthorized';
|
||||||
|
// case 403:
|
||||||
|
// return error["message"] ?? 'Forbidden';
|
||||||
|
// case 404:
|
||||||
|
// return error["message"] ?? 'Not Found';
|
||||||
|
// case 422:
|
||||||
|
// return error["message"] ?? 'Cannot proceed with the data provided.';
|
||||||
|
// case 406:
|
||||||
|
// return error["message"] ?? 'Input Mismatched';
|
||||||
|
// case 500:
|
||||||
|
// return error["message"] ?? 'Internal server error';
|
||||||
|
// case 502:
|
||||||
|
// return error["message"] ?? 'Bad gateway';
|
||||||
|
// default:
|
||||||
|
// return error["message"] ?? 'Oops something went wrong';
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// /// Handle the error and return a `CustomError`
|
||||||
|
// static CustomError handleError(DioException e) {
|
||||||
|
// final errorMessage = CustomDioExceptions.fromDioException(e).toString();
|
||||||
|
// return CustomError(errorMessage, e.response?.statusCode);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @override
|
||||||
|
// String toString() => message;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // class CustomDioExceptions implements Exception {
|
||||||
|
// // late String message;
|
||||||
|
|
||||||
|
// // CustomDioExceptions.fromDioException(DioException dioException) {
|
||||||
|
// // switch (dioException.type)
|
||||||
|
// // {
|
||||||
|
// // case DioExceptionType.cancel:
|
||||||
|
// // message = "Request to API server was cancelled";
|
||||||
|
// // break;
|
||||||
|
// // case DioExceptionType.connectionTimeout:
|
||||||
|
// // message = "Connection timeout with API server";
|
||||||
|
// // break;
|
||||||
|
// // case DioExceptionType.receiveTimeout:
|
||||||
|
// // message = "Receive timeout in connection with API server";
|
||||||
|
// // break;
|
||||||
|
// // case DioExceptionType.badResponse:
|
||||||
|
// // message = _handleStatusError(
|
||||||
|
// // dioException.response?.statusCode,
|
||||||
|
// // dioException.response?.data,
|
||||||
|
// // );
|
||||||
|
// // break;
|
||||||
|
// // case DioExceptionType.sendTimeout:
|
||||||
|
// // message = "Send timeout in connection with API server";
|
||||||
|
// // break;
|
||||||
|
// // case DioExceptionType.unknown:
|
||||||
|
// // message = "Unexpected error occurred";
|
||||||
|
// // break;
|
||||||
|
// // default:
|
||||||
|
// // message = "Something went wrong";
|
||||||
|
// // break;
|
||||||
|
// // }
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// // String _handleStatusError(int? statusCode, dynamic error) {
|
||||||
|
// // switch (statusCode) {
|
||||||
|
// // case 400:
|
||||||
|
// // return error["message"] ?? 'Bad request';
|
||||||
|
// // case 401:
|
||||||
|
// // return error["message"] ?? 'Unauthorized';
|
||||||
|
// // case 403:
|
||||||
|
// // return error["message"] ?? 'Forbidden';
|
||||||
|
// // case 404:
|
||||||
|
// // return error["message"] ?? 'Not Found';
|
||||||
|
// // case 422:
|
||||||
|
// // return error["message"] ?? 'Can not proceed with the data provided.';
|
||||||
|
// // case 406:
|
||||||
|
// // return error["message"] ?? 'Input Mismatched';
|
||||||
|
// // case 500:
|
||||||
|
// // return error["message"] ?? 'Internal server error';
|
||||||
|
// // case 502:
|
||||||
|
// // return error["message"] ?? 'Bad gateway';
|
||||||
|
// // default:
|
||||||
|
// // return error["message"] ?? 'Oops something went wrong';
|
||||||
|
// // }
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// // /// call this method from api repo to handle the error
|
||||||
|
// // static CustomError handleError(DioException e)
|
||||||
|
// // {
|
||||||
|
// // final errorMessage = CustomDioExceptions.fromDioException(e).toString();
|
||||||
|
|
||||||
|
// // return CustomError(errorMessage, e.response?.statusCode);
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// // @override
|
||||||
|
// // String toString() => message;
|
||||||
|
// // }
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:grocery_app/src/core/utils/response_type_def.dart';
|
||||||
|
|
||||||
|
|
||||||
|
class CustomDioExceptions implements Exception {
|
||||||
|
late String message;
|
||||||
|
|
||||||
|
CustomDioExceptions.fromDioException(DioException dioException) {
|
||||||
|
switch (dioException.type) {
|
||||||
|
case DioExceptionType.cancel:
|
||||||
|
message = "Request to API server was cancelled";
|
||||||
|
break;
|
||||||
|
case DioExceptionType.connectionTimeout:
|
||||||
|
message = "Connection timeout with API server";
|
||||||
|
break;
|
||||||
|
case DioExceptionType.receiveTimeout:
|
||||||
|
message = "Receive timeout in connection with API server";
|
||||||
|
break;
|
||||||
|
case DioExceptionType.badResponse:
|
||||||
|
message = _handleStatusError(
|
||||||
|
dioException.response?.statusCode,
|
||||||
|
dioException.response?.data,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case DioExceptionType.sendTimeout:
|
||||||
|
message = "Send timeout in connection with API server";
|
||||||
|
break;
|
||||||
|
case DioExceptionType.unknown:
|
||||||
|
message = "Unexpected error occurred";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
message = "Something went wrong";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String _handleStatusError(int? statusCode, dynamic error) {
|
||||||
|
if (error is Map<String, dynamic>) {
|
||||||
|
// Extract the actual message inside the response
|
||||||
|
final errorMessage = error["message"];
|
||||||
|
if (errorMessage is Map<String, dynamic>) {
|
||||||
|
return errorMessage["message"] ?? "Unknown error";
|
||||||
|
}
|
||||||
|
return errorMessage ?? "Unknown error";
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (statusCode) {
|
||||||
|
case 400:
|
||||||
|
return 'Bad request';
|
||||||
|
case 401:
|
||||||
|
return 'Unauthorized';
|
||||||
|
case 403:
|
||||||
|
return 'Forbidden';
|
||||||
|
case 404:
|
||||||
|
return 'Not Found';
|
||||||
|
case 422:
|
||||||
|
return 'Cannot proceed with the data provided.';
|
||||||
|
case 406:
|
||||||
|
return 'Input Mismatched';
|
||||||
|
case 500:
|
||||||
|
return 'Internal server error';
|
||||||
|
case 502:
|
||||||
|
return 'Bad gateway';
|
||||||
|
default:
|
||||||
|
return 'Oops something went wrong';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// final int statusCode;
|
||||||
|
// final String message;
|
||||||
|
// final String? error;
|
||||||
|
|
||||||
|
static CustomError handleError(DioException e) {
|
||||||
|
final errorMessage = CustomDioExceptions.fromDioException(e).toString();
|
||||||
|
|
||||||
|
return CustomError(
|
||||||
|
statusCode: e.response?.statusCode ?? 0,
|
||||||
|
message: errorMessage,
|
||||||
|
error: e.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() => message;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,34 @@
|
|||||||
|
// import 'package:fpdart/fpdart.dart';
|
||||||
|
|
||||||
|
// typedef FutureResult<T> = Future<Either<CustomError, T>>;
|
||||||
|
// typedef VoidResult<Void> = Future<Either<CustomError, Void>>;
|
||||||
|
|
||||||
|
// class CustomError {
|
||||||
|
// final String message;
|
||||||
|
// final int? code;
|
||||||
|
// CustomError(this.message, this.code);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
import 'package:fpdart/fpdart.dart';
|
import 'package:fpdart/fpdart.dart';
|
||||||
|
|
||||||
typedef FutureResult<T> = Future<Either<CustomError, T>>;
|
typedef FutureResult<T> = Future<Either<CustomError, T>>;
|
||||||
typedef VoidResult<Void> = Future<Either<CustomError, Void>>;
|
typedef VoidResult<Void> = Future<Either<CustomError, Void>>;
|
||||||
|
|
||||||
class CustomError {
|
class CustomError {
|
||||||
|
final int statusCode;
|
||||||
final String message;
|
final String message;
|
||||||
final int? code;
|
final String? error; // Optional field for additional error details
|
||||||
CustomError(this.message, this.code);
|
|
||||||
|
CustomError({required this.statusCode, required this.message, this.error});
|
||||||
|
|
||||||
|
factory CustomError.fromJson(Map<String, dynamic> json) {
|
||||||
|
return CustomError(
|
||||||
|
statusCode: json['statusCode'] ?? 0,
|
||||||
|
message: json['message'] is Map
|
||||||
|
? json['message']['message'] ?? "Unknown error"
|
||||||
|
: json['message'].toString(),
|
||||||
|
error: json['message'] is Map ? json['message']['error'] : null,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
162
lib/src/data/ProductCategoryModel.dart
Normal file
162
lib/src/data/ProductCategoryModel.dart
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
// // To parse this JSON data, do
|
||||||
|
// //
|
||||||
|
// // final productCategoryModel = productCategoryModelFromJson(jsondynamic);
|
||||||
|
|
||||||
|
// import 'dart:convert';
|
||||||
|
|
||||||
|
// List<ProductCategoryModel> productCategoryModelFromJson(dynamic str) => List<ProductCategoryModel>.from(json.decode(str).map((x) => ProductCategoryModel.fromJson(x)));
|
||||||
|
|
||||||
|
// dynamic productCategoryModelToJson(List<ProductCategoryModel> data) => json.encode(List<dynamic>.from(data.map((x) => x.toJson())));
|
||||||
|
|
||||||
|
// class ProductCategoryModel
|
||||||
|
// {
|
||||||
|
// dynamic id;
|
||||||
|
// dynamic name;
|
||||||
|
// dynamic description;
|
||||||
|
// dynamic image;
|
||||||
|
// dynamic slug;
|
||||||
|
// dynamic level;
|
||||||
|
// bool? isActive;
|
||||||
|
// DateTime? createdAt;
|
||||||
|
// DateTime? updatedAt;
|
||||||
|
// dynamic parentCategoryId;
|
||||||
|
// dynamic path;
|
||||||
|
// dynamic parentCategory;
|
||||||
|
// List<ProductCategoryModel>? childCategories;
|
||||||
|
|
||||||
|
// ProductCategoryModel({
|
||||||
|
// this.id,
|
||||||
|
// this.name,
|
||||||
|
// this.description,
|
||||||
|
// this.image,
|
||||||
|
// this.slug,
|
||||||
|
// this.level,
|
||||||
|
// this.isActive,
|
||||||
|
// this.createdAt,
|
||||||
|
// this.updatedAt,
|
||||||
|
// this.parentCategoryId,
|
||||||
|
// this.path,
|
||||||
|
// this.parentCategory,
|
||||||
|
// this.childCategories,
|
||||||
|
// });
|
||||||
|
|
||||||
|
// factory ProductCategoryModel.fromJson(Map<dynamic, dynamic> json) => ProductCategoryModel(
|
||||||
|
// id: json["id"],
|
||||||
|
// name: json["name"],
|
||||||
|
// description: json["description"],
|
||||||
|
// image: json["image"],
|
||||||
|
// slug: json["slug"],
|
||||||
|
// level: json["level"],
|
||||||
|
// isActive: json["isActive"],
|
||||||
|
// createdAt: DateTime.parse(json["createdAt"]),
|
||||||
|
// updatedAt: DateTime.parse(json["updatedAt"]),
|
||||||
|
// parentCategoryId: json["parentCategoryId"],
|
||||||
|
// path: json["path"],
|
||||||
|
// parentCategory: json["parentCategory"],
|
||||||
|
// childCategories: List<ProductCategoryModel>.from(json["childCategories"].map((x) => ProductCategoryModel.fromJson(x))),
|
||||||
|
// );
|
||||||
|
|
||||||
|
// Map<dynamic, dynamic> toJson() => {
|
||||||
|
// "id": id,
|
||||||
|
// "name": name,
|
||||||
|
// "description": description,
|
||||||
|
// "image": image,
|
||||||
|
// "slug": slug,
|
||||||
|
// "level": level,
|
||||||
|
// "isActive": isActive,
|
||||||
|
// "createdAt": createdAt,
|
||||||
|
// "updatedAt": updatedAt,
|
||||||
|
// "parentCategoryId": parentCategoryId,
|
||||||
|
// "path": path,
|
||||||
|
// "parentCategory": parentCategory,
|
||||||
|
// "childCategories": List<dynamic>.from(childCategories!.map((x) => x.toJson())),
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
List<ProductCategoryModel> productCategoryModelFromJson(String str) =>
|
||||||
|
List<ProductCategoryModel>.from(
|
||||||
|
json.decode(str).map((x) => ProductCategoryModel.fromJson(x)));
|
||||||
|
|
||||||
|
String productCategoryModelToJson(List<ProductCategoryModel> data) =>
|
||||||
|
json.encode(List<dynamic>.from(data.map((x) => x.toJson())));
|
||||||
|
|
||||||
|
class ProductCategoryModel {
|
||||||
|
String? id;
|
||||||
|
String? name;
|
||||||
|
String? description;
|
||||||
|
String? image;
|
||||||
|
String? slug;
|
||||||
|
int? level;
|
||||||
|
bool? isActive;
|
||||||
|
DateTime? createdAt;
|
||||||
|
DateTime? updatedAt;
|
||||||
|
String? parentCategoryId;
|
||||||
|
String? path;
|
||||||
|
dynamic commissionPercentage;
|
||||||
|
ProductCategoryModel? parentCategory;
|
||||||
|
List<ProductCategoryModel>? childCategories;
|
||||||
|
|
||||||
|
ProductCategoryModel(
|
||||||
|
{this.id,
|
||||||
|
this.name,
|
||||||
|
this.description,
|
||||||
|
this.image,
|
||||||
|
this.slug,
|
||||||
|
this.level,
|
||||||
|
this.isActive,
|
||||||
|
this.createdAt,
|
||||||
|
this.updatedAt,
|
||||||
|
this.parentCategoryId,
|
||||||
|
this.path,
|
||||||
|
this.parentCategory,
|
||||||
|
this.childCategories,
|
||||||
|
this.commissionPercentage});
|
||||||
|
|
||||||
|
factory ProductCategoryModel.fromJson(Map<String, dynamic> json) =>
|
||||||
|
ProductCategoryModel(
|
||||||
|
id: json["id"],
|
||||||
|
name: json["name"],
|
||||||
|
description: json["description"],
|
||||||
|
image: json["image"],
|
||||||
|
slug: json["slug"],
|
||||||
|
level: json["level"],
|
||||||
|
isActive: json["isActive"],
|
||||||
|
createdAt: json["createdAt"] == null
|
||||||
|
? null
|
||||||
|
: DateTime.parse(json["createdAt"]),
|
||||||
|
updatedAt: json["updatedAt"] == null
|
||||||
|
? null
|
||||||
|
: DateTime.parse(json["updatedAt"]),
|
||||||
|
parentCategoryId: json["parentCategoryId"],
|
||||||
|
path: json["path"],
|
||||||
|
parentCategory: json["parentCategory"] == null
|
||||||
|
? null
|
||||||
|
: ProductCategoryModel.fromJson(json["parentCategory"]),
|
||||||
|
childCategories: json["childCategories"] == null
|
||||||
|
? []
|
||||||
|
: List<ProductCategoryModel>.from(json["childCategories"]
|
||||||
|
.map((x) => ProductCategoryModel.fromJson(x))),
|
||||||
|
commissionPercentage: json["commissionPercentage"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"id": id,
|
||||||
|
"name": name,
|
||||||
|
"description": description,
|
||||||
|
"image": image,
|
||||||
|
"slug": slug,
|
||||||
|
"level": level,
|
||||||
|
"isActive": isActive,
|
||||||
|
"createdAt": createdAt?.toIso8601String(),
|
||||||
|
"updatedAt": updatedAt?.toIso8601String(),
|
||||||
|
"parentCategoryId": parentCategoryId,
|
||||||
|
"path": path,
|
||||||
|
"parentCategory": parentCategory?.toJson(),
|
||||||
|
"childCategories": childCategories == null
|
||||||
|
? []
|
||||||
|
: List<dynamic>.from(childCategories!.map((x) => x.toJson())),
|
||||||
|
"commissionPercentage": commissionPercentage,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -4,7 +4,8 @@
|
|||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
CouponDataModel couponDataFromJson(dynamic str) => CouponDataModel.fromJson(json.decode(str));
|
CouponDataModel couponDataFromJson(dynamic str) =>
|
||||||
|
CouponDataModel.fromJson(json.decode(str));
|
||||||
|
|
||||||
dynamic couponDataToJson(CouponDataModel data) => json.encode(data.toJson());
|
dynamic couponDataToJson(CouponDataModel data) => json.encode(data.toJson());
|
||||||
|
|
||||||
@@ -21,8 +22,10 @@ class CouponDataModel {
|
|||||||
this.limit,
|
this.limit,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory CouponDataModel.fromJson(Map<dynamic, dynamic> json) => CouponDataModel(
|
factory CouponDataModel.fromJson(Map<dynamic, dynamic> json) =>
|
||||||
data: List<CouponDatum>.from(json["data"].map((x) => CouponDatum.fromJson(x))),
|
CouponDataModel(
|
||||||
|
data: List<CouponDatum>.from(
|
||||||
|
json["data"].map((x) => CouponDatum.fromJson(x))),
|
||||||
total: json["total"],
|
total: json["total"],
|
||||||
page: json["page"],
|
page: json["page"],
|
||||||
limit: json["limit"],
|
limit: json["limit"],
|
||||||
@@ -66,9 +69,10 @@ class CouponDatum {
|
|||||||
List<dynamic>? applicableStoreIds;
|
List<dynamic>? applicableStoreIds;
|
||||||
List<dynamic>? applicableCategoryIds;
|
List<dynamic>? applicableCategoryIds;
|
||||||
List<dynamic>? applicableProductIds;
|
List<dynamic>? applicableProductIds;
|
||||||
|
dynamic imageUrl;
|
||||||
|
|
||||||
CouponDatum({
|
CouponDatum(
|
||||||
this.id,
|
{this.id,
|
||||||
this.code,
|
this.code,
|
||||||
this.type,
|
this.type,
|
||||||
this.discountValue,
|
this.discountValue,
|
||||||
@@ -97,7 +101,7 @@ class CouponDatum {
|
|||||||
this.applicableStoreIds,
|
this.applicableStoreIds,
|
||||||
this.applicableCategoryIds,
|
this.applicableCategoryIds,
|
||||||
this.applicableProductIds,
|
this.applicableProductIds,
|
||||||
});
|
this.imageUrl});
|
||||||
|
|
||||||
factory CouponDatum.fromJson(Map<dynamic, dynamic> json) => CouponDatum(
|
factory CouponDatum.fromJson(Map<dynamic, dynamic> json) => CouponDatum(
|
||||||
id: json["id"],
|
id: json["id"],
|
||||||
@@ -116,19 +120,27 @@ class CouponDatum {
|
|||||||
terms: json["terms"],
|
terms: json["terms"],
|
||||||
buyQuantity: json["buyQuantity"],
|
buyQuantity: json["buyQuantity"],
|
||||||
getQuantity: json["getQuantity"],
|
getQuantity: json["getQuantity"],
|
||||||
applicableUserRoles: List<dynamic>.from(json["applicableUserRoles"].map((x) => x)),
|
applicableUserRoles:
|
||||||
|
List<dynamic>.from(json["applicableUserRoles"].map((x) => x)),
|
||||||
totalUsageCount: json["totalUsageCount"],
|
totalUsageCount: json["totalUsageCount"],
|
||||||
isActive: json["isActive"],
|
isActive: json["isActive"],
|
||||||
createdBy: json["createdBy"],
|
createdBy: json["createdBy"],
|
||||||
createdAt: DateTime.parse(json["createdAt"]),
|
createdAt: DateTime.parse(json["createdAt"]),
|
||||||
updatedAt: DateTime.parse(json["updatedAt"]),
|
updatedAt: DateTime.parse(json["updatedAt"]),
|
||||||
applicableStores: List<dynamic>.from(json["applicableStores"].map((x) => x)),
|
applicableStores:
|
||||||
applicableCategories: List<dynamic>.from(json["applicableCategories"].map((x) => x)),
|
List<dynamic>.from(json["applicableStores"].map((x) => x)),
|
||||||
applicableProducts: List<dynamic>.from(json["applicableProducts"].map((x) => x)),
|
applicableCategories:
|
||||||
|
List<dynamic>.from(json["applicableCategories"].map((x) => x)),
|
||||||
|
applicableProducts:
|
||||||
|
List<dynamic>.from(json["applicableProducts"].map((x) => x)),
|
||||||
usages: List<dynamic>.from(json["usages"].map((x) => x)),
|
usages: List<dynamic>.from(json["usages"].map((x) => x)),
|
||||||
applicableStoreIds: List<dynamic>.from(json["applicableStoreIds"].map((x) => x)),
|
applicableStoreIds:
|
||||||
applicableCategoryIds: List<dynamic>.from(json["applicableCategoryIds"].map((x) => x)),
|
List<dynamic>.from(json["applicableStoreIds"].map((x) => x)),
|
||||||
applicableProductIds: List<dynamic>.from(json["applicableProductIds"].map((x) => x)),
|
applicableCategoryIds:
|
||||||
|
List<dynamic>.from(json["applicableCategoryIds"].map((x) => x)),
|
||||||
|
applicableProductIds:
|
||||||
|
List<dynamic>.from(json["applicableProductIds"].map((x) => x)),
|
||||||
|
imageUrl: json["imageUrl"],
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<dynamic, dynamic> toJson() => {
|
Map<dynamic, dynamic> toJson() => {
|
||||||
@@ -148,18 +160,25 @@ class CouponDatum {
|
|||||||
"terms": terms,
|
"terms": terms,
|
||||||
"buyQuantity": buyQuantity,
|
"buyQuantity": buyQuantity,
|
||||||
"getQuantity": getQuantity,
|
"getQuantity": getQuantity,
|
||||||
"applicableUserRoles": List<dynamic>.from(applicableUserRoles!.map((x) => x)),
|
"applicableUserRoles":
|
||||||
|
List<dynamic>.from(applicableUserRoles!.map((x) => x)),
|
||||||
"totalUsageCount": totalUsageCount,
|
"totalUsageCount": totalUsageCount,
|
||||||
"isActive": isActive,
|
"isActive": isActive,
|
||||||
"createdBy": createdBy,
|
"createdBy": createdBy,
|
||||||
"createdAt": createdAt,
|
"createdAt": createdAt,
|
||||||
"updatedAt": updatedAt,
|
"updatedAt": updatedAt,
|
||||||
"applicableStores": List<dynamic>.from(applicableStores!.map((x) => x)),
|
"applicableStores": List<dynamic>.from(applicableStores!.map((x) => x)),
|
||||||
"applicableCategories": List<dynamic>.from(applicableCategories!.map((x) => x)),
|
"applicableCategories":
|
||||||
"applicableProducts": List<dynamic>.from(applicableProducts!.map((x) => x)),
|
List<dynamic>.from(applicableCategories!.map((x) => x)),
|
||||||
|
"applicableProducts":
|
||||||
|
List<dynamic>.from(applicableProducts!.map((x) => x)),
|
||||||
"usages": List<dynamic>.from(usages!.map((x) => x)),
|
"usages": List<dynamic>.from(usages!.map((x) => x)),
|
||||||
"applicableStoreIds": List<dynamic>.from(applicableStoreIds!.map((x) => x)),
|
"applicableStoreIds":
|
||||||
"applicableCategoryIds": List<dynamic>.from(applicableCategoryIds!.map((x) => x)),
|
List<dynamic>.from(applicableStoreIds!.map((x) => x)),
|
||||||
"applicableProductIds": List<dynamic>.from(applicableProductIds!.map((x) => x)),
|
"applicableCategoryIds":
|
||||||
|
List<dynamic>.from(applicableCategoryIds!.map((x) => x)),
|
||||||
|
"applicableProductIds":
|
||||||
|
List<dynamic>.from(applicableProductIds!.map((x) => x)),
|
||||||
|
"imageUrl": imageUrl,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ dynamic productCategoryToJson(ProductCategory data) =>
|
|||||||
json.encode(data.toJson());
|
json.encode(data.toJson());
|
||||||
|
|
||||||
class ProductCategory {
|
class ProductCategory {
|
||||||
List<Datum>? data;
|
List<DatumCategory>? data;
|
||||||
Meta? meta;
|
Meta? meta;
|
||||||
|
|
||||||
ProductCategory({
|
ProductCategory({
|
||||||
@@ -19,7 +19,8 @@ class ProductCategory {
|
|||||||
ProductCategory(
|
ProductCategory(
|
||||||
data: json["data"] == null
|
data: json["data"] == null
|
||||||
? []
|
? []
|
||||||
: List<Datum>.from(json["data"].map((x) => Datum.fromJson(x))),
|
: List<DatumCategory>.from(
|
||||||
|
json["data"].map((x) => DatumCategory.fromJson(x))),
|
||||||
meta: json["meta"] == null ? null : Meta.fromJson(json["meta"]),
|
meta: json["meta"] == null ? null : Meta.fromJson(json["meta"]),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -31,7 +32,20 @@ class ProductCategory {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
class Datum {
|
List<DatumCategory> datumCategoryFromJson(dynamic str) {
|
||||||
|
if (str is String) {
|
||||||
|
return List<DatumCategory>.from(
|
||||||
|
json.decode(str).map((x) => DatumCategory.fromJson(x)));
|
||||||
|
} else if (str is List) {
|
||||||
|
return str.map((x) => DatumCategory.fromJson(x)).toList();
|
||||||
|
} else {
|
||||||
|
throw FormatException("Invalid JSON format");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dynamic datumCategoryToJson(ProductCategory data) => json.encode(data.toJson());
|
||||||
|
|
||||||
|
class DatumCategory {
|
||||||
dynamic id;
|
dynamic id;
|
||||||
dynamic name;
|
dynamic name;
|
||||||
dynamic description;
|
dynamic description;
|
||||||
@@ -46,7 +60,7 @@ class Datum {
|
|||||||
Category? parentCategory;
|
Category? parentCategory;
|
||||||
List<Category>? childCategories;
|
List<Category>? childCategories;
|
||||||
|
|
||||||
Datum({
|
DatumCategory({
|
||||||
this.id,
|
this.id,
|
||||||
this.name,
|
this.name,
|
||||||
this.description,
|
this.description,
|
||||||
@@ -62,7 +76,7 @@ class Datum {
|
|||||||
this.childCategories,
|
this.childCategories,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory Datum.fromJson(Map<dynamic, dynamic> json) => Datum(
|
factory DatumCategory.fromJson(Map<dynamic, dynamic> json) => DatumCategory(
|
||||||
id: json["id"],
|
id: json["id"],
|
||||||
name: json["name"],
|
name: json["name"],
|
||||||
description: json["description"],
|
description: json["description"],
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ class AddtocartProvider extends ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
},
|
},
|
||||||
(response) {
|
(response) {
|
||||||
print("kdjgkjfghjkfghjkl $response");
|
print("kdjgkjfghjkfghjkl ${response.data}");
|
||||||
couponDataModel = response!;
|
couponDataModel = response!;
|
||||||
iscouponLoading = false;
|
iscouponLoading = false;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
@@ -222,7 +222,7 @@ class AddtocartProvider extends ChangeNotifier {
|
|||||||
context.showLoader(show: false);
|
context.showLoader(show: false);
|
||||||
isCouponApply = false;
|
isCouponApply = false;
|
||||||
Fluttertoast.showToast(
|
Fluttertoast.showToast(
|
||||||
msg: "Coupon Code invalid!",
|
msg: "${error.message}",
|
||||||
toastLength: Toast.LENGTH_SHORT,
|
toastLength: Toast.LENGTH_SHORT,
|
||||||
gravity: ToastGravity.BOTTOM,
|
gravity: ToastGravity.BOTTOM,
|
||||||
backgroundColor: Colors.red,
|
backgroundColor: Colors.red,
|
||||||
@@ -267,6 +267,7 @@ class AddtocartProvider extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////orderPaymnet///////////////////////////
|
///////////////////////////////////orderPaymnet///////////////////////////
|
||||||
|
|
||||||
bool ispaymentLoader = false;
|
bool ispaymentLoader = false;
|
||||||
Future<void> orderPaymnet(
|
Future<void> orderPaymnet(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
@@ -285,7 +286,8 @@ class AddtocartProvider extends ChangeNotifier {
|
|||||||
"addressId": addressId,
|
"addressId": addressId,
|
||||||
"cartId": cartId,
|
"cartId": cartId,
|
||||||
};
|
};
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
data = {
|
data = {
|
||||||
"amount": originalAmount,
|
"amount": originalAmount,
|
||||||
"addressId": addressId,
|
"addressId": addressId,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import 'package:geolocator/geolocator.dart';
|
|||||||
import 'package:google_maps_flutter/google_maps_flutter.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/network_services/service_locator.dart';
|
||||||
import 'package:grocery_app/src/core/routes/routes.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/allProduct_model.dart';
|
||||||
import 'package:grocery_app/src/data/all_cart_items.dart';
|
import 'package:grocery_app/src/data/all_cart_items.dart';
|
||||||
import 'package:grocery_app/src/data/banners.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;
|
bool iscategroyloading = true;
|
||||||
Future<void> getAllcategory(BuildContext context) async {
|
Future<void> getAllcategory(BuildContext context) async {
|
||||||
@@ -201,6 +202,7 @@ class ProductProvider extends ChangeNotifier {
|
|||||||
},
|
},
|
||||||
(response) {
|
(response) {
|
||||||
print("jdshfjghdhfjhgjd");
|
print("jdshfjghdhfjhgjd");
|
||||||
|
|
||||||
categoryList = response.data!;
|
categoryList = response.data!;
|
||||||
iscategroyloading = false;
|
iscategroyloading = false;
|
||||||
notifyListeners();
|
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
|
//similarProduct
|
||||||
|
|
||||||
List<BannerData> banner = [];
|
List<BannerData> banner = [];
|
||||||
@@ -809,8 +865,7 @@ class ProductProvider extends ChangeNotifier {
|
|||||||
(error) {
|
(error) {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
},
|
},
|
||||||
(response)
|
(response) {
|
||||||
{
|
|
||||||
print("lkdfjglkfdglkh ${response.data}");
|
print("lkdfjglkfdglkh ${response.data}");
|
||||||
_suggestions.addAll(response.data as Iterable<Product>);
|
_suggestions.addAll(response.data as Iterable<Product>);
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
@@ -6,6 +7,7 @@ import 'package:fpdart/fpdart.dart';
|
|||||||
import 'package:grocery_app/src/core/routes/routes.dart';
|
import 'package:grocery_app/src/core/routes/routes.dart';
|
||||||
import 'package:grocery_app/src/core/utils/custom_dio_exception.dart';
|
import 'package:grocery_app/src/core/utils/custom_dio_exception.dart';
|
||||||
import 'package:grocery_app/src/core/utils/response_type_def.dart';
|
import 'package:grocery_app/src/core/utils/response_type_def.dart';
|
||||||
|
import 'package:grocery_app/src/data/ProductCategoryModel.dart';
|
||||||
import 'package:grocery_app/src/data/address.dart';
|
import 'package:grocery_app/src/data/address.dart';
|
||||||
import 'package:grocery_app/src/data/allProduct_model.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/all_cart_items.dart';
|
||||||
@@ -100,6 +102,64 @@ class ProductRepo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FutureResult<List<DatumCategory>> getSubcategory(
|
||||||
|
data, BuildContext context) async {
|
||||||
|
try {
|
||||||
|
var response = await _productService.getSubcategory(data);
|
||||||
|
|
||||||
|
print("Response Type: ${response.runtimeType}");
|
||||||
|
print("Raw Response: ${response.data}");
|
||||||
|
|
||||||
|
List<DatumCategory> categoryList;
|
||||||
|
|
||||||
|
if (response.data is List) {
|
||||||
|
categoryList = (response.data as List)
|
||||||
|
.map((item) => DatumCategory.fromJson(item))
|
||||||
|
.toList();
|
||||||
|
;
|
||||||
|
} else {
|
||||||
|
categoryList = (jsonDecode(response) as List)
|
||||||
|
.map((item) => DatumCategory.fromJson(item))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
print("Raw Response: $response");
|
||||||
|
|
||||||
|
// final String model = response.toString();
|
||||||
|
|
||||||
|
return right(categoryList);
|
||||||
|
} on DioException catch (e) {
|
||||||
|
var error = CustomDioExceptions.handleError(e);
|
||||||
|
return left(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FutureResult<List<ProductCategoryModel>> getCategoryByLevel(data) async {
|
||||||
|
try {
|
||||||
|
var response = await _productService.getCategoryByLevel(data);
|
||||||
|
|
||||||
|
final List<ProductCategoryModel> productModels = (response.data as List)
|
||||||
|
.map((item) => ProductCategoryModel.fromJson(item))
|
||||||
|
.toList();
|
||||||
|
if (response != null && response.data != null) {
|
||||||
|
// Parse the response data into a list of ProductCategoryModel
|
||||||
|
final List<ProductCategoryModel> productModels = (response.data as List)
|
||||||
|
.map((item) => ProductCategoryModel.fromJson(item))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
// Print or handle the fetched data
|
||||||
|
if (productModels.isNotEmpty) {
|
||||||
|
print(
|
||||||
|
"Data successfully fetched and parsed: ${productModels.length} categories.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return right(productModels);
|
||||||
|
} on DioException catch (e) {
|
||||||
|
var error = CustomDioExceptions.handleError(e);
|
||||||
|
return left(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FutureResult<OrderPaymnet> paymentOrder(data) async {
|
FutureResult<OrderPaymnet> paymentOrder(data) async {
|
||||||
try {
|
try {
|
||||||
var response = await _productService.paymentOrder(data);
|
var response = await _productService.paymentOrder(data);
|
||||||
@@ -176,7 +236,8 @@ class ProductRepo {
|
|||||||
try {
|
try {
|
||||||
var response = await _productService.applyCoupon(data);
|
var response = await _productService.applyCoupon(data);
|
||||||
|
|
||||||
CouponResponse couponresponse = couponResponseFromJson(response.toString());
|
CouponResponse couponresponse =
|
||||||
|
couponResponseFromJson(response.toString());
|
||||||
return right(couponresponse);
|
return right(couponresponse);
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
var error = CustomDioExceptions.handleError(e);
|
var error = CustomDioExceptions.handleError(e);
|
||||||
@@ -184,10 +245,6 @@ class ProductRepo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FutureResult<AddressResponse> getAddress(data) async {
|
FutureResult<AddressResponse> getAddress(data) async {
|
||||||
try {
|
try {
|
||||||
var response = await _productService.getAddress(data);
|
var response = await _productService.getAddress(data);
|
||||||
@@ -221,11 +278,9 @@ class ProductRepo {
|
|||||||
try {
|
try {
|
||||||
var response = await _productService.updateProfile(data);
|
var response = await _productService.updateProfile(data);
|
||||||
|
|
||||||
|
|
||||||
final String model = response.toString();
|
final String model = response.toString();
|
||||||
return right(model);
|
return right(model);
|
||||||
} on DioException catch (e)
|
} on DioException catch (e) {
|
||||||
{
|
|
||||||
var error = CustomDioExceptions.handleError(e);
|
var error = CustomDioExceptions.handleError(e);
|
||||||
return left(error);
|
return left(error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,20 @@ class ProductService extends ApiService {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future getSubcategory(data) async {
|
||||||
|
var response = await api.get(APIURL.getSubcategory, data: jsonEncode(data),queryParameters: data);
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future getCategoryByLevel(data) async {
|
||||||
|
var response = await api.get(APIURL.getCategoryByLevel, data: jsonEncode(data));
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Future paymentOrder(data) async {
|
Future paymentOrder(data) async {
|
||||||
var response = await api.post(APIURL.paymentOrder, data: jsonEncode(data));
|
var response = await api.post(APIURL.paymentOrder, data: jsonEncode(data));
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:carousel_slider/carousel_slider.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:flutter_animate/flutter_animate.dart';
|
import 'package:flutter_animate/flutter_animate.dart';
|
||||||
@@ -27,6 +28,7 @@ import 'package:grocery_app/utils/extensions/uicontext.dart';
|
|||||||
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:skeletonizer/skeletonizer.dart';
|
import 'package:skeletonizer/skeletonizer.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class Mycart extends StatefulWidget {
|
class Mycart extends StatefulWidget {
|
||||||
const Mycart({super.key});
|
const Mycart({super.key});
|
||||||
@@ -74,6 +76,7 @@ class _MycartState extends State<Mycart> {
|
|||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
cartItems(),
|
cartItems(),
|
||||||
|
bannerview(),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -1024,6 +1027,113 @@ class _MycartState extends State<Mycart> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget bannerview() {
|
||||||
|
return Consumer<ProductProvider>(builder: (context, provider, child) {
|
||||||
|
return provider.isBannerLoading
|
||||||
|
? Skeletonizer(
|
||||||
|
enabled: provider.isBannerLoading,
|
||||||
|
child: Container(
|
||||||
|
height: 180,
|
||||||
|
width: double.infinity,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey[300],
|
||||||
|
borderRadius: BorderRadius.circular(15),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: provider.banner.isEmpty
|
||||||
|
? SizedBox.shrink()
|
||||||
|
: CarouselSlider(
|
||||||
|
options: CarouselOptions(
|
||||||
|
height: 180,
|
||||||
|
autoPlay: true,
|
||||||
|
enlargeCenterPage: true,
|
||||||
|
viewportFraction: 1,
|
||||||
|
aspectRatio: 16 / 9,
|
||||||
|
initialPage: 0,
|
||||||
|
enableInfiniteScroll: true,
|
||||||
|
reverse: false,
|
||||||
|
autoPlayInterval: Duration(seconds: 3),
|
||||||
|
autoPlayAnimationDuration: Duration(milliseconds: 800),
|
||||||
|
autoPlayCurve: Curves.fastOutSlowIn,
|
||||||
|
enlargeFactor: 0.3,
|
||||||
|
),
|
||||||
|
items: provider.banner.map((banner) {
|
||||||
|
return Builder(
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
width: MediaQuery.of(context).size.width,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.greenAccent.withOpacity(0.1),
|
||||||
|
borderRadius: BorderRadius.circular(15),
|
||||||
|
),
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Positioned(
|
||||||
|
top: 15,
|
||||||
|
left: 15,
|
||||||
|
child: SizedBox(
|
||||||
|
width: 200,
|
||||||
|
child: Text(
|
||||||
|
banner.altText ?? "Special Event",
|
||||||
|
style: context.customExtraBold(
|
||||||
|
Colors.black, 18),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
bottom: 15,
|
||||||
|
left: 15,
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
_launchUrl(banner.redirectUrl);
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
height: 40,
|
||||||
|
width: 100,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: APPCOLOR.lightGreen,
|
||||||
|
borderRadius: BorderRadius.circular(5),
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
'Shop now',
|
||||||
|
style: context.customRegular(
|
||||||
|
Colors.white, 14),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
right: 15,
|
||||||
|
bottom: 15,
|
||||||
|
child: AppNetworkImage(
|
||||||
|
height: 130,
|
||||||
|
width: 150,
|
||||||
|
imageUrl: banner.imageUrl ??
|
||||||
|
'https://e7.pngegg.com/pngimages/742/816/png-clipart-coca-cola-can-illustration-coca-cola-soft-drink-surge-pepsi-coke-sweetness-cola-thumbnail.png',
|
||||||
|
backGroundColor: Colors.transparent,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _launchUrl(url) async {
|
||||||
|
print("jdhfjkgh ${url}");
|
||||||
|
final Uri uri = Uri.parse(url);
|
||||||
|
if (!await launchUrl(uri, mode: LaunchMode.externalApplication)) {
|
||||||
|
throw 'Could not launch $url';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AddressBottomSheet extends StatefulWidget {
|
class AddressBottomSheet extends StatefulWidget {
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
|
import 'dart:math';
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
|
import 'package:blur/blur.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:grocery_app/src/logic/provider/addTocart_provider.dart';
|
import 'package:grocery_app/src/logic/provider/addTocart_provider.dart';
|
||||||
import 'package:grocery_app/src/logic/provider/home_provider.dart';
|
import 'package:grocery_app/src/logic/provider/home_provider.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class CouponsScreen extends StatelessWidget {
|
class CouponsScreen extends StatelessWidget {
|
||||||
@@ -11,6 +16,7 @@ class CouponsScreen extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
Provider.of<AddtocartProvider>(context, listen: false).offerCoupon(context);
|
||||||
print("kldfjgdfkljgdf ${cartId}");
|
print("kldfjgdfkljgdf ${cartId}");
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
@@ -43,15 +49,12 @@ class CouponsScreen extends StatelessWidget {
|
|||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (_formKey.currentState!.validate()) {
|
if (_formKey.currentState!.validate()) {
|
||||||
// var status = await provider.applyCoupon(
|
var status = await provider.applyCoupon(
|
||||||
// context,
|
context, cartId, inpucode.text, '');
|
||||||
// cartId,
|
|
||||||
// inpucode.text,
|
|
||||||
// );
|
|
||||||
|
|
||||||
// if (status) {
|
if (status) {
|
||||||
// Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
@@ -84,78 +87,266 @@ class CouponsScreen extends StatelessWidget {
|
|||||||
return Expanded(
|
return Expanded(
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
itemCount: provider.couponDataModel.data!.length,
|
itemCount: provider.couponDataModel.data!.length,
|
||||||
itemBuilder: (context, index)
|
itemBuilder: (context, index) {
|
||||||
{
|
|
||||||
final coupon = provider.couponDataModel.data![index];
|
final coupon = provider.couponDataModel.data![index];
|
||||||
|
|
||||||
|
DateTime couponEndDate =
|
||||||
|
DateTime.parse(coupon.endDate.toString()).toUtc();
|
||||||
|
DateTime now = DateTime.now().toUtc();
|
||||||
|
|
||||||
|
bool isCouponValid = now.isBefore(couponEndDate);
|
||||||
|
|
||||||
|
print(
|
||||||
|
"Coupon Expiry: ${coupon.endDate} ${coupon.imageUrl}| Current UTC Time: $now | Valid: $isCouponValid");
|
||||||
return Card(
|
return Card(
|
||||||
color: Colors.white,
|
color: Colors.transparent,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
),
|
),
|
||||||
elevation: 2,
|
elevation: 4,
|
||||||
child: Padding(
|
child: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
// Background Image
|
||||||
|
Positioned.fill(
|
||||||
|
child: Image.network(
|
||||||
|
coupon.imageUrl,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// Blur Effect
|
||||||
|
Positioned.fill(
|
||||||
|
child: BackdropFilter(
|
||||||
|
filter:
|
||||||
|
ImageFilter.blur(sigmaX: 5, sigmaY: 5),
|
||||||
|
child: Container(
|
||||||
|
color: Colors.black.withOpacity(
|
||||||
|
0.3), // Dark overlay for readability
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// Coupon Content
|
||||||
|
Padding(
|
||||||
padding: EdgeInsets.all(16.0),
|
padding: EdgeInsets.all(16.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
coupon.description!,
|
coupon.description ?? '',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors
|
||||||
|
.white, // Ensure contrast with background
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 5),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Expired On : ",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors
|
||||||
|
.white, // Ensure contrast with background
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
DateFormat("dd-MM-yyyy").format(
|
||||||
|
DateTime.parse(
|
||||||
|
coupon.endDate.toString())),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color:
|
||||||
|
Colors.white, // Highlight price
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(height: 5),
|
||||||
|
Text(
|
||||||
|
"₹${coupon.discountValue ?? ''}",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors.amber, // Highlight price
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
Text(
|
Text(
|
||||||
coupon.terms!,
|
coupon.terms ?? "",
|
||||||
style: TextStyle(color: Colors.grey[600]),
|
style: TextStyle(color: Colors.white70),
|
||||||
),
|
),
|
||||||
SizedBox(height: 10),
|
SizedBox(height: 10),
|
||||||
|
|
||||||
|
// Coupon Code and Apply Button
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment:
|
mainAxisAlignment:
|
||||||
MainAxisAlignment.spaceBetween,
|
MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
|
// Coupon Code Box
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
horizontal: 10, vertical: 5),
|
horizontal: 10, vertical: 5),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border.all(color: Colors.green),
|
color:
|
||||||
borderRadius: BorderRadius.circular(8),
|
Colors.white.withOpacity(0.2),
|
||||||
|
border:
|
||||||
|
Border.all(color: Colors.green),
|
||||||
|
borderRadius:
|
||||||
|
BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
coupon.code!,
|
coupon.code!,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: Colors.green,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// Apply Button
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () async {
|
onPressed: isCouponValid
|
||||||
var status = await provider.applyCoupon(
|
? () async {
|
||||||
|
var status = await provider
|
||||||
|
.applyCoupon(
|
||||||
context,
|
context,
|
||||||
cartId,
|
cartId,
|
||||||
coupon.code,
|
coupon.code,
|
||||||
coupon.id);
|
coupon.id);
|
||||||
|
if (status) {
|
||||||
{
|
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
: null, // Disable button if expired
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Colors.green,
|
backgroundColor: isCouponValid
|
||||||
|
? Colors.green
|
||||||
|
: Colors.grey,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius:
|
||||||
|
BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Text("Apply"),
|
child: Text("Apply"),
|
||||||
)
|
),
|
||||||
],
|
],
|
||||||
)
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Card(
|
||||||
|
// color: Colors.transparent.withOpacity(0.4),
|
||||||
|
// // color: Color((Random().nextDouble() * 0xFFFFFF).toInt())
|
||||||
|
// // .withOpacity(0.9),
|
||||||
|
// shape: RoundedRectangleBorder(
|
||||||
|
// borderRadius: BorderRadius.circular(12),
|
||||||
|
// ),
|
||||||
|
// elevation: 2,
|
||||||
|
// child: Blur(
|
||||||
|
// blur: 2.5,
|
||||||
|
// // blurColor: Theme.of(context).primaryColor,
|
||||||
|
// child: Container(
|
||||||
|
// decoration: BoxDecoration(
|
||||||
|
// image: DecorationImage(
|
||||||
|
// image: NetworkImage(
|
||||||
|
// coupon.imageUrl), // Your background image
|
||||||
|
// fit: BoxFit.cover, // Adjust as needed
|
||||||
|
// ),
|
||||||
|
// borderRadius: BorderRadius.circular(
|
||||||
|
// 12), // Match Card's border radius
|
||||||
|
// ),
|
||||||
|
// child: Padding(
|
||||||
|
// padding: EdgeInsets.all(16.0),
|
||||||
|
// child: Column(
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
// children: [
|
||||||
|
// Text(
|
||||||
|
// coupon.description ?? '',
|
||||||
|
// style: TextStyle(
|
||||||
|
// fontSize: 16,
|
||||||
|
// fontWeight: FontWeight.bold,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// Text(
|
||||||
|
// "₹" + coupon.discountValue ?? '',
|
||||||
|
// style: TextStyle(
|
||||||
|
// fontSize: 16,
|
||||||
|
// fontWeight: FontWeight.bold,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// SizedBox(height: 5),
|
||||||
|
// Text(
|
||||||
|
// coupon.terms ?? "",
|
||||||
|
// style: TextStyle(color: Colors.grey[600]),
|
||||||
|
// ),
|
||||||
|
// SizedBox(height: 10),
|
||||||
|
// Row(
|
||||||
|
// mainAxisAlignment:
|
||||||
|
// MainAxisAlignment.spaceBetween,
|
||||||
|
// children: [
|
||||||
|
// Container(
|
||||||
|
// padding: EdgeInsets.symmetric(
|
||||||
|
// horizontal: 10, vertical: 5),
|
||||||
|
// decoration: BoxDecoration(
|
||||||
|
// border:
|
||||||
|
// Border.all(color: Colors.green),
|
||||||
|
// borderRadius:
|
||||||
|
// BorderRadius.circular(8),
|
||||||
|
// ),
|
||||||
|
// child: Text(
|
||||||
|
// coupon.code!,
|
||||||
|
// style: TextStyle(
|
||||||
|
// fontWeight: FontWeight.bold,
|
||||||
|
// color: Colors.green,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ElevatedButton(
|
||||||
|
// onPressed: isCouponValid
|
||||||
|
// ? () async {
|
||||||
|
// var status =
|
||||||
|
// await provider.applyCoupon(
|
||||||
|
// context,
|
||||||
|
// cartId,
|
||||||
|
// coupon.code,
|
||||||
|
// coupon.id);
|
||||||
|
|
||||||
|
// if (status) {
|
||||||
|
// Navigator.pop(context);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// : null, // Disables button if expired
|
||||||
|
// style: ElevatedButton.styleFrom(
|
||||||
|
// backgroundColor: isCouponValid
|
||||||
|
// ? Colors.green
|
||||||
|
// : Colors.grey,
|
||||||
|
// shape: RoundedRectangleBorder(
|
||||||
|
// borderRadius:
|
||||||
|
// BorderRadius.circular(8),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// child: Text("Apply"),
|
||||||
|
// )
|
||||||
|
// ],
|
||||||
|
// )
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import 'package:fluttertoast/fluttertoast.dart';
|
|||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:grocery_app/src/common_widget/network_image.dart';
|
import 'package:grocery_app/src/common_widget/network_image.dart';
|
||||||
import 'package:grocery_app/src/core/routes/routes.dart';
|
import 'package:grocery_app/src/core/routes/routes.dart';
|
||||||
|
import 'package:grocery_app/src/data/ProductCategoryModel.dart';
|
||||||
import 'package:grocery_app/src/data/product_category.dart';
|
import 'package:grocery_app/src/data/product_category.dart';
|
||||||
|
|
||||||
import 'package:grocery_app/src/logic/provider/home_provider.dart';
|
import 'package:grocery_app/src/logic/provider/home_provider.dart';
|
||||||
@@ -33,6 +34,7 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
|||||||
final productProvider =
|
final productProvider =
|
||||||
Provider.of<ProductProvider>(context, listen: false);
|
Provider.of<ProductProvider>(context, listen: false);
|
||||||
productProvider.getAllcategory(context);
|
productProvider.getAllcategory(context);
|
||||||
|
productProvider.getCategoryByLevel();
|
||||||
|
|
||||||
productProvider.gettAllProduct(context, "", true, '');
|
productProvider.gettAllProduct(context, "", true, '');
|
||||||
});
|
});
|
||||||
@@ -84,16 +86,7 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
// Padding(
|
|
||||||
// padding: const EdgeInsets.only(right: 10),
|
|
||||||
// child: InkWell(
|
|
||||||
// onTap: () {},
|
|
||||||
// child: Icon(
|
|
||||||
// MdiIcons.magnify,
|
|
||||||
// size: 35,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// )
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: Padding(
|
body: Padding(
|
||||||
@@ -465,107 +458,6 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
|||||||
return discountPercentage.round();
|
return discountPercentage.round();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Widget filterCategory() {
|
|
||||||
// final activeIndexProvider = Provider.of<ProductProvider>(context);
|
|
||||||
// return Consumer<ProductProvider>(builder: (context, provider, child) {
|
|
||||||
// if (provider.iscategroyloading) {
|
|
||||||
// return Center(
|
|
||||||
// child: Container(
|
|
||||||
// width: 20,
|
|
||||||
// height: 20,
|
|
||||||
// decoration: BoxDecoration(
|
|
||||||
// color: APPCOLOR.bgGrey,
|
|
||||||
// borderRadius: BorderRadius.circular(10),
|
|
||||||
// border: Border.all(
|
|
||||||
// color: APPCOLOR.bgGrey,
|
|
||||||
// width: 1,
|
|
||||||
// )),
|
|
||||||
// child: const Center(
|
|
||||||
// child: CupertinoActivityIndicator(),
|
|
||||||
// ),
|
|
||||||
// ));
|
|
||||||
// } else if (provider.categoryList.isEmpty) {
|
|
||||||
// return SizedBox.shrink();
|
|
||||||
// } else {
|
|
||||||
// return Container(
|
|
||||||
// decoration: const BoxDecoration(color: Colors.white),
|
|
||||||
// width: 100,
|
|
||||||
// child: ListView.builder(
|
|
||||||
// itemCount: provider.categoryList.length,
|
|
||||||
// scrollDirection: Axis.vertical,
|
|
||||||
// itemBuilder: (context, index) {
|
|
||||||
// var category = provider.categoryList[index];
|
|
||||||
// return InkWell(
|
|
||||||
// onTap: () {
|
|
||||||
// provider.iscroll = true;
|
|
||||||
// provider.products.clear();
|
|
||||||
// provider.isLoadingg = false;
|
|
||||||
// provider.hasMore = true;
|
|
||||||
// provider.page = 1;
|
|
||||||
// provider.notifyListeners();
|
|
||||||
// provider.gettAllProduct(
|
|
||||||
// context, "/category/${category.id}", true, '');
|
|
||||||
// activeIndexProvider.setActiveIndex(index);
|
|
||||||
// // provider.isLoadingg = false;
|
|
||||||
// // provider.hasMore = false;
|
|
||||||
// // provider.gettAllProduct(context, "/category/${category.id}");
|
|
||||||
// // activeIndexProvider.setActiveIndex(index);
|
|
||||||
// },
|
|
||||||
// child: SizedBox(
|
|
||||||
// height: 150,
|
|
||||||
// child: Column(
|
|
||||||
// children: [
|
|
||||||
// Row(
|
|
||||||
// children: [
|
|
||||||
// Expanded(
|
|
||||||
// child: Center(
|
|
||||||
// child: Container(
|
|
||||||
// decoration: BoxDecoration(
|
|
||||||
// color:
|
|
||||||
// activeIndexProvider.activeIndex == index
|
|
||||||
// ? Colors.greenAccent.withOpacity(0.1)
|
|
||||||
// : APPCOLOR.bgGrey,
|
|
||||||
// borderRadius: BorderRadius.circular(5),
|
|
||||||
// ),
|
|
||||||
// child: AppNetworkImage(
|
|
||||||
// height: 80,
|
|
||||||
// width: 80,
|
|
||||||
// imageUrl: category.image ??
|
|
||||||
// 'https://i.pinimg.com/originals/a5/f3/5f/a5f35fb23e942809da3df91b23718e8d.png',
|
|
||||||
// backGroundColor: APPCOLOR.bgGrey,
|
|
||||||
// radius: 10,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// Container(
|
|
||||||
// width: 3,
|
|
||||||
// height: 100,
|
|
||||||
// color: activeIndexProvider.activeIndex == index
|
|
||||||
// ? APPCOLOR.lightGreen
|
|
||||||
// : Colors.transparent,
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// Text(
|
|
||||||
// category.name,
|
|
||||||
// textAlign: TextAlign.center,
|
|
||||||
// maxLines: 2,
|
|
||||||
// overflow: TextOverflow.ellipsis,
|
|
||||||
// style: activeIndexProvider.activeIndex == index
|
|
||||||
// ? context.customExtraBold(APPCOLOR.balck1A1A1A, 14)
|
|
||||||
// : context.customMedium(APPCOLOR.balck1A1A1A, 14),
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
Widget filterCategory() {
|
Widget filterCategory() {
|
||||||
final activeIndexProvider = Provider.of<ProductProvider>(context);
|
final activeIndexProvider = Provider.of<ProductProvider>(context);
|
||||||
@@ -590,8 +482,8 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
final categories = [Datum(id: "all", name: "ALL")];
|
final categories = [DatumCategory(id: "all", name: "ALL")];
|
||||||
categories.addAll(provider.categoryList.cast<Datum>());
|
categories.addAll(provider.categoryList.cast<DatumCategory>());
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
decoration: const BoxDecoration(color: Colors.white),
|
decoration: const BoxDecoration(color: Colors.white),
|
||||||
@@ -602,6 +494,8 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
|||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
var category = categories[index];
|
var category = categories[index];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 8),
|
padding: const EdgeInsets.only(bottom: 8),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
@@ -637,17 +531,74 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
if (category.name == "ALL") ...{
|
||||||
|
if (provider.categoriesss.isNotEmpty)
|
||||||
|
PopupMenuButton<ProductCategoryModel>(
|
||||||
|
onSelected: (ProductCategoryModel value) {
|
||||||
|
activeIndexProvider.setActiveIndex(0);
|
||||||
|
|
||||||
|
if (value.id == "all") {
|
||||||
|
provider.iscroll = true;
|
||||||
|
provider.products.clear();
|
||||||
|
provider.isLoadingg = false;
|
||||||
|
provider.hasMore = true;
|
||||||
|
provider.page = 1;
|
||||||
|
provider.gettAllProduct(
|
||||||
|
context, "", true, '');
|
||||||
|
provider.getAllcategory(context);
|
||||||
|
} else {
|
||||||
|
provider.categoryList.clear();
|
||||||
|
provider.getSubcategory(
|
||||||
|
context, value.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
provider.setSelectedCategory(value);
|
||||||
|
},
|
||||||
|
itemBuilder: (BuildContext context) =>
|
||||||
|
provider.categoriesss
|
||||||
|
.map(
|
||||||
|
(category) => PopupMenuItem(
|
||||||
|
value: category,
|
||||||
|
child: Text(
|
||||||
|
category.name ?? "Unknown"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 10,
|
||||||
|
horizontal: 10,
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: 20,
|
||||||
|
child: Text(
|
||||||
|
provider.selectedCategory?.name ??
|
||||||
|
"All",
|
||||||
|
maxLines: 1,
|
||||||
|
style: context.customMedium(
|
||||||
|
APPCOLOR.balck1A1A1A,
|
||||||
|
12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Icon(
|
||||||
|
Icons.arrow_drop_down,
|
||||||
|
size: 20,
|
||||||
|
color: APPCOLOR.balck1A1A1A,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
} else ...{
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
Center(
|
Center(
|
||||||
child: Container(
|
child: Container(
|
||||||
// decoration: BoxDecoration(
|
|
||||||
// color: activeIndexProvider.activeIndex ==
|
|
||||||
// index
|
|
||||||
// ? Colors.greenAccent.withOpacity(0.1)
|
|
||||||
// : APPCOLOR.bgGrey,
|
|
||||||
// borderRadius: BorderRadius.circular(5),
|
|
||||||
// ),
|
|
||||||
child: AppNetworkImage(
|
child: AppNetworkImage(
|
||||||
height: 30,
|
height: 30,
|
||||||
width: 50,
|
width: 50,
|
||||||
@@ -668,8 +619,8 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
|||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style:
|
style: activeIndexProvider.activeIndex ==
|
||||||
activeIndexProvider.activeIndex == index
|
index
|
||||||
? context.customExtraBold(
|
? context.customExtraBold(
|
||||||
APPCOLOR.balck1A1A1A, 9)
|
APPCOLOR.balck1A1A1A, 9)
|
||||||
: context.customMedium(
|
: context.customMedium(
|
||||||
@@ -678,6 +629,7 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
},
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 5,
|
width: 5,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
productProvider.getHomeProduct(context, "", '', '', '', '');
|
productProvider.getHomeProduct(context, "", '', '', '', '');
|
||||||
productProvider.getBestDealProduct(context, '');
|
productProvider.getBestDealProduct(context, '');
|
||||||
productProvider.getAllcategory(context);
|
productProvider.getAllcategory(context);
|
||||||
|
// productProvider.getCategoryByLevel();
|
||||||
|
|
||||||
getUserDetails();
|
getUserDetails();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
context.push(MyRoutes.SIGNUP);
|
context.push(MyRoutes.SIGNUP);
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
"Login ",
|
" ",
|
||||||
style: context.customExtraBold(
|
style: context.customExtraBold(
|
||||||
top < 100 ? Colors.blue : Colors.blue,
|
top < 100 ? Colors.blue : Colors.blue,
|
||||||
14),
|
14),
|
||||||
@@ -330,7 +330,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to show the Bottom Sheet
|
|
||||||
void _showBottomSheet(BuildContext context) {
|
void _showBottomSheet(BuildContext context) {
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
|
|||||||
@@ -49,6 +49,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "8.0.4"
|
version: "8.0.4"
|
||||||
|
blur:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: blur
|
||||||
|
sha256: c17450404bceea429100e0838d19bbfaa6ad1f3053e7bac78a0264bbd60cfe01
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "4.0.0"
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ dependencies:
|
|||||||
url_launcher: ^6.3.1
|
url_launcher: ^6.3.1
|
||||||
skeletonizer: ^1.4.3
|
skeletonizer: ^1.4.3
|
||||||
art_sweetalert: ^0.0.5
|
art_sweetalert: ^0.0.5
|
||||||
|
blur:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user