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) {
  return LayoutBuilder(builder: (context, _) {
    return Container(
      constraints: const BoxConstraints(maxWidth: 1100),
      margin: EdgeInsets.symmetric(horizontal: context.isMobile ? 12 : 20),
      child: Column(
        children: [
          Center(
            child: Wrap(
              crossAxisAlignment: WrapCrossAlignment.end,
              alignment: WrapAlignment.center,
              children: [
                const Text(
                  'NEOPASS Club Results with Search-Credits  ',
                  textAlign: TextAlign.center,
                  style: TextStyle(
                    fontSize: 20,
                    fontWeight: FontWeight.w600,
                    color: ColorHelper.neutralMediumText,
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.only(bottom: 4),
                  child: Obx(() {
                    final date =
                        controller.bookingStats.value?.statsUpdatedAt ??
                            '1990';
                    return Text(
                      'updated ${FlightSearchUtils.formatDateTimeWithTime(DateTime.tryParse(date) ?? DateTime(1990), removeDayOfWeek: true).replaceAll('-', '.')}',
                      textAlign: TextAlign.center,
                      style: const TextStyle(
                        fontSize: 12,
                        fontWeight: FontWeight.w400,
                        color: ColorHelper.neutralLightText,
                      ),
                    );
                  }),
                ),
              ],
            ),
          ),
          12.dp.SpaceX,
          Obx(() {
            final bookedStats = [
              searchedCol(
                  '${(controller.bookingStats.value?.booked?.highestPercentage ?? 0).round()}%',
                  'Highest'),
              containerBreak(),
              searchedCol('~${getWeeklyBookedBookingValue()}%', 'Weekly'),
              containerBreak(),
              searchedCol('~${getMonthlyBookedBookingValue()}%', 'Monthly'),
              containerBreak(),
              searchedCol('~${getLifetimeBookedBookingValue()}%', 'Lifetime'),
            ];

            return ResponsiveGridRow(
              children: [
                ResponsiveGridCol(
                  lg: 6,
                  md: 6,
                  sm: 12,
                  xs: 12,
                  child: Container(
                    alignment: Alignment.topCenter,
                    margin: EdgeInsets.only(
                        right: context.isMobile ? 0 : 13,
                        bottom: context.isMobile ? 26 : 0),
                    height: context.isMobile ? null : 112,
                    decoration: BoxDecoration(
                      color: ColorHelper.bGLight2,
                      borderRadius: BorderRadius.circular(16),
                      border: Border.all(
                          color: ColorHelper.purpleTint, width: 0.5),
                    ),
                    child: Column(
                      children: [
                        Container(
                          height: 72,
                          decoration: const BoxDecoration(
                            color: Colors.white,
                            border: Border.symmetric(
                                horizontal: BorderSide(
                                    color: ColorHelper.purpleTint,
                                    width: 0.5)),
                            borderRadius: BorderRadius.only(
                              topLeft: Radius.circular(16),
                              topRight: Radius.circular(16),
                            ),
                          ),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                            children: [
                              searchedCol(
                                  '~${getLifetimeSearchedBookingValue()}%',
                                  'Lifetime'),
                              containerBreak(),
                              searchedCol(
                                  '~${getMonthlySearchedBookingValue()}%',
                                  'Monthly'),
                              containerBreak(),
                              searchedCol(
                                  '~${getWeeklySearchedBookingValue()}%',
                                  'Weekly'),
                              containerBreak(),
                              searchedCol(
                                  '${(controller.bookingStats.value?.searched?.highestPercentage ?? 0).round()}%',
                                  'Highest'),
                            ],
                          ),
                        ),
                        3.SpaceX,
                        if (context.isMobile)
                          Text(
                            'Searched',
                            style: TextStyle(
                              fontSize: 15.dp,
                              fontWeight: FontWeight.w600,
                              color: ColorHelper.primaryColor1,
                            ),
                          ),
                        Container(
                          width: double.infinity,
                          padding: const EdgeInsets.symmetric(
                              horizontal: 10, vertical: 3),
                          child: Wrap(
                            spacing: 8,
                            runSpacing: 8,
                            alignment: WrapAlignment.spaceBetween,
                            crossAxisAlignment: WrapCrossAlignment.center,
                            runAlignment: WrapAlignment.start,
                            children: [
                              Row(
                                mainAxisSize: MainAxisSize.min,
                                children: [
                                  SizedBox(
                                    width: 30,
                                    child: FittedBox(
                                      fit: BoxFit.fill,
                                      child: Switch(
                                        thumbIcon:
                                            const WidgetStatePropertyAll(Icon(
                                          Icons.circle,
                                          color: Colors.white,
                                        )),
                                        trackOutlineColor:
                                            const WidgetStatePropertyAll(
                                                Colors.transparent),
                                        activeColor: ColorHelper.white,
                                        activeTrackColor:
                                            ColorHelper.primaryColor2,
                                        inactiveThumbColor: ColorHelper.white,
                                        inactiveTrackColor:
                                            ColorHelper.neutralLightText,
                                        value: controller
                                            .isSearchedPremiumEcoClass.value,
                                        onChanged: (value) {
                                          controller.isSearchedPremiumEcoClass
                                              .value = value;
                                          if (!value) {
                                            controller.isSearchedBusinessClass
                                                .value = true;
                                          }
                                        },
                                      ),
                                    ),
                                  ),
                                  7.SpaceY,
                                  Image.asset(
                                      'assets/top_flights/noSymbol.png',
                                      height: 10.dp),
                                  4.SpaceY,
                                  Text(
                                    'Eco & Premium Eco Class',
                                    style: TextStyle(
                                      fontSize: 11.dp,
                                      fontWeight: FontWeight.w400,
                                      color: controller
                                              .isSearchedPremiumEcoClass
                                              .isFalse
                                          ? ColorHelper.neutralLightText
                                          : ColorHelper.black03,
                                    ),
                                  ),
                                ],
                              ),
                              if (!context.isMobile) ...[
                                Text(
                                  'Searched',
                                  style: TextStyle(
                                    fontSize: 15.dp,
                                    fontWeight: FontWeight.w600,
                                    color: ColorHelper.primaryColor1,
                                  ),
                                ),
                              ],
                              Row(
                                mainAxisSize: MainAxisSize.min,
                                children: [
                                  SizedBox(
                                    width: 30,
                                    child: FittedBox(
                                      fit: BoxFit.fill,
                                      child: Switch(
                                        thumbIcon:
                                            const WidgetStatePropertyAll(Icon(
                                          Icons.circle,
                                          color: Colors.white,
                                        )),
                                        trackOutlineColor:
                                            const WidgetStatePropertyAll(
                                                Colors.transparent),
                                        activeColor: ColorHelper.white,
                                        activeTrackColor:
                                            ColorHelper.primaryColor2,
                                        inactiveThumbColor: ColorHelper.white,
                                        inactiveTrackColor:
                                            ColorHelper.neutralLightText,
                                        value: controller
                                            .isSearchedBusinessClass.value,
                                        onChanged: (value) {
                                          controller.isSearchedBusinessClass
                                              .value = value;
                                          if (!value) {
                                            controller
                                                .isSearchedPremiumEcoClass
                                                .value = true;
                                          }
                                        },
                                      ),
                                    ),
                                  ),
                                  7.SpaceY,
                                  Image.asset(
                                      'assets/top_flights/noSymbol.png',
                                      height: 10.dp),
                                  4.SpaceY,
                                  Text(
                                    'Business & First Class',
                                    style: TextStyle(
                                      fontSize: 11.dp,
                                      fontWeight: FontWeight.w400,
                                      color: controller
                                              .isSearchedBusinessClass.isFalse
                                          ? ColorHelper.neutralLightText
                                          : ColorHelper.black03,
                                    ),
                                  ),
                                ],
                              ),
                            ],
                          ),
                        ),
                        4.SpaceX,
                      ],
                    ),
                  ),
                ),
                ResponsiveGridCol(
                  lg: 6,
                  md: 6,
                  sm: 12,
                  xs: 12,
                  child: Container(
                    margin: EdgeInsets.only(left: context.isMobile ? 0 : 13),
                    alignment: Alignment.topCenter,
                    height: context.isMobile ? null : 112,
                    decoration: BoxDecoration(
                      color: ColorHelper.bGLight2,
                      borderRadius: BorderRadius.circular(16),
                      border: Border.all(
                          color: ColorHelper.purpleTint, width: 0.5),
                    ),
                    child: Column(
                      children: [
                        Container(
                          height: 72,
                          decoration: const BoxDecoration(
                            color: Colors.white,
                            border: Border.symmetric(
                                horizontal: BorderSide(
                                    color: ColorHelper.purpleTint,
                                    width: 0.5)),
                            borderRadius: BorderRadius.only(
                              topLeft: Radius.circular(16),
                              topRight: Radius.circular(16),
                            ),
                          ),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                            children: context.isMobile
                                ? bookedStats.reversed.toList()
                                : bookedStats,
                          ),
                        ),
                        3.SpaceX,
                        if (context.isMobile)
                          Text(
                            'Booked',
                            style: TextStyle(
                              fontSize: 15.dp,
                              fontWeight: FontWeight.w600,
                              color: ColorHelper.primaryColor1,
                            ),
                          ),
                        Container(
                          width: double.infinity,
                          padding: const EdgeInsets.symmetric(
                              horizontal: 10, vertical: 3),
                          child: Wrap(
                            spacing: 8,
                            runSpacing: 8,
                            alignment: WrapAlignment.spaceBetween,
                            crossAxisAlignment: WrapCrossAlignment.center,
                            runAlignment: WrapAlignment.start,
                            children: [
                              Row(
                                mainAxisSize: MainAxisSize.min,
                                children: [
                                  SizedBox(
                                    width: 30,
                                    child: FittedBox(
                                      fit: BoxFit.fill,
                                      child: Switch(
                                        thumbIcon:
                                            const WidgetStatePropertyAll(Icon(
                                          Icons.circle,
                                          color: Colors.white,
                                        )),
                                        trackOutlineColor:
                                            const WidgetStatePropertyAll(
                                                Colors.transparent),
                                        activeColor: ColorHelper.white,
                                        activeTrackColor:
                                            ColorHelper.primaryColor2,
                                        inactiveThumbColor: ColorHelper.white,
                                        inactiveTrackColor:
                                            ColorHelper.neutralLightText,
                                        value: controller
                                            .isBookedPremiumEcoClass.value,
                                        onChanged: (value) {
                                          controller.isBookedPremiumEcoClass
                                              .value = value;
                                          if (!value) {
                                            controller.isBookedBusinessClass
                                                .value = true;
                                          }
                                        },
                                      ),
                                    ),
                                  ),
                                  7.SpaceY,
                                  Image.asset(
                                      'assets/top_flights/noSymbol.png',
                                      height: 10.dp),
                                  4.SpaceY,
                                  Text(
                                    'Eco & Premium Eco Class',
                                    style: TextStyle(
                                      fontSize: 11.dp,
                                      fontWeight: FontWeight.w400,
                                      color: controller
                                              .isBookedPremiumEcoClass.isFalse
                                          ? ColorHelper.neutralLightText
                                          : ColorHelper.black03,
                                    ),
                                  ),
                                ],
                              ),
                              if (!context.isMobile) ...[
                                Text(
                                  'Booked',
                                  style: TextStyle(
                                    fontSize: 15.dp,
                                    fontWeight: FontWeight.w600,
                                    color: ColorHelper.primaryColor1,
                                  ),
                                ),
                              ],
                              Row(
                                mainAxisSize: MainAxisSize.min,
                                children: [
                                  SizedBox(
                                    width: 30,
                                    child: FittedBox(
                                      fit: BoxFit.fill,
                                      child: Switch(
                                        thumbIcon:
                                            const WidgetStatePropertyAll(Icon(
                                          Icons.circle,
                                          color: Colors.white,
                                        )),
                                        trackOutlineColor:
                                            const WidgetStatePropertyAll(
                                                Colors.transparent),
                                        activeColor: ColorHelper.white,
                                        activeTrackColor:
                                            ColorHelper.primaryColor2,
                                        inactiveThumbColor: ColorHelper.white,
                                        inactiveTrackColor:
                                            ColorHelper.neutralLightText,
                                        value: controller
                                            .isBookedBusinessClass.value,
                                        onChanged: (value) {
                                          controller.isBookedBusinessClass
                                              .value = value;
                                          if (!value) {
                                            controller.isBookedPremiumEcoClass
                                                .value = true;
                                          }
                                        },
                                      ),
                                    ),
                                  ),
                                  7.SpaceY,
                                  Image.asset(
                                      'assets/top_flights/noSymbol.png',
                                      height: 10.dp),
                                  4.SpaceY,
                                  Text(
                                    'Business & First Class',
                                    style: TextStyle(
                                      fontSize: 11.dp,
                                      fontWeight: FontWeight.w400,
                                      color: controller
                                              .isBookedBusinessClass.isFalse
                                          ? ColorHelper.neutralLightText
                                          : ColorHelper.black03,
                                    ),
                                  ),
                                ],
                              ),
                            ],
                          ),
                        ),
                        4.SpaceX,
                      ],
                    ),
                  ),
                ),
              ],
            );
          }),
        ],
      ),
    );
  });
}