1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

FlutterでCloud Firestoreを使う(Web)

1
Last updated at Posted at 2022-03-07

下記の記事で、AndroidでCloud Firestoreを使う方法を記載しましたが、それをWebアプリに適用する方法を記載します。

  • Firebaseの準備

Firebaseのプロジェクトの設定で、Webアプリを追加します。
追加すると下記の情報が取得できます。

const firebaseConfig = {
  apiKey: "xxx",
  authDomain: "xxx",
  projectId: "xxx",
  storageBucket: "xxx",
  messagingSenderId: "xxx",
  appId: "xxx",
  measurementId: "xxx"
};
  • Flutterの実装

    • 変更前
main.dart
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(const MyApp());
}
  • 変更後
main.dart
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
    name: "xxx",
    options: const FirebaseOptions(
        apiKey: "xxx",
        projectId: "xxx",
        messagingSenderId: "xxx",
        appId: "xxx",
    ),
  );
  runApp(const MyApp());

上記の情報を追加することで、Webアプリが使用することが出来ます。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?