fixed issue add to cart
This commit is contained in:
@@ -992,7 +992,7 @@
|
||||
"languageVersion": "3.4"
|
||||
}
|
||||
],
|
||||
"generated": "2025-02-22T07:04:58.909640Z",
|
||||
"generated": "2025-02-22T13:29:09.162780Z",
|
||||
"generator": "pub",
|
||||
"generatorVersion": "3.4.4",
|
||||
"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(
|
||||
path: PRODUCTDETAILS,
|
||||
name: PRODUCTDETAILS,
|
||||
pageBuilder: (context, state) {
|
||||
final id = state.extra as String; // Get the extra object
|
||||
return ProductDetails(id: id);
|
||||
pageBuilder: (context, state)
|
||||
{
|
||||
// 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 {
|
||||
var result = await _homeRepo.paymentOrder(data);
|
||||
return result.fold(
|
||||
@@ -497,27 +496,31 @@ class AddtocartProvider extends ChangeNotifier {
|
||||
);
|
||||
},
|
||||
(response) async {
|
||||
print("kldfjghlkjfgkljh");
|
||||
await getItemCards(context);
|
||||
cartItems.add(productId); // Add product to cart
|
||||
// Fluttertoast.showToast(
|
||||
// msg: "Added to cart successfully!",
|
||||
// toastLength: Toast.LENGTH_SHORT,
|
||||
// gravity: ToastGravity.BOTTOM,
|
||||
// backgroundColor: Colors.green,
|
||||
// textColor: Colors.white,
|
||||
// fontSize: 14.0,
|
||||
// );
|
||||
cartItems.add(productId);
|
||||
|
||||
iscardAdded = true;
|
||||
notifyListeners(); // Update UI after adding to cart
|
||||
notifyListeners();
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text("Something went wrong"),
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
Fluttertoast.showToast(
|
||||
msg: "Insufficient stock!",
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
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 {
|
||||
isLoadingCart = false;
|
||||
isLoadings[productId] = false;
|
||||
|
||||
@@ -36,6 +36,7 @@ class ProductProvider extends ChangeNotifier {
|
||||
bool hasMore = true;
|
||||
|
||||
bool iscroll = true;
|
||||
|
||||
Future<void> gettAllProduct(
|
||||
BuildContext context, String id, bool status, String search) async {
|
||||
if (isLoadingg || !hasMore) return;
|
||||
@@ -132,12 +133,13 @@ class ProductProvider extends ChangeNotifier {
|
||||
ProductDetailsData productDetails = ProductDetailsData();
|
||||
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 = {};
|
||||
productDetails = ProductDetailsData();
|
||||
isProductLoading = true;
|
||||
quantitys = 1;
|
||||
_totalPrice = 0.0;
|
||||
quantitys = quantity;
|
||||
_totalPrice = quantity * (double.parse(price));
|
||||
notifyListeners();
|
||||
|
||||
var result = await _homeRepo.getProductDetails(data, context, id);
|
||||
@@ -435,11 +437,13 @@ class ProductProvider extends ChangeNotifier {
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text("Something went wrong"),
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
Fluttertoast.showToast(
|
||||
msg: "Insufficient stock!",
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.CENTER,
|
||||
backgroundColor: Colors.red,
|
||||
textColor: Colors.white,
|
||||
fontSize: 14.0,
|
||||
);
|
||||
} finally {
|
||||
isLoadingCart = false;
|
||||
|
||||
@@ -35,7 +35,7 @@ class ProfileProvider extends ChangeNotifier {
|
||||
_uploadedUrl = uploadImage.data!.url.toString();
|
||||
notifyListeners();
|
||||
|
||||
_showSnackBar(context, "Image uploaxded successfully!", Colors.green);
|
||||
_showSnackBar(context, "Image uploaded successfully !", Colors.green);
|
||||
return true;
|
||||
},
|
||||
);
|
||||
@@ -123,7 +123,7 @@ class ProfileProvider extends ChangeNotifier {
|
||||
allitem = response!;
|
||||
|
||||
_profile = response.img ?? '';
|
||||
_name = response.firstName ?? "" + " " + response.lastName ?? '';
|
||||
_name = response.firstName + " " + response.lastName;
|
||||
_email = response.email ?? "";
|
||||
|
||||
APPSTRING.userName = response.firstName ?? "";
|
||||
|
||||
@@ -299,7 +299,16 @@ class _BestDealScreenState extends State<BestDealScreen> {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
context.push(MyRoutes.PRODUCTDETAILS,
|
||||
extra: bestdealproduct.id);
|
||||
|
||||
|
||||
extra: {
|
||||
"id": bestdealproduct.id,
|
||||
"quantity": 0,
|
||||
"price": '0',
|
||||
},
|
||||
|
||||
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
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/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))],
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
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(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 40,
|
||||
backgroundColor: Colors.grey,
|
||||
backgroundImage: _image != null
|
||||
? FileImage(_image!)
|
||||
: (profile != null && profile!.isNotEmpty
|
||||
? NetworkImage(profile!)
|
||||
: const AssetImage("assets/default_profile.png")),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
_pickImage();
|
||||
},
|
||||
child: Container(
|
||||
height: 20,
|
||||
width: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: APPCOLOR.lightGreen,
|
||||
border: Border.all(color: Colors.white),
|
||||
borderRadius: BorderRadius.circular(5)),
|
||||
child: Center(
|
||||
child: Icon(
|
||||
MdiIcons.pencil,
|
||||
size: 10,
|
||||
color: Colors.white,
|
||||
InkWell(
|
||||
onTap: () {
|
||||
_pickImage();
|
||||
},
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 40,
|
||||
backgroundColor: Colors.grey,
|
||||
backgroundImage: _image != null
|
||||
? FileImage(_image!)
|
||||
: (profile != null && profile!.isNotEmpty
|
||||
? NetworkImage(profile!)
|
||||
: const AssetImage(
|
||||
"assets/default_profile.png")),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
_pickImage();
|
||||
},
|
||||
child: Container(
|
||||
height: 20,
|
||||
width: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: APPCOLOR.lightGreen,
|
||||
border: Border.all(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_screenutil/flutter_screenutil.dart';
|
||||
import 'package:go_router/go_router.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/logic/provider/bottom_navbar_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/utils/constants/color_constant.dart';
|
||||
import 'package:grocery_app/utils/extensions/uicontext.dart';
|
||||
@@ -146,7 +148,13 @@ class _FavouriteScreenState extends State<FavouriteScreen>
|
||||
return Expanded(
|
||||
child: _buildSkeletonLoader()); // Show Skeleton while loading
|
||||
} 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 {
|
||||
return Expanded(
|
||||
child: ListView.separated(
|
||||
@@ -162,7 +170,15 @@ class _FavouriteScreenState extends State<FavouriteScreen>
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
context.push(MyRoutes.PRODUCTDETAILS, extra: productId);
|
||||
context.push(MyRoutes.PRODUCTDETAILS,
|
||||
// extra: productId
|
||||
|
||||
extra: {
|
||||
"id":productId,
|
||||
"quantity": 0,
|
||||
"price": "0",
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:go_router/go_router.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/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/color_constant.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) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 80),
|
||||
child: Center(child: Text('No products available')),
|
||||
padding: const EdgeInsets.only(left: 40),
|
||||
child: DataNotFound(
|
||||
imagePath: 'assets/images/cart.jpg',
|
||||
message: "Product not abailable ",
|
||||
width: 200.w,
|
||||
height: 250.h,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Expanded(
|
||||
@@ -173,7 +180,15 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
context.push(MyRoutes.PRODUCTDETAILS,
|
||||
extra: product.id);
|
||||
// extra: product.id
|
||||
|
||||
extra: {
|
||||
"id": product.id,
|
||||
"quantity": 0,
|
||||
"price": "0",
|
||||
},
|
||||
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
height: itemHeight,
|
||||
|
||||
@@ -300,7 +300,16 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
context.push(MyRoutes.PRODUCTDETAILS,
|
||||
extra: bestdealproduct.id);
|
||||
// extra: bestdealproduct.id
|
||||
|
||||
extra: {
|
||||
"id":bestdealproduct.id,
|
||||
"quantity": 0,
|
||||
"price": "0",
|
||||
},
|
||||
|
||||
|
||||
);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
@@ -679,7 +688,14 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
context.push(MyRoutes.PRODUCTDETAILS,
|
||||
extra: product.id);
|
||||
// extra: product.id
|
||||
|
||||
extra: {
|
||||
"id":product.id,
|
||||
"quantity": 0,
|
||||
"price": "0",
|
||||
},
|
||||
);
|
||||
},
|
||||
child: SizedBox(
|
||||
child: Column(
|
||||
|
||||
@@ -26,7 +26,14 @@ import 'package:shimmer/shimmer.dart';
|
||||
|
||||
class ProductDetails extends StatefulWidget {
|
||||
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
|
||||
State<ProductDetails> createState() => _ProductDetailsState();
|
||||
@@ -41,7 +48,7 @@ class _ProductDetailsState extends State<ProductDetails> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
Provider.of<ProductProvider>(context, listen: false)
|
||||
.getProduuctDetails(context, widget.id);
|
||||
.getProduuctDetails(context, widget.id, widget.quantity, widget.price);
|
||||
}
|
||||
|
||||
double value = 3.5;
|
||||
@@ -979,7 +986,8 @@ class _ProductDetailsState extends State<ProductDetails> {
|
||||
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
provider.getProduuctDetails(context, bestdealproduct.id);
|
||||
provider.getProduuctDetails(
|
||||
context, bestdealproduct.id, 0, "0");
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(right: 10, bottom: 5, top: 5),
|
||||
|
||||
Reference in New Issue
Block a user