0

**> Here is my code. it contains a ListView builder which is wrapped with

RawScrollBar widget and they both wrapped with SingleChildScrollView Widget. I want a show ScrollBar in ListView.Builder**

 Scaffold(
      backgroundColor: kPrimaryColor,
      body: SafeArea(
        child: SizedBox(
          height: kGetSize(context).height,
          child: Column(
            children: [
              const SizedBox(
                height: 16,
              ),
              const Center(
                child: UserLevelDetailsContainer(),
              ),
              Expanded(
                child: Padding(
                  padding:
                      const EdgeInsets.symmetric(horizontal: 24, vertical: 24),
                  **child: SingleChildScrollView(
                    physics: const ScrollPhysics(),
                    controller: _scrollController,
                    child: Column(
                      mainAxisSize: MainAxisSize.min,
                      children: [
                    
                          Text(
                              'General Subjects',
                              style: GoogleFonts.openSans(
                                  fontWeight: FontWeight.w700,
                                  fontSize: 20,
                                  color: const Color(0xfff3c304)),
                            ),
                            
                        const SizedBox(
                          height: 8,
                        ),
                        RawScrollbar(
                          thumbVisibility: true,
                          interactive: true,
                          thumbColor: Colors.black,
                          controller: _scrollController,
                          radius: const Radius.circular(60),
                          thickness: 6,
                          child: ListView.builder(
                            controller: _scrollController,
                            physics: const NeverScrollableScrollPhysics(),
                            itemCount: SubjectDetail.listOfSubjects.length,
                            shrinkWrap: true,
                            itemBuilder: (context, index) {
                              return SizedBox(
                                width: 344,
                                height: 96,
                                child: Card(
                                  shape: RoundedRectangleBorder(
                                    borderRadius: BorderRadius.circular(12.0),
                                  ),
                                  child: ListTile(
                                    contentPadding: const EdgeInsets.symmetric(
                                        horizontal: 24, vertical: 8),
                                    title: Padding(
                                      padding: const EdgeInsets.only(bottom: 4),
                                      child: Text(
                                        SubjectDetail
                                            .listOfSubjects[index].name,
                                        style: GoogleFonts.openSans(
                                            fontWeight: FontWeight.w700,
                                            fontSize: 15),
                                      ),
                                    ),
                                    subtitle: Text(
                                      SubjectDetail
                                          .listOfSubjects[index].description,
                                      style: GoogleFonts.openSans(
                                          fontWeight: FontWeight.w400,
                                          fontSize: 10),
                                    ),
                                    trailing: Image.asset(SubjectDetail
                                        .listOfSubjects[index].imageUrl),
                                  ),
                                ),
                              );
                            },                          
                          ),
                        ),**
                        const SizedBox(
                          height: 8,
                        ),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Text(
                              'General Subjects',
                              style: GoogleFonts.openSans(
                                  fontWeight: FontWeight.w700,
                                  fontSize: 20,
                                  color: const Color(0xfff3c304)),
                            ),
                            Text(
                              '*select one subject',
                              style: GoogleFonts.openSans(
                                  fontWeight: FontWeight.w300,
                                  fontSize: 14,
                                  color: const Color(0xfff3c304)),
                            )
                          ],
                        ),
                      ],
                    ),
                  ),
                ),
              )
            ],
          ),
        ),
      ),
    );

I have given same ScrollController object to ListView builder, RawScrollBar and SingleChildScollView widget.Altough I had given different ScrollController objects to them

  • Did you mean the scrollbar's thumb is only visible while scrolling? Welcome to the StackOverflow by the way. – Rashid Wassan Jun 13 '22 at 14:35
  • No it is not visible at all, but when I remove SingleChildScrollView then its visible.Thank u bro – Pardeep Malhi Jun 13 '22 at 15:47
  • I got it now, the problem is that when you add SingleChildScrollView as an ancestor of ScrollBar, the swipe changes the position according to SingleChildScrollView, means it is the container which is being scrolled instead of the ListView. – Rashid Wassan Jun 14 '22 at 15:21

0 Answers0