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

FSelectMenuTile unselect #371

Open
botty87 opened this issue Jan 25, 2025 · 1 comment
Open

FSelectMenuTile unselect #371

botty87 opened this issue Jan 25, 2025 · 1 comment
Labels
type: ehancement A new feature or request

Comments

@botty87
Copy link

botty87 commented Jan 25, 2025

Is your feature request related to a problem? Please describe.
I'd like to unselect an item from FSelectMenuTile

Describe the solution you'd like
Using the existing method select on the controller, but removing the item when we send false as "selected value", or creating a clear method on the controller

@botty87 botty87 added the type: ehancement A new feature or request label Jan 25, 2025
@Pante
Copy link
Member

Pante commented Jan 26, 2025

Thanks for the filing the issue!

It should already be possible to unselect an item.

Using the code provided below:

class Foo extends StatefulWidget {
  const Foo({super.key});

  @override
  State<Foo> createState() => _FooState();
}

class _FooState extends State<Foo> {
  late FSelectGroupController<int> controller = FMultiSelectGroupController();

  @override
  Widget build(BuildContext context) => Column(
    children: [
      FSelectMenuTile(
        groupController: controller,
        title: const Text('Test'),
        menu: [
          FSelectTile(title: const Text('1'), value: 1),
          FSelectTile(title: const Text('2'), value: 2),
          FSelectTile(title: const Text('3'), value: 3),
        ],
      ),
    ],
  );
}
Screen.Recording.2025-01-26.at.10.40.42.AM.mov

You can call FSelectGroupController.select(value, false) to unselect a tile if doing so does not violate the range constraint.

Side note, we've also updated the method name to FSelectGroupController.update(value, selected: false) in the upcoming update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: ehancement A new feature or request
Projects
None yet
Development

No branches or pull requests

2 participants