build method

  1. @override
Widget build(
  1. BuildContext context
)
override

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:

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) {
  WidgetsBinding.instance.addPostFrameCallback((_) {
    if (isInit.isFalse) {
      isInit.value = true;
      final Map<String, String> queryParameters =
          GoRouterState.of(context).uri.queryParameters;
      final String? paymentId = queryParameters['paymentId'];
      if (paymentId != null && paymentId.isNotEmpty) {
        paymentStatusController.fetchPaymentDetails(paymentId);
      } else {
        debugPrint('Payment ID is missing in the URL');
      }
      controller.index1.value=Get.find<RotateImageController>().loadImage('paymentfail_banner_index',controller.imageList1.length);
    }
  });
  return SelectionArea(
    child: FlutterSizer(builder: (context, orientation, screenType) {
      return Scaffold(
        extendBody: true,
        bottomNavigationBar: Constants.isWeb() ? null :   BottomNavBar(),
         key: _scaffoldKey,
        endDrawer: const NotificationDrawer(),
        backgroundColor: ColorHelper.white,
        body: TopMenu(
          showTopMenuShadow: RxBool(true),
          pageContent: SingleChildScrollView(
            child: Container(
              width: context.x,
              child: Column(
                children: [
                  Obx(
                    () => Container(
                        width: context.x,
                        height: 278,
                        decoration:  BoxDecoration(
                            image: DecorationImage(
                                image: AssetImage(
                                  paymentStatusController.imageList1[paymentStatusController.index1.value],
                                ),
                                fit: BoxFit.fill)),
                        padding: EdgeInsets.symmetric(horizontal: context.x<1100?20.dp:0),
                        child: Stack(
                          children: [
                            if(context.x>768)
                              Positioned(
                                bottom: 28,
                                right: 20,
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.end,
                                  children: [
                                    Image.asset(
                                      'assets/neopass-logo-light-flat.png',
                                      height: 37,
                                    ),
                                  ],
                                ),
                              ),
                            Center(
                                child: ConstrainedBox(
                              constraints: const BoxConstraints(maxWidth: 1100),
                              child: Align(
                                alignment: Alignment.topLeft,
                                child: Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  mainAxisAlignment: MainAxisAlignment.center,
                                  children: [
                                     Text(
                                      paymentStatusController.title1[paymentStatusController.index1.value],
                                      style: TextStyle(
                                          fontSize: context.x<768?20.dp:26.dp,
                                          color: Colors.white,
                                          fontWeight: FontWeight.w600,
                                          fontFamily: 'PlayFairDisplay'),
                                    ),
                                    8.SpaceX,
                                    Container(
                                      width: 474,
                                      height: 1.dp,
                                      decoration: BoxDecoration(
                                        gradient: LinearGradient(
                                          colors: [
                                            Colors.white,
                                            Colors.white.withOpacity(0.1),
                                          ],
                                          begin: Alignment.centerLeft,
                                          end: Alignment.centerRight,
                                        ),
                                      ),
                                    ),
                                    8.SpaceX,
                                     Text(
                                      paymentStatusController.subtitle1[paymentStatusController.index1.value],
                                      style: const TextStyle(
                                          fontSize: 18,
                                          color: Colors.white,
                                          fontWeight: FontWeight.w600,
                                          fontFamily: 'PlayFairDisplay'),
                                    ),
                                  ],
                                ),
                              ),
                            )),
                          ],
                        )),
                  ),
                  Center(
                    child: ConstrainedBox(
                      constraints: const BoxConstraints(maxWidth: 1100),
                      child: Column(
                        children: [
                          44.SpaceX,
                          Image.asset(
                            'assets/flight_search/payment-failure.png',
                            height: 164,
                          ),
                          12.SpaceX,
                          RichText(
                            text: TextSpan(
                              text: 'Payment ',
                              style: TextStyle(
                                fontSize: 28.dp,
                                fontWeight: FontWeight.w600,
                                color: ColorHelper.textDark,
                                fontFamily: "PlayFairDisplay",
                              ),
                              children: [
                                WidgetSpan(
                                  child: GradientText('Failed!',
                                      style: TextStyle(
                                          fontSize: 28.dp,
                                          fontWeight: FontWeight.w600,
                                          height: 1.3,
                                          fontFamily: 'PlayFairDisplay'),
                                      gradientDirection:
                                          GradientDirection.ltr,
                                      colors: ColorHelper.gradientTextColors),
                                ),
                              ],
                            ),
                          ),
                          16.SpaceX,
                          Text(
                              'Please try again or use a different payment method.',
                              style: TextStyle(
                                  fontSize: 14.dp,
                                  fontWeight: FontWeight.w400,
                                  color: ColorHelper.neutralLightText)),
                          26.SpaceX,
                          Row(
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: [
                              context.x<768?

                              InkWell(
                                onTap: () {
                                  onTapPay();
                                },
                                child: Container(
                                  padding: EdgeInsets.symmetric(horizontal: 10.dp,vertical: 5),
                                  alignment: Alignment.center,
                                  decoration: BoxDecoration(
                                    color: ColorHelper.primaryColor1,
                                    borderRadius: BorderRadius.circular(8),
                                  ),
                                  child: const Text('Retry Payment',
                                  style: TextStyle(
                                    fontSize: 16,
                                    fontWeight: FontWeight.w500,
                                    color: ColorHelper.white,
                                  ),
                                  ),
                                ),
                              ):
                              CustomButton(
                                btnText: 'Retry Payment',
                                border: Border.all(
                                    color: ColorHelper.primaryColor1),
                                btnWidth: context.x<768?120.dp:160,
                                onTap: () {
                                  onTapPay();
                                },
                              ),
                              8.SpaceY,
                              context.x<768?
                              InkWell(
                                onTap: () {
                                 onTapPay();
                                },
                                child: Container(
                                  padding: EdgeInsets.symmetric(horizontal: 10.dp,vertical: 5),
                                  alignment: Alignment.center,
                                  decoration: BoxDecoration(
                                    borderRadius: BorderRadius.circular(8),
                                    border: Border.all(color: ColorHelper.neutralLightText,width: 1)
                                  ),
                                  child: const Text('Change Payment Method',
                                  style: TextStyle(
                                    fontSize: 16,
                                    fontWeight: FontWeight.w500,
                                    color: ColorHelper.primaryColor1,
                                  ),
                                  ),
                                ),
                              ):
                              CustomButton(
                                btnText: 'Change Payment Method',
                                btnclr: Colors.transparent,
                                btnTextColor: ColorHelper.primaryColor1,
                                border: Border.all(
                                    color: ColorHelper.primaryColor1),
                                btnWidth: context.x<768?180.dp:220,
                                onTap: () {
                                  onTapPay();
                                },
                              ),
                            ],
                          ),
                          54.SpaceX,
                          const Divider(
                            color: ColorHelper.genericBorderColor,
                            thickness: 1,
                          ),
                          Obx(() {
                            if(context.x>768){
                              return Padding(padding: const EdgeInsets.symmetric(vertical: 20),
                                child: Row(
                                  mainAxisAlignment:
                                  MainAxisAlignment.spaceBetween,
                                  children: [
                                    if (paymentStatusController.paymentStatusData.value.bookingId != null)
                                      Row(
                                        children: [
                                          const Text(
                                            'Booking ID: ',
                                            style: TextStyle(
                                                fontWeight: FontWeight.w400,
                                                fontSize: 14,
                                                color: ColorHelper
                                                    .neutralLightText),
                                          ),
                                          Text(
                                            paymentStatusController
                                                .paymentStatusData
                                                .value
                                                .bookingId ??
                                                "",
                                            style: const TextStyle(
                                                fontWeight: FontWeight.w400,
                                                fontSize: 14,
                                                color:
                                                ColorHelper.primaryColor1),
                                          ),
                                        ],
                                      ),
                                    Row(
                                      children: [
                                        Text(
                                          paymentStatusController
                                              .paymentStatusData
                                              .value
                                              .bookingId ==
                                              null
                                              ? 'Date & Time: '
                                              : 'Booked Date & Time: ',
                                          style: const TextStyle(
                                              fontWeight: FontWeight.w400,
                                              fontSize: 14,
                                              color:
                                              ColorHelper.neutralLightText),
                                        ),
                                        Builder(builder: (context) {
                                          final paymentDate =
                                              paymentStatusController
                                                  .paymentStatusData
                                                  .value
                                                  .paymentDate;
                                          final formattedDate = paymentDate !=
                                              null &&
                                              paymentDate
                                                  .toString()
                                                  .isNotEmpty
                                              ? DateFormat(
                                              'dd-MM-yyyy | hh:mm a')
                                              .format(DateTime.parse(
                                              paymentDate.toString()))
                                              : DateFormat(
                                              'dd-MM-yyyy | hh:mm a')
                                              .format(DateTime.now());
                                          return Text(
                                            formattedDate,
                                            style: const TextStyle(
                                                fontWeight: FontWeight.w400,
                                                fontSize: 14,
                                                color:
                                                ColorHelper.primaryColor1),
                                          );
                                        }),
                                      ],
                                    ),
                                    Row(
                                      children: [
                                        const Text(
                                          'Payment Method: ',
                                          style: TextStyle(
                                              fontWeight: FontWeight.w400,
                                              fontSize: 14,
                                              color:
                                              ColorHelper.neutralLightText),
                                        ),
                                        Text(
                                          paymentStatusController
                                              .paymentStatusData
                                              .value
                                              .type ??
                                              "",
                                          style: const TextStyle(
                                              fontWeight: FontWeight.w400,
                                              fontSize: 14,
                                              color: ColorHelper.primaryColor1),
                                        ),
                                      ],
                                    ),
                                    Row(
                                      children: [
                                        const Text(
                                          'Amount: ',
                                          style: TextStyle(
                                              fontWeight: FontWeight.w400,
                                              fontSize: 14,
                                              color:
                                              ColorHelper.neutralLightText),
                                        ),
                                        Row(
                                          children: [
                                            Text(
                                              "${controller.paymentStatusData.value.totalAmount == null ? "" : "\$"}${double.parse((controller.paymentStatusData.value.totalAmount ??"0")).toStringAsFixed(2).withCommas}",
                                              style: const TextStyle(
                                                  fontWeight: FontWeight.w400,
                                                  fontSize: 14,
                                                  color: ColorHelper
                                                      .primaryColor1),
                                            ),
                                            5.SpaceY,
                                          ],
                                        ),
                                      ],
                                    ),
                                    Row(
                                      children: [
                                        const Text(
                                          'Payment Reference: ',
                                          style: TextStyle(
                                              fontWeight: FontWeight.w400,
                                              fontSize: 14,
                                              color:
                                              ColorHelper.neutralLightText),
                                        ),
                                        Text(
                                          paymentStatusController
                                              .paymentStatusData.value.id ??
                                              "N/A",
                                          style: const TextStyle(
                                              fontWeight: FontWeight.w400,
                                              fontSize: 14,
                                              color: ColorHelper.primaryColor1),
                                        ),
                                      ],
                                    ),
                                  ],
                                ),
                              );
                            }else{
                              return Padding(padding: const EdgeInsets.symmetric(vertical: 20),
                                child: Column(
                                  mainAxisAlignment: MainAxisAlignment.start,
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: [
                                    if (paymentStatusController.paymentStatusData.value.bookingId != null)
                                      Row(
                                        mainAxisAlignment: MainAxisAlignment.center,
                                        children: [
                                          const Text(
                                            'Booking ID: ',
                                            style: TextStyle(
                                                fontWeight: FontWeight.w400,
                                                fontSize: 14,
                                                color: ColorHelper
                                                    .neutralLightText),
                                          ),
                                          Text(
                                            paymentStatusController
                                                .paymentStatusData
                                                .value
                                                .bookingId ??
                                                "",
                                            style: const TextStyle(
                                                fontWeight: FontWeight.w400,
                                                fontSize: 14,
                                                color:
                                                ColorHelper.primaryColor1),
                                          ),
                                        ],
                                      ),
                                    if (paymentStatusController.paymentStatusData.value.bookingId != null)
                                      20.dp.SpaceX,
                                    Row(
                                      mainAxisAlignment: MainAxisAlignment.center,
                                      children: [
                                        Text(
                                          paymentStatusController
                                              .paymentStatusData
                                              .value
                                              .bookingId ==
                                              null
                                              ? 'Date & Time: '
                                              : 'Booked Date & Time: ',
                                          style: const TextStyle(
                                              fontWeight: FontWeight.w400,
                                              fontSize: 14,
                                              color:
                                              ColorHelper.neutralLightText),
                                        ),
                                        Builder(builder: (context) {
                                          final paymentDate =
                                              paymentStatusController
                                                  .paymentStatusData
                                                  .value
                                                  .paymentDate;
                                          final formattedDate = paymentDate !=
                                              null &&
                                              paymentDate
                                                  .toString()
                                                  .isNotEmpty
                                              ? DateFormat(
                                              'dd-MM-yyyy | hh:mm a')
                                              .format(DateTime.parse(
                                              paymentDate.toString()))
                                              : DateFormat(
                                              'dd-MM-yyyy | hh:mm a')
                                              .format(DateTime.now());
                                          return Text(
                                            formattedDate,
                                            style: const TextStyle(
                                                fontWeight: FontWeight.w400,
                                                fontSize: 14,
                                                color:
                                                ColorHelper.primaryColor1),
                                          );
                                        }),
                                      ],
                                    ),
                                    20.dp.SpaceX,
                                    Row(
                                      mainAxisAlignment: MainAxisAlignment.center,
                                      children: [
                                        const Text(
                                          'Payment Method: ',
                                          style: TextStyle(
                                              fontWeight: FontWeight.w400,
                                              fontSize: 14,
                                              color:
                                              ColorHelper.neutralLightText),
                                        ),
                                        Text(
                                          paymentStatusController
                                              .paymentStatusData
                                              .value
                                              .type ??
                                              "",
                                          style: const TextStyle(
                                              fontWeight: FontWeight.w400,
                                              fontSize: 14,
                                              color: ColorHelper.primaryColor1),
                                        ),
                                      ],
                                    ),
                                    20.dp.SpaceX,
                                    Row(
                                      mainAxisAlignment: MainAxisAlignment.center,
                                      children: [
                                        const Text(
                                          'Amount: ',
                                          style: TextStyle(
                                              fontWeight: FontWeight.w400,
                                              fontSize: 14,
                                              color:
                                              ColorHelper.neutralLightText),
                                        ),
                                        Row(
                                          children: [
                                            Text(
                                              "${controller.paymentStatusData.value.totalAmount == null ? "" : "\$"}${double.parse((controller.paymentStatusData.value.totalAmount ??"0")).toStringAsFixed(2).withCommas}",
                                              style: const TextStyle(
                                                  fontWeight: FontWeight.w400,
                                                  fontSize: 14,
                                                  color: ColorHelper
                                                      .primaryColor1),
                                            ),
                                            5.SpaceY,
                                          ],
                                        ),
                                      ],
                                    ),
                                    20.dp.SpaceX,
                                    Row(
                                      mainAxisAlignment: MainAxisAlignment.center,
                                      children: [
                                        const Text(
                                          'Transaction ID: ',
                                          style: TextStyle(
                                              fontWeight: FontWeight.w400,
                                              fontSize: 14,
                                              color:
                                              ColorHelper.neutralLightText),
                                        ),
                                        Text(
                                          paymentStatusController
                                              .paymentStatusData.value.id ??
                                              "N/A",
                                          style: const TextStyle(
                                              fontWeight: FontWeight.w400,
                                              fontSize: 14,
                                              color: ColorHelper.primaryColor1),
                                        ),
                                      ],
                                    ),
                                  ],
                                ),
                              );
                            }
                          }),
                          const Divider(
                            color: ColorHelper.genericBorderColor,
                            thickness: 1,
                          ),
                          60.SpaceX,
                        ],
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ),
        ),
      );
    }),
  );
}