Flutter Firebase 存储不工作:没有默认存储桶

Flutter Firebase Storage not woriking: no default bucket

我正在尝试使用此功能将 pdf-file 上传到 Firebase-Storage

  static Future<String> savePdf({
    required Uint8List assetAsUint8List,
    required String fileName,
    required DocumentType documentType,
  }) async {
    String path =
        '${BackendService().keys.studs}/${AuthenticationService().currentUser?.uid}/${documentType.name}/$fileName';

    await FirebaseStorage.instanceFor().ref(path).putData(
          assetAsUint8List,
        );
    return FirebaseStorage.instance.ref(path).getDownloadURL();
  }

但这失败了 error:

Unhandled Exception: [firebase_storage/no-bucket] No default storage bucket could be found. Ensure you have correctly followed the Getting Started guide.

configure 我的应用程序在我的 main:

中是这样的
Future main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
    options: kIsWeb || Platform.isAndroid
        ? FirebaseOptions(
            apiKey: "my-api-key",
            appId: "my-app-id",
            messagingSenderId: "my-messaing-sender-id",
            projectId: "appflug",
          )
        : null,
  );
  runApp(
    const App(),
  );
}

它实际上正在 iOS 上工作!但不是在 Android 或网络上...

我按照文档进行操作,但它根本不起作用...我找不到任何有用的信息!

我在这里错过了什么?

如果您需要更多信息,请告诉我!

解决方案相当简单:我需要在我的 FirebaseOptions 中添加 storageBucket 所以我的 main 看起来像这样:

Future main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
    options: kIsWeb || Platform.isAndroid
        ? FirebaseOptions(
            apiKey: "my-app-key",
            appId: "my-app-id",
            messagingSenderId: "my-messaging-sender-id",
            projectId: "my-project-id",
            storageBucket: "myapp.appspot.com",
          )
        : null,
  );
  runApp(
    const App(),
  );
}