Skip to content

Commit

Permalink
Add trExists to context extension
Browse files Browse the repository at this point in the history
  • Loading branch information
omj-denis committed Jan 7, 2025
1 parent 1d1251a commit 9fdabe5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/src/public_ext.dart
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,16 @@ extension BuildContextEasyLocalizationExtension on BuildContext {
);
}

bool trExists(String key) {
final localization = Localization.of(this);

if (localization == null) {
throw const LocalizationNotFoundException();
}

return localization.exists(key);
}

String plural(
String key,
num number, {
Expand Down

0 comments on commit 9fdabe5

Please sign in to comment.