【问题标题】:Dart console app with cloud firestore and firebase storage带有云 Firestore 和 Firebase 存储的 Dart 控制台应用程序
【发布时间】:2020-08-07 08:33:04
【问题描述】:

我想制作一个与 Cloud Firestore 和 Firebase 存储交互的 Dart 控制台应用。

我的第一个问题是:这可能吗?

我在网上搜索了几个小时以寻找示例,但我没有找到任何示例。我发现的只是这个example here,但我不明白它是如何工作的。我试过这段代码:

import 'package:firebase/firebase.dart';
import 'package:firebase/firestore.dart' as fs;

void main() {
  initializeApp(
    apiKey: "YourApiKey",
    authDomain: "YourAuthDomain",
    databaseURL: "YourDatabaseUrl",
    projectId: "YourProjectId",
    appId: "YourAppId",
    storageBucket: "YourStorageBucket");

  fs.Firestore store = firestore();
  fs.CollectionReference ref = store.collection('myCollection');
  ref.onSnapshot.listen((querySnapshot) {
    print(querySnapshot);
  });  
}

第一件事是我不知道在哪里可以找到那些initializeApp 信息,例如YourApiKeyYourAuthDomain ...

第二件事是 VS 代码给了我这个警告

Omit type annotations for local variables.

【问题讨论】:

    标签: firebase dart google-cloud-firestore firebase-storage


    【解决方案1】:

    第一件事:从Firebase console,打开您的 Firebase 项目。 [我假设你已经有了一个?]

    点击“+Add App”,选择“Web”作为平台。

    输入应用的昵称并点击“注册应用”

    然后它将为您生成值。复制它们,并将它们粘贴到安全的地方,然后单击“继续到控制台”。

    然后您可以根据需要将各种值复制并粘贴到您的代码中。

    第二件事:你可以忽略那些开始。它们是风格问题,它们不会阻止您的代码编译或运行。

    【讨论】:

      猜你喜欢
      • 2012-10-21
      • 1970-01-01
      • 1970-01-01
      • 2019-04-06
      • 1970-01-01
      • 1970-01-01
      • 2016-12-20
      • 1970-01-01
      • 2014-08-06
      相关资源
      最近更新 更多