I using TextField in my flutter app. It worked on on android. but on ios when I try to paste from the clipboard into the field I get the error:
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
This is part of my code, main page:
return Localizations(
locale: Locale('en'),
delegates: [
GlobalMaterialLocalizations.delegate,
DefaultCupertinoLocalizations.delegate,
DefaultWidgetsLocalizations.delegate,
],
child: CupertinoTabScaffold(
tabBar: CupertinoTabBar(...)
....
)
in each tabs I use this page:
return MaterialApp(
navigatorKey: navKey,
home: child,);
I have separate navigation in each tab.
how do I fix this? any ideas? I will be grateful
CodePudding user response:
You can try to add a delegate of GlobalCupertinoLocalizations
instead of DefaultCupertinoLocalizations
into your delegates
:
delegates: [
GlobalMaterialLocalizations.delegate,
// DefaultCupertinoLocalizations.delegate,
GlobalCupertinoLocalizations.delegate, // Here !
DefaultWidgetsLocalizations.delegate,
],
EDIT:
You may need to add supportedLocales
too.
supportedLocales: [
const Locale('en'), // English
// const Locale('de'), // German, etc.
]