Search packages, repositories and app categories

material_segmented_control cover
Package detailsv5.0.1

material_segmented_control

A segmented control widget like the one for iOS, but in Material design.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
11.2K
Likes
103
Pub points
150

Install package

flutter pub add material_segmented_control

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A Flutter widget that implements a segmented control with Material Design aesthetics, offering a visually consistent alternative to iOS-style segmented controls. It enables users to select one option from a set of mutually exclusive choices, commonly used in settings or filters. The control supports customization of colors, labels, and selection behavior while maintaining platform-appropriate styling across Android, iOS, Web, macOS, Windows, and Linux.

Use cases

  • Form input selection
  • Filtering data by category
  • User preference settings
  • Navigation between tabs
  • Customizable UI components

Key features

  • Material Design appearance
  • Cross-platform compatibility
  • Customizable colors and labels
  • Supports single selection
  • Easy integration with existing widgets

Suitable for

  • Developers building cross-platform apps
  • Designers seeking Material-compliant UI elements
  • Apps requiring intuitive tab-like navigation
  • Teams prioritizing consistency across platforms
  • Projects with filtering or configuration interfaces

Considerations

  • Limited to single selection only
  • Requires manual handling of selection callbacks
  • May need additional styling for complex layouts
  • Not optimized for large numbers of segments
  • Depends on external package maintenance

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Material Segmented Control

A material segmented control like the one for iOS, in Material style.

image

Why?

We all know well the Cupertino segmented widget in Flutter. But there is no similar in Material, so I thought, why not to create one.

You can check it out on pub.dev: (see package on pub.dev)

How to use

Import the package

In your pubspec.yaml, add

dependencies: 
    material_segmented_control: ^5.0.1
Import code

Wherever you want to use this widget, import

import 'package:material_segmented_control/material_segmented_control.dart';
Basic usage
int _currentSelection = 0;

MaterialSegmentedControl(
    children: _children,
    selectionIndex: _currentSelection,
    borderColor: Colors.grey,
    selectedColor: Colors.redAccent,
    unselectedColor: Colors.white,
    selectedTextStyle: TextStyle(color: Colors.white),
    unselectedTextStyle: TextStyle(color: Colors.redAccent),
    borderWidth: 0.7,
    borderRadius: 32.0,
    disabledChildren: [3],
    onSegmentTapped: (index) {
      setState(() {
        _currentSelection = index;
      });
    },
);

Map<int, Widget> _children = {
  0: Text('Hummingbird'),
  1: Text('Kiwi'),
  2: Text('Rio'),
  3: Text('Telluraves')
};
Features
  • Disable the selection for all children by setting selectionIndex to null. It un-selects all options.
  • Disable children to being not "clickable" (like setting onPressed to null on a button) by setting disabledChildren. Give it a list with all indices that should be disabled. Give it either null or an empty list to not use the disabled feature.

You might want to check out the example project.

Categories

Source repository

Projects using this package