ButtonBar constructor

const ButtonBar({
  1. Key? key,
  2. int selectedIndex = 0,
  3. required List<IconTab> buttons,
})

Creates a ButtonBar widget.

The buttons parameter is required and contains the list of tabs to display. The selectedIndex parameter indicates which tab should be shown as selected, defaulting to 0 (the first tab).

Example:

ButtonBar(
  selectedIndex: _currentIndex,
  buttons: [
    IconTab(
      icon: Icons.home,
      label: "Home",
      onPressed: () => setState(() => _currentIndex = 0),
    ),
    IconTab(
      icon: Icons.search,
      label: "Search",
      onPressed: () => setState(() => _currentIndex = 1),
    ),
  ],
)

Implementation

const ButtonBar({super.key, this.selectedIndex = 0, required this.buttons});