Flutter TextField with number keyboard, comma is needed instead of period (Only iOS)
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:
Comments
-
Niklas Raab over 1 year
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 (.)?
-
Keerti Purswani about 5 yearsYou have changed the
keyboardType
so obviously you will get period to be able to type decimal number. Don't give the type if you don't want that to happen. -
Niklas Raab about 5 years@KeertiPurswani Hi, thanks for your comment, but I want a comma (,) instead of the period (.) in the keyboard. In Germany we use the comma (,) as decimal seperator!
-
Keerti Purswani about 5 yearsOh I didnt know that. Sorry.
-
Aleksandar over 4 years@NiklasRaab have you found a solution for your problem? I have the same one and can't seem to find the right way of fixing it...
-