How to Deploy Flutter Web on Server?
To create a production build for the web now flutter supports flutter build web command similar to other platforms (android and ios) and you will see
folder generated with the source files mainly index.html,main.dart.js and the assets folder and you can simply deploy it on your server.
you simply need to do a production build by using a webdev tool. to install webdev you need a pub tool.
- so go to the location where you have dart installed and inside the bin folder, you should have a pub batch file. You need to provide the bin folder’s path to the environment variable in order to use the pub from cmd.
- now open cmd and hit the below command to install webdevpub global activate webdev// in your IntelliJ Idea terminal
- now go to the root folder of your project and do a build in release mode
flutter build web
- you should see a build folder (/build/web) in the root directory, just copy that folder and host it on a web server.
- I used the same way to deploy it to GitHub pages here’s a how-in detail guide.
Here is the simple way to deploy your flutter web application on an amazon web server.
Following is the simple process:
- Build a flutter web: flutter build web —release
- Create an instance on AWS ec2 server: mean allocate some memory for your website on the server. An instance is a virtual server in the AWS cloud.
- Connect to your server(instance) with the help of putty :
- Install Vesta control panel on your server.
- Upload your content(website) on the server. With the help of FileZilla, you can easily upload your website content on a server.
If it’s a Firebase project you can use Firebase Hosting. It will ask you to install Firebase Tools on your system and you will have to initialize it on the root folder of your project. Then you just have to:
flutter build web firebase deploy
Thanks for being with us on a Flutter Journey !!!
So in this article, we have been through How to Deploy Flutter Web on Server.
Keep Learning !!! Keep Fluttering !!!
Flutter Agency is our portal Platform dedicated to Flutter Technology and Flutter Developers. The portal is full of cool resources from Flutter like Flutter Widget Guide, Flutter Projects, Code libs and etc.
Flutter Agency is one of the most popular online portals dedicated to Flutter Technology and daily thousands of unique visitors come to this portal to enhance their knowledge of Flutter.