19.7 费用小计
实现步骤:
第 1 步:组件 BuildTotalItem
lib/pages/my/order_details/widgets/total_item.dart
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| import 'package:flutter/material.dart'; import 'package:flutter_woo_commerce_getx_learn/common/index.dart';
class BuildTotalItem extends StatelessWidget { const BuildTotalItem({ Key? key, this.title, this.price, this.currencySymbol, }) : super(key: key);
final String? title;
final String? price;
final String? currencySymbol;
Widget _buildView() { return <Widget>[ TextWidget.body1(title ?? "").expanded(),
TextWidget.body2("$currencySymbol $price"), ].toRow(); }
@override Widget build(BuildContext context) { return _buildView(); } }
|
第 2 步:视图
lib/pages/my/order_details/view.dart
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| Widget _buildTotal() { return <Widget>[ <Widget>[ TextWidget.body1(LocaleKeys.orderDetailsPaymentMethod.tr),
const TextWidget.body2("VISA Card Payment"),
BuildTotalItem( title: LocaleKeys.orderDetailsBalance.tr, currencySymbol: controller.order.currencySymbol, price: "0", ), ] .toColumn( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, ) .expanded(),
SizedBox( width: AppSpace.iconTextMedium, ),
<Widget>[ BuildTotalItem( title: LocaleKeys.orderDetailsTotal.tr, currencySymbol: controller.order.currencySymbol, price: controller.order.total, ),
BuildTotalItem( title: LocaleKeys.orderDetailsShipping.tr, currencySymbol: controller.order.currencySymbol, price: controller.order.shippingTotal, ),
BuildTotalItem( title: LocaleKeys.orderDetailsDiscount.tr, currencySymbol: controller.order.currencySymbol, price: controller.order.discountTotal, ), ] .toColumn( mainAxisAlignment: MainAxisAlignment.spaceAround, ) .expanded(), ].toRow().height(100).paddingAll(AppSpace.card).card(); }
|
提交代码到 git