Flutter web 给出一个关于Unsupported operation: Platform._operatingSystem代码在 flutter android 上正常运行的错误。我认为错误在于我的上传图像方法,它在 flutter web 上不起作用。
Here is the error
Error: Unsupported operation: Platform._operatingSystem
at Object.throw_ [as throw] (http://localhost:37805/dart_sdk.js:5388:11)
at Function._operatingSystem (http://localhost:37805/dart_sdk.js:61565:17)
at Function.get operatingSystem [as operatingSystem] (http://localhost:37805/dart_sdk.js:61611:27)
at get _operatingSystem (http://localhost:37805/dart_sdk.js:61524:27)
at Function.desc.get [as _operatingSystem] (http://localhost:37805/dart_sdk.js:5897:17)
at get isWindows (http://localhost:37805/dart_sdk.js:61542:26)
at Function.desc.get [as isWindows] (http://localhost:37805/dart_sdk.js:5897:17)
at Function._isAbsolute (http://localhost:37805/dart_sdk.js:56712:33)
at io._File.new.get isAbsolute [as isAbsolute] (http://localhost:37805/dart_sdk.js:56708:34)
at io._File.new.get [_absolutePath] (http://localhost:37805/dart_sdk.js:56719:26)
at io._File.new.get absolute [as absolute] (http://localhost:37805/dart_sdk.js:58252:30)
at firebase_storage.Reference.__.putFile (http://localhost:37805/packages/firebase_storage/firebase_storage.dart.lib.js:385:27)
at productprovider.ProductProvider.new.uploadProductImage (http://localhost:37805/packages/phataphat_web_dashboard/services/productprovider.dart.lib.js:223:93)
at uploadProductImage.next …Run Code Online (Sandbox Code Playgroud) 我正在尝试制作 MultiProvider。我不知道错误在哪里。我是 Dart 和 Flutter 新手。尝试自己修复它,但无法修复它。当我运行该项目时,它卡在错误屏幕上。我附上带有问题的图片。
\n\n这是我的代码 main.dart 文件
\nimport \'package:firebase_core/firebase_core.dart\';\nimport \'package:flutter/material.dart\';\nimport \'package:provider/provider.dart\';\nimport \'package:vendorapp/providers/auth_providers.dart\';\nimport \'package:vendorapp/screens/homescreen.dart\';\nimport \'package:vendorapp/screens/registerscreen.dart\';\nimport \'package:vendorapp/screens/splashscreen.dart\';\n\nvoid main() async {\n //Provider.debugCheckInvalidValueType = null;\n WidgetsFlutterBinding.ensureInitialized();\n await Firebase.initializeApp();\n\n runApp( MultiProvider(\n providers:[\n Provider (create: (_) => AuthProvider()),\n ],\n child: MyApp(),\n )\n );\n}\n\nclass MyApp extends StatelessWidget {\n const MyApp({key}) : super(key: key);\n\n @override\n Widget build(BuildContext context) {\n return MaterialApp(\n debugShowCheckedModeBanner: false,\n theme: ThemeData(\n primaryColor: Colors.greenAccent,\n fontFamily: \'Poppins\',\n ),\n initialRoute: SplashScreen.id,\n routes: {\n SplashScreen.id: (context) => SplashScreen(),\n RegisterScreen.id: (context) => RegisterScreen(),\n …Run Code Online (Sandbox Code Playgroud)