1

I am trying to render list of cards in flutter, but i am getting exception Vertical viewport was given unbounded height.

import 'package:ServiceDispatch/core/widgets/job_card.dart';

import '../../core/utils/app_colors.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'home_with_tasks_screen_logic.dart';
import '../../core/widgets/index.dart';

class HomeWithTasksScreenView extends GetView<HomeWithTasksScreenLogic> {
  const HomeWithTasksScreenView({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: AppColors.backgroundColor,
      appBar: CommonWidgets.commonAppBar(),
      body: SingleChildScrollView(
        child: Column(
          children: [
            SizedBox(
              height: 10.h,
            ),
            Obx(() {
              return CommonWidgets.commonScreenSwitchButton(
                  isActiveScreen: controller.isActiveScreen);
            }),
            Container(
              margin: EdgeInsets.only(
                left: 16.w,
                right: 16.w,
                top: 10.h,
                bottom: 20.h,
              ),
              child: Obx(() {
                if (controller.isActiveScreen.value == true) {
                  return JobCard(
                    jobDetails: controller.jobDetails,
                    commentData: controller.commentData,
                    icons: controller.icons,
                    serviceDetails: controller.serviceDetails,
                    hasAcknowledged: controller.hasAcknowledged,
                    hasArrived: controller.hasArrived,
                    hasDeparted: controller.hasDeparted,
                  );
                } else {
                  return ListView.builder(
                      itemBuilder: (BuildContext context, int index) {
                    return JobCard(
                      jobDetails: controller.completedJobs[index],
                      commentData: controller.commentData,
                      icons: controller.icons,
                    );
                  });
                }
              }),
            ),
          ],
        ),
      ),
    );
  }
}

My JobCard widget is fine because if i remove ListView.builder then a single card renders perfectly, i know this is some layout issue, but i can't seem to solve it. Please suggest what i am doing wrong. Thanks everyone.

0

1 Answer 1

0

Found The issue!! I am using ListView.builder(), inside SingleChildScrollView() due to which the error occured. i replaced my ListView.builder() with map and everything worked fine.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.