gpt4 book ai didi

ios - Flutter(iOS) -"No CupertinoLocalizations found",如何解决?

转载 作者:行者123 更新时间:2023-12-05 00:23:33 24 4
gpt4 key购买 nike

我在我的 flutter 应用程序中使用 TextField 。它适用于android。但是在ios上,当我尝试从剪贴板粘贴到字段中时,出现错误:

 No CupertinoLocalizations found.
_CupertinoTextSelectionControlsToolbar widgets require CupertinoLocalizations to be provided by a Localizations widget ancestor.
The cupertino library uses Localizations to generate messages, labels, and abbreviations.
To introduce a CupertinoLocalizations, either use a CupertinoApp at the root of your application to include them automatically,
The specific widget that could not find a CupertinoLocalizations ancestor was: _CupertinoTextSelectionControlsToolbar
enter image description here
这是我的代码的一部分,主页:
return Localizations(
locale: Locale('en'),
delegates: [
GlobalMaterialLocalizations.delegate,
DefaultCupertinoLocalizations.delegate,
DefaultWidgetsLocalizations.delegate,
],
child: CupertinoTabScaffold(
tabBar: CupertinoTabBar(...)
....
)
在每个标签中我使用这个页面:
 return MaterialApp(
navigatorKey: navKey,
home: child,);
我在每个选项卡中都有单独的导航。
我该如何解决?有任何想法吗?我会很感激

最佳答案

您可以尝试添加 GlobalCupertinoLocalizations 的代表而不是 DefaultCupertinoLocalizations进入您的delegates :

delegates: [
GlobalMaterialLocalizations.delegate,
// DefaultCupertinoLocalizations.delegate,
GlobalCupertinoLocalizations.delegate, // Here !
DefaultWidgetsLocalizations.delegate,
],
编辑:
您可能需要添加 supportedLocales也。
supportedLocales: [
const Locale('en'), // English
// const Locale('de'), // German, etc.
]

关于ios - Flutter(iOS) -"No CupertinoLocalizations found",如何解决?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70066318/

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