getFontSize static method

double? getFontSize(
  1. BuildContext context
)

Retrieves the font size from the current theme's body medium text style.

This method extracts the font size value from the app's current theme, specifically from Theme.of(context).textTheme.bodyMedium. This ensures that empty state widgets use consistent typography that matches the overall application design.

Theme Integration

The method respects:

  • System Font Scaling: Adapts to user's accessibility font size settings
  • App Theme: Uses the application's defined text theme
  • Material Design: Follows Material Design typography guidelines
  • Platform Conventions: Respects platform-specific text sizing

Return Value

Returns the font size as a double, or null if the theme doesn't specify a font size for the body medium text style. In practice, this should rarely be null as Material themes provide default values.

context The build context to access the current theme.

Example:

final fontSize = CustomEmptyWidgetHelper.getFontSize(context);
if (fontSize != null) {
  // Use the theme-consistent font size
  print('Using font size: $fontSize');
}

Implementation

static double? getFontSize(BuildContext context) {
  return Theme.of(context).textTheme.bodyMedium?.fontSize;
}