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 = getUrlParameters(context);
      final String? paymentId = queryParameters['paymentId'];
      if (paymentId != null && paymentId.isNotEmpty) {
        controller.fetchPaymentDetails(paymentId);
      } else {
        debugPrint('Payment ID is missing in the URL');
      }
      controller.index.value=Get.find<RotateImageController>().loadImage('paymentsuccess_banner_index',controller.imageList.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: SizedBox(
              width: context.x,
              child: Column(
                children: [
                  Obx(() {
                    return Container(
                        width: context.x,
                        height: context.x<768? 220:278,
                        decoration: BoxDecoration(
                            image: DecorationImage(
                                image: AssetImage(
                                  (controller.paymentStatusData.value
                                      .purpose ==
                                      "FLIGHT_BOOKING")
                                      ? (context.x<768?'assets/flight_search/payment-success-flight-small.webp':'assets/flight_search/payment-success-flight.webp')
                                      : context.x<768?controller.mobileImageList[controller.index.value] :controller.imageList[controller.index.value],
                                ),
                                fit: BoxFit.fill)),
                        padding: EdgeInsets.symmetric(horizontal: context.x<1100?20: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(
                                          (controller.paymentStatusData.value
                                              .purpose ==
                                              "FLIGHT_BOOKING")
                                              ? 'Your Crypto just took off.'
                                              : controller.title[controller.index.value],
                                          style: TextStyle(
                                              fontSize: context.x<500?18.dp:context.x<768?20.dp:25.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(
                                          (controller.paymentStatusData.value
                                              .purpose ==
                                              "FLIGHT_BOOKING")
                                              ? 'Travel the world, pay with crypto – seamless, secure, and rewarding.'
                                              : controller.subtitle[controller.index.value],
                                          style: TextStyle(
                                              fontSize: context.x<500?13.dp:context.x<768?14.5.dp:16.dp,
                                              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-success.png',
                            height: context.x<768?145:164,
                          ),
                          12.SpaceX,
                          Padding(
                            padding:  EdgeInsets.symmetric(horizontal: context.isMobile? 58: 0),
                            child: RichText(
                              text: TextSpan(
                                text: controller.paymentStatusData.value.purpose != "SEARCH_CREDIT" ?'Payment ': '',
                                style: const TextStyle(
                                  fontSize: 28,
                                  fontWeight: FontWeight.w600,
                                  color: ColorHelper.textDark,
                                  fontFamily: "PlayFairDisplay",
                                ),
                                children: [
                                  WidgetSpan(
                                    child: GradientText(controller.paymentStatusData.value.purpose == "SEARCH_CREDIT"? 'Congratulations' :  'Successful!',
                                        style: const TextStyle(
                                            fontSize: 28,
                                            fontWeight: FontWeight.w600,
                                            height: 1.3,
                                            fontFamily: 'PlayFairDisplay'),
                                        gradientDirection:
                                        GradientDirection.ltr,
                                        colors: ColorHelper.gradientTextColors),
                                  ),
                                  if(controller.paymentStatusData.value.purpose == "SEARCH_CREDIT")
                                  const TextSpan(
                                     text:  ' on Your Search-Credit Purchase!',
                                    style: TextStyle(
                                      fontSize: 28,
                                      fontWeight: FontWeight.w600,
                                      color: ColorHelper.textDark,
                                      fontFamily: "PlayFairDisplay",
                                    ),
                                  )
                                ],
                              ),
                            ),
                          ),
                          16.SpaceX,
                          Obx(
                            () {
                              final hasPlan = authenticationController.hasActiveSubscription;
                              return Padding(
                                padding: EdgeInsets.symmetric(horizontal: context.isMobile?18:0),
                                child: Text( (controller.paymentStatusData.value
                                    .purpose ==
                                    "FLIGHT_BOOKING")?
                                'Payment Successful! Your booking is pending.':
                                (controller.paymentStatusData.value.purpose == "SEARCH_CREDIT" && !hasPlan) ?
                                'Congratulations! You’ve successfully purchased your search-credits and Your${context.isMobile?' ':'\n'}Prestige Pass Is ready to be activated now!' :
                                'Your payment is confirmed.',
                                textAlign: TextAlign.center,
                                    style: const TextStyle(
                                        fontSize: 14,
                                        fontWeight: FontWeight.w400,
                                        color: ColorHelper.neutralLightText

                                        )),
                              );
                            }
                          ),
                          12.SpaceX,
                          Obx(() {
                            return RichText(
                              textAlign: TextAlign.center,
                              text: TextSpan(
                                text:
                                'A confirmation email has been sent to ',
                                style: const TextStyle(
                                  fontSize: 12,
                                  fontWeight: FontWeight.w400,
                                  color: ColorHelper.neutralLightText,
                                ),
                                children: [
                                  TextSpan(
                                    text:
                                    '${authenticationController.userProfileModel.value.data?.user?.email ?? "N/A"}.',
                                    style: const TextStyle(
                                      fontSize: 12,
                                      fontWeight: FontWeight.w400,
                                      color: ColorHelper.primaryColor2,
                                    ),
                                  )
                                ],
                              ),
                            );
                          }),
                          20.SpaceX,
                          Obx(() {
                            final hasPlan = authenticationController.hasActiveSubscription;
                            return Wrap(
                              runSpacing: 8,
                              alignment: WrapAlignment.center,
                              children: [
                                if (controller.paymentStatusData.value.purpose == "FLIGHT_BOOKING") ...{
                                  CustomButton(
                                    fontSize: 16,
                                    fontWeight: FontWeight.w500,
                                    border: Border.all(
                                        color: ColorHelper.primaryColor1),
                                    btnText: 'Book Another Flight',
                                    btnclr: ColorHelper.primaryColor1,
                                    btnWidth: context.x<430?140:context.x<768?169:194,
                                    onTap: () {
                                      goto(Routes.TOP_FLIGHTS);
                                    },
                                  ),
                                  8.SpaceY,
                                  CustomButton(
                                    fontSize: 16,
                                    fontWeight: FontWeight.w500,
                                    btnText: 'See Booking History',
                                    btnclr: Colors.transparent,
                                    btnTextColor: ColorHelper.primaryColor1,
                                    border: Border.all(
                                        color: ColorHelper.primaryColor1),
                                    btnWidth: context.x<430?140:context.x<768?172:248,
                                    onTap: () {
                                      goto(Routes.DASHBOARD_FLGIHTS_BOOKED);
                                    },
                                  ),
                                },
                                if (controller.paymentStatusData.value.purpose == "SEARCH_CREDIT") ...{
                                  if (hasPlan) ...{
                                    CustomButton(
                                      fontSize: 18,
                                      fontWeight: FontWeight.w500,
                                      btnText: 'Search Flights',
                                      btnclr: ColorHelper.primaryColor1,
                                      border: Border.all(
                                          color: ColorHelper.primaryColor1),
                                      btnWidth: 141,
                                      onTap: () {
                                        goto(Routes.TOP_FLIGHTS);
                                      },
                                    ),
                                    8.SpaceY,
                                    CustomButton(
                                      fontSize: 18,
                                      fontWeight: FontWeight.w500,
                                      btnText: 'Unlock PASS',
                                      btnclr: Colors.transparent,
                                      btnTextColor: ColorHelper.primaryColor1,
                                      border: Border.all(
                                          color: ColorHelper.primaryColor1),
                                      btnWidth: 141,
                                      onTap: () async {
                                        goto(Routes.SUBSCRIPTION);
                                        authenticationController.activateSignaturePassFlow();
                                      },
                                    ),
                                  },
                                  if (!hasPlan) ...{
                                    CustomButton(
                                      fontSize: 18,
                                      fontWeight: FontWeight.w500,
                                      btnText: 'Access Exclusive PLUS Rates',
                                      btnclr: Colors.transparent,
                                      border: Border.all(
                                          color: ColorHelper.primaryColor1),
                                      btnTextColor: ColorHelper.primaryColor1,
                                      btnWidth: context.x<500? 312: context.x<768? 200: 280,
                                      onTap: () {
                                        goto(Routes.TOP_FLIGHTS);
                                      },
                                    ),
                                    if(!context.isMobile)
                                    8.SpaceY,
                                    CustomButton(
                                      fontSize: 18,
                                      fontWeight: FontWeight.w500,
                                      btnText: 'Activate Prestige PASS',
                                      btnclr: ColorHelper.primaryColor1,
                                      border: Border.all(
                                          color: ColorHelper.primaryColor1),
                                      btnWidth: context.x<500? 312: context.x<768?225:234,
                                      onTap: () async {
                                        closeDialog();
                                        authenticationController.activateSignaturePassFlow();
                                      },
                                    ),
                                  },
                                },
                                if (controller.paymentStatusData.value.purpose == "SUBSCRIPTION") ...{
                                  CustomButton(
                                    btnText: 'Search Flights',
                                    btnclr: ColorHelper.primaryColor1,
                                    border: Border.all(
                                        color: ColorHelper.primaryColor1),
                                    btnWidth: context.x<768?120:194,
                                    onTap: () {
                                      goto(Routes.TOP_FLIGHTS);
                                    },
                                  ),
                                  8.SpaceY,
                                  CustomButton(
                                    btnText: 'Purchase Search Credit',
                                    btnclr: Colors.transparent,
                                    btnTextColor: ColorHelper.primaryColor1,
                                    border: Border.all(
                                        color: ColorHelper.primaryColor1),
                                    btnWidth: context.x<768?180:242,
                                    onTap: () {
                                      goto(Routes.SEARCH_CREDIT);
                                    },
                                  ),
                                },
                              ],
                            );
                          }),
                          35.dp.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: [
                                    Row(
                                      children: [
                                        Text(
                                          controller.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 = controller
                                              .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(
                                          controller.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),
                                            ),
                                          ],
                                        ),
                                      ],
                                    ),
                                    Row(
                                      children: [
                                        const Text(
                                          'Payment Reference: ',
                                          style: TextStyle(
                                              fontWeight: FontWeight.w400,
                                              fontSize: 14,
                                              color:
                                              ColorHelper.neutralLightText),
                                        ),
                                        Text(
                                          controller
                                              .paymentStatusData.value.id ??
                                              "N/A",
                                          style: const TextStyle(
                                              fontWeight: FontWeight.w400,
                                              fontSize: 14,
                                              color: ColorHelper.primaryColor1),
                                        ),
                                      ],
                                    ),
                                  ],
                                ),
                              );
                            }else{
                              return Padding(
                                padding: EdgeInsets.symmetric(vertical: 16.dp),
                                child: Column(
                                  mainAxisAlignment: MainAxisAlignment.start,
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: [
                                    Row(
                                      mainAxisAlignment: MainAxisAlignment.center,
                                      children: [
                                        Text(
                                          controller.paymentStatusData.value
                                              .bookingId ==
                                              null
                                              ? 'Payment date & Time: '
                                              : 'Booked Date & Time: ',
                                          style: const TextStyle(
                                              fontWeight: FontWeight.w400,
                                              fontSize: 14,
                                              color:
                                              ColorHelper.neutralLightText),
                                        ),
                                        Builder(builder: (context) {
                                          final paymentDate = controller
                                              .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(
                                          controller.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),
                                            ),
                                          ],
                                        ),
                                      ],
                                    ),
                                    20.dp.SpaceX,
                                    Row(
                                      mainAxisAlignment: MainAxisAlignment.center,
                                      children: [
                                        const Text(
                                          'Transaction ID: ',
                                          style: TextStyle(
                                              fontWeight: FontWeight.w400,
                                              fontSize: 14,
                                              color:
                                              ColorHelper.neutralLightText),
                                        ),
                                        Text(
                                          controller
                                              .paymentStatusData.value.id ??
                                              "N/A",
                                          style: const TextStyle(
                                              fontWeight: FontWeight.w400,
                                              fontSize: 14,
                                              color: ColorHelper.primaryColor1),
                                        ),
                                      ],
                                    ),
                                  ],
                                ),
                              );
                            }
                          }),
                          const Divider(
                            color: ColorHelper.genericBorderColor,
                            thickness: 1,
                          ),
                          Obx(() {
                            if(controller.isSearching.isFalse && controller.selectedBooking.value != null &&
                                controller.paymentStatusData.value.purpose == "FLIGHT_BOOKING"){
                              return Container(
                                margin: EdgeInsets.only(top: context.isMobile ? 10 : 40),
                                child: ResponsiveGridRow(
                                  children: [
                                    _topBanner(context),
                                    _buildSpacerColumn(),
                                    _buildBookingDetails(context),
                                    _supportBanner(context),
                                  ],
                                ),
                              );
                            }

                            return const SizedBox();
                          }),
                          context.isMobile ? 39.SpaceX : 67.SpaceX,
                          Container(
                            alignment: Alignment.topLeft,
                            padding: EdgeInsets.symmetric(horizontal: context.isMobile ? 12 : 0),
                            child: Text(
                              'Enhance Your Trip',
                              style: TextStyle(
                                fontSize: context.isMobile ? 28 : 32,
                                fontWeight: context.isMobile ? FontWeight.w600 : FontWeight.w700,
                                color: ColorHelper.neutralDark,
                              ),
                            ),
                          ),
                          context.isMobile ? 21.SpaceX : 16.SpaceX,
                          EnhanceTripCardsList(),
                        ],
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ),
        ),
      );
    }),
  );
}