Web App Setup
If you want to create new project run the following command to make one:
flutter create
If you haven't installed it, be sure to install it first.
Note: If you want to change in Chatify web app you can do change and apply
your firebase credentials in index.html and in main.dart
Follow below steps for firbase web app setup
1. Setup Firebase
- Login into current Firebase Account.
- Select Chatify App
-
In Project Setting, scroll down and click Add App.
- One pop up will appear, in that select html tag (
< />) option.
- Now enter your app name
- Now check on checkbox for the web hosting and provide hosting name (web name)
and click
on Register app button
- Now select Use a
<script> tag and copy code in your web app project inside
web/index.html
- Now initalize firebase in main.dart
- Add Data according to your requirement.
Note: For access your data in Web app also upload your image you need to
give permission to
Firestore database for data, get update and Storage for Images Upload. For
that see the
Firebase Rules
2. Install the firebase-tools CLI
- 🏃♀Skip this step if you already have firebase-tools installed.
- If you do not have npm, you must install that first.
☝️Note: If you are not sure whether npm is installed on your machine, run $ npm -v , and see if it lists a version number. If it does, then you already have npm.- Installing npm on windows.
- Installing npm on linux.
- Installing npm on mac.
- Or download it directly from Node.js.
- Once npm is installed, run the following command to install the firebase-tools:
npm install -g firebase-toolsIf you haven't installed it, be sure to install it first.
- firebase-tools is now installed!
3. Initialize Firebase hosting for your Flutter project
- Open a terminal and navigate to the root directory for your Flutter app and run
this
command
to login:
firebase login - ☝️Note: If you are already logged in and want to re-login as different account,
first
logout
with:
firebase logout -
Follow the command prompt and the link in your browser. Accept the permissions
by
clicking
Ok. When you return to your terminal you should see that you are now logged
in:
- Build your app for web:
flutter build web - Next, run this command from the root directory of your Flutter app to initialize
your
Firebase project:
firebase init - Use the arrow keys to navigate the cursor to Hosting and hit the spacebar to
select
it,
then
press enter. Now you will see this screen
- Select Use an existing project by pressing Enter. Use the arrow keys to
select
the
project
you made in step 1.
- Next, write build/web as the public directory and press enter, then enter n (for no) to select the single page app option
- Next, write y (for yes) to Configure as a single-page app (rewrite all urls to /index.html)? option
- Next, write n (for no) to deploy with Github option
- Next, write y (for yes) to overwrite 404.html option, If this option show
- Next, write y (for yes) to overwrite index.html option
- Again Build your app for web:
firebase hosting:sites:create [Your app name] - Next, Enter this command
flutter build web - Next, Enter this command nvim firebase.json
- Next, Enter this line "site": "Your app name"
- ☝️Note: After this step, 2 new files are created (.firebaserc and firebase.json) in your root directory. Check and make sure they are there. If not, check for errors in the firebase init step and retry.
- This builds the necessary files in
/build/web. - Finally, run this command firebase deploy --only hosting: [your
site name]
firebase deploy --only hosting:[your site name] - The hosting files are uploaded and hosted at your Firebase URL. You can follow the link in your terminal to your Flutter web project!