offer update
This commit is contained in:
@@ -80,8 +80,7 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
||||
|
||||
Widget productWidget() {
|
||||
return Consumer<ProductProvider>(builder: (context, provider, child) {
|
||||
if (provider.isLoadingg)
|
||||
{
|
||||
if (provider.isLoadingg) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 120),
|
||||
child: Center(
|
||||
@@ -126,8 +125,7 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
||||
var product = provider.products[index];
|
||||
|
||||
return InkWell(
|
||||
onTap: ()
|
||||
{
|
||||
onTap: () {
|
||||
context.push(MyRoutes.PRODUCTDETAILS,
|
||||
extra: product.id);
|
||||
},
|
||||
@@ -168,6 +166,26 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
||||
"https://5.imimg.com/data5/SELLER/Default/2024/2/385126988/OL/DA/VW/8627346/1l-fortune-sunflower-oil.jpg",
|
||||
backGroundColor: Colors.transparent,
|
||||
),
|
||||
Positioned(
|
||||
right: 1,
|
||||
bottom: 0,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 6, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red,
|
||||
borderRadius:
|
||||
BorderRadius.circular(5),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
"${calculateDiscountPercentage(double.parse(product.basePrice), double.parse(product!.discountPrice))}% OFF",
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12)),
|
||||
),
|
||||
),
|
||||
)
|
||||
// Positioned(
|
||||
// right: 5,
|
||||
// top: 5,
|
||||
@@ -343,8 +361,6 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -362,6 +378,21 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
|
||||
});
|
||||
}
|
||||
|
||||
int calculateDiscountPercentage(double basePrice, double discountPrice) {
|
||||
print(
|
||||
"Base Price (Before Discount): $basePrice, Discount Price (After Discount): $discountPrice");
|
||||
|
||||
if (basePrice <= 0 || discountPrice <= 0 || discountPrice > basePrice) {
|
||||
print("Error: Invalid price values.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
double discountAmount = basePrice - discountPrice;
|
||||
double discountPercentage = (discountAmount / basePrice) * 100;
|
||||
|
||||
return discountPercentage.round();
|
||||
}
|
||||
|
||||
Widget filterCategory() {
|
||||
final activeIndexProvider = Provider.of<ProductProvider>(context);
|
||||
return Consumer<ProductProvider>(builder: (context, provider, child) {
|
||||
|
||||
Reference in New Issue
Block a user