i'm traying to add if statement in flutter based on easy_localization chosen language
here is the code
Future<bool> handleFcmSubscribtion() async {
final SharedPreferences sp = await SharedPreferences.getInstance();
bool _subscription = sp.getBool('subscribed') ?? true;
if (_subscription == true && Localizations.localeOf(context).languageCode == 'es') {
_fcm.subscribeToTopic(subscriptionTopic);
debugPrint('subscribed');
} else {
_fcm.unsubscribeFromTopic(subscriptionTopic);
debugPrint('unsubscribed');
}
return _subscription;
}
the problem is when i add && Localizations.localeOf(context).languageCode == 'es' i get Undefined name 'context' i can't figure it out how to use it here, I'm just start with flutter sorry my target is, i will add firebase topic depend on user chosen lang on this step
where is passed this code ? you need call it valid context