fixed issue add to cart
This commit is contained in:
@@ -992,7 +992,7 @@
|
|||||||
"languageVersion": "3.4"
|
"languageVersion": "3.4"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"generated": "2025-02-22T07:04:58.909640Z",
|
"generated": "2025-02-22T13:29:09.162780Z",
|
||||||
"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",
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
BIN
assets/images/cart.jpg
Normal file
BIN
assets/images/cart.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 MiB |
BIN
assets/images/cartempty.jpg
Normal file
BIN
assets/images/cartempty.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
BIN
assets/images/wishlist.jpg
Normal file
BIN
assets/images/wishlist.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 MiB |
@@ -99,9 +99,18 @@ class MyRoutes {
|
|||||||
animatedGoRoute(
|
animatedGoRoute(
|
||||||
path: PRODUCTDETAILS,
|
path: PRODUCTDETAILS,
|
||||||
name: PRODUCTDETAILS,
|
name: PRODUCTDETAILS,
|
||||||
pageBuilder: (context, state) {
|
pageBuilder: (context, state)
|
||||||
final id = state.extra as String; // Get the extra object
|
{
|
||||||
return ProductDetails(id: id);
|
// final id = state.extra as String; // Get the extra object
|
||||||
|
// return ProductDetails(id: id);
|
||||||
|
|
||||||
|
final args = state.extra as Map<String, dynamic>;
|
||||||
|
|
||||||
|
return ProductDetails(
|
||||||
|
id: args["id"],
|
||||||
|
quantity: args["quantity"],
|
||||||
|
price: args["price"],
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|||||||
@@ -293,7 +293,6 @@ class AddtocartProvider extends ChangeNotifier {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var result = await _homeRepo.paymentOrder(data);
|
var result = await _homeRepo.paymentOrder(data);
|
||||||
return result.fold(
|
return result.fold(
|
||||||
@@ -497,27 +496,31 @@ class AddtocartProvider extends ChangeNotifier {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
(response) async {
|
(response) async {
|
||||||
|
print("kldfjghlkjfgkljh");
|
||||||
await getItemCards(context);
|
await getItemCards(context);
|
||||||
cartItems.add(productId); // Add product to cart
|
cartItems.add(productId);
|
||||||
// Fluttertoast.showToast(
|
|
||||||
// msg: "Added to cart successfully!",
|
|
||||||
// toastLength: Toast.LENGTH_SHORT,
|
|
||||||
// gravity: ToastGravity.BOTTOM,
|
|
||||||
// backgroundColor: Colors.green,
|
|
||||||
// textColor: Colors.white,
|
|
||||||
// fontSize: 14.0,
|
|
||||||
// );
|
|
||||||
iscardAdded = true;
|
iscardAdded = true;
|
||||||
notifyListeners(); // Update UI after adding to cart
|
notifyListeners();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
Fluttertoast.showToast(
|
||||||
SnackBar(
|
msg: "Insufficient stock!",
|
||||||
content: Text("Something went wrong"),
|
toastLength: Toast.LENGTH_SHORT,
|
||||||
backgroundColor: Colors.red,
|
gravity: ToastGravity.CENTER,
|
||||||
),
|
backgroundColor: Colors.red,
|
||||||
|
textColor: Colors.white,
|
||||||
|
fontSize: 14.0,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
context.showLoader(show: false);
|
||||||
|
await getItemCards(context);
|
||||||
|
|
||||||
|
// isLoadingCart = false;
|
||||||
|
// iscardAdded = true;
|
||||||
|
// isLoadings[productId] = false;
|
||||||
|
notifyListeners();
|
||||||
} finally {
|
} finally {
|
||||||
isLoadingCart = false;
|
isLoadingCart = false;
|
||||||
isLoadings[productId] = false;
|
isLoadings[productId] = false;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ class ProductProvider extends ChangeNotifier {
|
|||||||
bool hasMore = true;
|
bool hasMore = true;
|
||||||
|
|
||||||
bool iscroll = true;
|
bool iscroll = true;
|
||||||
|
|
||||||
Future<void> gettAllProduct(
|
Future<void> gettAllProduct(
|
||||||
BuildContext context, String id, bool status, String search) async {
|
BuildContext context, String id, bool status, String search) async {
|
||||||
if (isLoadingg || !hasMore) return;
|
if (isLoadingg || !hasMore) return;
|
||||||
@@ -132,12 +133,13 @@ class ProductProvider extends ChangeNotifier {
|
|||||||
ProductDetailsData productDetails = ProductDetailsData();
|
ProductDetailsData productDetails = ProductDetailsData();
|
||||||
bool isProductLoading = true;
|
bool isProductLoading = true;
|
||||||
|
|
||||||
Future<void> getProduuctDetails(BuildContext context, String id) async {
|
Future<void> getProduuctDetails(
|
||||||
|
BuildContext context, String id, int quantity, String price) async {
|
||||||
var data = {};
|
var data = {};
|
||||||
productDetails = ProductDetailsData();
|
productDetails = ProductDetailsData();
|
||||||
isProductLoading = true;
|
isProductLoading = true;
|
||||||
quantitys = 1;
|
quantitys = quantity;
|
||||||
_totalPrice = 0.0;
|
_totalPrice = quantity * (double.parse(price));
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
||||||
var result = await _homeRepo.getProductDetails(data, context, id);
|
var result = await _homeRepo.getProductDetails(data, context, id);
|
||||||
@@ -435,11 +437,13 @@ class ProductProvider extends ChangeNotifier {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
Fluttertoast.showToast(
|
||||||
SnackBar(
|
msg: "Insufficient stock!",
|
||||||
content: Text("Something went wrong"),
|
toastLength: Toast.LENGTH_SHORT,
|
||||||
backgroundColor: Colors.red,
|
gravity: ToastGravity.CENTER,
|
||||||
),
|
backgroundColor: Colors.red,
|
||||||
|
textColor: Colors.white,
|
||||||
|
fontSize: 14.0,
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
isLoadingCart = false;
|
isLoadingCart = false;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class ProfileProvider extends ChangeNotifier {
|
|||||||
_uploadedUrl = uploadImage.data!.url.toString();
|
_uploadedUrl = uploadImage.data!.url.toString();
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
||||||
_showSnackBar(context, "Image uploaxded successfully!", Colors.green);
|
_showSnackBar(context, "Image uploaded successfully !", Colors.green);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -123,7 +123,7 @@ class ProfileProvider extends ChangeNotifier {
|
|||||||
allitem = response!;
|
allitem = response!;
|
||||||
|
|
||||||
_profile = response.img ?? '';
|
_profile = response.img ?? '';
|
||||||
_name = response.firstName ?? "" + " " + response.lastName ?? '';
|
_name = response.firstName + " " + response.lastName;
|
||||||
_email = response.email ?? "";
|
_email = response.email ?? "";
|
||||||
|
|
||||||
APPSTRING.userName = response.firstName ?? "";
|
APPSTRING.userName = response.firstName ?? "";
|
||||||
|
|||||||
@@ -299,7 +299,16 @@ class _BestDealScreenState extends State<BestDealScreen> {
|
|||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.push(MyRoutes.PRODUCTDETAILS,
|
context.push(MyRoutes.PRODUCTDETAILS,
|
||||||
extra: bestdealproduct.id);
|
|
||||||
|
|
||||||
|
extra: {
|
||||||
|
"id": bestdealproduct.id,
|
||||||
|
"quantity": 0,
|
||||||
|
"price": '0',
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import 'package:grocery_app/src/logic/provider/bottom_navbar_provider.dart';
|
|||||||
import 'package:grocery_app/src/logic/provider/home_provider.dart';
|
import 'package:grocery_app/src/logic/provider/home_provider.dart';
|
||||||
import 'package:grocery_app/src/ui/bestdeal/bestdeal_screen.dart';
|
import 'package:grocery_app/src/ui/bestdeal/bestdeal_screen.dart';
|
||||||
import 'package:grocery_app/src/ui/card_checkout/card_checkout_screen.dart';
|
import 'package:grocery_app/src/ui/card_checkout/card_checkout_screen.dart';
|
||||||
|
import 'package:grocery_app/src/ui/data_notfound.dart';
|
||||||
|
|
||||||
import 'package:grocery_app/src/ui/widgets/custom_icon_button.dart';
|
import 'package:grocery_app/src/ui/widgets/custom_icon_button.dart';
|
||||||
import 'package:grocery_app/src/ui/widgets/elevated_button.dart';
|
import 'package:grocery_app/src/ui/widgets/elevated_button.dart';
|
||||||
@@ -112,7 +113,15 @@ class _MycartState extends State<Mycart> {
|
|||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.push(MyRoutes.PRODUCTDETAILS,
|
context.push(MyRoutes.PRODUCTDETAILS,
|
||||||
extra: bestdealproduct.id);
|
|
||||||
|
|
||||||
|
extra: {
|
||||||
|
"id":bestdealproduct.id,
|
||||||
|
"quantity": 0,
|
||||||
|
"price": "0",
|
||||||
|
},
|
||||||
|
|
||||||
|
);
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(right: 5, bottom: 5, top: 5),
|
padding: const EdgeInsets.only(right: 5, bottom: 5, top: 5),
|
||||||
@@ -422,7 +431,12 @@ class _MycartState extends State<Mycart> {
|
|||||||
} else if (provider.allitem == null ||
|
} else if (provider.allitem == null ||
|
||||||
provider.allitem.items == null ||
|
provider.allitem.items == null ||
|
||||||
provider.allitem.items!.isEmpty) {
|
provider.allitem.items!.isEmpty) {
|
||||||
return Center(child: Text('🛒 Your Front Shop Cart is empty'));
|
return DataNotFound(
|
||||||
|
imagePath: 'assets/images/cartempty.jpg',
|
||||||
|
message: "",
|
||||||
|
width: 250.w,
|
||||||
|
height: 200.h,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return ListView.separated(
|
return ListView.separated(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
@@ -435,195 +449,212 @@ class _MycartState extends State<Mycart> {
|
|||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
var items = provider.allitem.items![index];
|
var items = provider.allitem.items![index];
|
||||||
|
|
||||||
return Padding(
|
return InkWell(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 10.w),
|
onTap: ()
|
||||||
child: Row(
|
{
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
context.push(
|
||||||
children: [
|
MyRoutes.PRODUCTDETAILS,
|
||||||
Container(
|
extra: {
|
||||||
decoration: BoxDecoration(
|
"id": items.product!.id,
|
||||||
color: Colors.greenAccent.withOpacity(0.1),
|
"quantity": items.quantity,
|
||||||
borderRadius: BorderRadius.circular(5),
|
"price": items.product!.discountPrice,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 10.w),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.greenAccent.withOpacity(0.1),
|
||||||
|
borderRadius: BorderRadius.circular(5),
|
||||||
|
),
|
||||||
|
child: AppNetworkImage(
|
||||||
|
width: 60.w,
|
||||||
|
height: 70.h,
|
||||||
|
imageUrl:
|
||||||
|
items.product!.productImages!.first.url ?? " ",
|
||||||
|
backGroundColor: APPCOLOR.bgGrey,
|
||||||
|
radius: 10,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
child: AppNetworkImage(
|
16.horizontalSpace,
|
||||||
width: 60.w,
|
Container(
|
||||||
height: 70.h,
|
width: 150.w,
|
||||||
imageUrl: items.product!.productImages!.first.url ?? " ",
|
child: Column(
|
||||||
backGroundColor: APPCOLOR.bgGrey,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
radius: 10,
|
children: [
|
||||||
),
|
Text(
|
||||||
),
|
items.product!.name ?? "",
|
||||||
16.horizontalSpace,
|
maxLines: 2,
|
||||||
Container(
|
overflow: TextOverflow.ellipsis,
|
||||||
width: 150.w,
|
style:
|
||||||
child: Column(
|
context.customMedium(APPCOLOR.balck1A1A1A, 14),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
items.product!.name ?? "",
|
|
||||||
maxLines: 2,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
|
|
||||||
),
|
|
||||||
2.verticalSpace,
|
|
||||||
Text(
|
|
||||||
items.product!.unit ?? "",
|
|
||||||
style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"₹${items.product!.discountPrice ?? ""} ",
|
|
||||||
textAlign: TextAlign.left,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: context.customSemiBold(Colors.black, 12),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
"₹${items.product!.basePrice ?? ""}",
|
|
||||||
textAlign: TextAlign.left,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: context
|
|
||||||
.customMedium(
|
|
||||||
Colors.grey.withOpacity(0.8),
|
|
||||||
12,
|
|
||||||
)
|
|
||||||
.copyWith(
|
|
||||||
decoration: TextDecoration.lineThrough,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(width: 10),
|
|
||||||
Container(
|
|
||||||
// padding: EdgeInsets.symmetric(
|
|
||||||
// horizontal: 6, vertical: 2),
|
|
||||||
// decoration: BoxDecoration(
|
|
||||||
// color: Colors.green,
|
|
||||||
// borderRadius: BorderRadius.circular(5),
|
|
||||||
// ),
|
|
||||||
child: Text(
|
|
||||||
"${calculateDiscountPercentage(double.parse(items.product!.basePrice.toString()), double.parse(items.product!.discountPrice.toString()))}%off",
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.lightGreen, fontSize: 12)),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Gap(5),
|
|
||||||
InkWell(
|
|
||||||
onTap: () {
|
|
||||||
showReturnPolicyBottomSheet(context);
|
|
||||||
},
|
|
||||||
child: Text("3 days Return & Exchange ",
|
|
||||||
style:
|
|
||||||
TextStyle(color: Colors.green, fontSize: 1)),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Spacer(),
|
|
||||||
Column(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
height: 25,
|
|
||||||
width: 70,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.all(Radius.circular(7)),
|
|
||||||
shape: BoxShape.rectangle,
|
|
||||||
border: Border.all(
|
|
||||||
color: APPCOLOR.lightGreen,
|
|
||||||
width: 1,
|
|
||||||
),
|
),
|
||||||
),
|
2.verticalSpace,
|
||||||
child: Center(
|
Text(
|
||||||
child: Row(
|
items.product!.unit ?? "",
|
||||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
style:
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
context.customMedium(APPCOLOR.balck1A1A1A, 14),
|
||||||
|
),
|
||||||
|
Row(
|
||||||
children: [
|
children: [
|
||||||
InkWell(
|
|
||||||
onTap: () async {
|
|
||||||
if (items.quantity! > 1) {
|
|
||||||
await provider.decreaseCartQuantity(
|
|
||||||
context,
|
|
||||||
items.id!,
|
|
||||||
int.parse(items.quantity.toString()) -
|
|
||||||
1);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Icon(
|
|
||||||
Icons.remove,
|
|
||||||
size: 15,
|
|
||||||
color: APPCOLOR.lightGreen,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// IconButton(
|
|
||||||
// // width: 14.w,
|
|
||||||
// // height: 14.h,
|
|
||||||
// onPressed: () async {
|
|
||||||
// if (items.quantity! > 1) {
|
|
||||||
// await provider.decreaseCartQuantity(
|
|
||||||
// context,
|
|
||||||
// items.id!,
|
|
||||||
// int.parse(items.quantity.toString()) -
|
|
||||||
// 1);
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// icon: Icon(Icons.minimize_rounded),
|
|
||||||
// iconSize: 10,
|
|
||||||
// ),
|
|
||||||
Gap(10),
|
|
||||||
Text(
|
Text(
|
||||||
items.quantity.toString(),
|
"₹${items.product!.discountPrice ?? ""} ",
|
||||||
style: context.customMedium(
|
textAlign: TextAlign.left,
|
||||||
APPCOLOR.balck1A1A1A, 14),
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: context.customSemiBold(Colors.black, 12),
|
||||||
),
|
),
|
||||||
Gap(10),
|
Text(
|
||||||
InkWell(
|
"₹${items.product!.basePrice ?? ""}",
|
||||||
onTap: () async {
|
textAlign: TextAlign.left,
|
||||||
await provider.addToCart(
|
maxLines: 1,
|
||||||
context, items.productId!, 1);
|
overflow: TextOverflow.ellipsis,
|
||||||
},
|
style: context
|
||||||
child: Icon(
|
.customMedium(
|
||||||
Icons.add,
|
Colors.grey.withOpacity(0.8),
|
||||||
size: 15,
|
12,
|
||||||
color: APPCOLOR.lightGreen,
|
)
|
||||||
),
|
.copyWith(
|
||||||
|
decoration: TextDecoration.lineThrough,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(width: 10),
|
||||||
|
Container(
|
||||||
|
// padding: EdgeInsets.symmetric(
|
||||||
|
// horizontal: 6, vertical: 2),
|
||||||
|
// decoration: BoxDecoration(
|
||||||
|
// color: Colors.green,
|
||||||
|
// borderRadius: BorderRadius.circular(5),
|
||||||
|
// ),
|
||||||
|
child: Text(
|
||||||
|
"${calculateDiscountPercentage(double.parse(items.product!.basePrice.toString()), double.parse(items.product!.discountPrice.toString()))}%off",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.lightGreen,
|
||||||
|
fontSize: 12)),
|
||||||
),
|
),
|
||||||
// IconButton(
|
|
||||||
// onPressed: () async {
|
|
||||||
// await provider.addToCart(
|
|
||||||
// context, items.productId!, 1);
|
|
||||||
|
|
||||||
// // await provider.getItemCards(context);
|
|
||||||
// },
|
|
||||||
// icon: Icon(Icons.add),
|
|
||||||
// iconSize: 10,
|
|
||||||
// ),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
Gap(5),
|
||||||
|
InkWell(
|
||||||
|
onTap: () {
|
||||||
|
showReturnPolicyBottomSheet(context);
|
||||||
|
},
|
||||||
|
child: Text("3 days Return & Exchange ",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.green, fontSize: 1)),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
Gap(20),
|
),
|
||||||
InkWell(
|
const Spacer(),
|
||||||
onTap: () async {
|
Column(
|
||||||
provider.deleteItem(context, items.id);
|
children: [
|
||||||
},
|
Container(
|
||||||
child: provider.isRemoveItem[items.id] ?? false
|
height: 25,
|
||||||
? Center(
|
width: 70,
|
||||||
child: Padding(
|
decoration: BoxDecoration(
|
||||||
padding: const EdgeInsets.all(8.0),
|
borderRadius: BorderRadius.all(Radius.circular(7)),
|
||||||
child: Container(
|
shape: BoxShape.rectangle,
|
||||||
height: 5,
|
border: Border.all(
|
||||||
width: 5,
|
color: APPCOLOR.lightGreen,
|
||||||
child: CircularProgressIndicator(
|
width: 1,
|
||||||
color: Colors.green, strokeWidth: 1),
|
),
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Row(
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
InkWell(
|
||||||
|
onTap: () async {
|
||||||
|
if (items.quantity! > 1) {
|
||||||
|
await provider.decreaseCartQuantity(
|
||||||
|
context,
|
||||||
|
items.id!,
|
||||||
|
int.parse(items.quantity.toString()) -
|
||||||
|
1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Icon(
|
||||||
|
Icons.remove,
|
||||||
|
size: 15,
|
||||||
|
color: APPCOLOR.lightGreen,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
// IconButton(
|
||||||
: Center(child: Text("Delete")),
|
// // width: 14.w,
|
||||||
)
|
// // height: 14.h,
|
||||||
],
|
// onPressed: () async {
|
||||||
)
|
// if (items.quantity! > 1) {
|
||||||
],
|
// await provider.decreaseCartQuantity(
|
||||||
|
// context,
|
||||||
|
// items.id!,
|
||||||
|
// int.parse(items.quantity.toString()) -
|
||||||
|
// 1);
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// icon: Icon(Icons.minimize_rounded),
|
||||||
|
// iconSize: 10,
|
||||||
|
// ),
|
||||||
|
Gap(10),
|
||||||
|
Text(
|
||||||
|
items.quantity.toString(),
|
||||||
|
style: context.customMedium(
|
||||||
|
APPCOLOR.balck1A1A1A, 14),
|
||||||
|
),
|
||||||
|
Gap(10),
|
||||||
|
InkWell(
|
||||||
|
onTap: () async {
|
||||||
|
await provider.addToCart(
|
||||||
|
context, items.productId!, 1);
|
||||||
|
},
|
||||||
|
child: Icon(
|
||||||
|
Icons.add,
|
||||||
|
size: 15,
|
||||||
|
color: APPCOLOR.lightGreen,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// IconButton(
|
||||||
|
// onPressed: () async {
|
||||||
|
// await provider.addToCart(
|
||||||
|
// context, items.productId!, 1);
|
||||||
|
|
||||||
|
// // await provider.getItemCards(context);
|
||||||
|
// },
|
||||||
|
// icon: Icon(Icons.add),
|
||||||
|
// iconSize: 10,
|
||||||
|
// ),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Gap(20),
|
||||||
|
InkWell(
|
||||||
|
onTap: () async {
|
||||||
|
provider.deleteItem(context, items.id);
|
||||||
|
},
|
||||||
|
child: provider.isRemoveItem[items.id] ?? false
|
||||||
|
? Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Container(
|
||||||
|
height: 5,
|
||||||
|
width: 5,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
color: Colors.green, strokeWidth: 1),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Center(child: Text("Delete")),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -858,29 +889,6 @@ class _MycartState extends State<Mycart> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// ElevatedButton(
|
|
||||||
// style: ElevatedButton.styleFrom(
|
|
||||||
// backgroundColor: APPCOLOR.lightGreen),
|
|
||||||
// onPressed: () {
|
|
||||||
// if (provider.isDeliverable) {
|
|
||||||
// _showAddressBottomSheet(context);
|
|
||||||
// } else {
|
|
||||||
// Fluttertoast.showToast(
|
|
||||||
// msg:
|
|
||||||
// "Delivery is not available for this pincode. Please try another pincode!",
|
|
||||||
// toastLength: Toast.LENGTH_SHORT,
|
|
||||||
// gravity: ToastGravity.BOTTOM,
|
|
||||||
// backgroundColor: Colors.red,
|
|
||||||
// textColor: Colors.white,
|
|
||||||
// fontSize: 14.0,
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// child: Row(
|
|
||||||
// mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
// children: [Text('Place Order', style: TextStyle(fontSize: 16))],
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
39
lib/src/ui/data_notfound.dart
Normal file
39
lib/src/ui/data_notfound.dart
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class DataNotFound extends StatelessWidget {
|
||||||
|
final String message;
|
||||||
|
final String imagePath;
|
||||||
|
final double width;
|
||||||
|
final double height;
|
||||||
|
|
||||||
|
const DataNotFound({
|
||||||
|
Key? key,
|
||||||
|
this.message = "No Data Available",
|
||||||
|
required this.imagePath,
|
||||||
|
this.width = 200,
|
||||||
|
this.height = 200,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Image.asset(
|
||||||
|
imagePath,
|
||||||
|
width: width,
|
||||||
|
height: height,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
Text(
|
||||||
|
message,
|
||||||
|
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w500),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -161,42 +161,48 @@ class _EditProfileScreenState extends State<EditProfileScreen> {
|
|||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Stack(
|
InkWell(
|
||||||
alignment: Alignment.center,
|
onTap: () {
|
||||||
children: [
|
_pickImage();
|
||||||
CircleAvatar(
|
},
|
||||||
radius: 40,
|
child: Stack(
|
||||||
backgroundColor: Colors.grey,
|
alignment: Alignment.center,
|
||||||
backgroundImage: _image != null
|
children: [
|
||||||
? FileImage(_image!)
|
CircleAvatar(
|
||||||
: (profile != null && profile!.isNotEmpty
|
radius: 40,
|
||||||
? NetworkImage(profile!)
|
backgroundColor: Colors.grey,
|
||||||
: const AssetImage("assets/default_profile.png")),
|
backgroundImage: _image != null
|
||||||
),
|
? FileImage(_image!)
|
||||||
Positioned(
|
: (profile != null && profile!.isNotEmpty
|
||||||
bottom: 0,
|
? NetworkImage(profile!)
|
||||||
right: 0,
|
: const AssetImage(
|
||||||
child: GestureDetector(
|
"assets/default_profile.png")),
|
||||||
onTap: () {
|
),
|
||||||
_pickImage();
|
Positioned(
|
||||||
},
|
bottom: 0,
|
||||||
child: Container(
|
right: 0,
|
||||||
height: 20,
|
child: GestureDetector(
|
||||||
width: 20,
|
onTap: () {
|
||||||
decoration: BoxDecoration(
|
_pickImage();
|
||||||
color: APPCOLOR.lightGreen,
|
},
|
||||||
border: Border.all(color: Colors.white),
|
child: Container(
|
||||||
borderRadius: BorderRadius.circular(5)),
|
height: 20,
|
||||||
child: Center(
|
width: 20,
|
||||||
child: Icon(
|
decoration: BoxDecoration(
|
||||||
MdiIcons.pencil,
|
color: APPCOLOR.lightGreen,
|
||||||
size: 10,
|
border: Border.all(color: Colors.white),
|
||||||
color: Colors.white,
|
borderRadius: BorderRadius.circular(5)),
|
||||||
|
child: Center(
|
||||||
|
child: Icon(
|
||||||
|
MdiIcons.pencil,
|
||||||
|
size: 10,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
)),
|
||||||
)),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.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/logic/provider/bottom_navbar_provider.dart';
|
import 'package:grocery_app/src/logic/provider/bottom_navbar_provider.dart';
|
||||||
import 'package:grocery_app/src/logic/provider/home_provider.dart';
|
import 'package:grocery_app/src/logic/provider/home_provider.dart';
|
||||||
|
import 'package:grocery_app/src/ui/data_notfound.dart';
|
||||||
import 'package:grocery_app/src/ui/header.dart';
|
import 'package:grocery_app/src/ui/header.dart';
|
||||||
import 'package:grocery_app/utils/constants/color_constant.dart';
|
import 'package:grocery_app/utils/constants/color_constant.dart';
|
||||||
import 'package:grocery_app/utils/extensions/uicontext.dart';
|
import 'package:grocery_app/utils/extensions/uicontext.dart';
|
||||||
@@ -146,7 +148,13 @@ class _FavouriteScreenState extends State<FavouriteScreen>
|
|||||||
return Expanded(
|
return Expanded(
|
||||||
child: _buildSkeletonLoader()); // Show Skeleton while loading
|
child: _buildSkeletonLoader()); // Show Skeleton while loading
|
||||||
} else if (provider.wishListItem.isEmpty) {
|
} else if (provider.wishListItem.isEmpty) {
|
||||||
return Expanded(child: Center(child: Text('No products available')));
|
return Expanded(
|
||||||
|
child: DataNotFound(
|
||||||
|
imagePath: 'assets/images/wishlist.jpg',
|
||||||
|
message: "Your Wish list is empty. Please add some items",
|
||||||
|
width: 250.w,
|
||||||
|
height: 200.h,
|
||||||
|
));
|
||||||
} else {
|
} else {
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: ListView.separated(
|
child: ListView.separated(
|
||||||
@@ -162,7 +170,15 @@ class _FavouriteScreenState extends State<FavouriteScreen>
|
|||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.push(MyRoutes.PRODUCTDETAILS, extra: productId);
|
context.push(MyRoutes.PRODUCTDETAILS,
|
||||||
|
// extra: productId
|
||||||
|
|
||||||
|
extra: {
|
||||||
|
"id":productId,
|
||||||
|
"quantity": 0,
|
||||||
|
"price": "0",
|
||||||
|
},
|
||||||
|
);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.all(8),
|
padding: EdgeInsets.all(8),
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:fluttertoast/fluttertoast.dart';
|
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/logic/provider/home_provider.dart';
|
import 'package:grocery_app/src/logic/provider/home_provider.dart';
|
||||||
|
import 'package:grocery_app/src/ui/data_notfound.dart';
|
||||||
import 'package:grocery_app/utils/constants/assets_constant.dart';
|
import 'package:grocery_app/utils/constants/assets_constant.dart';
|
||||||
import 'package:grocery_app/utils/constants/color_constant.dart';
|
import 'package:grocery_app/utils/constants/color_constant.dart';
|
||||||
import 'package:grocery_app/utils/constants/shared_pref_utils.dart';
|
import 'package:grocery_app/utils/constants/shared_pref_utils.dart';
|
||||||
@@ -121,8 +123,13 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
|||||||
);
|
);
|
||||||
} else if (provider.products.isEmpty) {
|
} else if (provider.products.isEmpty) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(left: 80),
|
padding: const EdgeInsets.only(left: 40),
|
||||||
child: Center(child: Text('No products available')),
|
child: DataNotFound(
|
||||||
|
imagePath: 'assets/images/cart.jpg',
|
||||||
|
message: "Product not abailable ",
|
||||||
|
width: 200.w,
|
||||||
|
height: 250.h,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return Expanded(
|
return Expanded(
|
||||||
@@ -173,7 +180,15 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
|||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.push(MyRoutes.PRODUCTDETAILS,
|
context.push(MyRoutes.PRODUCTDETAILS,
|
||||||
extra: product.id);
|
// extra: product.id
|
||||||
|
|
||||||
|
extra: {
|
||||||
|
"id": product.id,
|
||||||
|
"quantity": 0,
|
||||||
|
"price": "0",
|
||||||
|
},
|
||||||
|
|
||||||
|
);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
height: itemHeight,
|
height: itemHeight,
|
||||||
|
|||||||
@@ -300,7 +300,16 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.push(MyRoutes.PRODUCTDETAILS,
|
context.push(MyRoutes.PRODUCTDETAILS,
|
||||||
extra: bestdealproduct.id);
|
// extra: bestdealproduct.id
|
||||||
|
|
||||||
|
extra: {
|
||||||
|
"id":bestdealproduct.id,
|
||||||
|
"quantity": 0,
|
||||||
|
"price": "0",
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
);
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
@@ -679,7 +688,14 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.push(MyRoutes.PRODUCTDETAILS,
|
context.push(MyRoutes.PRODUCTDETAILS,
|
||||||
extra: product.id);
|
// extra: product.id
|
||||||
|
|
||||||
|
extra: {
|
||||||
|
"id":product.id,
|
||||||
|
"quantity": 0,
|
||||||
|
"price": "0",
|
||||||
|
},
|
||||||
|
);
|
||||||
},
|
},
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
child: Column(
|
child: Column(
|
||||||
|
|||||||
@@ -26,7 +26,14 @@ import 'package:shimmer/shimmer.dart';
|
|||||||
|
|
||||||
class ProductDetails extends StatefulWidget {
|
class ProductDetails extends StatefulWidget {
|
||||||
String id;
|
String id;
|
||||||
ProductDetails({super.key, required this.id});
|
int quantity;
|
||||||
|
String price;
|
||||||
|
|
||||||
|
ProductDetails(
|
||||||
|
{super.key,
|
||||||
|
required this.id,
|
||||||
|
required this.quantity,
|
||||||
|
required this.price});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ProductDetails> createState() => _ProductDetailsState();
|
State<ProductDetails> createState() => _ProductDetailsState();
|
||||||
@@ -41,7 +48,7 @@ class _ProductDetailsState extends State<ProductDetails> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
Provider.of<ProductProvider>(context, listen: false)
|
Provider.of<ProductProvider>(context, listen: false)
|
||||||
.getProduuctDetails(context, widget.id);
|
.getProduuctDetails(context, widget.id, widget.quantity, widget.price);
|
||||||
}
|
}
|
||||||
|
|
||||||
double value = 3.5;
|
double value = 3.5;
|
||||||
@@ -979,7 +986,8 @@ class _ProductDetailsState extends State<ProductDetails> {
|
|||||||
|
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
provider.getProduuctDetails(context, bestdealproduct.id);
|
provider.getProduuctDetails(
|
||||||
|
context, bestdealproduct.id, 0, "0");
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(right: 10, bottom: 5, top: 5),
|
padding: const EdgeInsets.only(right: 10, bottom: 5, top: 5),
|
||||||
|
|||||||
Reference in New Issue
Block a user