Error: Unsupported operation: Platform._localeName
Error: Unsupported operation: Platform._localeName
我正在使用 dart.io 包并尝试使用 Platform.localeName 检测系统的当前位置,就像这样
WidgetsFlutterBinding.ensureInitialized();
String defaultSystemLocale = Platform.localeName;
print('$defaultSystemLocale');
但是当我 运行 Chrome (Web) 中的应用程序时,出现此错误
Error: Unsupported operation: Platform._localeName
at Object.throw_ [as throw] (http://localhost:62284/dart_sdk.js:5061:11)
at Function._localeName (http://localhost:62284/dart_sdk.js:54692:17)
at Function.localeName (http://localhost:62284/dart_sdk.js:54698:71)
at Function.get localeName [as localeName] (http://localhost:62284/dart_sdk.js:54574:27)
at main (http://localhost:62284/packages/testapp/main4.dart.lib.js:97:45)
知道为什么吗?
如果您从 dart:io
获取 Platform
,它在网络上不受支持(改为 see this website). You can import it from universal_io。
我正在使用 dart.io 包并尝试使用 Platform.localeName 检测系统的当前位置,就像这样
WidgetsFlutterBinding.ensureInitialized();
String defaultSystemLocale = Platform.localeName;
print('$defaultSystemLocale');
但是当我 运行 Chrome (Web) 中的应用程序时,出现此错误
Error: Unsupported operation: Platform._localeName
at Object.throw_ [as throw] (http://localhost:62284/dart_sdk.js:5061:11)
at Function._localeName (http://localhost:62284/dart_sdk.js:54692:17)
at Function.localeName (http://localhost:62284/dart_sdk.js:54698:71)
at Function.get localeName [as localeName] (http://localhost:62284/dart_sdk.js:54574:27)
at main (http://localhost:62284/packages/testapp/main4.dart.lib.js:97:45)
知道为什么吗?
如果您从 dart:io
获取 Platform
,它在网络上不受支持(改为 see this website). You can import it from universal_io。