What should I use for i18n in Flutter: S.of(context) or S.current?

Viewed 1238

I'm using the i18n plugin for Flutter (I believe it's this one) that comes with Android Studio.

And in every example I see it says to use S.of(context).my_string to get the Strings but it always returns null.

If I use S.current.my_string, it seems to work.

So is S.current the right way to do it and every doc/tutorial out there is wrong, are they the same or what?

What I'm basically asking here, is what is the difference between them.

1 Answers

Seems like S.of(context) is initially available way to access localised string.

But sometimes you need to use it without Build Context (in ViewModel, for example). So S.current was added for these cases.

More info here

Related