0

I will first give a bit of background of my problem and then ask the actual question which I am trying to achieve:

BACKGROUND:

I posted this earlier question about preventing rows from disappearing as soon as they entered the padding area of the CupertinoScrollbar's parent Padding widget:

Flutter Padding on CupertinoScrollbar - how to prevent row from disappearing as soon as they enter the padding area?

I have figured out a workaround solution which involves removing the parent Padding widget entirely and instead wrapping the SliverList only in SliverPadding which achieves the padding on the list. However, this makes the scrollbar start at the top as it's the parent of the SliverPadding and thus doesn't know the padding for the inner SliverList.

I have figured out a solution for this problem. I can edit the source code of the CupertinoScrollbar and modify the following line in the updateScrollbarPainter method:

..padding = MediaQuery.of(context).padding

to what I need.

QUESTION:

This updateScrollbarPainter is part of the private state implementation _CupertinoScrollbarState, so I can't access it outside from my app.

Is there a workaround for this?

If not, is the only possible solution to modify the padding there is to copy the entire source code from this file into my app and then modify it there? It seems a bit complicated for modifying a single line of code no?

Here's the line I can modify:

enter image description here

1 Answers1

0

You can try wrapping widget with MediaQuery and provide the padding while it depends on context.

body: MediaQuery(
    data: MediaQuery.of(context).copyWith(
      padding: EdgeInsets.all(52), //here modify the one you want
    ),
    child: Scrollbar(
Md. Yeasin Sheikh
  • 54,221
  • 7
  • 29
  • 56
  • Unfortunately, this method ends up adding the padding to the CustomScrollView too as its a child of the Scrollbar. This is no different than wrapping the entire thing in Padding itself (something I can't do as I don't want padding on the scrollview). I only want to change the padding for the scrollbar. – sudoExclaimationExclaimation Sep 09 '22 at 07:36