Skip to content

Commit 8808fbb

Browse files
committed
add firebase configs for flutter-web
following https://firebase.flutter.dev/docs/installation/web
1 parent 5730a59 commit 8808fbb

File tree

6 files changed

+55
-2
lines changed

6 files changed

+55
-2
lines changed

Diff for: .firebaserc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"projects": {
3+
"default": "flutter-catalog"
4+
}
5+
}

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,4 @@ build/
7676
ios/Flutter/flutter_export_environment.sh
7777
.flutter-plugins-dependencies
7878
.fvm/flutter_sdk
79+
.firebase/*.cache

Diff for: firebase.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"hosting": {
3+
"public": "build/web",
4+
"ignore": [
5+
"firebase.json",
6+
"**/.*",
7+
"**/node_modules/**"
8+
],
9+
"rewrites": [
10+
{
11+
"source": "**",
12+
"destination": "/index.html"
13+
}
14+
]
15+
}
16+
}

Diff for: lib/constants.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'dart:io' show Platform;
22

3+
import 'package:flutter/foundation.dart';
34
import 'package:flutter/material.dart';
45

56
// ignore_for_file: constant_identifier_names
@@ -18,4 +19,5 @@ const GITHUB_URL = 'https://github.com/X-Wei/flutter_catalog';
1819
const AUTHOR_SITE = 'http://x-wei.github.io';
1920

2021
// Whether the app is running on mobile phones (Android/iOS)
21-
final kIsOnMobile = Platform.isAndroid || Platform.isIOS;
22+
// ! `Platform` is not available on web !
23+
final kIsOnMobile = kIsWeb || Platform.isAndroid || Platform.isIOS;

Diff for: pubspec.yaml

+6-1
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,23 @@ dependencies:
2323
cached_network_image: ^2.5.0
2424
charts_flutter: 0.9.0
2525
cloud_firestore: ^0.16.0+1
26+
cloud_firestore_web:
2627
convex_bottom_bar: ^2.7.1+2
2728
day_night_switcher: ^0.2.0
2829
edge_detection: ^1.0.5
2930
english_words: 3.1.5
30-
extended_image: 1.5.0-dev # cf. https://github.com/fluttercandies/extended_image/issues/310
31+
extended_image: 1.5.0-dev
3132
feature_discovery: ^0.13.0+2
3233
firebase_analytics: ^7.0.1
34+
firebase_analytics_web:
3335
firebase_auth: ^0.20.1
36+
firebase_auth_web:
3437
firebase_core: ^0.7.0
38+
firebase_core_web:
3539
firebase_database: ^6.0.0
3640
firebase_ml_vision: ^0.11.0
3741
firebase_storage: ^7.0.0
42+
firebase_storage_web:
3843
fl_chart: ^0.20.1
3944
flutter_bloc: ^6.1.3
4045
flutter_gallery_assets: ^0.2.6

Diff for: web/index.html

+24
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,30 @@
3030
<link rel="manifest" href="manifest.json">
3131
</head>
3232
<body>
33+
<!-- The core Firebase JS SDK is always required and must be listed first -->
34+
<script src="https://www.gstatic.com/firebasejs/7.20.0/firebase-app.js"></script>
35+
<!--Add SDKs for Firebase products that you want to use
36+
https://firebase.google.com/docs/web/setup#available-libraries -->
37+
<script src="https://www.gstatic.com/firebasejs/7.20.0/firebase-analytics.js"></script>
38+
<script src="https://www.gstatic.com/firebasejs/7.20.0/firebase-auth.js"></script>
39+
<script src="https://www.gstatic.com/firebasejs/7.20.0/firebase-firestore.js"></script>
40+
<script src="https://www.gstatic.com/firebasejs/7.20.0/firebase-storage.js"></script>
41+
42+
<script>
43+
// Your web app's Firebase configuration
44+
var firebaseConfig = {
45+
apiKey: "AIzaSyAlngHUW_mWw0G9mVX9_tw2nqKdPepqyBU",
46+
authDomain: "flutter-catalog.firebaseapp.com",
47+
databaseURL: "https://flutter-catalog.firebaseio.com",
48+
projectId: "flutter-catalog",
49+
storageBucket: "flutter-catalog.appspot.com",
50+
messagingSenderId: "785184947614",
51+
appId: "1:785184947614:web:4d5471b36872c2dbf3aa8f"
52+
};
53+
// Initialize Firebase
54+
firebase.initializeApp(firebaseConfig);
55+
</script>
56+
3357
<!-- This script installs service_worker.js to provide PWA functionality to
3458
application. For more information, see:
3559
https://developers.google.com/web/fundamentals/primers/service-workers -->

0 commit comments

Comments
 (0)