I want to create a TextField in Flutter. The TextField is for decimal numbers. So i set keyboardType: TextInputType.numberWithOptions(decimal: true)
. Now I get a number keyboard on iOS, but this number keyboard has a period (.) instead of a comma (,). The language of the iOS device is German.
My current TextField:
TextField(
key: Key("pricePerLiter"),
style: TextStyle(color: inputTextColor),
textAlign: TextAlign.end,
focusNode: pricePerLiterFocusNode,
keyboardType:
TextInputType.numberWithOptions(decimal: true),
decoration: inputDecoration.copyWith(
suffixText: "€", errorText: pricePerLiterError),
controller: pricePerLiterTextController,
onEditingComplete: () {},
onChanged: (value) {},
)
My Localization is set up like following in my Material app:
MaterialApp(
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: [
const Locale('de', 'DE'),
],
home: MyHomePage(),
)
What do I need to change to get a number keyboard with a comma (,) instead of a period (.)?
On iOS you have to enable the de (or any other locale than en_US) locale in the ios build settings even for flutter apps. Open the ios/Runner.xcworkspace of your flutter app with Xcode. Select the Project Runner. On the "Info" page you will see the locales enabled for your app under "Localisations". Add the de locale (or any other) here. Rebuild the app (by Xcode or Flutter, doesn't matter).
Look also here for another approach:
https://flutter.dev/docs/development/accessibility-and-localization/internationalization#appendix-updating-the-ios-app-bundle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With