sliding_segmented_control 1.1.0
sliding_segmented_control: ^1.1.0 copied to clipboard
A themeable segmented control whose selection is marked by a pill sliding between segments, with an optional body that cross-fades underneath it.
Changelog #
1.1.0 #
- The selection can be dragged: press the pill and slide it, as on iOS.
The pill follows the pointer, ticks out haptic feedback as it crosses into
each segment, and commits to the segment nearest where it is let go. A press
that starts anywhere but on the pill is still an ordinary tap.
enableDragandenableFeedbackturn each half of that off. - Keyboard support. The control is one tab stop, like a radio group: Tab
reaches the selected segment, the arrow keys move the selection from there —
stepping over disabled segments, stopping at the ends, and mirroring under
RTL — Home and End jump to either end, and Space or Enter selects the
focused segment.
autofocusgives the control focus on first build. - The focused segment is drawn with
focusColorbehind it and a ring infocusOutlineColor, and the segment under the pointer takeshoverColor. All three are on the theme, alongsidefocusOutlineWidth. - Sizing modes, through
sizing.SegmentSizing.equalis the old behaviour and stays the default;intrinsicsizes each segment to its own content and shrink-wraps the control, squeezing the segments proportionally rather than overflowing when they do not fit;scrollableputs content-sized segments in a horizontal scroll view that keeps the selection in view. The pill takes the width of whichever segment it is under. SegmentedControlTheme.segmentPaddinginsets a segment's content, and is what gives a content-sized segment its width beyond the label.SegmentgainsiconWidgetfor an icon this package cannot express as anIconData,badgefor a count or status chip after the label, andchildto replace the icon and label outright whilelabelstays on as the screen-reader text.SegmentandSegmentPageboth gaincopyWith, andSegmentPagenow compares by value.- Every segment carries
SlidingSegmentedControl.segmentKey(index), so host tests can find and measure one. - The floors come down to Dart 3.12.0 and Flutter 3.44.0, which is as low as
material_uiitself goes — nothing here needs anything newer thanRoundedSuperellipseBorder, in the framework since 3.32. The example moves down with the package. - The
material_uiconstraint floats across major versions,>=1.0.0 <3.0.0, rather than being capped at 1.x. - The layout is a render object rather than a
Stackof aligned children, which is what lets the pill size itself to segments of different widths. Nothing public changed with it:indicatorKeyandindicatorAlignmentare where they were, and the widget is drop-in from 1.0.0.
1.0.0 #
-
Breaking. Material comes from the
material_uipackage, not frompackage:flutter/material.dart. Everyimport 'package:flutter/material.dart'is nowimport 'package:material_ui/material_ui.dart'.The types this package exposes —
ThemeExtension,ThemeData,ColorScheme,TextTheme— arematerial_ui's, and those are distinct from the framework's classes of the same name. A host registeringSegmentedControlThemeas a theme extension, or reading it throughSegmentedControlTheme.of, has to be onmaterial_uitoo.dart fix --apply --code=migrate_design_widgetsdoes the import rewrite for you.Hosts still on framework Material stay on 0.1.1.
-
The SDK floor moves to Dart 3.13.0 and Flutter 3.47.0.
-
The example's Flutter floor, left behind at 3.27.0, moves up with the package.
0.1.1 #
- Dropped the
figma_squircledependency: the package now needs nothing but Flutter. Corners are drawn byRoundedSuperellipseBorder, in the framework since Flutter 3.32, which the engine rasterises directly. - Corner radii are settable from the call site.
trackRadiusandindicatorRadiustake anyBorderRadiusGeometry— one radius, a different radius per corner, elliptical corners, or the directionalBorderRadiusDirectional— on the theme or per instance. trackShape/indicatorShapetake a wholeShapeBorder, also per instance, so a host can bring corner geometry this package does not ship — afigma_squirclesquircle, for instance — and keep that dependency in its own pubspec.cornerSmoothing, afigma_squirclenotion, gives way to thesmoothCornersflag.- The Flutter floor moves to 3.32.0 for
RoundedSuperellipseBorder.
0.1.0 #
- First release.
SlidingSegmentedControl— a segmented control whose selection is marked by a pill sliding between equally-sized segments, with per-segment icons, tooltips and disabled states.SegmentedBody— the control above the body of the selected segment, which cross-fades on change. Works controlled or uncontrolled, and builds only the selected page.SegmentedBodyTransition—fade(the default),slideandscalefor the body change, withtransitionBuilderstill there for anything else.slidefollows the direction the selection moved in, and mirrors under RTL.SegmentedControlTheme, aThemeExtensioncovering colours, text styles, shapes and metrics, withcopyWithandlerp. With none registered, the palette is derived from the ambientColorScheme.- Right-to-left is handled by positioning the indicator with
AlignmentDirectional. - Segments are exposed to screen readers as buttons carrying their selected and enabled state.
- README screenshots are generated from the real widgets by
example/test/screenshots_test.dart.
