Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Horizontal scrolling GroupButton (e.g. for creating "quick search buttons") #75

Closed
asmith26 opened this issue Mar 12, 2022 · 3 comments

Comments

@asmith26
Copy link
Contributor

asmith26 commented Mar 12, 2022

I'm trying to add "quick search buttons" to my flutter app like (in red):

image

This packages looks great for the button part of this, but I'm struggling to make the GroupButton horizontal scrollable. I can achieve this using a ListView.separated, e.g. (from https://stackoverflow.com/a/71386591/5179470)

ListView.separated(
                itemCount: fruits.length,
                scrollDirection: Axis.horizontal,
                itemBuilder: (context, index) => FilterChip(
                  label: Text(fruits[index]),
                  selected: index == selectedIndex,
                  onSelected: (value) {
                    setState(() {
                      selectedIndex = index;
                    });
                  },
                ),

but I can't seem to get a GroupButton to work with this. This issue looks related: #21 (mentioning @YouSour in case they have got it to work).

Many thanks for any help, and for this amazing lib!! :)

@Frezyx
Copy link
Owner

Frezyx commented Mar 12, 2022

Hello @asmith26 !
At this moment, you can't do US using ListView.builder() and the Group Button package.
The only solution I can offer for you - use ListView on top of GroupButton.

Simple example:

ListView(
          scrollDirection: Axis.horizontal,
          children: [
            GroupButton(
              controller: controller,
              options: GroupButtonOptions(
                groupingType: GroupingType.row,
              ),
              isRadio: false,
              buttons: List.generate(25, (i) => '${i + 1}'),
              onSelected: (i, selected) => debugPrint('Button #$i $selected'),
            ),
          ],
        ),

@Frezyx
Copy link
Owner

Frezyx commented Mar 12, 2022

2022-03-12.18.33.55.mp4

@asmith26
Copy link
Contributor Author

Thanks soooooooo much for your help @Frezyx, this works beautifully!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants