Getting BuildContext in Flutter for localization

后端 未结 4 1901
名媛妹妹
名媛妹妹 2021-02-13 17:00

I try to localize a String in Flutter with the localization package. The problem is the location where my translation is needed. It is not related to the UI, rather it is somewh

4条回答
  •  说谎
    说谎 (楼主)
    2021-02-13 17:31

    I am not sure if i did it right (from performance point of view) and maybe someone can comment on this but i have rx BehaviorSubject in my AppLocalization and fire event once new locales are loaded. I am listening to it in my main.dart and doing setState on receiving an event. I checked performance tab but did not noticed any big changes in it once comparing my method vs accessing translations through context (inherited widget).

提交回复
热议问题