<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Gihan Lakshan</title>
    <description>The latest articles on DEV Community by Gihan Lakshan (@gihan667).</description>
    <link>https://dev.to/gihan667</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F618609%2F4d92f0a7-cfa2-4c12-a90d-1c88dd7b4d52.jpeg</url>
      <title>DEV Community: Gihan Lakshan</title>
      <link>https://dev.to/gihan667</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gihan667"/>
    <language>en</language>
    <item>
      <title>Host Flutter Web App On Firebase Hosting</title>
      <dc:creator>Gihan Lakshan</dc:creator>
      <pubDate>Thu, 29 Apr 2021 05:05:58 +0000</pubDate>
      <link>https://dev.to/gihan667/host-flutter-web-app-on-firebase-hosting-5c8b</link>
      <guid>https://dev.to/gihan667/host-flutter-web-app-on-firebase-hosting-5c8b</guid>
      <description>&lt;p&gt;Hello guys, in this post I will show you how to deploy your Flutter Web App on Firebase.&lt;/p&gt;

&lt;p&gt;In this tutorial I’m assuming you have installed firebase-tools and you have created firebase project on firebase console.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.npmjs.com/package/firebase-tools"&gt;Click here to learn How to Install firebase-tools&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before diving into the process, Let’s talk about some topics in flutter web deployment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Minification
&lt;/h2&gt;

&lt;p&gt;Minification is handled for you when you create a release build.&lt;/p&gt;

&lt;p&gt;A debug build of a web app is not minified and tree shaking has not been performed.&lt;/p&gt;

&lt;p&gt;A profile build is not minified and tree shaking has been performed.&lt;/p&gt;

&lt;p&gt;A release build is both minified and tree shaking has been performed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Web Renderers
&lt;/h2&gt;

&lt;p&gt;By default, the flutter build and flutter run commands use the auto choice for the web renderer. This means that your app runs with the HTML renderer on mobile browsers and CanvasKit on desktop browsers. This is Flutter recommended combination to optimize for the characteristics of each platform. You can also define the renderer when building by using --web-renderer option with flutter build web command. See more about &lt;a href="https://flutter.dev/docs/development/tools/web-renderers"&gt;Web Renderers&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Building Flutter Project for Release
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Open your terminal and cd to your root of flutter project&lt;/li&gt;
&lt;li&gt;Then run &lt;code&gt;flutter build web&lt;/code&gt; command, This generates the app including the assets, and places the files into &lt;strong&gt;build/web&lt;/strong&gt; directory&lt;/li&gt;
&lt;li&gt;The release build of a simple app has the following structure:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/build/web
  assets
    AssetManifest.json
    FontManifest.json
    NOTICES
    fonts
      MaterialIcons-Regular.ttf
      &amp;lt;other font files&amp;gt;
    &amp;lt;image files&amp;gt;
  index.html
  main.dart.js
  main.dart.js.map
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Initializing Firebase
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Run &lt;code&gt;firebase init&lt;/code&gt; command in root of the project&lt;/li&gt;
&lt;li&gt;Choose &lt;strong&gt;Hosting: Configure and deploy Firebase Hosting sites&lt;/strong&gt; option (press space bar to choose) and press &lt;strong&gt;Enter&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Now I’m using &lt;strong&gt;Use an existing project&lt;/strong&gt; option you can use &lt;strong&gt;Create a new project&lt;/strong&gt; option if you haven’t created the firebase project yet.&lt;/li&gt;
&lt;li&gt;Now select your newly created project&lt;/li&gt;
&lt;li&gt;Now enter &lt;strong&gt;build/web&lt;/strong&gt; as public directory&lt;/li&gt;
&lt;li&gt;For next question enter &lt;strong&gt;Y&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Then it will ask to setup automatic builds and deploys using git, in this tutorial we skip that option by saying &lt;strong&gt;N&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;It will ask another question, to override the build/web/index.html, say no to it by entering &lt;strong&gt;N&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Now firebase has initialized on our project directory, you will see two new files as &lt;strong&gt;firebase.json &amp;amp; .firebaserc&lt;/strong&gt;, it means firebase has initialised, let’s move on&lt;/li&gt;
&lt;li&gt;Now run &lt;code&gt;firebase deploy&lt;/code&gt; this command will deploy our app to firebase, after successful deploy you will see like below.&lt;/li&gt;
&lt;li&gt;Visit your newly hosted web app by going to &lt;strong&gt;Hosting URL&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Watch the short video tutorial on YouTube:&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/WBCF2DvMg1s"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Want to develop this simple landing page using Flutter? Watch my tutorial on YouTube:&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/PM-ASOgxBn8"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>firebase</category>
      <category>flutterfirebase</category>
      <category>firebasehosting</category>
    </item>
  </channel>
</rss>
