You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
iOS: let SegmentedControl labels use the TextStyle's fontFamily and the selected style's weight #114
I searched the existing feature requests and this is not a duplicate.
Framework or plugin?
Framework
Platform
iOS
Use case
SegmentedControl's labels can't use the app's font on iOS. Its docs list only fontSize, fontWeight and color for labelFontStyle, and say the selected style's size and weight override the base style "on Android" (lib/src/widgets/segmented_control.dart). On an iPhone, labelFontStyle: TextStyle(fontFamily: 'Manrope') gives SF labels, and the selected segment can't be bolder than the others.
SegmentedControl(
segments:const ['Arrivals', 'Departures'],
labelFontStyle:constTextStyle(fontFamily:'Manrope', fontSize:14),
selectedLabelFontStyle:constTextStyle(fontWeight:FontWeight.w800),
// iOS: SF at the default weight for both segments
);
An app with its own typeface then has one control in the system font. Our workaround is a segmented control drawn in Dart, which means keeping its accessibility and contrast up ourselves. (#69 added icons per segment and pointed to building your own for icon plus text; this one is only about the label font.)
Proposal
On iOS, pass both styles through UISegmentedControl.setTitleTextAttributes(_:for:), for .normal and .selected, with a UIFont built from the TextStyle's fontFamily, fontSize and fontWeight (the same font lookup Text already uses for registered fonts). Then fontFamily works and selectedLabelFontStyle's size and weight apply on both platforms.
Activity