fixed issue add to cart
This commit is contained in:
@@ -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/ui/bestdeal/bestdeal_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/elevated_button.dart';
|
||||
@@ -112,7 +113,15 @@ class _MycartState extends State<Mycart> {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
context.push(MyRoutes.PRODUCTDETAILS,
|
||||
extra: bestdealproduct.id);
|
||||
|
||||
|
||||
extra: {
|
||||
"id":bestdealproduct.id,
|
||||
"quantity": 0,
|
||||
"price": "0",
|
||||
},
|
||||
|
||||
);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(right: 5, bottom: 5, top: 5),
|
||||
@@ -422,7 +431,12 @@ class _MycartState extends State<Mycart> {
|
||||
} else if (provider.allitem == null ||
|
||||
provider.allitem.items == null ||
|
||||
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 {
|
||||
return ListView.separated(
|
||||
shrinkWrap: true,
|
||||
@@ -435,195 +449,212 @@ class _MycartState extends State<Mycart> {
|
||||
itemBuilder: (context, index) {
|
||||
var items = provider.allitem.items![index];
|
||||
|
||||
return 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),
|
||||
return InkWell(
|
||||
onTap: ()
|
||||
{
|
||||
context.push(
|
||||
MyRoutes.PRODUCTDETAILS,
|
||||
extra: {
|
||||
"id": items.product!.id,
|
||||
"quantity": items.quantity,
|
||||
"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(
|
||||
width: 60.w,
|
||||
height: 70.h,
|
||||
imageUrl: items.product!.productImages!.first.url ?? " ",
|
||||
backGroundColor: APPCOLOR.bgGrey,
|
||||
radius: 10,
|
||||
),
|
||||
),
|
||||
16.horizontalSpace,
|
||||
Container(
|
||||
width: 150.w,
|
||||
child: Column(
|
||||
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,
|
||||
16.horizontalSpace,
|
||||
Container(
|
||||
width: 150.w,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
items.product!.name ?? "",
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style:
|
||||
context.customMedium(APPCOLOR.balck1A1A1A, 14),
|
||||
),
|
||||
),
|
||||
child: Center(
|
||||
child: Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
2.verticalSpace,
|
||||
Text(
|
||||
items.product!.unit ?? "",
|
||||
style:
|
||||
context.customMedium(APPCOLOR.balck1A1A1A, 14),
|
||||
),
|
||||
Row(
|
||||
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(
|
||||
items.quantity.toString(),
|
||||
style: context.customMedium(
|
||||
APPCOLOR.balck1A1A1A, 14),
|
||||
"₹${items.product!.discountPrice ?? ""} ",
|
||||
textAlign: TextAlign.left,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: context.customSemiBold(Colors.black, 12),
|
||||
),
|
||||
Gap(10),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
await provider.addToCart(
|
||||
context, items.productId!, 1);
|
||||
},
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
size: 15,
|
||||
color: APPCOLOR.lightGreen,
|
||||
),
|
||||
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)),
|
||||
),
|
||||
// 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(
|
||||
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),
|
||||
),
|
||||
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,
|
||||
),
|
||||
),
|
||||
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,
|
||||
),
|
||||
),
|
||||
)
|
||||
: Center(child: Text("Delete")),
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
// 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(
|
||||
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))],
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user