build method
- BuildContext context
Describes the part of the user interface represented by this widget.
The framework calls this method when this widget is inserted into the tree in a given BuildContext and when the dependencies of this widget change (e.g., an InheritedWidget referenced by this widget changes). This method can potentially be called in every frame and should not have any side effects beyond building a widget.
The framework replaces the subtree below this widget with the widget returned by this method, either by updating the existing subtree or by removing the subtree and inflating a new subtree, depending on whether the widget returned by this method can update the root of the existing subtree, as determined by calling Widget.canUpdate.
Typically implementations return a newly created constellation of widgets that are configured with information from this widget's constructor and from the given BuildContext.
The given BuildContext contains information about the location in the tree at which this widget is being built. For example, the context provides the set of inherited widgets for this location in the tree. A given widget might be built with multiple different BuildContext arguments over time if the widget is moved around the tree or if the widget is inserted into the tree in multiple places at once.
The implementation of this method must only depend on:
- the fields of the widget, which themselves must not change over time, and
- any ambient state obtained from the
contextusing BuildContext.dependOnInheritedWidgetOfExactType.
If a widget's build method is to depend on anything else, use a StatefulWidget instead.
See also:
- StatelessWidget, which contains the discussion on performance considerations.
Implementation
@override
Widget build(BuildContext context) {
controller.getUserPaymentTransactions();
return ConstrainedBox(
constraints: context.x > 1100
? BoxConstraints(maxWidth: 1100)
: BoxConstraints(maxWidth: context.x),
child: Container(
padding: EdgeInsets.symmetric(horizontal: context.x < 1100 ? 20 : 0),
// padding: EdgeInsets.symmetric(
// horizontal: context.x < 800
// ? 50.dp
// : context.x > 1120
// ? 183.dp
// : 100.dp),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ResponsiveGridRow(children: [
ResponsiveGridCol(
lg: 12,
md: 12,
sm: 12,
xs: 12,
child: ResponsiveGridRow(
children: [
ResponsiveGridCol(
child: Column(
children: [
Obx(() => controller
.isPaymentTransactionLoading.value
? const SizedBox()
: tb.ResponsiveDataTable<Transactions>(
margin: const EdgeInsets.fromLTRB(0, 0, 0, 10),
customFilter: InkWell(
onTap: () async {
await openDialog(
const PaymentsFilterDialog(
height: 540,
title: 'Filter By',
),
);
},
child: Container(
width: 32.dp,
height: 32.dp,
alignment: Alignment.center,
decoration: BoxDecoration(
color: ColorHelper.bGLight2,
borderRadius:
BorderRadius.circular(4.dp),
),
child: SvgPicture.asset(
"assets/dashboard/ic_filter.svg",
width: 24,
height: 24,
),
),
),
columns: [
tb.DataColumn(
label: 'Date',
width: 0.6,
builder: (trx) {
return Text(
trx.paymentDate ??
trx.createdAt
?.split("T")
.first ??
'',
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 11.dp,
fontWeight: FontWeight.w400,
color: ColorHelper.black01,
),
);
},
),
tb.DataColumn(
label: 'Category',
width: 0.8,
text: (trx) {
return trx.purpose
?.replaceAll("_", " ").replaceAll('SUBSCRIPTION', 'MEMBERSHIP') ??
'N/A';
},
),
tb.DataColumn(
label: 'Transaction ID',
width: 0.8,
text: (trx) {
return trx.transactionId ?? 'N/A';
},
),
tb.DataColumn(
label: 'Payment Method',
width: 0.7,
text: (trx) {
if(trx.provider == 'NEO PASS'){
return 'COMPLIMENTARY';
}else{
return trx.type ?? 'N/A';
}
},
),
tb.DataColumn(
label: 'Amount Paid',
width: 0.7,
text: (trx) {
return trx.status == "COMPLETED"?'\$ ${trx.amountToPay ?? 'N/A'} ' :'\$ ${trx.totalAmount ?? 'N/A'} ';
},
),
tb.DataColumn(
label: 'Details',
width: 0.7,
text: (trx) {
return trx.booking != null
? ('${trx.booking?.fromAirport?.display3} -> ${trx.booking?.toAirport?.display3}')
: capitalizeFirstLetter(
trx.purpose ?? '')
.replaceAll("_", " ").replaceAll('Subscription', 'Membership');
},
),
tb.DataColumn(
label: 'Status',
width: 0.5,
builder: (trx) {
final status =
DashboardUtils.mapPaymentStatus(
trx.status ?? '');
return Text(
status.text,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: status.textColor,
),
);
},
),
tb.DataColumn(
label: '',
width: .2,
builder: (item) =>
PopupMenuButton<String>(
tooltip: '',
padding: EdgeInsets.zero,
color: ColorHelper.white,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(16.dp),
),
itemBuilder: (BuildContext context) =>
<PopupMenuEntry<String>>[],
onSelected: (String value) {},
child: Container(
margin: EdgeInsets.only(top: 12.dp),
alignment: Alignment.centerLeft,
child: SvgPicture.asset(
'assets/profile/ic_menu.svg',
width: 16.dp,
height: 16.dp,
),
),
),
),
],
currentPage: controller.currentPage.value,
totalPages: controller.totalPages.value,
totalRows: controller.totalRequests.value,
rowsPerPage: controller.rowsPerPage.value,
nextPage: controller.nextPage,
previousPage: controller.previousPage,
pageOpened: controller.goToPage,
values: controller.paymentTransactions,
updateRowsPerPage: controller.selectNumRows,
title: 'Payment History',
)),
20.SpaceX,
],
),
)
],
))
]),
// 2.h.SpaceX,
// LayoutBuilder(
// builder: (BuildContext context, BoxConstraints constraints) {
// return ResponsiveGridRow(
// children: [
// // ResponsiveGridCol(
// // lg: context.x > 1120 ? 6 : 8,
// // md: 8,
// // sm: 10,
// // xs: 12,
// // child: Container(
// // height: context.x<1070? null: context.x<1156? constraints.maxWidth/1.4: context.x<1300? constraints.maxWidth/1.6: context.x<1300? constraints.maxWidth/1.75: context.x>1340? 470: constraints.maxWidth/1.9,
// // decoration: BoxDecoration(
// // color: ColorHelper.white,
// // borderRadius: BorderRadius.circular(15),
// // border: Border.all(
// // width: 1,
// // color: ColorHelper.grey01,
// // )),
// // padding: EdgeInsets.fromLTRB(25.dp, 25.dp, 25.dp, 25.dp),
// // margin: EdgeInsets.only(right: 10.dp, bottom: 10.dp),
// // child: Column(
// // crossAxisAlignment: CrossAxisAlignment.start,
// // children: [
// // buildTitle('NEOPass Bank Details'),
// // 20.dp.SpaceX,
// // detailsRow('Beneficiary Name', 'NEOPASS By My NEO Group'),
// // detailsRow('IBAN', 'BG9287328467326452567'),
// // detailsRow('Account Number', '0089327484738'),
// // ResponsiveGridRow(
// // children: [
// // ResponsiveGridCol(
// // lg: 6,
// // md: 8,
// // sm: 10,
// // xs: 12,
// // child: detailsRow('BIC', '0089327484738'),
// // ),
// // ResponsiveGridCol(
// // lg: 6,
// // md: 8,
// // sm: 10,
// // xs: 12,
// // child: detailsRow('SWIFT', '0089327484738'),
// // )
// // ],
// // ),
// // detailsRow('Bank Name', 'Baron Capital Bank'),
// // detailsRow('Bank Address',
// // '6391 Elgin St. Celina, Delaware 10299', isLast: true)
// // ],
// // ),
// // ),
// // ),
// // ResponsiveGridCol(
// // lg: context.x > 1100 ? 6 : 8,
// // md: 8,
// // sm: 10,
// // xs: 12,
// // child: Container(
// // // height: context.x<1070? null: context.x<1156? constraints.maxWidth/1.4: context.x<1300? constraints.maxWidth/1.6: context.x>1340? 470: constraints.maxWidth/1.9,
// // decoration: BoxDecoration(
// // color: ColorHelper.white,
// // borderRadius: BorderRadius.circular(15),
// // border: Border.all(
// // width: 1,
// // color: ColorHelper.grey01,
// // )),
// // padding:
// // EdgeInsets.fromLTRB(25.dp, 25.dp, 25.dp, 25.dp),
// // margin: EdgeInsets.only(
// // left: context.x > 1120 ? 10.dp : 0.dp,
// // bottom: 40.dp),
// // child: Column(
// // crossAxisAlignment: CrossAxisAlignment.start,
// // children: [
// // buildTitle('NEO Miles Rewards'),
// // 20.dp.SpaceX,
// // availableBalanceWidget('AVAILABLE BALANCE',
// // '${controller.neoMilesBalance}'),
// // 14.dp.SpaceX,
// // ResponsiveGridRow(
// // children: [
// // ResponsiveGridCol(
// // lg: 6,
// // md: 8,
// // sm: 10,
// // xs: 12,
// // child: rewardValues('Redeemable Value',
// // '\$1 = 100 NEO Miles'),
// // ),
// // ResponsiveGridCol(
// // lg: 6,
// // md: 8,
// // sm: 10,
// // xs: 12,
// // child: rewardValues('Earning Rate',
// // '\$ 100 Spend = 200 NEO Miles'),
// // )
// // ],
// // ),
// // 34.dp.SpaceX,
// // Row(
// // mainAxisAlignment: MainAxisAlignment.spaceBetween,
// // children: [
// // Expanded(
// // child: CustomButton(
// // fontSize: 16.dp,
// // fontWeight: FontWeight.w500,
// // btnText: 'Transfer Miles',
// // btnTextColor: ColorHelper.primaryColor1,
// // btnclr: ColorHelper.white,
// // border: Border.all(
// // color: ColorHelper.primaryColor1),
// // ),
// // ),
// // 10.dp.SpaceY,
// // Expanded(
// // child: CustomButton(
// // btnText: 'Deposit Miles',
// // fontWeight: FontWeight.w500,
// // fontSize: 16.dp,
// // ),
// // ),
// // ],
// // )
// // ],
// // ),
// // ),
// // ),
// ],
// );
// },
// ),
],
),
),
);
}