railson-ferreira / scrollable_list_tab_scroller

Customizable Flutter widget that synchronizes a scrollable list of grouped items with tabs
https://pub.dev/packages/scrollable_list_tab_scroller
MIT License
19 stars 13 forks source link

How to remove extra leading space in the tab Builder #7

Closed theAkshay60 closed 5 months ago

theAkshay60 commented 10 months ago
Screenshot 2023-12-12 at 3 24 38 PM
ScrollableListTabScroller(
        padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 0),
        headerContainerBuilder: (context, widget) {
          return widget;
        },
        itemCount: resultList!.length,
        itemBuilder: (BuildContext context, int index) {
          final data = resultList?[index].item;

          return SizedBox(
            height: MediaQuery.of(context).size.height,
            child: ListView.builder(
                itemCount: data?.length,
                itemBuilder: (context, index) {
                  return ListTile(
                    title: Text("${data?[index]}"),
                  );
                }),
          );
        },
        tabBuilder: (BuildContext context, int index, bool active) {
          return Container(
            width: size.width / 4,
            decoration: BoxDecoration(
              border: Border(
                bottom: BorderSide(
                  color: active
                      ? const Color.fromRGBO(0, 79, 224, 1)
                      : Colors.transparent,
                  width: 2,
                ),
              ),
            ),
            child: Center(
              child: Text(
                "${resultList?[index].category}",
                style: TextStyle(
                  fontSize: 18,
                  color: active
                      ? const Color.fromRGBO(0, 79, 224, 1)
                      : Colors.black,
                ),
              ),
            ),
          );
        },
        initialAlignment: 0,
        earlyChangePositionOffset: 50,
      )

Above is my code for the tab bar scroller, however there is an unwanted leading space in the tab bar, how can we remove this ? Attached image for reference

railson-ferreira commented 10 months ago

I wasn't able to simulate the same result with that code, can you provide the code for the entire example project in a repository?

theAkshay60 commented 10 months ago

Sure, here is the repo:

https://github.com/theAkshay60/tab_scroll_demo/tree/master

railson-ferreira commented 10 months ago

It was introduced the 'tabAlignment' on Flutter, that is causing this issue. An option to set your preferences is to customize the Theme. I've done this suggestion and opened a PR for your repository: https://github.com/theAkshay60/tab_scroll_demo/pull/1

I might include an easier way to customize that in the next versions.

theAkshay60 commented 10 months ago

Thank you for the workaround, I appreciate it. I did a small change to your fix and it's working as expected

railson-ferreira commented 5 months ago

Solved: https://github.com/railson-ferreira/scrollable_list_tab_scroller/releases/tag/v2.0.0