matchesLocale static method

bool matchesLocale(
  1. BuildContext? context,
  2. String languageCode, [
  3. String? countryCode
])

Check if the current locale matches a specific language (and optionally country).

Implementation

static bool matchesLocale(
  BuildContext? context,
  String languageCode, [
  String? countryCode,
]) {
  final currentLocale = getCurrentLocale(context: context);
  if (countryCode != null) {
    return currentLocale.languageCode == languageCode &&
        currentLocale.countryCode == countryCode;
  }
  return currentLocale.languageCode == languageCode;
}