Flutter 从单个动态值实现总单位值
] 大家好,这是一个购物车应用程序的json 在列表的每个对象中都有折扣开始和折扣结束 所以我知道如何根据单个产品的时间来调整价格,,, 但是当我合计价格并将其显示在ui中时,逻辑看起来有点混乱,,, 例如10+5(折扣价)+10+5(折扣价)+5(折扣价) 总价35 现在假设5分钟后用户仍在屏幕上显示某个产品端的折扣 看起来像这样 10+10+10+5(折扣价)+5(折扣价) 总价40 因此,单独分配折扣是可以的,,,但正如您所看到的,我如何根据每个独特产品的不同折扣开始时间和折扣结束时间计算总价Flutter 从单个动态值实现总单位值,flutter,dart,widget,Flutter,Dart,Widget,] 大家好,这是一个购物车应用程序的json 在列表的每个对象中都有折扣开始和折扣结束 所以我知道如何根据单个产品的时间来调整价格,,, 但是当我合计价格并将其显示在ui中时,逻辑看起来有点混乱,,, 例如10+5(折扣价)+10+5(折扣价)+5(折扣价) 总价35 现在假设5分钟后用户仍在屏幕上显示某个产品端的折扣 看起来像这样 10+10+10+5(折扣价)+5(折扣价) 总价40 因此,单独分配折扣是可以的,,,但正如您所看到的,我如何根据每个独特产品的不同折扣开始时间和折扣结束时间计算
"cartDetails": [
{
"cartId": "d1e11788-90be-4428-9b5e-3dac66196272",
"storeProductId": 100017,
"quantity": 1,
"supplied_quantity": null,
"total_price": "13.99",
"shopper_price": null,
"notes": "",
"outOfStock": "r",
"createdAt": "2020-10-01T16:12:59.000Z",
"updatedAt": "2020-10-01T16:12:59.000Z",
"deletedAt": null,
"outOfStockStoreProductId": null,
"storeProduct": {
"id": 100017,
"productId": "pick-n-pay-dewfresh-cultured-buttermilk-500ml",
"storeId": "pick-n-pay-family-the-gardens",
"price": "13.99",
"discountType": null,
"discount": null,
"discountStart": null,
"discountEnd": null,
"isVisible": true,
"storeFront": false,
"createdAt": null,
"updatedAt": null,
"unitId": null,
"product": {
"id": "pick-n-pay-dewfresh-cultured-buttermilk-500ml",
"name": "Dewfresh Cultured Buttermilk 500ml",
"tagline": null,
"description": "We recommend that you do not rely solely on this information and always check product labels. Where dietary or other information is important to you please contact Pick n Pay Customer Services if the poduct is Pick n Pay branded or otherwise the product manufacturer. Although we strive to keep this information as accurate as possible, Pick n Pay are unable to accept liability for any incorrect information. This does not affect your statutory rights.",
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"productImages": [
{
"id": 2,
"img_url": "https://cdn-prd-02.pnp.co.za/sys-master/root/h73/he4/9146952319006/265099_EA_400Wx400H",
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"productId": "pick-n-pay-dewfresh-cultured-buttermilk-500ml"
}
]
},
"unit": null,
"store": {
"id": "pick-n-pay-family-the-gardens",
"name": "Pick N Pay Family The Gardens",
"description": null,
"location": {
"type": "Point",
"coordinates": [
-33.9701875,
25.5264375
]
},
"full_address": "166 circular dr, lorraine, port elizabeth, 6000",
"suburb": "lorraine",
"city": "port elizabeth",
"isClosed": false,
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"merchantId": "pick-n-pay",
"merchant": {
"id": "pick-n-pay",
"name": "Pick n Pay",
"description": null,
"logo": "https://delivast-public.s3.us-east-2.amazonaws.com/logo/pnp.jpg",
"visible": true,
"createdAt": null,
"updatedAt": null,
"deletedAt": null
}
}
}
},
{
"cartId": "d1e11788-90be-4428-9b5e-3dac66196272",
"storeProductId": 100028,
"quantity": 1,
"supplied_quantity": null,
"total_price": "32.99",
"shopper_price": null,
"notes": "",
"outOfStock": "r",
"createdAt": "2020-10-01T16:13:07.000Z",
"updatedAt": "2020-10-01T16:13:07.000Z",
"deletedAt": null,
"outOfStockStoreProductId": null,
"storeProduct": {
"id": 100028,
"productId": "pick-n-pay-lancewood-dairy-mushroom-sauce-250ml",
"storeId": "pick-n-pay-family-the-gardens",
"price": "32.99",
"discountType": null,
"discount": null,
"discountStart": null,
"discountEnd": null,
"isVisible": true,
"storeFront": false,
"createdAt": null,
"updatedAt": null,
"unitId": null,
"product": {
"id": "pick-n-pay-lancewood-dairy-mushroom-sauce-250ml",
"name": "Lancewood Dairy Mushroom Sauce 250ml",
"tagline": null,
"description": "We recommend that you do not rely solely on this information and always check product labels. Where dietary or other information is important to you please contact Pick n Pay Customer Services if the poduct is Pick n Pay branded or otherwise the product manufacturer. Although we strive to keep this information as accurate as possible, Pick n Pay are unable to accept liability for any incorrect information. This does not affect your statutory rights.",
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"productImages": [
{
"id": 3,
"img_url": "https://cdn-prd-02.pnp.co.za/sys-master/images/h68/hcb/9537212776478/silo-product-image-v2-12Jul2019-180120-6009617224506-front-361116-125_400Wx400H",
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"productId": "pick-n-pay-lancewood-dairy-mushroom-sauce-250ml"
},
{
"id": 35,
"img_url": "https://cdn-prd-02.pnp.co.za/sys-master/images/h68/hcb/9537212776478/silo-product-image-v2-12Jul2019-180120-6009617224506-front-361116-125_400Wx400H",
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"productId": "pick-n-pay-lancewood-dairy-mushroom-sauce-250ml"
}
]
},
"unit": null,
"store": {
"id": "pick-n-pay-family-the-gardens",
"name": "Pick N Pay Family The Gardens",
"description": null,
"location": {
"type": "Point",
"coordinates": [
-33.9701875,
25.5264375
]
},
"full_address": "166 circular dr, lorraine, port elizabeth, 6000",
"suburb": "lorraine",
"city": "port elizabeth",
"isClosed": false,
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"merchantId": "pick-n-pay",
"merchant": {
"id": "pick-n-pay",
"name": "Pick n Pay",
"description": null,
"logo": "https://delivast-public.s3.us-east-2.amazonaws.com/logo/pnp.jpg",
"visible": true,
"createdAt": null,
"updatedAt": null,
"deletedAt": null
}
}
}
},
{
"cartId": "d1e11788-90be-4428-9b5e-3dac66196272",
"storeProductId": 100039,
"quantity": 1,
"supplied_quantity": null,
"total_price": "32.99",
"shopper_price": null,
"notes": "",
"outOfStock": "r",
"createdAt": "2020-10-01T16:13:10.000Z",
"updatedAt": "2020-10-01T16:13:10.000Z",
"deletedAt": null,
"outOfStockStoreProductId": null,
"storeProduct": {
"id": 100039,
"productId": "pick-n-pay-lancewood-dairy-pepper-sauce-250ml",
"storeId": "pick-n-pay-family-the-gardens",
"price": "32.99",
"discountType": null,
"discount": null,
"discountStart": null,
"discountEnd": null,
"isVisible": true,
"storeFront": false,
"createdAt": null,
"updatedAt": null,
"unitId": null,
"product": {
"id": "pick-n-pay-lancewood-dairy-pepper-sauce-250ml",
"name": "Lancewood Dairy Pepper Sauce 250ml",
"tagline": null,
"description": "We recommend that you do not rely solely on this information and always check product labels. Where dietary or other information is important to you please contact Pick n Pay Customer Services if the poduct is Pick n Pay branded or otherwise the product manufacturer. Although we strive to keep this information as accurate as possible, Pick n Pay are unable to accept liability for any incorrect information. This does not affect your statutory rights.",
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"productImages": [
{
"id": 4,
"img_url": "https://cdn-prd-02.pnp.co.za/sys-master/images/h50/hf3/9448265351198/silo-product-image-v2-12Mar2019-155834-6009617224483-front-343331-74_400Wx400H",
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"productId": "pick-n-pay-lancewood-dairy-pepper-sauce-250ml"
}
]
},
"unit": null,
"store": {
"id": "pick-n-pay-family-the-gardens",
"name": "Pick N Pay Family The Gardens",
"description": null,
"location": {
"type": "Point",
"coordinates": [
-33.9701875,
25.5264375
]
},
"full_address": "166 circular dr, lorraine, port elizabeth, 6000",
"suburb": "lorraine",
"city": "port elizabeth",
"isClosed": false,
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"merchantId": "pick-n-pay",
"merchant": {
"id": "pick-n-pay",
"name": "Pick n Pay",
"description": null,
"logo": "https://delivast-public.s3.us-east-2.amazonaws.com/logo/pnp.jpg",
"visible": true,
"createdAt": null,
"updatedAt": null,
"deletedAt": null
}
}
}
},
{
"cartId": "d1e11788-90be-4428-9b5e-3dac66196272",
"storeProductId": 100050,
"quantity": 1,
"supplied_quantity": null,
"total_price": "18.99",
"shopper_price": null,
"notes": "",
"outOfStock": "r",
"createdAt": "2020-10-01T16:13:18.000Z",
"updatedAt": "2020-10-01T16:13:18.000Z",
"deletedAt": null,
"outOfStockStoreProductId": null,
"storeProduct": {
"id": 100050,
"productId": "pick-n-pay-clover-nolac-lactose-free-fresh-milk-1l",
"storeId": "pick-n-pay-family-the-gardens",
"price": "18.99",
"discountType": null,
"discount": null,
"discountStart": null,
"discountEnd": null,
"isVisible": true,
"storeFront": false,
"createdAt": null,
"updatedAt": null,
"unitId": null,
"product": {
"id": "pick-n-pay-clover-nolac-lactose-free-fresh-milk-1l",
"name": "Clover Nolac Lactose Free Fresh Milk 1l",
"tagline": null,
"description": "We recommend that you do not rely solely on this information and always check product labels. Where dietary or other information is important to you please contact Pick n Pay Customer Services if the poduct is Pick n Pay branded or otherwise the product manufacturer. Although we strive to keep this information as accurate as possible, Pick n Pay are unable to accept liability for any incorrect information. This does not affect your statutory rights.",
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"productImages": [
{
"id": 5,
"img_url": "https://cdn-prd-02.pnp.co.za/sys-master/images/he3/h35/9581816971294/silo-product-image-v2-04Sep2019-180108-6001299006746-up-372791-242_400Wx400H",
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"productId": "pick-n-pay-clover-nolac-lactose-free-fresh-milk-1l"
},
{
"id": 6,
"img_url": "https://cdn-prd-02.pnp.co.za/sys-master/images/h90/h51/9581811630110/silo-product-image-v2-04Sep2019-180108-6001299006746-up-372791-242_96Wx96H",
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"productId": "pick-n-pay-clover-nolac-lactose-free-fresh-milk-1l"
}
]
},
"unit": null,
"store": {
"id": "pick-n-pay-family-the-gardens",
"name": "Pick N Pay Family The Gardens",
"description": null,
"location": {
"type": "Point",
"coordinates": [
-33.9701875,
25.5264375
]
},
"full_address": "166 circular dr, lorraine, port elizabeth, 6000",
"suburb": "lorraine",
"city": "port elizabeth",
"isClosed": false,
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"merchantId": "pick-n-pay",
"merchant": {
"id": "pick-n-pay",
"name": "Pick n Pay",
"description": null,
"logo": "https://delivast-public.s3.us-east-2.amazonaws.com/logo/pnp.jpg",
"visible": true,
"createdAt": null,
"updatedAt": null,
"deletedAt": null
}
}
}
},
{
"cartId": "d1e11788-90be-4428-9b5e-3dac66196272",
"storeProductId": 200020,
"quantity": 1,
"supplied_quantity": null,
"total_price": "39.00",
"shopper_price": null,
"notes": "",
"outOfStock": "r",
"createdAt": "2020-10-02T17:13:55.000Z",
"updatedAt": "2020-10-02T17:13:55.000Z",
"deletedAt": null,
"outOfStockStoreProductId": null,
"storeProduct": {
"id": 200020,
"productId": "makro-excella--sunflower-oil--(1-x-2l)",
"storeId": "makro-store-port-elizabeth",
"price": "39.00",
"discountType": null,
"discount": null,
"discountStart": null,
"discountEnd": null,
"isVisible": true,
"storeFront": false,
"createdAt": null,
"updatedAt": null,
"unitId": null,
"product": {
"id": "makro-excella--sunflower-oil--(1-x-2l)",
"name": "Excella Sunflower Oil (1 x 2L)",
"tagline": null,
"description": " Size 1 x 2L ",
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"productImages": [
{
"id": 156,
"img_url": "https://www.makro.co.za/sys-master/images/hc8/hd3/8894496768030/silo-MIN_24890_EAA_large",
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"productId": "makro-excella--sunflower-oil--(1-x-2l)"
}
]
},
"unit": null,
"store": {
"id": "makro-store-port-elizabeth",
"name": "Makro Store Port Elizabeth",
"description": null,
"location": {
"type": "Point",
"coordinates": [
-33.944312499999995,
25.5096875
]
},
"full_address": "cnr cape rd &, bramlin st, kabega, port elizabeth, 6025, south africa",
"suburb": "port elizabeth",
"city": "6025",
"isClosed": false,
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"merchantId": "makro",
"merchant": {
"id": "makro",
"name": "Makro",
"description": null,
"logo": "https://delivast-public.s3.us-east-2.amazonaws.com/logo/makro.webp",
"visible": true,
"createdAt": null,
"updatedAt": null,
"deletedAt": null
}
}
}
},
{
"cartId": "d1e11788-90be-4428-9b5e-3dac66196272",
"storeProductId": 200022,
"quantity": 1,
"supplied_quantity": null,
"total_price": "27.95",
"shopper_price": null,
"notes": "",
"outOfStock": "r",
"createdAt": "2020-10-02T17:16:45.000Z",
"updatedAt": "2020-10-02T17:16:45.000Z",
"deletedAt": null,
"outOfStockStoreProductId": null,
"storeProduct": {
"id": 200022,
"productId": "makro-miami--mango-achar--hot--(400g)",
"storeId": "makro-store-port-elizabeth",
"price": "27.95",
"discountType": null,
"discount": null,
"discountStart": null,
"discountEnd": null,
"isVisible": true,
"storeFront": false,
"createdAt": null,
"updatedAt": null,
"unitId": null,
"product": {
"id": "makro-miami--mango-achar--hot--(400g)",
"name": "Miami Mango Achar Hot (400g)",
"tagline": null,
"description": " Size 400g ",
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"productImages": [
{
"id": 159,
"img_url": "https://www.makro.co.za/sys-master/images/h7d/h17/9599051628574/silo-MIN_91800001_EAA_large",
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"productId": "makro-miami--mango-achar--hot--(400g)"
}
]
},
"unit": null,
"store": {
"id": "makro-store-port-elizabeth",
"name": "Makro Store Port Elizabeth",
"description": null,
"location": {
"type": "Point",
"coordinates": [
-33.944312499999995,
25.5096875
]
},
"full_address": "cnr cape rd &, bramlin st, kabega, port elizabeth, 6025, south africa",
"suburb": "port elizabeth",
"city": "6025",
"isClosed": false,
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"merchantId": "makro",
"merchant": {
"id": "makro",
"name": "Makro",
"description": null,
"logo": "https://delivast-public.s3.us-east-2.amazonaws.com/logo/makro.webp",
"visible": true,
"createdAt": null,
"updatedAt": null,
"deletedAt": null
}
}
}
},
{
"cartId": "d1e11788-90be-4428-9b5e-3dac66196272",
"storeProductId": 200023,
"quantity": 1,
"supplied_quantity": null,
"total_price": "52.85",
"shopper_price": null,
"notes": "",
"outOfStock": "r",
"createdAt": "2020-10-02T17:16:48.000Z",
"updatedAt": "2020-10-02T17:16:48.000Z",
"deletedAt": null,
"outOfStockStoreProductId": null,
"storeProduct": {
"id": 200023,
"productId": "makro-miami--vegetable-atchar--(all-variants)--(1-x-760g)",
"storeId": "makro-store-port-elizabeth",
"price": "52.85",
"discountType": null,
"discount": null,
"discountStart": null,
"discountEnd": null,
"isVisible": true,
"storeFront": false,
"createdAt": null,
"updatedAt": null,
"unitId": null,
"product": {
"id": "makro-miami--vegetable-atchar--(all-variants)--(1-x-760g)",
"name": "Miami Vegetable Atchar (All Variants) (1 x",
"tagline": null,
"description": " Size 1 x 760g ",
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"productImages": [
{
"id": 160,
"img_url": "https://www.makro.co.za/sys-master/images/h5c/he5/8896191791134/silo-MIN_91882002_EAA_large",
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"productId": "makro-miami--vegetable-atchar--(all-variants)--(1-x-760g)"
},
{
"id": 171,
"img_url": "https://www.makro.co.za/sys-master/images/hf3/hb7/9694304763934/silo-MIN_91882001_EAA_large",
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"productId": "makro-miami--vegetable-atchar--(all-variants)--(1-x-760g)"
}
]
},
"unit": null,
"store": {
"id": "makro-store-port-elizabeth",
"name": "Makro Store Port Elizabeth",
"description": null,
"location": {
"type": "Point",
"coordinates": [
-33.944312499999995,
25.5096875
]
},
"full_address": "cnr cape rd &, bramlin st, kabega, port elizabeth, 6025, south africa",
"suburb": "port elizabeth",
"city": "6025",
"isClosed": false,
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"merchantId": "makro",
"merchant": {
"id": "makro",
"name": "Makro",
"description": null,
"logo": "https://delivast-public.s3.us-east-2.amazonaws.com/logo/makro.webp",
"visible": true,
"createdAt": null,
"updatedAt": null,
"deletedAt": null
}
}
}
},
{
"cartId": "d1e11788-90be-4428-9b5e-3dac66196272",
"storeProductId": 200029,
"quantity": 1,
"supplied_quantity": null,
"total_price": "52.85",
"shopper_price": null,
"notes": "",
"outOfStock": "r",
"createdAt": "2020-10-02T17:16:51.000Z",
"updatedAt": "2020-10-02T17:16:51.000Z",
"deletedAt": null,
"outOfStockStoreProductId": null,
"storeProduct": {
"id": 200029,
"productId": "makro-miami--mango-achar--hot--(1-x-780g)",
"storeId": "makro-store-port-elizabeth",
"price": "52.85",
"discountType": null,
"discount": null,
"discountStart": null,
"discountEnd": null,
"isVisible": true,
"storeFront": false,
"createdAt": null,
"updatedAt": null,
"unitId": null,
"product": {
"id": "makro-miami--mango-achar--hot--(1-x-780g)",
"name": "Miami Mango Achar Hot (1 x 780g)",
"tagline": null,
"description": " Size 1 x 780g ",
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"productImages": [
{
"id": 169,
"img_url": "https://www.makro.co.za/sys-master/images/h23/hb1/9694304960542/silo-MIN_91801001_EAA_large",
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"productId": "makro-miami--mango-achar--hot--(1-x-780g)"
}
]
},
"unit": null,
"store": {
"id": "makro-store-port-elizabeth",
"name": "Makro Store Port Elizabeth",
"description": null,
"location": {
"type": "Point",
"coordinates": [
-33.944312499999995,
25.5096875
]
},
"full_address": "cnr cape rd &, bramlin st, kabega, port elizabeth, 6025, south africa",
"suburb": "port elizabeth",
"city": "6025",
"isClosed": false,
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"merchantId": "makro",
"merchant": {
"id": "makro",
"name": "Makro",
"description": null,
"logo": "https://delivast-public.s3.us-east-2.amazonaws.com/logo/makro.webp",
"visible": true,
"createdAt": null,
"updatedAt": null,
"deletedAt": null
}
}
}
},
{
"cartId": "d1e11788-90be-4428-9b5e-3dac66196272",
"storeProductId": 200038,
"quantity": 1,
"supplied_quantity": null,
"total_price": "28.95",
"shopper_price": null,
"notes": "",
"outOfStock": "r",
"createdAt": "2020-10-02T17:20:55.000Z",
"updatedAt": "2020-10-02T17:20:55.000Z",
"deletedAt": null,
"outOfStockStoreProductId": null,
"storeProduct": {
"id": 200038,
"productId": "makro-kings--vinegar--white--(1--x-5l)",
"storeId": "makro-store-port-elizabeth",
"price": "28.95",
"discountType": null,
"discount": null,
"discountStart": null,
"discountEnd": null,
"isVisible": true,
"storeFront": false,
"createdAt": null,
"updatedAt": null,
"unitId": null,
"product": {
"id": "makro-kings--vinegar--white--(1--x-5l)",
"name": "Kings Vinegar White (1 x 5L)",
"tagline": null,
"description": " Size 1 x 5L ",
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"productImages": [
{
"id": 179,
"img_url": "https://www.makro.co.za/sys-master/images/hd1/h8c/8904670117918/silo-MIN_148040002_EAA_large",
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"productId": "makro-kings--vinegar--white--(1--x-5l)"
},
{
"id": 180,
"img_url": "https://www.makro.co.za/sys-master/images/ha1/h93/8904670314526/silo-MIN_148040002_EAC_large",
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"productId": "makro-kings--vinegar--white--(1--x-5l)"
}
]
},
"unit": null,
"store": {
"id": "makro-store-port-elizabeth",
"name": "Makro Store Port Elizabeth",
"description": null,
"location": {
"type": "Point",
"coordinates": [
-33.944312499999995,
25.5096875
]
},
"full_address": "cnr cape rd &, bramlin st, kabega, port elizabeth, 6025, south africa",
"suburb": "port elizabeth",
"city": "6025",
"isClosed": false,
"createdAt": null,
"updatedAt": null,
"deletedAt": null,
"merchantId": "makro",
"merchant": {
"id": "makro",
"name": "Makro",
"description": null,
"logo": "https://delivast-public.s3.us-east-2.amazonaws.com/logo/makro.webp",
"visible": true,
"createdAt": null,
"updatedAt": null,
"deletedAt": null
}
}
}
}