ruki_filter 0.0.4

SDKflutter
Platformandroidioswindowslinuxmacosweb

Filter Button Provides, a quick and easy use of toggles using just enums, and Filter Dropdown provides a quick and easy way to select fillters.

A Filter Paradise, This Widget contains 2 style of Filtering, DropDown Filter selection or FilterToggle. You can use this for any model data or just enumerations.

Features

  • FilterDropdown Allows you to select from a dropdown list of FilterDropdownItems<T>, or a modal list instead.
  • FilterToggle Create n size of items and have the option to toggle between the selections.

Usage

import 'package:flutter/material.dart';
import 'package:ruki_filter/ruki_filter.dart';

class MyHomePage extends StatelessWidget {
  final String title;
  const MyHomePage({super.key, required this.title});
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
      ),
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          const Text("Filter Button Example:"),

          Padding(
            padding: const EdgeInsets.all(8.0),
            child: Center(
              child: FilterToggle<Filter>(
                filters: Filter.values,
                currentFilter: Filter.all,
                onSelected: (filter) {
                  print(filter);
                },
              ),
            ),
          ),

          const Text("Filter Dropdown Example:"),
          Padding(
            padding: const EdgeInsets.all(8.0),
            child: SizedBox(
              width: 400,
              height: 40,
              child: Row(
                children: [
                   Expanded(
                     child: FilterDropdownMenu<Filter>(
                      type: DropdownType.menu,
                       items: Filter.values.map((e) => FilterDropdownItem<Filter>(child: Text(e.toString().split('.').last), value: e)).toList(),
                       currentValue: Filter.all,
                       onSelected: (filter) {
                                         print(filter);
                       },
                     ),
                   ),
                   Spacer(),
                   Expanded(
                     child: FilterDropdownMenu<Filter>(
                       items: Filter.values.map((e) => FilterDropdownItem<Filter>(child: Text(e.toString().split('.').last), value: e)).toList(),
                       currentValue: Filter.all,
                       onSelected: (filter) {
                                         print(filter);
                       },
                     ),
                   ),
                   Spacer(),
                   Expanded(
                     child: FilterDropdownMenu<Filter>(
                       items: Filter.values.map((e) => FilterDropdownItem<Filter>(child: Text(e.toString().split('.').last), value: e)).toList(),
                       currentValue: Filter.all,
                       onSelected: (filter) {
                                         print(filter);
                       },
                     ),
                   ),
                ],
              ),
            )
          ),
           const Text("Filter Radios Dropdown Example:"),
          Padding(
            padding: const EdgeInsets.all(8.0),
            child: SizedBox(
              width: 600,
              height: 40,
              child: Row(
                children: [
                  Expanded(
                    child: FilterDropdownMenu<Filter>(
                      type: DropdownType.radio_menu,
                      items: Filter.values.map((e) => FilterDropdownItem<Filter>(child: Text(e.toString().split('.').last), value: e)).toList(),
                      currentValue: Filter.all,
                      onSelected: (filter) {
                        print(filter);
                      },
                    ),
                  ),
                  Spacer(),
                  Expanded(
                    child: FilterDropdownMenu<Filter>(
                      type: DropdownType.radio_list,
                      width: 200,
                      items: Filter.values.map((e) => FilterDropdownItem<Filter>(child: Text(e.toString().split('.').last), value: e)).toList(),
                      currentValue: Filter.all,
                      onSelected: (filter) {
                        print(filter);
                      },
                    ),
                  ),
                  Spacer(),
                  Expanded(
                    child: FilterDropdownMenu<Filter>(
                      type: DropdownType.radio_list,
                      items: Filter.values.map((e) => FilterDropdownItem<Filter>(child: Text(e.toString().split('.').last), value: e)).toList(),
                      currentValue: Filter.all,
                      onSelected: (filter) {
                        print(filter);
                      },
                    ),
                  ),
                ],
              ),
            )
          ),
        const Text("Filter Checkbox Dropdown"),
        Padding(
          padding: const EdgeInsets.all(8.0),
          child: SizedBox(
            width: 600,
            height: 40,
            child: Row(
              children: [
                Expanded(
                  child: FilterDropdownMenu<Filter>(
                    type: DropdownType.checkbox_menu,
                    items: Filter.values.map((e) => FilterDropdownItem<Filter>(child: Text(e.toString().split('.').last), value: e)).toList(),
                    currentValue: Filter.all,
                    onSelected: (filter) {
                      print(filter);
                    },
                  ),
                ),
                Spacer(),
                Expanded(
                  child: FilterDropdownMenu<Filter>(
                    type: DropdownType.checkbox_list,
                    width: 200,
                    items: Filter.values.map((e) => FilterDropdownItem<Filter>(child: Text(e.toString().split('.').last), value: e)).toList(),
                    currentValue: Filter.all,
                    onSelected: (filter) {
                      print(filter);
                    },
                  ),
                ),
                Spacer(),
                Expanded(
                  child: FilterDropdownMenu<Filter>(
                    type: DropdownType.checkbox_list,
                    items: Filter.values.map((e) => FilterDropdownItem<Filter>(child: Text(e.toString().split('.').last), value: e)).toList(),
                    currentValue: Filter.all,
                    onSelected: (filter) {
                      print(filter);
                    },
                  ),
                ),
              ],
            ),
          )
        )
        ],
      ),
    );
  }
}


API Reference

FilterDropdownMenu

PropertyDescriptionType
valueThe currently selected valuedynamic
childThe child widget to displayWidget
itemsThe list of items to display in the dropdown menuList
onSelectedCallback function that is called when an item is selectedFunction(dynamic)
filledWhether the dropdown menu should be filled with a background colorbool
inputFillColorThe background color of the filled dropdown menuColor?
borderRadiusThe border radius of the dropdown menu containerdouble
borderWidthThe width of the border of the dropdown menu containerdouble
inputStyleThe style of the text in the dropdown menuTextStyle
labelAlignThe alignment of the text in the dropdown menuTextAlign
widthThe maximum width of the dropdown menudouble?
selectedItemsFor When type = DropdownType.checkbox_menu, List of Selected ItemsList?
onMultiSelectedFor When type = DropdownType.checkbox_menu, Multilist calbackFunction(List)?
closeDialogOnExitOnlytrue means, clicking on a multilist item won't close the dialogbool

FilterToggle

PropertyDescriptionType
currentFilterThe currently selected filterT
filtersThe list of available filtersList
spacingThe spacing between filter buttonsdouble
onSelectedCallback function that is called when a filter is selectedFunction(T)