带数字键盘的 Flutter TextField,需要逗号而不是句点(仅限 iOS)

Nik*_*aab 11 textfield ios flutter

我想在 Flutter 中创建一个 TextField。TextField 用于十进制数字。所以我设定了keyboardType: TextInputType.numberWithOptions(decimal: true)。现在我在 iOS 上得到了一个数字键盘,但这个数字键盘有一个句点 (.),而不是逗号 (,)。iOS 设备的语言是德语

\n\n

我当前的文本字段:

\n\n
TextField(\n  key: Key("pricePerLiter"),\n  style: TextStyle(color: inputTextColor),\n  textAlign: TextAlign.end,\n  focusNode: pricePerLiterFocusNode,\n  keyboardType:\n      TextInputType.numberWithOptions(decimal: true),\n  decoration: inputDecoration.copyWith(\n      suffixText: "\xe2\x82\xac", errorText: pricePerLiterError),\n  controller: pricePerLiterTextController,\n  onEditingComplete: () {},\n  onChanged: (value) {},\n)\n
Run Code Online (Sandbox Code Playgroud)\n\n

我的本地化在我的 Material 应用程序中设置如下:

\n\n
MaterialApp(\n  localizationsDelegates: [\n    GlobalMaterialLocalizations.delegate,\n    GlobalWidgetsLocalizations.delegate,\n  ],\n  supportedLocales: [\n    const Locale(\'de\', \'DE\'),\n  ],\n  home: MyHomePage(),\n)\n
Run Code Online (Sandbox Code Playgroud)\n\n

我需要更改什么才能获得带有逗号 (,) 而不是句点 (.) 的数字键盘?

\n

Ola*_*ter 3

在 iOS 上,即使对于 flutter 应用程序,您也必须在 ios 构建设置中启用 de(或 en_US 以外的任何其他区域设置)区域设置。使用 Xcode 打开 flutter 应用程序的 ios/Runner.xcworkspace。选择项目运行者。在“信息”页面上,您将在“本地化”下看到为您的应用程序启用的区域设置。在此处添加区域设置(或任何其他区域)。重建应用程序(通过 Xcode 或 Flutter,没关系)。

另请参阅此处的另一种方法:

https://flutter.dev/docs/development/accessibility-and-localization/internationalization#appendix-updating-the-ios-app-bundle