[cupertino] Expose useful typography constants
- Dominant language
- Dart
- Stars
- 179k
- Forks
- 31.1k
- PR merge metrics
- PR metrics pending
Description
### Use case
Similar to https://github.com/flutter/flutter/issues/179828
Several typography-related constants were privately defined in cupertino/menu_anchor.dart, but it may be useful to expose them for other widgets to access.
### Proposal
Rename and expose the following constants in cupertino/text_theme.dart:
```dart
/// The font family for menu items at smaller text scales.
const String _kBodyFont = 'CupertinoSystemText';
/// The font family for menu items at larger text scales.
const String _kDisplayFont = 'CupertinoSystemDisplay';
/// Base font size used for text-scaling calculations.
///
/// On iOS the text scale changes in increments of 1/17 (≈5.88%), as
/// observed on the iOS 18.5 simulator. Each step (1/17 of the base font size)
/// is referred to as one "unit" in the documentation for [CupertinoMenuAnchor]
const double _kCupertinoMobileBaseFontSize = 17.0;
/// The CupertinoMenuAnchor layout policy changes depending on whether the user is using
/// a "regular" font size vs a "large" font size. This is a spectrum. There are
/// many "regular" font sizes and many "large" font sizes. But depending on which
/// policy is currently being used, a menu is laid out differently.
///
/// Empirically, the jump from one policy to the other occurs at the following text
/// scale factors:
/// * Max "regular" scale factor ≈ 23/17 ≈ 1.352... (normalized text scale: 6)
/// * Min "accessible" scale factor ≈ 28/17 ≈ 1.647... (normalized text scale: 11)
///
/// The following constant represents a division in text scale factor beyond which
/// we want to change how the menu is laid out.
///
/// This explanation was ported from cupertino/dialog.dart.
const double _kMinimumAccessibleNormalizedTextScale = 11;
/// The minimum normalized text scale factor supported on iOS.
const double _kMinimumTextScaleFactor = 1 - 3 / _kCupertinoMobileBaseFontSize;
/// The minimum normalized text scale factor supported on iOS.
const double _kMaximumTextScaleFactor = 1 + 36 / _kCupertinoMobileBaseFontSize;
```
Alternatively, these constants could be placed in cupertino/constants.dart.
Contributor guide
Research direction
Start by comparing the private typography constants in cupertino/menu_anchor.dart with the public API organization in cupertino/text_theme.dart. Check whether cupertino/constants.dart is a better location, then expose the named constants with their documented values and verify that the resulting public API matches the proposal.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- mobile-dev
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100