<?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 Rumaan Khalander on Medium]]></title>
        <description><![CDATA[Stories by Rumaan Khalander on Medium]]></description>
        <link>https://medium.com/@rumaankalander?source=rss-6fe74e031e41------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jPtvGsW80bonDxjLdPEb5g.jpeg</url>
            <title>Stories by Rumaan Khalander on Medium</title>
            <link>https://medium.com/@rumaankalander?source=rss-6fe74e031e41------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 01:27:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rumaankalander/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[Drawing Custom Shapes in Flutter using CustomPainter]]></title>
            <link>https://medium.com/@rumaankalander/drawing-custom-shapes-in-flutter-using-custompainter-47be782b697?source=rss-6fe74e031e41------2</link>
            <guid isPermaLink="false">https://medium.com/p/47be782b697</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[custom-paint]]></category>
            <category><![CDATA[apps]]></category>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[draw-custom-shapes]]></category>
            <dc:creator><![CDATA[Rumaan Khalander]]></dc:creator>
            <pubDate>Tue, 22 Jan 2019 17:10:50 GMT</pubDate>
            <atom:updated>2019-01-22T17:17:36.410Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1zzGbMA7MfBgxXan.png" /></figure><h4>Brief intro about Flutter</h4><p>Flutter is a Mobile UI framework by Google which allows developers to create beautiful apps in record time for both iOS and Android with a single codebase. Most talked about feature that Flutter comes with is “Hot Reload” that allows blazing fast reload times (without actually loosing the current state of the app)</p><p><em>This article assumes that you are already familiar with or at least have an understanding of building a basic Flutter App with simple nested widgets.</em></p><h4>Custom Shapes</h4><p>Apart from inbuilt or trivial widgets that Flutter Framework provides like a Text Widget, a RaisedButton or a Container for bare bones what if we want to draw a custom button that has a custom shape or you just simply want to bring out that inner artist in you, Flutter makes it a breeze to draw these custom artistic shapes.</p><figure><img alt="Custom Lines draw using CustomPainter in flutter." src="https://cdn-images-1.medium.com/max/381/0*RqBv8Xg5bz7CaXoJ.png" /></figure><p>Custom Lines</p><figure><img alt="Custom Shapes and Curves drawn using CustomPainter in Flutter" src="https://cdn-images-1.medium.com/max/392/0*DsJnmwbmTXeDoAD2.png" /></figure><p>Custom Shapes and Custom Curves</p><h4>Let’s get started with making some simple custom shapes</h4><p>Step 1: Create a new Flutter Project</p><p>Run the following command in your Terminal/Command prompt</p><p>flutter create custom_shapes</p><p>This will create a new flutter project and set up all the dependencies for you. After its done just open the folder in your preferred code editor. I will be using VSCode throughout this article for this project.</p><p>You can see the basic material app code that flutter generated for you in the lib/main.dart file. To run the app in emulator or your phone just goto Command Pallet (Command/Control + Shift + P) and type “Flutter: Select Device” and choose the device in which you would like to run the app. Goto Debug -&gt; Start Without Debugging to start compiling and running the app on the chosen device.</p><figure><img alt="Selecting the device option from the VSCode Command Pallete" src="https://cdn-images-1.medium.com/max/740/0*JYuwKaY0pCzwT3sT.png" /></figure><p>Flutter: Select Device</p><figure><img alt="Selecting the Device on which the app will run on from the list of devices connected in VSCode" src="https://cdn-images-1.medium.com/max/740/0*8skZVVSeKMjvhWNg.png" /></figure><p>List of Emulators or devices connected</p><figure><img alt="Start the app without debugging option in VSCode to run the flutter app" src="https://cdn-images-1.medium.com/max/740/0*pye0xUlM0WE4Rupv.png" /></figure><p>Running the app on chosen device</p><p>Step 2: Creating a Base UI</p><p>Let’s remove all the unwanted code from the <em>main.dart</em> file and start from the beginning with a bare minimum app screen that has a simple scaffold with an AppBar having the title.</p><pre>import &#39;package:flutter/material.dart&#39;;<br><br>void main() =&gt; runApp(HomePage());<br><br>class HomePage extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      theme: ThemeData(<br>        brightness: Brightness.dark,<br>        accentColor: Colors.deepOrangeAccent,<br>      ),<br>      home: Scaffold(<br>        appBar: AppBar(<br>          title: Text(&#39;Custom Shapes&#39;),<br>        ),<br>        body: Padding(<br>          padding: EdgeInsets.all(8.0),<br>          child: Container(),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><figure><img alt="Initial App screen when its run with all the widgets removed and just having a MaterialApp and a Scaffold with Container" src="https://cdn-images-1.medium.com/max/512/0*BSfJ07k_zspmmHun.png" /><figcaption>Initial Screen</figcaption></figure><p>Step 3: Let’s draw something</p><p>We will make use <a href="https://docs.flutter.io/flutter/widgets/CustomPaint-class.html">CustomPaint</a> Widget which allow us to draw things on the screen by making use of a CustomPainter object.</p><pre>CustomPaint(<br>  painter: MyCustomPainter(),<br>  child: Widget(),<br>  ....<br>)</pre><p>CustomPaint widget requires mainly two things, a <em>painter</em> and a <em>child widget</em>. The Custom paint uses the <em>painter</em> to paint/draw (ex: custom shapes) on the canvas after which it draws the child widget on top of it. Let’s add this CustomPaint Widget to our app and start drawing something.</p><pre>body: Padding(<br>          padding: EdgeInsets.all(8.0),<br>          child: CustomPaint(<br>            painter: ShapesPainter(),<br>            child: Container(height: 700,),<br>          ),<br>       ),</pre><p><em>ShapesPainter</em> is an instance of a class that extends <em>CustomPainter. </em>The <em>CustomPainter </em>class provides us with 2 methods to override.</p><pre>class ShapesPainter extends CustomPainter {<br>  @override<br>  void paint(Canvas canvas, Size size) {<br>    // TODO: implement paint<br>  }<br><br>  @override<br>  bool shouldRepaint(CustomPainter oldDelegate) {<br>    // TODO: implement shouldRepaint<br>    return null;<br>  }<br>}</pre><p>The <em>shouldRepaint</em> method is used to optimise repaints and basically tell whether the widget needs to be repainted if this properties change. You can read more about that <a href="https://docs.flutter.io/flutter/rendering/CustomPainter/shouldRepaint.html">here</a>.</p><p>The <em>paint </em>method is where the real magic happens. This method comes with two parameters. A canvas and the Size of the canvas (or boundaries). We <strong><em>draw</em></strong><em> </em>stuffs <strong>on</strong> this <strong><em>Canvas</em></strong> using a <strong><em>Paint </em></strong>object which can be created and customised as required. The <em>paint </em>can have various properties like color, shader, style etc. more about it <a href="https://docs.flutter.io/flutter/dart-ui/Paint-class.html">here</a>.</p><p>So to just sum it all up, we use a paint (more like a brush) and draw stuffs on the Canvas that we have been provided with which has some width and height. It’s similar to how we draw something on a piece of paper using a pencil. Here the paper would have definite width and height (that would be the Canvas object here) and the pencil that we used to draw might have different levels of darkness and color etc. (that would be our Paint object here).</p><p>The <a href="https://docs.flutter.io/flutter/dart-ui/Canvas-class.html">canvas</a> object comes with some helper methods like drawCircle, drawRect etc. to draw a circle and draw a rectangle. All the draw..() methods in the canvas requires a paint object.</p><p>Let’s create a simple paint object which has a color of Colors.deepOrange and draw a circle on the canvas.</p><pre>class ShapesPainter extends CustomPainter {<br>  @override<br>  void paint(Canvas canvas, Size size) {<br>    final paint = Paint();<br>    // set the color property of the paint<br>    paint.color = Colors.deepOrange;<br><br>    // center of the canvas is (x,y) =&gt; (width/2, height/2)<br>    var center = Offset(size.width / 2, size.height / 2);<br>    <br>    // draw the circle on centre of canvas having radius 75.0<br>    canvas.drawCircle(center, 75.0, paint);<br>  }<br><br>  @override<br>  bool shouldRepaint(CustomPainter oldDelegate) =&gt; false;<br>}</pre><figure><img alt="A Custom Orange circle drawn on the middle of the canvas" src="https://cdn-images-1.medium.com/max/512/0*_pKQ46GksWIz09D9.png" /><figcaption>Custom Drawn Circle at the center of canvas</figcaption></figure><p><em>canvas.drawCircle(…)</em> method takes in three parameters, the centre of the circle, the radius and the paint object to be used. Here, we draw the circle at the centre of the canvas. We find the centre using <em>size.width</em> and <em>size.height</em> from the Size object which returns the width and height of the canvas.</p><p>The <em>shouldRepaint</em> method here just returns <em>false </em>since we don’t have any fields/values that might change and influence the custom shapes that we draw.</p><p>Now let’s draw a simple white rectangle which spans to the entire width and height of the canvas. We can use the <em>canvas.drawRect(..)</em> method to do so. The <em>drawRect()</em> method takes <a href="https://docs.flutter.io/flutter/dart-ui/Rect-class.html">Rect</a> object and a <em>paint</em>. We can create an instance of Rect object in various ways. We’ll use <a href="https://docs.flutter.io/flutter/dart-ui/Rect/Rect.fromLTWH.html"><em>Rect.fromLTWH()</em></a><em>, </em>where LTWH stands for Left, Top, Width and Height which means the initial (x,y) point that we start from or the left-topmost point of the rectangle and the width and height of the rectangle that would be added to left and top points which forms the required rectangle.</p><pre>@override<br>  void paint(Canvas canvas, Size size) {<br>    final paint = Paint();<br><br>    // set the color property of the paint<br>    paint.color = Colors.deepOrange;<br><br>    // center of the canvas is (x,y) =&gt; (width/2, height/2)<br>    var center = Offset(size.width / 2, size.height / 2);<br><br>    // draw the circle with center having radius 75.0<br>    canvas.drawCircle(center, 75.0, paint);<br><br>    // set the paint color to be white<br>    paint.color = Colors.white;<br>    <br>    // Create a rectangle with size and width same as the canvas<br>    var rect = Rect.fromLTWH(0, 0, size.width, size.height);<br><br>    // draw the rectangle using the paint<br>    canvas.drawRect(rect, paint);<br>  }</pre><figure><img alt="Custom White Rectangle drawn which spans to the canvas width and height but its drawn above the orange circle" src="https://cdn-images-1.medium.com/max/512/0*MZyxwRvvSyJJW436.png" /><figcaption>White Rectangle</figcaption></figure><p>But wait, where is the circle?</p><p>Well, the circle hasn’t gone anywhere. It’s just hidden behind the rectangle. This brings up an important characteristic of drawing using CustomPainter here. The <em>order how you write</em> the draw commands matter. If you look at the code closely, the drawCircle() function is called first and after that the drawRect(). So, the circle will be drawn on the canvas first and then the rectangle. We can easily fix (since we want the circle on the rectangle) that by just moving the drawCircle() function after the drawRect().</p><pre>@override<br>  void paint(Canvas canvas, Size size) {<br>    final paint = Paint();<br><br>    // set the paint color to be white<br>    paint.color = Colors.white;<br>    <br>    // Create a rectangle with size and width same as the canvas<br>    var rect = Rect.fromLTWH(0, 0, size.width, size.height);<br><br>    // draw the rectangle using the paint<br>    canvas.drawRect(rect, paint);<br><br>    // set the color property of the paint<br>    paint.color = Colors.deepOrange;<br><br>    // center of the canvas is (x,y) =&gt; (width/2, height/2)<br>    var center = Offset(size.width / 2, size.height / 2);<br><br>    // draw the circle with center having radius 75.0<br>    canvas.drawCircle(center, 75.0, paint);<br>  }</pre><figure><img alt="The Orange circle drawn over the white rectangle after fixing the code." src="https://cdn-images-1.medium.com/max/512/0*A_13VTSTMHVQnxgL.png" /><figcaption>Orange Circle over the white rectangle</figcaption></figure><p>Looks good! Now let’s draw a custom path and wrap this up!</p><p>To draw a custom path we’ll use drawPath() method from the canvas. We’ll draw a path from <em>top-left(0,0)</em> to <em>bottom-left(0, size.height)</em> to <em>top-right(size.width, 0) </em>which forms a simple triangle.</p><p>To do this we’ll have to use a <a href="https://docs.flutter.io/flutter/dart-ui/Path-class.html"><em>Path</em></a> object to represent the path that we draw. The way we draw the path is quite simple. Whenever we initialise a path object i.e path = Path(), the initial point defaults to (0,0) i.e top-left off the screen. The coordinate system of the canvas looks something like this.</p><figure><img alt="Coordinate system in the Flutter canvas" src="https://cdn-images-1.medium.com/max/634/0*pLR8MbwA2EYgwxwW.png" /><figcaption>Coordinate system</figcaption></figure><p>We can use the lineTo() method to create a line from (x,y) to (x1, y1). Here it would be from (0,0) which is initialised by default, to (0, size.height) which is the bottom-left of the canvas. Finally we use close() to close the path which will forms a triangle.</p><pre>paint.color = Colors.yellow;<br><br>// create a path<br>var path = Path();<br>path.lineTo(0, size.height);<br>path.lineTo(size.width, 0);<br>// close the path to form a bounded shape<br>path.close();</pre><figure><img alt="A yellow path drawn on canvas that makes up a triangle" src="https://cdn-images-1.medium.com/max/512/0*ky1GisiS6BxcPdJ7.png" /><figcaption>Yellow path</figcaption></figure><p>Let’s move the code that draws the circle to the end so that it’s layered on top of all the other shapes.</p><p>Here’s the entire code.</p><pre>import &#39;package:flutter/material.dart&#39;;<br><br>void main() =&gt; runApp(HomePage());<br><br>class HomePage extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      theme: ThemeData(<br>        brightness: Brightness.dark,<br>        accentColor: Colors.deepOrangeAccent,<br>      ),<br>      home: Scaffold(<br>        appBar: AppBar(<br>          title: Text(&#39;Custom Shapes&#39;),<br>        ),<br>        body: Padding(<br>          padding: EdgeInsets.all(8.0),<br>          child: CustomPaint(<br>            painter: ShapesPainter(),<br>            child: Container(<br>              height: 700,<br>            ),<br>          ),<br>        ),<br>      ),<br>    );<br>  }<br>}<br><br>class ShapesPainter extends CustomPainter {<br>  @override<br>  void paint(Canvas canvas, Size size) {<br>    final paint = Paint();<br><br>    // set the paint color to be white<br>    paint.color = Colors.white;<br><br>    // Create a rectangle with size and width same as the canvas<br>    var rect = Rect.fromLTWH(0, 0, size.width, size.height);<br><br>    // draw the rectangle using the paint<br>    canvas.drawRect(rect, paint);<br><br>    paint.color = Colors.yellow;<br><br>    // create a path<br>    var path = Path();<br>    path.lineTo(0, size.height);<br>    path.lineTo(size.width, 0);<br>    // close the path to form a bounded shape<br>    path.close();<br><br>    canvas.drawPath(path, paint);<br><br>    // set the color property of the paint<br>    paint.color = Colors.deepOrange;<br><br>    // center of the canvas is (x,y) =&gt; (width/2, height/2)<br>    var center = Offset(size.width / 2, size.height / 2);<br><br>    // draw the circle with center having radius 75.0<br>    canvas.drawCircle(center, 75.0, paint);<br>  }<br><br>  @override<br>  bool shouldRepaint(CustomPainter oldDelegate) =&gt; false;<br>}</pre><figure><img alt="Final app with a white rectangular background and yellow triangle path and an orange circle on top all of which drawn on the canvas." src="https://cdn-images-1.medium.com/max/512/0*VRCog44RjrjktxPw.png" /><figcaption>Final App with custom shapes</figcaption></figure><p>Play around with the code and try new shapes and colors and what not.</p><p>You can find the code <a href="https://github.com/rumaan/custom_shapes_flutter">here</a> in this GitHub repo.</p><p>🤤</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=47be782b697" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting started with Android Development [Java] — Make your first Android App]]></title>
            <link>https://medium.com/@rumaankalander/getting-started-with-android-development-java-make-your-first-android-app-45375be0641b?source=rss-6fe74e031e41------2</link>
            <guid isPermaLink="false">https://medium.com/p/45375be0641b</guid>
            <category><![CDATA[apps]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[application]]></category>
            <category><![CDATA[android-studio]]></category>
            <dc:creator><![CDATA[Rumaan Khalander]]></dc:creator>
            <pubDate>Sun, 14 Jan 2018 06:50:37 GMT</pubDate>
            <atom:updated>2018-07-25T12:48:14.569Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9WcS3fX3K3mXZede.png" /></figure><p>Have an excellent idea that you want to turn up into an app or you’re just a beginner who wants to get started with Android development.</p><p>Here are a few steps to hop right in:</p><p>First things first is you will need an IDE(Integrated Development Environment)</p><p>Back in the days people used to use Eclipse for developing Android Apps but Google has its own IDE now called <a href="https://developer.android.com/studio/index.html">Android Studio</a></p><p>and it’s available for multiple platforms like Windows, macOS, Linux.</p><p>You can download and install it from <a href="https://developer.android.com/studio/index.html">here</a>.</p><p>After you’ve done installing and setting up Android Studio.</p><p>1.Open Android Studio and at this page select ‘Start a new Android Studio Project’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/0*VAuNyIYy-0zU62Gu.png" /></figure><p>2. Choose your Application name — [This is the name of the app and it’s going to show up in the App launcher]</p><p>Set the company domain — [Leave it as is]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*w5PrXdWdFtRcl91A.png" /></figure><p>Choose the project location — [Where the project and its files must be saved]</p><p>Leave the other options as is. [For now 😜]</p><ol><li>Select Phone and Tablet and choose the API level [for now leave this as is] and hit next.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*dh6GAvkNpcscDUTT.png" /></figure><ol><li>Choose Basic Activity or Empty Activity and hit next. This is actually the template for the App [More on this coming soon😇]</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*paPkBElxRPvbPqZK.png" /></figure><ol><li>Leave the options as is [again, for time being 😉] and hit next!</li><li>Let Android Studio build the project and set everything up for you [Based of your system configuration it should take about a minute or two]. Be patient and let Android Studio do its <em>“thing”</em>. After its done, look to the top right and you should see this.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/0*oEmaAZOyPq4P6p9r.png" /></figure><p>Hit the <strong><em>Green Play</em></strong> button.</p><ol><li>When this window pops up, plug in your Phone [or if you’re using an Emulator, start it] and select the phone the list and hit <strong>OK</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/0*D-CEos1dvkWfZyNA.png" /></figure><p>If your device doesn’t show up make sure,</p><ol><li>Your USB cable is working fine</li><li>USB debugging is enabled in the Developer Options [Read further to know how?]</li><li>Install drivers for your phone [Just Google ‘**Your phone**drivers’]</li></ol><p>To enable USB debugging [on Stock/Vanilla Android], open ‘Settings App’ and goto ‘About Phone’, and find ‘Build Number’ and tap on it several times until you see something like, ‘You’re <strong>x</strong> steps away from becoming a Developer’. Keep tapping it until you see the message ‘You’re a developer now’ or something like that. Head back into settings and you’ll see that a new section called ‘Developer Options’ is available now. Tap on it and scroll down a little and find ‘Android Debugging’ and enable it. If any warning messages pop up just ignore and hit OK. Now your phone should show up on the Android Studio Deployment Target screen.</p><p>When you select your phone and Hit OK, Android Studio should start building/compiling your app. Meanwhile if there’s a pop up on your screen saying ‘this PC wants to use this device for USB debugging’ or something similar, just choose always allow and hit allow.</p><p>After Build/Compile is done you should see your App running on your device!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/503/0*tOguC1QSOu9ZMkG2.png" /></figure><p>Congrats! You’ve just build your first Android App.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45375be0641b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>