gpt4 book ai didi

flutter - 我应该在 Flutter : S. of(context) 或 S.current 中为 i18n 使用什么?

转载 作者:行者123 更新时间:2023-12-04 17:32:24 27 4
gpt4 key购买 nike

我正在使用 i18n plugin for Flutter (我相信它是 this one )附带 Android Studio .

在每个例子中,我看到它说使用 S.of(context).my_string获取 Strings但它总是返回 null .

如果我使用 S.current.my_string ,它似乎工作。
S.current也是如此正确的方法和每个文档/教程都是错误的,它们是相同的还是什么?

我在这里主要问的是它们之间有什么区别。

最佳答案

好像S.of(context)最初是访问本地化字符串的可用方式。

但有时您需要在没有构建上下文的情况下使用它(例如在 ViewModel 中)。所以S.current为这些情况添加了。

更多信息 here

关于flutter - 我应该在 Flutter : S. of(context) 或 S.current 中为 i18n 使用什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58193203/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com