我在我的 flutter 应用程序中使用 TextField。它在安卓上运行。但在 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
这是我的代码的一部分,主页:
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,
],
EDIT:
您可能需要添加supportedLocales
too.
supportedLocales: [
const Locale('en'), // English
// const Locale('de'), // German, etc.
]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)