<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ibtesam Ansari on Medium]]></title>
        <description><![CDATA[Stories by Ibtesam Ansari on Medium]]></description>
        <link>https://medium.com/@ibtesamansari070?source=rss-24b035320fd6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*BZU1ycrae7hwSQqFlXNKMQ.jpeg</url>
            <title>Stories by Ibtesam Ansari on Medium</title>
            <link>https://medium.com/@ibtesamansari070?source=rss-24b035320fd6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 18:57:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ibtesamansari070/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Making Production-Ready apps in Flutter]]></title>
            <link>https://itnext.io/making-production-ready-apps-in-flutter-e0abd1c23c83?source=rss-24b035320fd6------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0abd1c23c83</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Ibtesam Ansari]]></dc:creator>
            <pubDate>Mon, 24 Aug 2020 10:41:57 GMT</pubDate>
            <atom:updated>2020-08-24T14:32:56.043Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TJ4f4cfLVZSauUlpswomQg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@christianw?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Christian Wiediger</a> on <a href="https://unsplash.com/s/photos/mobile-app?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>In this article, I will be discussing some of the points which should be kept in mind while developing an app. It is always a good practice to write apps that are scalable and maintainable.</p><p>I will be covering the following topics in this article:</p><ol><li>Setting up the development/production environment</li><li>Best practices for writing clean code</li><li>Testing, debugging, and monitoring</li><li>Distribution of the app through CI/CD</li></ol><h3>Setting up the environment</h3><h4>Git Version control and branching strategy</h4><p>Version control allows you to keep track of any file changes and identify differences in your code. It is a handy tool while working in a team. But it can become chaotic very quickly if everyone starts committing changes to the master branch. Thus, there should be specific branches defined for different purposes. A straightforward convention is to have three branches :</p><ul><li><strong>master: </strong>The production-ready code goes here.</li><li><strong>develop: </strong>The code on which final tests are done before merging to master branch</li><li><strong>feature-specific branch: </strong>These are the branches with the name of the feature that is currently being worked on</li></ul><figure><img alt="Git Branching strategy" src="https://cdn-images-1.medium.com/max/801/1*_OoxaNV6CaL4ktQIGCwgig.png" /><figcaption><em>Image is taken from </em><a href="https://buddy.works/blog/5-types-of-git-workflows"><em>https://buddy.works/blog/5-types-of-git-workflows</em></a></figcaption></figure><h4>Docker Containers for Flutter (Optional)</h4><p>Imagine a situation where you want to run a Flutter project on a machine that doesn’t have Flutter or Android SDK installed. Manually downloading and installing everything is a tiresome process. Let alone fixing installation errors 😰. This is where Docker comes into play. Docker containers are very useful and save us from the “<strong><em>But it runs on my machine..</em></strong>” problems. It is portable and very light-weight. It is also platform-independent, which means it runs exactly as on your machine as it runs on mine, irrespective of the OS.</p><p>Setting up Docker for Flutter is relatively easy. You can refer to this article for help.</p><p><a href="https://blog.codemagic.io/how-to-dockerize-flutter-apps/">How to dockerize Flutter apps | Codemagic Blog</a></p><h3>Best practices for writing clean code</h3><h4>Clean Architecture</h4><p>No matter how great your app is if you can’t understand and debug the code you wrote a few days ago, it is of no use. Everyone should follow at least a basic architecture and separate the business logic from the UI. The architecture which I like to follow is a slight modification of the architecture suggested by <a href="https://resocoder.com/2019/08/27/flutter-tdd-clean-architecture-course-1-explanation-project-structure/">Reso Coder</a>.</p><figure><img alt="Clean Architecture" src="https://cdn-images-1.medium.com/max/812/1*gKp-nIN1Dlqok3UI7ju6eg.png" /><figcaption>Clean Architecture pattern</figcaption></figure><p>A breakdown of the architecture is as follows:</p><ol><li><strong>UI</strong>: It is the section which the user interacts with. This section takes input from the user and sends it to the Provider. Validation of the data can be done here.</li><li><strong>Provider: </strong>This section consists of any state management that you want to use. In the above diagram, I have used the provider package.</li><li><strong>Repository(Domain): </strong>The repository in the domain layer is an abstract class containing all the methods that the Provider requires.</li><li><strong>Repository(Data):</strong> The repository in the data layer is the implementation of the abstraction. This layer decides whether the data required by the user should be fetched from the server or the local cache.</li><li><strong>Remote: </strong>As the name suggests, it handles all the server requests.</li><li><strong>Local: </strong>This manages all the tasks related to storing data offline and fetching data from the local database whenever required.</li></ol><p>Here is a project using the above architecture.</p><p><a href="https://github.com/ibtesam123/NumberTrivia">ibtesam123/NumberTrivia</a></p><h4>Error Handling</h4><p>Error Handling is one of the most crucial aspects of any app. Errors and crashes can significantly affect your userbase. You can solve this problem by using data types like <a href="https://pub.dev/packages/dartz"><strong>Either</strong></a><strong>. </strong>Either is a part of the dartz library, and it can help deal with exceptions efficiently. It acts as a wrapper around two datatypes — Left(the exception) and Right(the expected data). The benefit of using Either is that you need to define logic for both the cases. This ensures that you handle each situation.</p><p>Using Either type for error handling</p><h3>Testing, Debugging, and Monitoring</h3><h4>Testing</h4><p><a href="https://flutter.dev/docs/testing">Testing</a> is essential so that you can identify and correct bugs before delivering the app to the users. Manual testing becomes harder as your app grows. Flutter offers three categories of test:</p><ul><li><strong>Unit Test: </strong>To test for a single function, method, or class. There should be a bunch of unit tests as these tests are fast to execute. All unit tests can be carried out in a CI environment.</li><li><strong>Widget Test:</strong> To test a single widget; These tests are slower than the unit tests and should be carried out locally. Try not to run them in a CI environment as they will take up a lot of your build minutes.</li><li><strong>Integration Test:</strong> To test the complete app or a large part of it; These tests should strictly be carried out locally as they are very slow and not ideal for CI environments.</li></ul><p>Testing also ensures no one breaks the previously working code. A CI workflow could be set up to run the tests whenever there is a pull request to the development branch.</p><h4>Debugging</h4><p>The dart <a href="https://flutter.dev/docs/development/tools/devtools/overview"><strong>DevTools</strong></a><strong> </strong>offers a wide variety of tools and features to help debug Flutter apps. I am fairly new to dev tools, but I like the flutter inspector, which lets to test out different layout parameters without changing the actual code. You can also monitor network requests that your app makes without needing to print them out manually inside the app.</p><figure><img alt="Dart DevTools" src="https://cdn-images-1.medium.com/max/1024/1*Z0lh29E1IqiyuAtCJxai1A.gif" /><figcaption>Image is taken from <a href="https://flutter.dev/">flutter.dev</a></figcaption></figure><h4>Monitoring</h4><p>Deploying your app on the play store or the app store is not the end. You need to keep track of bugs and errors which escapes the development phase. <a href="https://pub.dev/packages/firebase_crashlytics"><strong>Firebase crashlytics</strong></a> offer an easy way to monitor how your app behaves on the user’s phone. You can record the error and even log them.</p><p>Firebase Crashlytics</p><h3>Distribution through CI/CD</h3><h4>Why is it important?</h4><ul><li>If you push updates for your app frequently, CI/CD can help you automated various tasks so that you don’t have to waste a lot of time.</li><li>Detection of error as early as possible; You can also identify the location of the error easily.</li><li>Faster Release Rate. CI/CD continuously merges codes and deploys them to production after thorough testing, keeping the code in a release-ready state.</li><li>Increases productive time; As CI/CD automates a lot of tasks, developers can spend more time on development.</li></ul><h4>How to set it up for your flutter app?</h4><p>The easiest way is with <a href="https://codemagic.io/start/">Codemagic</a>. Codemagic provides an easy to setup UI for creating your workflows. You can check out their tutorials.</p><p><a href="https://blog.codemagic.io/tags/publishing/">Publishing - Codemagic blog. CI/CD for mobile app projects</a></p><p>There are other options as well, like <a href="https://github.com/features/actions">Github Actions</a>. I will be writing a blog next on how to securely set up a workflow for your Flutter app for different environments.</p><h3>Recap</h3><ul><li>Set up git for your project and a git branching strategy to keep your production and development code separate.</li><li>You can set up Docker for your project to ensure development on all platforms easily.</li><li>Follow an architecture pattern to separate your business logic and UI components.</li><li>Choose Either type for better error handling.</li><li>Always write tests for your app. This ensures bug-free releases for your users.</li><li>Use debugger tools to make the process of debugging apps easier and also monitor the resource usage of the app.</li><li>Use Firebase crashlytics to track crashes on the user’s device.</li><li>Use CI/CD to automate all the repetitive tasks and spend more time on actual development.</li></ul><p>These are some of the points I keep in mind while developing an app for production. If you liked the article, don’t forget to give some claps 👏. If you have more points to add, please comment them down below. Thank you 😄</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0abd1c23c83" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/making-production-ready-apps-in-flutter-e0abd1c23c83">Making Production-Ready apps in Flutter</a> was originally published in <a href="https://itnext.io/">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Realtime Chat App - One-to-One using Flutter, Socket.io & Node.js]]></title>
            <link>https://medium.com/flutter-community/realtime-chat-app-one-to-one-using-flutter-socket-io-node-js-acd4152c6a00?source=rss-24b035320fd6------2</link>
            <guid isPermaLink="false">https://medium.com/p/acd4152c6a00</guid>
            <category><![CDATA[chat]]></category>
            <category><![CDATA[socketio]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[realtime]]></category>
            <dc:creator><![CDATA[Ibtesam Ansari]]></dc:creator>
            <pubDate>Mon, 11 May 2020 12:21:34 GMT</pubDate>
            <atom:updated>2020-05-14T23:15:25.321Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e5LdWP1mxlqjSHd9I28JVg.png" /></figure><p>In my previous blog on real-time chat I discussed about how to get started with socket.io and setup a simple chat app in which one can chat with all the people online. You can read it <a href="https://medium.com/flutter-community/realtime-chat-app-flutter-node-js-socket-io-e298cd27fb06">here</a>. In this article I will be discussing about making a chat app in which you can chat one to one with someone.</p><p><strong>What will you learn?</strong></p><ul><li>Using socket.io to create a real-time connection between two devices</li><li>The concept of rooms and how to use them with socket.io</li><li>A bit of scoped model library 😅</li></ul><p><strong>Prerequisites</strong></p><p>The following should be installed and running in your PC.</p><ul><li>Node.js : <a href="https://nodejs.org/en/download/">https://nodejs.org/en/download/</a></li><li>Flutter : <a href="https://flutter.dev/docs/get-started/install">https://flutter.dev/docs/get-started/install</a></li><li>Heroku CLI : <a href="https://devcenter.heroku.com/articles/heroku-cli">https://devcenter.heroku.com/articles/heroku-cli</a></li><li>git : <a href="https://git-scm.com/downloads">https://git-scm.com/downloads</a></li></ul><h3><strong>Rooms</strong></h3><p>Rooms are logical grouping mechanism which can be used to target only a specific socket and not all of them.</p><p>Lets understand it in simple figures :</p><p>Previously one user was sending a message and the server broadcasted it to all the other users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Va3NRj5QXg0QZMvt7-GMpw.png" /><figcaption>Before using room</figcaption></figure><p>After using rooms the server only sends the message to the particular room.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4hBlqqG3gG7E5dD6syzy4Q.png" /><figcaption>After using room</figcaption></figure><p>This way we can achieve one to one chat using rooms. So let’s get started.</p><h3><strong>Node.js (Server-Side)</strong></h3><p>Create a new node project and install the following dependencies:</p><ul><li>express</li><li>http</li><li>nodemon</li><li>socket.io</li></ul><p>Go to <strong>package.json </strong>and add the <strong>dev </strong>script:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*EMbJnRl2LPlIE8NV0W104Q.png" /><figcaption><strong>dev </strong>script in <strong>package.json</strong></figcaption></figure><p>Next in the <strong>index.js</strong> file add the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dab1b0d1952a62b705f9d3303d048f03/href">https://medium.com/media/dab1b0d1952a62b705f9d3303d048f03/href</a></iframe><p>Every user connected to our server has a particular chatID and that user joins the room with the same chatID. Thus if anyone wants to send message to a particular user he targets their chatID.</p><p>Now that our server side code is completed lets deploy it to <strong>Heroku</strong>.</p><p>Create a new file in the root directory named <strong>Procfile </strong>and add the following line</p><pre>web: node index.js</pre><p>Next create a file named <strong>.gitignore </strong>and add the following line</p><pre>/node_modules</pre><p>After this initialize git and commit all the contents. Next create a new heroku app and push the contents to the master branch. If you face any issues, you can refer to my <a href="https://medium.com/flutter-community/realtime-chat-app-flutter-node-js-socket-io-e298cd27fb06">previous blog</a> or the heroku <a href="https://devcenter.heroku.com/articles/git">documentation</a>. After successful deployment we will get the url of our node server.</p><h3><strong>Flutter (Client-Side)</strong></h3><p>Now that our backend is up and running, its time to create the flutter app. Create a new flutter project and add the following dependencies in <strong>pubspec.yaml </strong>file :</p><ul><li>scoped_model: ^1.0.1</li><li>flutter_socket_io: ^0.6.0</li></ul><p>Let’s create our two data classes <strong>Message.dart </strong>and <strong>User.dart</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9913517d46eaa0be6748fe636245d1a7/href">https://medium.com/media/9913517d46eaa0be6748fe636245d1a7/href</a></iframe><p>Next create the <strong>ChatModel.dart</strong> where all the logic for socket and all the data will be stored.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/00f4b324de59180ff4f0ccf42b713a3c/href">https://medium.com/media/00f4b324de59180ff4f0ccf42b713a3c/href</a></iframe><p>The <strong>ChatModel </strong>class contains dummy data of all the users, the current user and the friend list of that user (which is all the users except the current user). It also contains all the messages. There are there methods in it.</p><ul><li><strong>init() : </strong>For initializing all the variables and also initializing the socket and adding listeners to the socket.</li><li><strong>sendMessage() : </strong>Sending message to the server and adding it to the list of messages.</li><li><strong>getMessagesForChatID()</strong>: Extracting the messages from the message list which are relevant to the current conversation.</li></ul><p>Next let’s create <strong>AllChatsPage.dart. </strong>This will be the page where all the users will be displayed.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ad2cd4ded89ad2f5aa054d0ce5bda1a/href">https://medium.com/media/2ad2cd4ded89ad2f5aa054d0ce5bda1a/href</a></iframe><p>The <strong>init()</strong> in the <strong>ChatModel </strong>is called from the <strong>initState()</strong> of <strong>AllChatsPage</strong>, thus initializing our app on start.</p><p>Create the <strong>ChatPage.dart</strong> where the messages will be displayed.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ff6e111d360f6665c4e642364113f5d7/href">https://medium.com/media/ff6e111d360f6665c4e642364113f5d7/href</a></iframe><p>Finally open <strong>main.dart </strong>and replace the existing code with the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c97fa387a3a0d4dc0c2d0fe03d436901/href">https://medium.com/media/c97fa387a3a0d4dc0c2d0fe03d436901/href</a></iframe><h3><strong>How to test if its working?</strong></h3><p>Build and run the app in one device. Then open the ChatModel.dart and in the init() method initialize currentUser with someone else. Example:</p><pre>currentUser=users[1]</pre><p>Rebuild and run the app in another device. Now you can chat with the other person. 😄</p><blockquote><strong>What’s next?</strong></blockquote><blockquote><strong>Build a cool UI for the app. Remove the dummy users list and store the user in some database. Also try to implement online status for a particular user.</strong></blockquote><blockquote><strong>Quick tip : Check for the number of users in the particular room.</strong></blockquote><p><strong>If you face any problem, you can check out my github repo :</strong></p><ul><li><a href="https://github.com/ibtesam123/chat-app-2-flutter">ibtesam123/chat-app-2-flutter</a></li><li><a href="https://github.com/ibtesam123/chat-app-2-node">ibtesam123/chat-app-2-node</a></li></ul><p>Don’t forget to star ⭐ the repo and give claps 👏 if you liked the article. If you have any queries you can ask in comments. Thank you 😄</p><p><a href="https://www.twitter.com/FlutterComm">https://www.twitter.com/FlutterComm</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=acd4152c6a00" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flutter-community/realtime-chat-app-one-to-one-using-flutter-socket-io-node-js-acd4152c6a00">Realtime Chat App - One-to-One using Flutter, Socket.io &amp; Node.js</a> was originally published in <a href="https://medium.com/flutter-community">Flutter Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Realtime Chat App — Flutter, Node.js & Socket.io]]></title>
            <link>https://medium.com/flutter-community/realtime-chat-app-flutter-node-js-socket-io-e298cd27fb06?source=rss-24b035320fd6------2</link>
            <guid isPermaLink="false">https://medium.com/p/e298cd27fb06</guid>
            <category><![CDATA[heroku]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[socketio]]></category>
            <category><![CDATA[real-time-chat]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Ibtesam Ansari]]></dc:creator>
            <pubDate>Fri, 20 Dec 2019 17:12:18 GMT</pubDate>
            <atom:updated>2020-05-11T12:37:30.490Z</atom:updated>
            <content:encoded><![CDATA[<h3>Realtime Chat App — Flutter, Node.js &amp; Socket.io</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/338/1*GuCGH4vKxRNiujUo4NeP1w.jpeg" /></figure><p>In this blog we will see how to make a realtime chat app using <strong>Node.js</strong> as the backend and <strong>Flutter </strong>as the frontend. We will use sockets to communicate between devices.</p><p><strong>Prerequisites</strong></p><p>The following should be installed and running in your PC.</p><ul><li>Node.js : <a href="https://nodejs.org/en/download/">https://nodejs.org/en/download/</a></li><li>Flutter : <a href="https://flutter.dev/docs/get-started/install">https://flutter.dev/docs/get-started/install</a></li><li>Heroku CLI : <a href="https://devcenter.heroku.com/articles/heroku-cli">https://devcenter.heroku.com/articles/heroku-cli</a></li><li>git : <a href="https://git-scm.com/downloads">https://git-scm.com/downloads</a></li></ul><h3>Nodejs (Server-Side)</h3><p>Create a folder named <strong>real_chat_node </strong>and open it in the terminal. Then run the following command:</p><pre>\real_chat_node&gt; <strong>npm init</strong></pre><p>Accept the defaults by pressing Enter. Next install the required packages through <strong>npm</strong>,<strong> </strong>which is available by default when you install node.</p><pre>\real_chat_node&gt; <strong>npm install express</strong><br>\real_chat_node&gt; <strong>npm install</strong> <strong>nodemon<br></strong>\real_chat_node&gt; <strong>npm install http<br></strong>\real_chat_node&gt; <strong>npm install socket.io</strong></pre><p>Open the folder with your favourite IDE. Then go to <strong>package.json </strong>and in scripts add a <strong>dev </strong>key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/1*7nzwOQP5pYeRYuhpY3m7hQ.png" /></figure><p>Next create a <strong>index.js</strong> file in your root directory. Write the following code in it.</p><pre>const app = require(&#39;express&#39;)()<br>const http = require(&#39;http&#39;).createServer(app)<br></pre><pre>app.get(&#39;/&#39;, (req, res) =&gt; {<br>   res.send(&quot;Node Server is running. Yay!!&quot;)<br>})</pre><pre>http.listen(8080)</pre><p>On your terminal type the following command:</p><pre>\real_chat_node&gt; <strong>npm run dev</strong></pre><p>Leave it running and go to <a href="http://localhost:8080/"><strong>http://localhost:8080</strong></a><strong> </strong>and you will get the message.</p><p>Now lets add socket in our nodejs app.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fa22cae310f954463816a2c4eca92131/href">https://medium.com/media/fa22cae310f954463816a2c4eca92131/href</a></iframe><p>The <strong>connection</strong> event is triggered whenever a socket is connected to our app. We then add a listener to the <strong>send_message </strong>event which forwards any data that is sent to it to <strong>receive_message </strong>event.</p><p><em>Voila!! Our backend is ready. Let’s deploy it to heroku and then we can start our Flutter app.</em></p><blockquote><strong>Quick Note: The following are the ways to send and listen on events.</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*fNrtU4TpdWFwyXOxzPlFNQ.png" /></figure><h3>Heroku (Deployment)</h3><p>Heroku is a cloud platform which will deploy our app so that we can access it from anywhere though a url. Let’s get started.</p><p>Before we deploy our app, we just need to make few changes.</p><ol><li>In <strong>index.js</strong> file replace port 8080 with <em>process.env.PORT.</em></li></ol><pre>http.listen(process.env.PORT)</pre><p>2. Create a file named <strong>Procfile </strong>in the root directory and write the following in it.</p><pre>web: node index.js</pre><p>3. Also create a <strong>.gitignore </strong>file and add the folowing</p><pre>/node_modules</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*ssgP-pRF8Uq6bUB09MroJA.png" /><figcaption>Added .gitignore and Procfile</figcaption></figure><p>4. Next open the root directory in your terminal and setup heroku cli</p><pre>\real_chat_node&gt; <strong>heroku login</strong></pre><p>You will be asked to login in. Enter your credentials and you are good to go.</p><p>5. Now create your heroku app</p><pre>\real_chat_node&gt; <strong>heroku create &lt;your-app-name-here&gt;</strong></pre><p>6. Now initialize git and commit everything to <strong>heroku master</strong>.</p><pre>\real_chat_node&gt; <strong>git init</strong><br>\real_chat_node&gt; <strong>git add .<br></strong>\real_chat_node&gt; <strong>git commit -m &quot;Initial Commit&quot;<br></strong>\real_chat_node&gt; <strong>git push heroku master</strong></pre><p>Wait for it to finish and done. You can go to the url generated to see the same message as earlier.</p><p><em>Note: Use your own url that will be generated.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*fnq9gxWN5dCw2hNW5ZOWZQ.png" /></figure><p>We will use the url for connecting in our flutter app.</p><h3>Flutter (Client-Side)</h3><p>So our backend part is complete and now its time to start making our chat app in Flutter.</p><p>Open your terminal and type in the following command to create our flutter app.</p><pre>flutter create --androidx real_chat_flutter</pre><p>After the project is created open the folder in your IDE.</p><p>In your <strong>pubspec.yaml</strong> file add the following dependency</p><pre>dependencies:<br>  flutter:<br>    sdk: flutter<br>  cupertino_icons: ^0.1.2<br>  <strong>flutter_socket_io: ^0.6.0</strong>  <em>//Add this dependency</em></pre><p>Open the <strong>main.dart </strong>in the lib folder and delete all the code and add the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/602862b4a46aee7a317f29c8585017e8/href">https://medium.com/media/602862b4a46aee7a317f29c8585017e8/href</a></iframe><p>Now we have to create the ChatPage. Create <strong>ChatPage.dart</strong> file inside lib folder. Lets write the code for our Chat Page.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/104bd7fd56b27a8acdd71c417be3d8c9/href">https://medium.com/media/104bd7fd56b27a8acdd71c417be3d8c9/href</a></iframe><p>Now run the app in two devices and chat back and forth 😄.</p><blockquote><em>What’s next?<br>Now that the working is implemented, try to create a nice UI for the app. Also don’t forget that you can send more values in JSON data. So try sending username and the message as JSON data and display them accordingly. Check out my next </em><a href="https://medium.com/@ibtesamansari070/realtime-chat-app-one-to-one-using-flutter-socket-io-node-js-acd4152c6a00"><em>article</em></a><em> for one-to-one chat using socket.io.</em></blockquote><p><strong>If you face any problem, you can check out my github repo :</strong></p><ul><li><a href="https://github.com/ibtesam123/real_chat_flutter">ibtesam123/real_chat_flutter</a></li><li><a href="https://github.com/ibtesam123/real_chat_node">ibtesam123/real_chat_node</a></li></ul><p>Don’t forget to star ⭐ the repo and give claps 👏 if you liked the article. If you have any queries you can ask in comments. Thank you 😄</p><p><a href="https://www.twitter.com/FlutterComm">JavaScript is not available.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e298cd27fb06" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flutter-community/realtime-chat-app-flutter-node-js-socket-io-e298cd27fb06">Realtime Chat App — Flutter, Node.js &amp; Socket.io</a> was originally published in <a href="https://medium.com/flutter-community">Flutter Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>