Home > OS >  How to add full scroll to the page in flutter?
How to add full scroll to the page in flutter?

Time:09-08

I have tabs with pages. I need to add the ability to fully scroll the page. Now I have a separate scrolling list, which is located at the bottom of the page. But I need to be able to scroll the entire page. I tried to add a ListView but it didn't work for me and an error occurred, tell me how to add a scroll?

return Container(
      decoration: BoxDecoration(
        color: constants.Colors.greyXDark.withOpacity(0.8),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          const SizedBox(height: 15),
          Padding(
            padding: const EdgeInsets.only(right: 11),
            child: Align(
              alignment: Alignment.topRight,
              child: GestureDetector(
                onTap: () {
                  setState(() {
                    isCalendar = !isCalendar;
                  });
                },
                child: SvgPicture.asset(
                  isCalendar
                      ? constants.Assets.burgerMenuDots
                      : constants.Assets.calendarBooking,
                  height: isCalendar ? 16 : 20,
                ),
              ),
            ),
          ),
          SizedBox(height: isCalendar ? 17 : 0),
          Align( 
            alignment: Alignment.centerLeft,
            child: const Padding(
              padding: EdgeInsets.symmetric(horizontal: 20),
              child: Text.rich(
                TextSpan(
                  text: 'Show only ',
                  style: TextStyle(
                    fontFamily: constants.FontFamily.AvenirLtStd,
                    fontSize: 18,
                    fontWeight: FontWeight.w400,
                    color: constants.Colors.white,
                    decoration: TextDecoration.underline,
                  ),
                  children: [
                    TextSpan(
                      text: 'Pending Bookings',
                      style: TextStyle(
                        fontFamily: constants.FontFamily.AvenirLtStd,
                        fontSize: 18,
                        fontWeight: FontWeight.w400,
                        color: constants.Colors.yellow,
                        decoration: TextDecoration.underline,
                        decorationColor: constants.Colors.yellow,
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ),
          const SizedBox(height: 10),
          isCalendar
              ? Expanded(
                  child: MediaQuery.removePadding(
                    context: context,
                    removeTop: true,
                    child: ListView(
                      children: const [
                        SizedBox(height: 10),
                        CalendarBooking(),
                      ],
                    ),
                  ),
                )
              : Expanded(
                  child: Padding(
                    padding: const EdgeInsets.symmetric(horizontal: 20),
                    child: MediaQuery.removePadding(
                      context: context,
                      removeTop: true,
                      child: Padding(
                        padding: const EdgeInsets.only(top: 24, bottom: 18),
                        child: isOrders
                            ? const ListPoyntsBookings()

CodePudding user response:

Have you tried wrapping your root widget with SingleChildScrollView ? If the widget tree contains ListView you should set it's ShrinkWrap parameter to true.

  • Related