addtocart

This commit is contained in:
bestonemitRam
2025-01-31 00:48:19 +05:30
parent 48fab4a1c0
commit 028155a1d7
11 changed files with 1021 additions and 675 deletions

View File

@@ -213,12 +213,15 @@ class _MycartState extends State<Mycart> {
Widget cartItems() {
return Consumer<AddtocartProvider>(builder: (context, provider, child) {
print("djkhsfjh ${provider.allitem.items}");
if (provider.isLoaddcartItem) {
return Padding(
padding: const EdgeInsets.only(left: 120),
child: CircularProgressIndicator(),
);
} else if (provider.allitem != null) {
} else if (provider.allitem == null) {
return Center(child: Text('🛒 Your Front Shop Cart is empty'));
} else if (provider.allitem.items == null) {
return Center(child: Text('🛒 Your Front Shop Cart is empty'));
} else {
return ListView.separated(
@@ -229,83 +232,119 @@ class _MycartState extends State<Mycart> {
child: const Divider(thickness: 1),
),
itemCount: provider.allitem.items!.length,
itemBuilder: (context, index) => Padding(
padding: EdgeInsets.symmetric(horizontal: 24.w),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
decoration: BoxDecoration(
color: Colors.greenAccent.withOpacity(0.1),
borderRadius: BorderRadius.circular(5),
),
child: AppNetworkImage(
width: 50.w,
height: 40.h,
imageUrl:
'https://i.pinimg.com/originals/a5/f3/5f/a5f35fb23e942809da3df91b23718e8d.png',
backGroundColor: APPCOLOR.bgGrey,
radius: 10,
),
),
// Image.asset(product.image, width: 50.w, height: 40.h),
itemBuilder: (context, index) {
var items = provider.allitem.items![index];
16.horizontalSpace,
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Vegitables and Fruits",
textAlign: TextAlign.center,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
print("kdfgdjfgkj ${items}");
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),
),
5.verticalSpace,
Text(
'1kg, 10\$',
style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
child: AppNetworkImage(
width: 60.w,
height: 70.h,
imageUrl: items.product!.productImages!.first.url ?? " ",
backGroundColor: APPCOLOR.bgGrey,
radius: 10,
),
],
),
const Spacer(),
Row(
children: [
CustomIconButton(
width: 20.w,
height: 20.h,
onPressed: () {},
icon: SvgPicture.asset(
APPASSETS.removeIcon,
fit: BoxFit.none,
),
// Image.asset(product.image, width: 50.w, height: 40.h),
16.horizontalSpace,
Container(
width: 150.w,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
items.product!.name ?? "",
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
),
5.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,
),
),
],
),
],
),
),
const Spacer(),
Row(
children: [
CustomIconButton(
width: 14.w,
height: 14.h,
onPressed: () {
// provider.decreaseQuantity(items);
},
icon: SvgPicture.asset(
APPASSETS.removeIcon,
fit: BoxFit.none,
),
backgroundColor: APPCOLOR.appGreen,
),
backgroundColor: APPCOLOR.appGreen,
),
16.horizontalSpace,
Text(
"10",
style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
),
16.horizontalSpace,
CustomIconButton(
width: 20.w,
height: 20.h,
onPressed: () {},
icon: SvgPicture.asset(
APPASSETS.addIcon,
fit: BoxFit.none,
5.horizontalSpace,
Text(
items.quantity.toString(),
style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
),
backgroundColor: APPCOLOR.appGreen,
),
],
)
],
),
).animate(delay: (100 * index).ms).fade().slideX(
duration: 300.ms,
begin: -1,
curve: Curves.easeInSine,
5.horizontalSpace,
CustomIconButton(
width: 14.w,
height: 14.h,
onPressed: () {
// provider..increaseQuantity(items);
},
icon: SvgPicture.asset(
APPASSETS.addIcon,
fit: BoxFit.none,
),
backgroundColor: APPCOLOR.appGreen,
),
],
)
],
),
).animate(delay: (100 * index).ms).fade().slideX(
duration: 300.ms,
begin: -1,
curve: Curves.easeInSine,
);
},
);
}
});
@@ -321,7 +360,7 @@ class _MycartState extends State<Mycart> {
);
} else if (provider.allitem == null) {
return Center(child: Text('🛒 Your Front Shop Cart is empty'));
} else if (provider.allitem.items != null) {
} else if (provider.allitem.items == null) {
return Center(
child: ElevatedButton(
style: ElevatedButton.styleFrom(backgroundColor: Colors.green),
@@ -345,7 +384,9 @@ class _MycartState extends State<Mycart> {
trailing: Icon(Icons.arrow_forward_ios),
onTap: () {},
),
SummaryRow(label: 'Item Total', value: '\$24'),
SummaryRow(
label: 'Item Total',
value: '\$22'),
SummaryRow(label: 'Discount', value: '\$2'),
SummaryRow(label: 'Delivery Free', value: 'Free', isGreen: true),
Divider(),