<?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 Ruban Raghavendar K on Medium]]></title>
        <description><![CDATA[Stories by Ruban Raghavendar K on Medium]]></description>
        <link>https://medium.com/@rubanraghavendar?source=rss-890732543ff2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*WDWoHmYp6FTkgZkT7TYltg.jpeg</url>
            <title>Stories by Ruban Raghavendar K on Medium</title>
            <link>https://medium.com/@rubanraghavendar?source=rss-890732543ff2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 18:10:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rubanraghavendar/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[ReactJS — A Complete Learning Guide for Beginners]]></title>
            <link>https://rubanraghavendar.medium.com/reactjs-a-complete-learning-guide-for-beginners-624d12433168?source=rss-890732543ff2------2</link>
            <guid isPermaLink="false">https://medium.com/p/624d12433168</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[hooks]]></category>
            <dc:creator><![CDATA[Ruban Raghavendar K]]></dc:creator>
            <pubDate>Thu, 29 May 2025 05:34:07 GMT</pubDate>
            <atom:updated>2025-05-29T05:34:07.011Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>ReactJS — A Complete Learning Guide for Beginners</strong></h3><p>A Javascript Library</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3M8OpMfN4Go1sB07" /><figcaption>REACTJS</figcaption></figure><p><strong>ReactJS</strong> is a free and open-source JavaScript library developed by Facebook in 2011. It’s widely used for building user interfaces (UIs), especially single-page applications (SPAs). React empowers developers to create fast, modular, and scalable front-end applications using components.</p><blockquote>📦 <strong>What is React?</strong></blockquote><p>React is a <strong>component-based</strong> library that helps developers build <strong>modular and reusable UIs</strong>. Components in React work similarly to JavaScript functions, but they return JSX — a syntax extension that resembles HTML.</p><p><strong><em>Write once, use anywhere:</em></strong><em> Once you learn React, you can build web apps, mobile apps (with React Native), desktop apps (with Electron), and even VR apps.</em></p><blockquote>🧩 <strong>Component Model:</strong></blockquote><p>A <strong>component</strong> is a piece of UI with its own logic and appearance. Components can be:</p><ul><li>As small as a button</li><li>As large as an entire page</li></ul><p>Each component is <strong>independent and reusable</strong>. They serve the same purpose as functions in JS but return HTML or JSX.</p><blockquote>🌐 <strong>Multi-Platform Development</strong></blockquote><p>React isn’t limited to the browser. You can use React to build:</p><ul><li>Web applications</li><li>Mobile apps (React Native)</li><li>Desktop apps (Electron)</li><li>Virtual Reality experiences (React VR)</li></ul><blockquote>🧬 <strong>JSX — JavaScript XML</strong></blockquote><p>JSX allows you to write HTML-like code inside your JavaScript. Although it looks like HTML, it’s ultimately JavaScript behind the scenes.</p><p><strong>Key Points:</strong></p><ul><li>Use className instead of class</li><li>Use htmlFor instead of for in form elements</li><li>JSX must return a <strong>single parent element</strong></li><li>Embed JavaScript expressions inside {}</li></ul><blockquote>📃 <strong>Rendering Lists</strong></blockquote><p>To render lists in React, use the map() function:</p><pre>const items = [&quot;Apple&quot;, &quot;Banana&quot;, &quot;Mango&quot;];<br>items.map((item) =&gt; &lt;li key={item}&gt;{item}&lt;/li&gt;);</pre><blockquote>🎁 <strong>Props</strong></blockquote><p><strong>Props (short for properties)</strong> are how data is passed from a <strong>parent</strong> component to a <strong>child</strong>.</p><ul><li>Passed like HTML attributes</li><li>Read-only</li><li>Enable component reuse</li></ul><blockquote>🔀 <strong>Conditional Rendering</strong></blockquote><p>React allows you to render content conditionally using:</p><ul><li>Ternary operator (condition ? true : false)</li><li>if statements inside functions</li></ul><blockquote>📦 <strong>State and Hooks</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*VVftzFBz20CWs9LE" /></figure><blockquote>🪝 <strong>useState</strong></blockquote><p>The useState() hook lets you manage local component state.</p><pre>const [count, setCount] = useState(0);</pre><blockquote>🪝 <strong>useEffect</strong></blockquote><p>Runs side effects like API calls or DOM manipulation.</p><pre>useEffect(() =&gt; {<br>  // runs after render<br>}, [dependencies]);</pre><blockquote>🪝 <strong>useContext</strong></blockquote><p>Avoid <strong>prop drilling</strong> by sharing global state:</p><pre>const MyContext = createContext();<br>const value = useContext(MyContext);</pre><blockquote>⚙️ <strong>Advanced React Hooks</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PPnAk6FUtVlknVrR.gif" /></figure><blockquote>1. <strong>useReducer</strong></blockquote><p>Great for complex state management (similar to Redux pattern).</p><pre>const [state, dispatch] = useReducer(reducerFn, initialState);</pre><blockquote><strong>2. </strong><strong>useRef</strong></blockquote><p>Used for:</p><ul><li>Referencing DOM elements</li><li>Storing mutable values that persist across renders</li></ul><pre>const inputRef = useRef();<br>inputRef.current.focus();</pre><blockquote><strong>3. </strong><strong>useImperativeHandle + </strong><strong>forwardRef</strong></blockquote><p>Expose custom methods from child components to the parent.</p><pre>useImperativeHandle(ref, () =&gt; ({<br>  focusInput: () =&gt; inputRef.current.focus(),<br>}));</pre><blockquote><strong>🎨 Layout and Style Hooks</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*qpSoPL9LawMU712Y.gif" /></figure><blockquote><strong>4. </strong><strong>useLayoutEffect</strong></blockquote><p>Same as useEffect, but fires <strong>before paint</strong>, ensuring DOM is ready.</p><pre>useLayoutEffect(() =&gt; {<br>  // sync layout before painting<br>});</pre><blockquote><strong>5. </strong><strong>useInsertionEffect</strong></blockquote><p>Inject styles before layout and paint to prevent FOUC (Flash of Unstyled Content).</p><pre>useInsertionEffect(() =&gt; {<br>  const style = document.createElement(&quot;style&quot;);<br>  style.textContent = `.myClass { color: red; }`;<br>  document.head.appendChild(style);<br>  return () =&gt; document.head.removeChild(style);<br>});</pre><blockquote><strong>🆔 </strong><strong>useId</strong></blockquote><p>Generates unique IDs useful for accessibility:</p><pre>const id = useId();<br>&lt;label htmlFor={id}&gt;Name&lt;/label&gt;<br>&lt;input id={id} /&gt;</pre><blockquote>⏳ <strong>Performance Optimization Hooks</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*2ZV5qUIEExfqpg2O" /></figure><blockquote><strong>useTransition</strong></blockquote><p>Defer non-urgent UI updates to prioritize fast interactions:</p><pre>const [isPending, startTransition] = useTransition();</pre><blockquote><strong>useDeferredValue</strong></blockquote><p>Used to delay the update of a value:</p><pre>const deferredQuery = useDeferredValue(query);</pre><blockquote><strong>🌍 External State Management</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MUjc0lxf6QRfYVfV.gif" /></figure><blockquote><strong>useSyncExternalStore</strong></blockquote><p>Subscribe to an external store (React 18+), useful for state managers like Redux:</p><pre>const storeValue = useSyncExternalStore(subscribe, getSnapshot);</pre><blockquote><strong>🧠 Memoization Hooks</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*Qshrdzo5DhFLMbI3.gif" /></figure><blockquote><strong>useMemo</strong></blockquote><p>Caches expensive calculations:</p><pre>const memoizedValue = useMemo(() =&gt; computeExpensiveValue(), [dependencies]);</pre><blockquote><strong>useCallback</strong></blockquote><p>Memoizes functions to prevent unnecessary re-renders:</p><pre>const memoizedFn = useCallback(() =&gt; doSomething(), [deps]);</pre><blockquote>✅ <strong>Final Words</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*CesXHtuHy6ejfQuZ.gif" /></figure><p>React Hooks have revolutionized the way we build components. With hooks, we can manage state, side effects, refs, and even performance optimization — all with functional components.</p><p>If you’re just starting with React, begin with useState, useEffect, and useContext. As you get more comfortable, explore advanced hooks like useReducer, useRef, and useTransition.</p><p>React gives you <strong>flexibility</strong>, <strong>power</strong>, and <strong>control</strong> — once you understand these hooks, there’s no limit to what you can build.</p><p><em>I hope this will be useful for you ✨</em></p><p><em>Thank you for reading🫂</em></p><p><em>See you soon👋</em></p><p><em>Until then, Signing off — </em><a href="https://www.linkedin.com/in/ruban-raghavendar-k/"><strong><em>Ruban</em></strong></a>❤️️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=624d12433168" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter — Expanded Vs Flexible]]></title>
            <link>https://rubanraghavendar.medium.com/flutter-expanded-vs-flexible-d528c71efbdb?source=rss-890732543ff2------2</link>
            <guid isPermaLink="false">https://medium.com/p/d528c71efbdb</guid>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flexible]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[responsive-design]]></category>
            <category><![CDATA[expanded]]></category>
            <dc:creator><![CDATA[Ruban Raghavendar K]]></dc:creator>
            <pubDate>Sat, 04 Jan 2025 09:44:47 GMT</pubDate>
            <atom:updated>2025-01-04T09:45:59.516Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flutter — Expanded Vs Flexible</h3><p>Understanding How to Make Your Widgets Fit Perfectly</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BLtb2Z4eZ8syDLL47C0pCQ.png" /></figure><p>Flutter provides powerful layout widgets that help you build responsive UIs. Among them, Expanded and Flexible are two commonly used widgets that allow you to control how a child widget takes up space within a Row, Column, or Flex.</p><p>In this blog, we’ll explore the differences between these two widgets and provide examples to help clarify their uses.</p><blockquote><strong>What is the </strong><strong>Expanded Widget?</strong></blockquote><p>The Expanded widget is a simple way to make a child widget fill the available space in a flex container. When you wrap a widget with Expanded, it takes up <strong>all the available space</strong>, sharing it with other Expanded widgets based on their flex property.</p><blockquote><strong>Key Features of </strong><strong>Expanded Widget:</strong></blockquote><ul><li><strong>Takes all available space:</strong> It expands to fill the parent widget’s available space.</li><li><strong>Flex property:</strong> You can specify a flex property to control how space is distributed among multiple Expanded widgets.</li></ul><blockquote><strong>Example of </strong><strong>Expanded Widget:</strong></blockquote><pre>import &#39;package:flutter/material.dart&#39;;<br><br>void main() {<br>  runApp(MyApp());<br>}<br><br>class MyApp extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      home: Scaffold(<br>        appBar: AppBar(title: Text(&#39;Expanded Example&#39;)),<br>        body: Column(<br>          children: [<br>            Expanded(<br>              child: Container(color: Colors.red),<br>            ),<br>            Expanded(<br>              child: Container(color: Colors.blue),<br>            ),<br>          ],<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>In this example, we have two Expanded widgets in a Column. Each Container will take equal space, and the screen will be divided equally among the two colors.</p><blockquote><strong>What is the </strong><strong>Flexible Widget?</strong></blockquote><p>The Flexible widget also allows a child to take space within a flex container, but it gives you more control over how the space is allocated. Unlike Expanded, Flexible does not force the child to fill the available space entirely. It allows the child to be smaller than the available space.</p><blockquote><strong>Key Features of </strong><strong>Flexible:</strong></blockquote><ul><li><strong>Flexible sizing:</strong> It allows the child widget to be smaller than the available space.</li><li><strong>Flex property:</strong> You can control how space is distributed among Flexible widgets with the flex property.</li></ul><pre>import &#39;package:flutter/material.dart&#39;;<br><br>void main() {<br>  runApp(MyApp());<br>}<br><br>class MyApp extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      home: Scaffold(<br>        appBar: AppBar(title: Text(&#39;Flexible Example&#39;)),<br>        body: Row(<br>          children: [<br>            Flexible(<br>              flex: 2,<br>              child: Container(color: Colors.red),<br>            ),<br>            Flexible(<br>              flex: 1,<br>              child: Container(color: Colors.green),<br>            ),<br>            Flexible(<br>              flex: 1,<br>              child: Container(color: Colors.blue),<br>            ),<br>          ],<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>In this example, we have three Flexible widgets in a Row. The red container takes twice as much space as the green and blue containers, which share the remaining space equally.</p><blockquote><strong>Key Differences Between </strong><strong>Expanded and </strong><strong>Flexible :</strong></blockquote><ol><li><strong>Space Occupation:</strong></li></ol><ul><li>Expanded forces the child to fill all available space.</li><li>Flexible allows the child to be smaller than the available space.</li></ul><p><strong>2. Use Case:</strong></p><ul><li>Use Expanded when you want a widget to take all the remaining space.</li><li>Use Flexible when you want to control how much space a widget takes without forcing it to fill all available space.</li></ul><blockquote><strong>For more understanding, see the below example:</strong></blockquote><pre>import &#39;package:flutter/material.dart&#39;;<br><br>void main() {<br>  runApp(MyApp());<br>}<br><br>class MyApp extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      home: Scaffold(<br>        appBar: AppBar(title: Text(&#39;Expanded and Flexible&#39;)),<br>        body: Center(<br>          child: Container(<br>            color: Colors.black,<br>            child: Column(<br>              mainAxisAlignment: MainAxisAlignment.center,<br>              children: [<br>                Expanded(<br>                  child: Container(<br>                    color: Colors.red,<br>                    child: Text(&quot;Expanded Text&quot;),<br>                  ),<br>                ),<br>                Flexible(<br>                  child: Container(<br>                    color: Colors.blue,<br>                    child: Text(&quot;Flexible Text&quot;),<br>                  ),<br>                ),<br>              ],<br>            ),<br>          ),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*hfgvKXjm1HZoXCcRvgCSVg.png" /></figure><blockquote><strong>In the above example:</strong></blockquote><ul><li>There is an black Container which contains a child column.</li><li>Inside the Column, children contains both Expanded and Flexible widgets.</li><li>Each widget contains an text widget, but the space allocation is different.</li><li>The Expanded widget takes all available spaces for it’s child, but the Flexible widget takes only the space needed for it’s child.</li><li>Both will work similar, but when the child comes, the space allocation may differ.</li></ul><blockquote><strong>Conclusion</strong></blockquote><p>Understanding the differences between Expanded and Flexible is essential for building responsive Flutter layouts. Use Expanded when you need widgets to fill available space completely, and Flexible when you want more control over the size of your widgets within a flex layout.</p><p>I hope this will be useful for you ✨</p><p>Thank you for listening🫂</p><p>See you soon👋</p><p>Until then, Signing off:</p><p><a href="https://www.linkedin.com/in/ruban-raghavendar-k/">Ruban</a>❤️️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d528c71efbdb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter — Developer — Part-2]]></title>
            <link>https://medium.com/yavar/flutter-developer-part-2-fb922bb177a7?source=rss-890732543ff2------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb922bb177a7</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-developer]]></category>
            <category><![CDATA[mobi̇le]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Ruban Raghavendar K]]></dc:creator>
            <pubDate>Tue, 09 Jul 2024 06:17:23 GMT</pubDate>
            <atom:updated>2024-07-16T09:00:51.310Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flutter — Developer — Part-2</h3><p>Flutter: Complete Roadmap Series…</p><p>Hello, my friend, Welcome back to my Flutter Roadmap series if you missed my “<a href="https://medium.com/yavar/flutter-developer-part-1-ca12c362d55a"><strong>Flutter — Developer — Part-1</strong></a>” then please complete that and come back…</p><blockquote><strong>Control Flow Statements:</strong></blockquote><p>Control flow statements are used to control the flow of execution of a program. The following are the main types of control flow statements in Dart:</p><ul><li>if-else: used to conditionally execute code based on a boolean expression.</li><li>for loop: used to repeat a block of code a specific number of times.</li><li>while loop: used to repeat a block of code as long as a given condition is true.</li><li>do-while loop: similar to the while loop, but the block of code is executed at least once before the condition is evaluated.</li><li>switch-case: used to select one of several code blocks to execute based on a value.</li><li>break: used to exit a loop early.</li><li>continue: used to skip the current iteration of a loop and continue with the next one.</li></ul><p>These control flow statements can be used to create complex logic and control the flow of execution in Dart programs.</p><blockquote><strong>Loops:</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*2Hm-8CYeAnritxDmorbPjg.gif" /></figure><p><strong>For Loop:</strong></p><p>A for loop is a control flow structure that allows you to execute a block of code repeatedly for a specified number of times. Dart provides several variations of the for loop to suit different looping scenarios.</p><p>Here’s the basic syntax of a for loop in Dart:</p><pre>for (initialization; condition; update) {<br>  // Code to be executed in each iteration<br>}</pre><ul><li>initialization: The loop variable is initialized before the loop starts.</li><li>condition: The loop continues as long as the condition is true.</li><li>update: The loop variable is updated after each iteration.</li></ul><p>Let’s explore some examples of different types of for loops in Dart:</p><ol><li>Standard for Loop: This is the most common type of for loop. It&#39;s used when you know the exact number of iterations.</li></ol><pre>for (int i = 0; i &lt; 5; i++) {<br>  print(&#39;Iteration $i&#39;);<br>}</pre><p>2. for-in Loop: The for-in loop is used to iterate over elements of a collection (e.g., lists, sets, maps).</p><pre>List&lt;String&gt; fruits = [&#39;Apple&#39;, &#39;Banana&#39;, &#39;Orange&#39;];<br>for (String fruit in fruits) {<br>  print(fruit);<br>}</pre><p>3. forEach Loop: The forEach loop is a more concise way to iterate over elements of a collection.</p><pre>List&lt;String&gt; fruits = [&#39;Apple&#39;, &#39;Banana&#39;, &#39;Orange&#39;];<br>fruits.forEach((fruit) {<br>  print(fruit);<br>});</pre><p><strong>While Loop:</strong></p><p>A while loop in Dart is a control flow structure that allows you to repeatedly execute a block of code as long as a specified condition is true. The loop evaluates the condition before each iteration, and if the condition is true, the block of code is executed. If the condition becomes false, the loop terminates, and the program continues with the next statement after the loop.</p><p>Here’s the basic syntax of a while loop in Dart:</p><pre>while (condition) {<br>  // Code to be executed in each iteration<br>}</pre><ul><li>condition: The loop continues as long as the condition is true.</li></ul><p>Let’s see some examples of using while loops in Dart:</p><ol><li>Simple while Loop: This is the basic usage of a while loop. It continues executing the block of code as long as the condition is true.</li></ol><pre>void main() {<br>  int count = 0;<br><br>  while (count &lt; 5) {<br>    print(&#39;Count: $count&#39;);<br>    count++;<br>  }<br>}</pre><p><strong>Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*g3N8XvUYJpLyPSsPohYpZw.png" /></figure><p><strong>Do-While:</strong></p><p>do-while Loop: The do-while loop is similar to the while loop, but it ensures that the block of code is executed at least once before checking the condition.</p><pre>void main() {<br>  int count = 0;<br><br>  do {<br>    print(&#39;Count: $count&#39;);<br>    count++;<br>  } while (count &lt; 5);<br>}</pre><p>while loops are useful when you want to repeat a block of code while a specific condition remains true. Keep in mind that you need to ensure the loop condition eventually becomes false to avoid creating an infinite loop.</p><p><strong>Break:</strong></p><p>break Statement: The break statement is used to immediately terminate the execution of a loop, causing the program to exit the loop and continue with the next statement after the loop.</p><pre>void main() {<br>  for (int i = 0; i &lt; 5; i++) {<br>    if (i == 3) {<br>      break; // Exit the loop when i is 3<br>    }<br>    print(&#39;Value of i: $i&#39;);<br>  }<br>  print(&#39;Loop complete&#39;);<br>}</pre><p><strong>Continue:</strong></p><p>continue Statement: The continue statement is used to skip the rest of the current iteration of a loop and proceed to the next iteration.</p><pre>void main() {<br>  for (int i = 0; i &lt; 5; i++) {<br>    if (i == 2) {<br>      continue; // Skip the rest of the loop body when i is 2<br>    }<br>    print(&#39;Value of i: $i&#39;);<br>  }<br>}</pre><p><strong>Where:</strong></p><p>The where keyword is often used in combination with collection methods to filter elements based on a specified condition. It&#39;s commonly used with List, Set, and Iterable objects to create a new collection containing only the elements that satisfy the specified condition.</p><p>Here’s how the where keyword is typically used:</p><pre>Iterable&lt;T&gt; where(bool test(T element))</pre><ul><li>T is the type of the elements in the collection.</li><li>test is a function that takes an element of type T and returns a boolean value indicating whether the element should be included in the filtered collection.</li></ul><p>Let’s see a simple example of using the where keyword to filter elements from a list:</p><pre>void main() {<br>  List&lt;int&gt; numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];<br><br>  List&lt;int&gt; evenNumbers = numbers.where((number) =&gt; number % 2 == 0).toList();<br><br>  print(&#39;Original numbers: $numbers&#39;);<br>  print(&#39;Even numbers: $evenNumbers&#39;);<br>}</pre><p><strong>Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*WOkEnf4n--_amvkmmpxwjA.png" /></figure><p>In this example, we have a list of numbers. We use the where method to filter out only the even numbers from the list, creating a new list of even numbers. The condition (number) =&gt; number % 2 == 0 checks if a number is even. Finally, we use toList() to convert the filtered Iterable back into a List</p><blockquote><strong>Branches:</strong></blockquote><p>The “branches” typically refer to conditional statements that allow your code to make decisions based on certain conditions. Dart provides two main types of branching statements: if statements and switch statements.</p><p><strong>If:</strong></p><p>if Statements: An if statement allows you to execute a block of code if a specified condition is true.</p><pre>void main() {<br>  int number = 10;<br><br>  if (number &gt; 5) {<br>    print(&#39;Number is greater than 5&#39;);<br>  } else {<br>    print(&#39;Number is not greater than 5&#39;);<br>  }<br>}</pre><p><strong>If-Else:</strong></p><p>if-else if-else Statements: You can chain multiple conditions using else if to provide alternative cases.</p><pre>void main() {<br>  int number = 7;<br><br>  if (number &gt; 10) {<br>    print(&#39;Number is greater than 10&#39;);<br>  } else if (number &gt; 5) {<br>    print(&#39;Number is greater than 5 but not greater than 10&#39;);<br>  } else {<br>    print(&#39;Number is not greater than 5&#39;);<br>  }<br>}</pre><p><strong>Switch:</strong></p><p>switch Statements: A switch statement allows you to select one of many code blocks to be executed based on a specified expression.</p><pre>void main() {<br>  String color = &#39;red&#39;;<br><br>  switch (color) {<br>    case &#39;red&#39;:<br>      print(&#39;Stop!&#39;);<br>      break;<br>    case &#39;yellow&#39;:<br>      print(&#39;Slow down&#39;);<br>      break;<br>    case &#39;green&#39;:<br>      print(&#39;Go&#39;);<br>      break;<br>    default:<br>      print(&#39;Unknown signal&#39;);<br>  }<br>}</pre><p>Setup Development Environment</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*owYK-Obce47ZmGlHg2pTbA.jpeg" /></figure><p>To set up a development environment for Flutter, you need to install the following software:</p><ul><li>Flutter SDK: Download and install the latest version of the Flutter SDK from the official website (<a href="https://docs.flutter.dev/get-started/install">https://flutter.dev/docs/get-started/install</a>).</li><li>Integrated Development Environment (IDE): You can use Android Studio, Visual Studio Code, IntelliJ IDEA or any other IDE of your choice.</li><li>Emulator or a physical device: You can use an emulator or a physical device to run and test your Flutter apps. You can use the Android emulator provided by Android Studio or use a physical Android or iOS device.</li><li>Git: Git is used for version control and is recommended for Flutter development. You can download and install Git from <a href="https://git-scm.com/">https://git-scm.com</a>/.</li><li>Dart SDK: Dart is the programming language used by Flutter, and the Dart SDK is required to develop Flutter apps. The <a href="https://dart.dev/get-dart">Dart SDK</a> is included in the Flutter SDK.</li></ul><p>Once you have installed all the required software, you can create a new Flutter project using the Flutter CLI or your IDE, and start building your app.</p><blockquote><strong>Flutter CLI:</strong></blockquote><p>The Flutter CLI (Command Line Interface) is a set of tools that allow you to interact with and manage Flutter projects from the command line. It provides commands for creating, building, testing, and running Flutter applications, as well as managing dependencies and packages.</p><p>Here are some commonly used Flutter CLI commands:</p><ol><li>Creating a New Flutter Project: You can use the flutter create a command followed by the project name to create a new Flutter project.</li></ol><pre>flutter create my_app</pre><p>2. Running the App: The flutter run the command launches your Flutter app on an attached device (emulator or physical device).</p><pre>flutter run</pre><p>3. Building the App: To build the Flutter app for production, you can use the flutter build command with options like apk, appbundle, ios, etc.</p><pre>flutter build apk --release</pre><p>4. Managing Dependencies: You can use the flutter pub command to manage your project&#39;s dependencies, such as adding, updating, or removing packages.</p><pre>flutter pub get      # Install dependencies<br>flutter pub outdated # Check Outdated dependencies<br>flutter pub upgrade  # Update dependencies</pre><p>5. Running Tests: The flutter test command runs tests defined in your project.</p><pre>flutter test</pre><p>6. Formatting Code: The flutter format command formats your code according to Dart&#39;s style guidelines.</p><pre>flutter format</pre><p>7. Analyzing Code: The flutter analyze command analyzes your code for potential issues and errors.</p><pre>flutter analyze</pre><p>8. Creating Widgets: You can generate boilerplate code for widgets using the flutter create command with the widget template.</p><pre>flutter create my_widget --template=widget</pre><p>9. To view all commands that flutter support.</p><pre>flutter --help --verbose</pre><p>10. To get the current version of the Flutter SDK, including its framework, engine, and tools.</p><pre>flutter --version</pre><p>These are just a few examples of the many commands available in the Flutter CLI. To see a full list of available commands and their options, you can run flutter --help or flutter &lt;command&gt; --help.</p><p>Using the Flutter CLI, you can efficiently manage your Flutter projects, develop and test your apps, and streamline your development workflow.</p><p><strong>Flutter Commands:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DhHrBUgUHyqYr2CfZXOv8Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n7GwWBfA8OCqZnSmiCWsBQ.png" /></figure><blockquote><strong>Command-line and server libraries and packages:</strong></blockquote><p>In the context of Dart and Flutter, command-line and server libraries and packages refer to software components that are designed to be used in command-line applications and server-side applications, respectively. These libraries and packages provide tools, utilities, and functionality to help developers build efficient and effective command-line interfaces (CLIs) and server applications.</p><p><strong>Command-Line Libraries and Packages:</strong></p><p>Command-line libraries and packages in Dart are designed to facilitate the creation of command-line applications. They offer features for parsing command-line arguments, formatting output, interacting with the user, and more. Some popular command-line libraries include:</p><ul><li>args: A library for parsing command-line arguments.</li><li>shelf: A package for building HTTP servers.</li><li>dart:io: The core I/O library in Dart that provides classes for working with files, directories, sockets, and more.</li><li>ansi_term: A package for formatting text with ANSI escape codes for colors and styles in the terminal.</li></ul><p><strong>Server Libraries and Packages:</strong></p><p>Server libraries and packages in Dart are used to develop server-side applications that handle requests and provide services over the network. They often include features for handling HTTP requests, managing databases, handling concurrency, and more. Some popular server libraries include:</p><ul><li>http: A package for making HTTP requests and building HTTP servers.</li><li>shelf: A flexible package for building web servers and handling HTTP requests.</li><li>aqueduct: A full-featured web framework for building server applications.</li><li>angel: A highly customizable web framework for building HTTP servers and APIs.</li><li>mongo_dart: A package for working with MongoDB databases.</li></ul><p>These libraries and packages can be added to your Dart projects by including them in your pubspec.yaml file as dependencies. For example:</p><pre>dependencies:<br>  args: ^2.0.0<br>  shelf: ^1.0.0</pre><p>The specific libraries and packages you choose will depend on the requirements of your command line or server application. They help you save time and effort by providing pre-built solutions for common tasks, allowing you to focus on implementing the core functionality of your application.</p><p>Keep in mind that the Dart and Flutter ecosystem is continuously evolving, and new libraries and packages may become available over time. Always check the official Dart package repository (<a href="https://pub.dev/">https://pub.dev</a>) for the latest and most up-to-date options.</p><blockquote><strong>Get started: Command-line and server apps:</strong></blockquote><p>Building command-line apps in Dart is a great way to create utilities, scripts, or tools that can be run directly from the terminal or command prompt. Here’s a simple step-by-step guide to get you started:</p><ol><li>Set Up Your Environment: Make sure you have Dart SDK installed on your system. You can download it from the official Dart website: <a href="https://dart.dev/get-dart">https://dart.dev/get-dart</a></li><li>Create a New Dart Project: Open a terminal or command prompt and navigate to the directory where you want to create your project. Run the following commands:</li></ol><pre>mkdir my_cli_app<br>cd my_cli_app<br>dart create .</pre><p>3. Edit the Code: Open the bin directory in your project, where you&#39;ll find a Dart file (e.g., main.dart). Edit this file to implement your command-line app. For example:</p><pre>import &#39;dart:io&#39;;<br><br>void main(List&lt;String&gt; arguments) {<br>  print(&#39;Hello, Dart Command-line App!&#39;);<br>}</pre><p>I hope this journey will be more useful for us! 💯</p><p>Thank you for being a part of this magical journey🫂</p><p>See you on the next journey👋👋👋</p><p>Until then, Signing off:</p><p><a href="https://www.linkedin.com/in/ruban-raghavendar-k/">Ruban</a>❤️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb922bb177a7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/yavar/flutter-developer-part-2-fb922bb177a7">Flutter — Developer — Part-2</a> was originally published in <a href="https://medium.com/yavar">YavarTechWorks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bridging Widget Gaps with gap_here]]></title>
            <link>https://medium.com/yavar/bridging-widget-gaps-with-gap-here-3eed32149d97?source=rss-890732543ff2------2</link>
            <guid isPermaLink="false">https://medium.com/p/3eed32149d97</guid>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[pubdev]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[responsive-design]]></category>
            <dc:creator><![CDATA[Ruban Raghavendar K]]></dc:creator>
            <pubDate>Wed, 01 May 2024 07:33:20 GMT</pubDate>
            <atom:updated>2024-05-07T04:54:38.032Z</atom:updated>
            <content:encoded><![CDATA[<p>Your Path to Responsive &amp; Seamless Layouts!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*plMA70Q021zOECLGdGCliA.png" /><figcaption>Gap Here</figcaption></figure><p>Hey there, fellow creators! Are you ready to take your Flutter layouts to the next level of responsiveness and elegance? Hold on tight because I’m about to introduce you to a game-changing tool: <a href="https://pub.dev/packages/gap_here"><strong>gap_here</strong></a>!</p><p>This powerful package is going to revolutionize the way you space out your widgets, making your UIs look stunningly responsive and professional on any device!</p><blockquote><strong>What is gap_here?</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*bvBdhRxnU1TEeyRhraewAw.gif" /></figure><p><a href="https://pub.dev/packages/gap_here"><strong>gap_here</strong></a> is your secret weapon for creating beautifully spaced layouts in Flutter. It’s all about those fine-tuned details that make your UIs stand out!</p><p>With <a href="https://pub.dev/packages/gap_here"><strong>gap_here</strong></a>, you can effortlessly add gaps between your widgets, both horizontally and vertically, using double values like 0.2 or 0.3, which represent percentages of the screen size.</p><p>This means your layouts will adapt seamlessly to different devices, giving your users a consistent and polished experience every time.</p><blockquote><strong>How does it work?</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*e25J1GGdvlR-5v64XqIk4w.gif" /></figure><p>Imagine having a magic ruler that automatically adjusts the spacing between your widgets based on the size of the screen. That’s the power of <a href="http://pub.dev/packages/gap_here"><strong>gap_here</strong></a>! You simply provide a value like 0.2 or 0.3, and <a href="http://pub.dev/packages/gap_here"><strong>gap_here</strong></a> handle the rest, ensuring your layouts look perfect on devices of all shapes and sizes.</p><blockquote><strong>Getting started</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*rpHG7FssEMQZjFz7E58FBw.gif" /></figure><p>Ready to dive into the world of responsive layouts with <a href="https://pub.dev/packages/gap_here"><strong>gap_here</strong></a>?</p><p>Setting up this powerful tool is as easy; Let’s get started:</p><ol><li><strong>Open up your Flutter project:</strong> Fire up your favorite code editor and open the Flutter project where you want to use <a href="https://pub.dev/packages/gap_here"><strong>gap_here</strong></a>.</li><li><strong>Visit pub.dev:</strong> Head over to <a href="http://pub.dev/"><strong>pub.dev</strong></a> and search for “<a href="https://pub.dev/packages/gap_here"><strong>gap_here</strong></a>”. Click on the package to view the installation instructions.</li><li><strong>Copy and paste:</strong> Copy the installation commands and paste them into your terminal. Hit enter, and watch as <a href="https://pub.dev/packages/gap_here"><strong>gap_here</strong></a> becomes a part of your Flutter project in seconds!</li></ol><blockquote><strong>Installations:</strong></blockquote><p>Run this command:</p><pre>flutter pub add gap_here</pre><p>This will add a line like this to your package’s pubspec.yaml (and run an implicit flutter pub get):</p><pre>dependencies:<br>  gap_here: ^0.0.6</pre><p>Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.</p><p>Import it, Now in your Dart code, you can use:</p><pre>import &#39;package:gap_here/gap_here.dart&#39;;</pre><blockquote><strong>Usage</strong></blockquote><p>Wrap your widgets with GapHere and specify the desired spacing size as a percentage of the screen size.</p><pre>Column(<br>  children: [<br>    Container(color: Colors.blue, width: 100, height: 100),<br>    GapHere(0.1), // Adding vertical spacing of 10% of screen height<br>    Container(color: Colors.green, width: 100, height: 100),<br>  ],<br>)</pre><pre>Row(<br>  children: [<br>    Container(color: Colors.blue, width: 100, height: 100),<br>    GapHere(0.2), // Adding horizontal spacing of 20% of screen width<br>    Container(color: Colors.green, width: 100, height: 100),<br>  ],<br>)</pre><blockquote><strong>Example Main File:</strong></blockquote><pre>// main.dart<br><br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:gap_here/gap_here.dart&#39;;<br><br>void main() =&gt; runApp(const MyApp());<br><br>class MyApp extends StatelessWidget {<br>  const MyApp({super.key});<br><br>  @override<br>  Widget build(BuildContext context) =&gt; MaterialApp(<br>        home: Scaffold(<br>          appBar: AppBar(<br>            title: const Text(&#39;GapHere Example&#39;),<br>          ),<br>          body: Center(<br>            child: Column(<br>              mainAxisAlignment: MainAxisAlignment.center,<br>              children: [<br>                Container(<br>                  color: Colors.blue,<br>                  width: 100,<br>                  height: 100,<br>                ),<br>                const GapHere(0.2), // Adding vertical spacing of 20% of screen height<br>                Container(<br>                  color: Colors.green,<br>                  width: 100,<br>                  height: 100,<br>                ),<br>              ],<br>            ),<br>          ),<br>        ),<br>      );<br>}</pre><blockquote><strong>Properties Usage</strong></blockquote><p>size Specifies the size of the spacing to be added between widgets. The value should be provided as a double representing a percentage of the screen size.</p><p>By default, the package internally uses MediaQuery to calculate spacing based on percentages, ensuring consistency across different screen sizes and resolutions.</p><blockquote><strong>Package Link:</strong></blockquote><p><a href="https://pub.dev/packages/gap_here">gap_here | Flutter package</a></p><p>See how effortlessly we’re using double values to represent percentages of the screen size? With <a href="https://pub.dev/packages/gap_here"><strong>gap_here</strong></a>, responsive layouts are a breeze!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*rD3O7LrqDR6fK5R1e1GuEw.gif" /></figure><p>But wait, there’s more!</p><p><a href="https://pub.dev/packages/gap_here"><strong>gap_here</strong></a> isn’t just about adding gaps between widgets. It’s also about making your layouts truly responsive and adaptable. Whether you’re building for smartphones, tablets, or even web browsers, <a href="https://pub.dev/packages/gap_here"><strong>gap_here</strong></a> ensures your UIs look fantastic on every screen.</p><p>So, what are you waiting for? Give <a href="https://pub.dev/packages/gap_here"><strong>gap_here</strong></a> a try today and experience the power of responsive layouts like never before!</p><p>Happy coding, my fellow layout masters! 🌟📏</p><p>I hope this journey will be more useful for us! 💯</p><p>Thank you for being a part of this magical journey🫂</p><p>See you on the next journey👋👋👋</p><p>Until then, Signing off:</p><p><a href="https://www.linkedin.com/in/ruban-raghavendar-k/">Ruban</a>❤️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3eed32149d97" width="1" height="1" alt=""><hr><p><a href="https://medium.com/yavar/bridging-widget-gaps-with-gap-here-3eed32149d97">Bridging Widget Gaps with gap_here</a> was originally published in <a href="https://medium.com/yavar">YavarTechWorks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Gradient Text — TextGradiate Package]]></title>
            <link>https://medium.com/yavar/gradient-text-textgradiate-package-f3a20c2cfdd9?source=rss-890732543ff2------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3a20c2cfdd9</guid>
            <category><![CDATA[pubdev]]></category>
            <category><![CDATA[gradient]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[gradient-text]]></category>
            <dc:creator><![CDATA[Ruban Raghavendar K]]></dc:creator>
            <pubDate>Fri, 26 Apr 2024 03:20:38 GMT</pubDate>
            <atom:updated>2024-05-01T07:20:13.010Z</atom:updated>
            <content:encoded><![CDATA[<h3>Gradient Text — TextGradiate Package</h3><p>Create Colorful Text Magic with <a href="https://pub.dev/packages/text_gradiate"><strong>text_gradiate</strong></a>: A Fun Guide for Everyone!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GggGw8H8jSiU291i9cGFBA.png" /></figure><blockquote><strong>Introduction:</strong></blockquote><p>Hey there, fellow creators! Are you ready to sprinkle some rainbow magic into your text? Well, you’re in luck because I’ve got something super cool to share with you today. It’s called <a href="https://pub.dev/packages/text_gradiate/"><strong>text_gradiate</strong></a>, and trust me, it’s going to make your words pop like never before!</p><blockquote>What is text_gradiate?</blockquote><p><a href="https://pub.dev/packages/text_gradiate/"><strong>text_gradiate</strong></a> is like a magic wand for your text. It lets you turn boring old words into vibrant, colorful masterpieces! With just a simple string of text and a list of colors, you can create stunning gradient text that will make everyone go “Wow!”</p><blockquote>How does it work?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*pt1XrcqsyMZKZhTS0fgUew.gif" /></figure><p>Imagine you have a magic paintbrush that can paint your words with every color of the rainbow. That’s exactly what <a href="https://pub.dev/packages/text_gradiate/"><strong>text_gradiate</strong> </a>does! You tell it what words you want to paint, and then you pick your colors. <a href="https://pub.dev/packages/text_gradiate/"><strong>text_gradiate</strong></a>does the rest, blending those colors together to create a beautiful gradient effect.</p><blockquote>Getting started</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*w8DOjpXSBe4jIS0WDC3hHw.gif" /></figure><p>Okay, let’s dive into the fun part: creating your own gradient text! But don’t worry, it’s as easy as pie!</p><p>First things first, you need to install <a href="https://pub.dev/packages/text_gradiate/"><strong>text_gradiate</strong></a>. Don’t worry, it’s totally free and easy peasy! Just follow these simple steps:</p><ol><li><strong>Open up your Flutter project:</strong> You know, that cool app you’ve been working on? Yeah, open that up!</li><li><strong>Go to </strong><strong>pub.dev:</strong> This is where all the cool Flutter packages hang out. Search for <a href="https://pub.dev/packages/text_gradiate/"><strong>text_gradiate</strong></a> and click on it.</li><li><strong>Copy the installation instructions:</strong> Just copy those magical commands and paste them into your terminal.</li><li><strong>Hit enter and watch the magic happen:</strong> That’s it! <a href="https://pub.dev/packages/text_gradiate/"><strong>text_gradiate</strong></a> is now part of your Flutter project, ready to make your text dreams come true.</li><li>Or try this one step magic: Just run the below command to add the <a href="https://pub.dev/packages/text_gradiate/"><strong>text_gradiate</strong></a> to your flutter project:</li></ol><pre>flutter pub add text_gradiate</pre><blockquote>Creating your first gradient text</blockquote><p>Now that you’ve got <a href="https://pub.dev/packages/text_gradiate/"><strong>text_gradiate</strong></a> installed, it’s time to unleash your creativity! Here’s how you can create your very first gradient text:</p><blockquote><strong>Installation:</strong></blockquote><p>To use this package, add text_gradiate as a dependency in your pubspec.yaml file:</p><pre>dependencies:<br>  text_gradiate: ^1.0.1</pre><p>Then, import the package into your Dart code:</p><pre>import &#39;package:text_gradiate/text_gradiate.dart&#39;;</pre><p>Wrap your text widget with TextGradiate and specify the desired gradient properties.</p><pre>TextGradiate(<br>  text: Text(<br>    &#39;Hello, Gradient!&#39;,<br>    style: TextStyle(fontSize: 24.0),<br>  ),<br>  colors: [Colors.blue, Colors.green],<br>  gradientType: GradientType.linear,<br>  begin: Alignment.centerLeft,<br>  end: Alignment.centerRight,<br>  tileMode: TileMode.clamp,<br>)</pre><p>Here’s a simple example that shows how to use the TextGradiate widget with some properties:</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:text_gradiate/text_gradiate.dart&#39;;<br><br>void main() {<br>  runApp(MyApp());<br>}<br><br>class MyApp extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      home: Scaffold(<br>        appBar: AppBar(<br>          title: Text(&#39;TextGradiate Example&#39;),<br>        ),<br>        body: Center(<br>          child: TextGradiate(<br>            text: Text(<br>              &#39;Hello, Gradient!&#39;,<br>              style: TextStyle(fontSize: 24.0),<br>            ),<br>            colors: [Colors.blue, Colors.green],<br>            gradientType: GradientType.linear,<br>            begin: Alignment.centerLeft,<br>            end: Alignment.centerRight,<br>            tileMode: TileMode.clamp,<br>          ),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>See how easy that was? Just tell text_gradiate what text you want to use and what colors you want to paint with, and it does all the hard work for you!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*JJYja1RaI-bnbarOP4Dh-A.gif" /></figure><blockquote>But wait, there’s more!</blockquote><p><a href="https://pub.dev/packages/text_gradiate"><strong>text_gradiate</strong></a> isn’t just about creating gradient text. Oh no, it’s got a whole bag of tricks up its sleeve! You can change the type of gradient (linear, radial, or sweep), adjust the direction, and even add some sparkle with shadow effects. All the tricky properties are give below use it and feel the magic🫧</p><ul><li>text: The child widget to which the gradient effect will be applied.</li><li>colors: The list of colors to use for the gradient.</li><li>gradientType: Specifies the type of gradient (linear, radial, or sweep).</li><li>begin (for linear gradients): The starting point of the gradient.</li><li>end (for linear gradients): The ending point of the gradient.</li><li>tileMode (for linear gradients): The tiling strategy for the gradient.</li><li>center (for radial and sweep gradients): The center point of the gradient.</li><li>focal (for radial gradients): The focal point of the gradient.</li><li>focalRadius (for radial gradients): The focal radius of the gradient.</li><li>startAngle (for sweep gradients): The starting angle of the gradient.</li><li>endAngle (for sweep gradients): The ending angle of the gradient.</li><li>stops: The stops of the gradient.</li><li>transform: The transform matrix for the gradient (applicable only for linear and sweep gradients).</li></ul><blockquote><strong>Package Link:</strong></blockquote><p><a href="https://pub.dev/packages/text_gradiate">text_gradiate | Flutter package</a></p><blockquote><strong>Reference video:</strong></blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fuyc-XOxlZVw%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Duyc-XOxlZVw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fuyc-XOxlZVw%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/19b4610f67a0b7ae976f0b58bbf0d761/href">https://medium.com/media/19b4610f67a0b7ae976f0b58bbf0d761/href</a></iframe><p>So, what are you waiting for? Go ahead and give <a href="https://pub.dev/packages/text_gradiate"><strong>text_gradiate</strong></a> a try.</p><p>I promise you won’t be disappointed💯</p><p>I hope this magical journey will be more useful for us💯</p><p>If there are any suggestions or corrections, you’re always welcome!!!</p><p>Thank you for being a part of this magical journey🫂</p><p>See you on the next journey👋👋👋</p><p>Until then, Signing off:</p><p><a href="https://www.linkedin.com/in/ruban-raghavendar-k/">Ruban</a>❤️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3a20c2cfdd9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/yavar/gradient-text-textgradiate-package-f3a20c2cfdd9">Gradient Text — TextGradiate Package</a> was originally published in <a href="https://medium.com/yavar">YavarTechWorks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter — Provider]]></title>
            <link>https://medium.com/yavar/flutter-provider-ca6f6752f59e?source=rss-890732543ff2------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca6f6752f59e</guid>
            <category><![CDATA[provider]]></category>
            <category><![CDATA[flutter-provider]]></category>
            <category><![CDATA[state-management]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Ruban Raghavendar K]]></dc:creator>
            <pubDate>Wed, 17 Jan 2024 13:48:32 GMT</pubDate>
            <atom:updated>2024-01-18T05:10:23.755Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flutter — Provider</h3><p>State Management using Provider</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*d-1pMhgf2J-GHfBG4KW1Vg.jpeg" /></figure><p>Welcome back, friends! In this journey, we’ll look into the Flutter <a href="https://pub.dev/packages/provider">Provider</a> package for state management.</p><p>Through this Journey, we’ll see,</p><ol><li>Introduction to State Management</li><li>Flutter State Management Tools</li><li>Get — Into the Provider</li><li>Usage with an Example</li><li>Benefits for the users</li><li>Finale</li></ol><p>Before starting the journey, I wish to say something to you…</p><p>First of all, I’m requesting everyone to read this blog fully. And follow the step-by-step process to reach our destination!</p><p>Then only you&#39;ll be able to understand this concept.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*jbnEwUn9DcMk1jU7fWkAVQ.gif" /></figure><h3>Introduction to State Management:</h3><p>Before we dive into the world of state management, let’s understand why it’s crucial to Flutter development.</p><blockquote><strong>App State:</strong></blockquote><ul><li>In the context of mobile app development, ‘<em>state’</em> refers to any data that can change over time.</li><li>This data can include user input, the content displayed on the screen, network responses, or even the device’s orientation.</li><li>For instance, think about a weather app. The location, temperature, and weather conditions are all examples of app state because they can change as the user interacts with the app or as new data arrives from an external source.</li></ul><blockquote><strong>Importance of State Management:</strong></blockquote><ul><li>Imagine building an app without any mechanism to handle the state. Every time something in your app changes, you need to manually update the user interface (UI) to reflect those changes.</li><li>This approach quickly becomes chaotic, error-prone, and unsustainable as your app grows in complexity.</li><li>This is where state management comes into play. It’s the practice of efficiently managing and updating the state of your application.</li><li>State management solutions provide structured ways to handle state changes and ensure that your app remains responsive and consistent.</li></ul><blockquote><strong>Role Play:</strong></blockquote><ul><li>Flutter is known for its impressive UI capabilities and robust performance. However, to make the most of Flutter’s potential, you need to manage your app’s state effectively.</li><li>Proper state management in Flutter involves handling everything from UI updates in response to user interactions to managing data fetched from APIs.</li><li>In a Flutter app, you’ll often find yourself needing to update the UI based on changes in the underlying data.</li><li>For example, when a user likes a post in a social media app, you need to update the UI to reflect the change in the number of likes. Without state management, this task can become convoluted.</li></ul><p>To summarize, state management in Flutter is all about maintaining, updating, and synchronizing the data that your app relies on to function correctly. It’s the cornerstone of building responsive and dynamic user interfaces.</p><h3>Flutter State Management Tools:</h3><p>There are various state management approaches and packages available for Flutter. Here are some of the most popular ones:</p><ol><li><a href="https://api.flutter.dev/flutter/widgets/State/setState.html">setState</a>: The simplest form of state management built into Flutter. It’s suitable for small projects but can become cumbersome as your app grows.</li><li><a href="https://pub.dev/packages/provider">Provider</a>: A minimalistic and straightforward package for state management, suitable for small to medium-sized projects.</li><li><a href="https://pub.dev/packages/flutter_bloc">Bloc</a>: A more advanced approach using streams and reactive programming for complex state management scenarios.</li><li><a href="https://pub.dev/packages/get">GetX</a>: It is a sophisticated microframework that allows us to create routing, manage states, and execute dependency injection.</li></ol><h3>Get — Into the Provider:</h3><ul><li>In Flutter, “<a href="https://pub.dev/packages/provider">Provider</a>” refers to a design pattern and a package that helps manage the state of your application. It’s commonly used to efficiently share and update data between different parts of your app, such as widgets, without the need for prop drilling (passing data through multiple widget layers).</li><li>The “<a href="https://pub.dev/packages/provider">Provider</a>” package in Flutter provides a way to manage and consume data using a provider class, which acts as a source of truth for your app’s state.</li></ul><p>Currently, I’m using this provider version:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ulocHhZZUNabi9RP7IurDw.png" /></figure><p>Use the latest version 👉 <a href="https://pub.dev/packages/provider&#39;">Provider Package</a></p><h3>Usage with an example:</h3><p>In this journey, we’ll see how Flutter’s default counter application state will be managed using Flutter <a href="https://pub.dev/packages/provider">Provider</a>.</p><ol><li>Create a Flutter provider with a counter application.</li><li>The application must display a number 0 by initial value, an increment button, and a decrement button.</li><li>Functionality: The number should be increment when you hit the increment button and it should be decrement when you hit the decrement button.</li><li>Add the Flutter <a href="https://pub.dev/packages/provider">Provider</a> package to your project using this command:</li></ol><pre>flutter pub add provider</pre><p>5. Then run flutter pub get to get the dependencies.</p><p>6. Create a provider class for the counter application which should extend the changeNotifier.</p><pre>// counter_provider.dart<br><br>import &#39;package:flutter/material.dart&#39;;<br>class CounterProvider extends ChangeNotifier {<br>  // Methods<br>}</pre><p>7. Create a counterValue variable and initiate it as 0 in the constructor.</p><pre>// counter_provider.dart<br><br>import &#39;package:flutter/material.dart&#39;;<br><br>class CounterProvider extends ChangeNotifier {<br>  int counterValue;<br><br>  CounterProvider({<br>    this.counterValue = 0,<br>  });<br>}</pre><p>8. Create an increment and decrement function to do the increment and decrement operations.</p><pre>// counter_provider.dart<br><br>import &#39;package:flutter/material.dart&#39;;<br><br>class CounterProvider extends ChangeNotifier {<br>  int counterValue;<br><br>  CounterProvider({<br>    this.counterValue = 0,<br>  });<br><br>  void incrementNumber() {<br>    counterValue++;<br>    notifyListeners();// To notify all the listeners that the value may change<br>  }<br><br>  void decrementNumber() {<br>    counterValue--;<br>    notifyListeners();<br>  }<br>}</pre><blockquote><strong>Please note :</strong><br>Only you can able to access the notifyListeners() method by extending your class from ChangeNotifier. So make sure that you’ve extended your class from ChangeNotifier.</blockquote><p>9. Add that provider to the main tree by using MultiProvider to access anywhere in the project.</p><pre>// main.dart<br><br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:practice_provider/home.dart&#39;;<br>import &#39;package:practice_provider/user_provider.dart&#39;;<br>import &#39;package:provider/provider.dart&#39;;<br><br>void main() =&gt; runApp(const MyApp());<br><br>class MyApp extends StatelessWidget {<br>  const MyApp({super.key});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return MultiProvider(<br>      providers: [<br>        ChangeNotifierProvider(<br>          create: (context) =&gt; CounterProvider(),<br>        ),<br>      ],<br>      child: const MaterialApp(<br>        debugShowCheckedModeBanner: false,<br>        home: Home(),<br>      ),<br>    );<br>  }<br>}</pre><p>MultiProvideruses the provider&#39;s property to take a list of providers and inject them into the widget-tree at the same level.</p><p>10. Append the values in the UI part.</p><pre>// home.dart<br> <br>Text(<br>   // Use the toString() method to convert an integer to a string.<br>   context.watch&lt;CounterProvider&gt;().counterValue.toString(),<br> ),</pre><p>In the above code, thewatch() method is used to listen to the changes.</p><pre>// home.dart<br><br><br>// Increment<br>ElevatedButton(<br>  onPressed: () {<br>  context.read&lt;CounterProvider&gt;().incrementNumber();<br>  },<br>  child: const Text(<br>    &#39;+&#39;,<br>  ),<br>),<br><br>// Decrement<br>ElevatedButton(<br>  onPressed: () {<br>  context.read&lt;CounterProvider&gt;().decrementNumber();<br>  },<br>  child: const Text(<br>    &#39;-&#39;,<br>  ),<br>),</pre><ul><li>In the above code, theread() method is used not to listen but to access and change the state.</li><li>By calling the decrement function, the counter value will be decreased by 1, and the increment will be increased by 1.</li></ul><p>Now that we&#39;ve completed the counter application using the <a href="https://pub.dev/packages/provider">Provider</a>, we can see the output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HFZIf2bI90PKQJwlWVkabA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l1F9r9adBr3cbNnRJZDX2Q.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iOcfaMQNO2OfyfRGq_QB5g.jpeg" /><figcaption>Initial | Increment | Decrement</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*-4paol5i4F_UhyqrBgDwMQ.gif" /></figure><p>I’ll push this code in <a href="https://github.com/Ruban-07/Counter-App-Provider-"><strong>GitHub</strong></a>, please make use of it.</p><h3>Benefits for users:</h3><ol><li><strong>Simplicity: </strong>Provider offers a straightforward and easy-to-understand approach to state management in Flutter.</li><li><strong>Scoped Instances:</strong> It allows the creation of scoped instances, ensuring that the state is available only where needed in the widget tree.</li><li><strong>Reactive Programming:</strong> The provider supports a reactive programming style, resulting in efficient widget updates when the state changes.</li><li><strong>Minimal Boilerplate:</strong> Reduces the amount of boilerplate code, promoting clean and maintainable code.</li><li><strong>Community Support:</strong> Widely adopted in the Flutter community, the Provider comes with ample resources, tutorials, and community support.</li></ol><h3>Finale:</h3><ul><li>Flutter Provider state management offers a powerful yet simple solution for handling the state in Flutter applications.</li><li>With its scoped instances, reactive programming model, and seamless dependency injection, Provider provides an efficient and organized way to manage the state at various levels of the widget tree.</li><li>Overall, Flutter Provider emerges as a versatile and well-supported choice for state management, balancing ease of use with flexibility and scalability in Flutter applications.</li></ul><p>I hope this journey will be more useful for us💯</p><p>If any Suggestions or Corrections, you’re always welcome!!!</p><p>Thank you for being a part of this journey🫂</p><p>See you on the next journey👋👋👋</p><p>Until then, Signing off:</p><p><a href="https://www.linkedin.com/in/ruban-raghavendar-k/">Ruban</a>❤️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca6f6752f59e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/yavar/flutter-provider-ca6f6752f59e">Flutter — Provider</a> was originally published in <a href="https://medium.com/yavar">YavarTechWorks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git — Version Control System]]></title>
            <link>https://medium.com/yavar/git-version-control-system-8673be9031a9?source=rss-890732543ff2------2</link>
            <guid isPermaLink="false">https://medium.com/p/8673be9031a9</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[git-commands]]></category>
            <category><![CDATA[version-control-system]]></category>
            <dc:creator><![CDATA[Ruban Raghavendar K]]></dc:creator>
            <pubDate>Mon, 15 Jan 2024 12:27:22 GMT</pubDate>
            <atom:updated>2024-01-17T05:01:19.017Z</atom:updated>
            <content:encoded><![CDATA[<h3>Git — Version Control System</h3><p>Basic Guide for Developers</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cKaYfzjtBxmJDp6xWnvHTQ.jpeg" /></figure><p>What are all the things you’ll learn through this journey…</p><ol><li>Introduction to Version Control System.</li><li>Source code management.</li><li>Git and GitHub.</li><li>Born History.</li><li>Uses of Git and GitHub.</li><li>Users of Git and GitHub.</li><li>Installation of Git for Every OS.</li><li>Git Configurations.</li><li>Basic Git Commands for Developers.</li><li>Git Extension.</li><li>Finale.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*5yMZcpkbrtZU0TUXHQpEow.gif" /><figcaption>START</figcaption></figure><h3><strong>Introduction to Version Control System:</strong></h3><ul><li>Version control, also known as source control, is the practice of tracking and managing changes to software code.</li><li>Version control systems are software tools that help software teams manage changes to source code over time.</li><li>As development environments have accelerated, version control systems help software teams work faster and smarter.</li><li>They are especially useful for DevOps teams since they help them reduce development time and increase successful deployments.</li><li>By the way, Git and GitHub is an amazing platform for the version control system.</li></ul><h3><strong>Source code management(SCM):</strong></h3><ul><li>Source code management (SCM) is used to track modifications to a source code repository.</li><li>SCM tracks a running history of changes to a code base and helps resolve conflicts when merging updates from multiple contributors. SCM is also synonymous with Version control.</li></ul><h3><strong>Git and GitHub.</strong></h3><ul><li>In the fast-paced world of software development, version control is a necessity.</li><li>Git, a distributed version control system, and GitHub, a web-based platform built around Git, have revolutionized collaboration and code management.</li><li>Git allows developers to track changes, collaborate seamlessly, and maintain a structured history of their projects, while GitHub serves as a centralized hub for hosting and sharing repositories.</li></ul><h3><strong>Born History of Git &amp; GitHub:</strong></h3><blockquote><strong>GIT:</strong></blockquote><p>Inventor/Developer: <strong>Linus Torvalds</strong><br>Year Launched: <strong>2005</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6a-eA2GejOrLYf0S.jpg" /><figcaption>Linus Torvalds</figcaption></figure><ul><li>Git, the version control system, was created by Linus Torvalds, the same person who created the Linux operating system.</li><li>Linus Torvalds began working on Git in 2005 to manage the development of the Linux kernel.</li><li>Git was developed to address the limitations and challenges of existing version control systems.</li></ul><blockquote><strong>GITHUB:</strong></blockquote><p>Founders: <strong>Tom Preston-Werner, Chris Wanstrath, PJ Hyett</strong><br>Year Launched: <strong>2008</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cS4-aKhPbsVaMpPR.jpg" /><figcaption>PJ Hyett, Tom Preston-Werner, and Chris Wanstrath</figcaption></figure><ul><li>GitHub, on the other hand, is a web-based platform for hosting and collaborating on Git repositories.</li><li>It was founded by <strong>Tom Preston-Werner, Chris Wanstrath, and PJ Hyett</strong> in 2008.</li><li>GitHub aims to provide a user-friendly interface for Git and facilitate collaboration among developers by offering features like pull requests, issue tracking, and branching.</li></ul><p>Both Git and GitHub have since become integral parts of the software development ecosystem, playing a crucial role in version control and collaborative coding practices.</p><h3><strong>Use of Git and GitHub</strong></h3><blockquote><strong>Git and GitHub offer a multitude of benefits to developers:</strong></blockquote><ul><li><strong>Collaboration:</strong> Multiple developers can work on the same project simultaneously, with Git managing changes and merging efforts.</li><li><strong>Versioning:</strong> Git tracks every change made to a project, making it easy to revert to previous versions if needed.</li><li><strong>Remote Repositories:</strong> GitHub provides a platform for hosting repositories remotely, enabling easy sharing and collaboration.</li><li><strong>Issue Tracking:</strong> GitHub’s issue tracking system helps manage and prioritize tasks, enhancing project management.</li></ul><h3><strong>Users of Git and GitHub:</strong></h3><ul><li>Git and GitHub have revolutionized the way individuals and groups manage their code, fostering collaboration, and providing powerful version control.</li><li>Let’s explore the diverse user base of Git and GitHub, highlighting the specific ways these platforms cater to different needs.</li></ul><ol><li><strong>Individual Developers:</strong></li></ol><p>Git and GitHub are essential tools for individual developers managing personal projects. These platforms facilitate version control, ensuring a streamlined development process for solo coders.</p><p><strong><em>Use Cases:</em></strong></p><p><strong>Personal Projects:</strong> Git allows developers to maintain version control for their coding projects, while GitHub serves as a platform to showcase and share their work.</p><p><strong>2. Open Source Contributors:</strong></p><p>Git and GitHub play a crucial role in the open-source community, providing a platform for collaboration and version control across global contributors.</p><p><strong><em>Use Cases:</em></strong></p><ul><li><strong>Collaboration:</strong> Open source projects leverage Git’s branching and merging capabilities to allow contributors from diverse backgrounds to work on the same codebase.</li><li><strong>Issue Tracking:</strong> GitHub’s issue tracking system facilitates effective communication among contributors, streamlining bug fixes and feature implementations.</li></ul><p><strong>3. Enterprise and Corporate Teams:</strong></p><p>Many organizations have adopted Git and GitHub as standard tools for version control and collaboration. These platforms are particularly valuable for agile development teams working on large-scale projects.</p><p><strong><em>Use Cases:</em></strong></p><ul><li><strong>Open Source Contributors:</strong> GitHub’s pull request feature streamlines the code review process, enabling teams to maintain code quality through collaborative efforts.</li><li><strong>Project Management:</strong> GitHub’s project boards and milestones assist teams in organizing and managing their development workflow effectively.</li></ul><p><strong>4. Educational Institutions:</strong></p><p>Git and GitHub are widely used in educational settings to teach version control practices, collaborative coding, and industry-standard development workflows.</p><p><strong><em>Use Cases:</em></strong></p><ul><li><strong>Classroom Projects:</strong> Instructors use GitHub to distribute assignments, track student progress, and provide feedback on code.</li><li><strong>Practical Learning:</strong> Students gain hands-on experience with version control and collaboration, skills crucial for their future careers.</li></ul><p><strong>5. Freelancers and Consultants:</strong></p><p>Freelancers and consultants leverage Git and GitHub to efficiently manage client projects, collaborate remotely, and showcase their work professionally.</p><p><strong><em>Use Cases:</em></strong></p><ul><li><strong>Client Collaboration:</strong> Git enables freelancers to collaborate with clients on project development, while GitHub provides a platform to share progress and receive feedback.</li><li><strong>Code Hosting:</strong> GitHub serves as a professional platform for hosting code repositories, allowing freelancers to present their work in a polished manner.</li></ul><h3><strong>Installation of Git for Every OS</strong></h3><p>Git is cross-platform, and installing it on different operating systems is straightforward.</p><blockquote><strong>Windows:</strong></blockquote><ul><li>Download the installer from <a href="https://gitforwindows.org/"><strong>Git for Windows</strong></a>.</li><li>Run the installer and follow the on-screen instructions.</li></ul><blockquote><strong>Ubuntu:</strong></blockquote><p>Open a terminal and run the following command:</p><pre>sudo apt-get update<br>sudo apt-get install git</pre><blockquote>macOS:</blockquote><ul><li>Install Git via <a href="https://brew.sh/"><strong>Homebrew</strong></a>:</li></ul><pre>brew install git</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*MmUs7Fa1t9aGr7ED" /></figure><p>Or use this link to download git for your OSs “ <a href="https://www.git-scm.com/downloads"><strong>Git Download</strong></a>”.</p><h3><strong>Git Configurations:</strong></h3><p>Configuring the git is the first step after the installation. These settings apply to all repositories on your machine and are associated with your user account.</p><blockquote><strong>Set Your Name:</strong></blockquote><pre>git config --global user.name &quot;Your Name&quot;</pre><blockquote><strong>Set Your Email:</strong></blockquote><pre>git config --global user.email &quot;your.email@example.com&quot;</pre><p>These Set Name and Set Email are enough to start the journey.</p><blockquote><strong>Set Your Preferred Text Editor (e.g., VSCode):</strong></blockquote><pre>git config --global core.editor &quot;code --wait&quot;</pre><blockquote><strong>View Global Configurations:</strong></blockquote><pre>git config --global --list</pre><p><strong>Repository-specific Configuration:</strong></p><p>These settings are specific to a particular Git repository.</p><blockquote><strong>Set Repository Name:</strong></blockquote><pre>git config user.name &quot;Your Name&quot;</pre><blockquote><strong>Set Repository Email:</strong></blockquote><pre>git config user.email &quot;your.email@example.com&quot;</pre><blockquote><strong>Set Default Branch Name (e.g., to ‘main’):</strong></blockquote><pre>git config init.defaultBranch main</pre><blockquote><strong>View Repository Configurations:</strong></blockquote><pre>git config --list</pre><p><strong>Credential Management:</strong><br>Git can cache credentials to avoid repeatedly prompting for them.</p><blockquote><strong>Enable Credential Caching (Default is 15 minutes):</strong></blockquote><pre>git config --global credential.helper cache</pre><blockquote><strong>Set Custom Cache Timeout (e.g., 1 hour):</strong></blockquote><pre>git config --global credential.helper &#39;cache --timeout=3600&#39;</pre><p><strong>Viewing and Editing Configuration</strong></p><blockquote><strong>View a Specific Configuration:</strong></blockquote><pre>git config user.name</pre><blockquote><strong>Edit a Specific Configuration:</strong></blockquote><pre>git config --global --edit</pre><blockquote><strong>Edit System-Wide Configuration (requires administrative rights):</strong></blockquote><pre>git config --system --edit</pre><p><strong>Helpful Tips:</strong></p><blockquote><strong>Unset a Configuration:</strong></blockquote><pre>git config --unset user.email</pre><blockquote><strong>Set Color Output:</strong></blockquote><pre>git config --global color.ui auto</pre><blockquote><strong>Set Push Default (e.g., to ‘simple’):</strong></blockquote><pre>git config --global push.default simple</pre><blockquote><strong>Set Default Behavior for Merging:</strong></blockquote><pre>git config --global pull.rebase true</pre><p>These are just a few Git configurations.</p><h3><strong>Basic Git Commands for Developers:</strong></h3><blockquote><strong>Creating a New Repository(Remote):</strong></blockquote><ul><li>First of all check whether you’ve signed in or not, if not please sign in into <a href="http://github.com/">github.com</a>. Or if you are a new user, create an account and sign-in.</li><li>Go to the Dashboard and click <a href="https://github.com/new"><strong>New</strong></a> to open an “Create a new repository” window.</li><li>There you can enter the repository name which you want and select the type “Public” or “Private”.</li><li>And also there itself you’ve an option to initialize the repo with readme.md file. If you want it, you can select that checkbox.</li><li>Finally click the button Create repository to create new repo.</li><li>Then you’ll see the quick setup window, there you can copy the repo link by HTTPS or SSH .</li></ul><p>After these steps, go to your local directory and push the code to remote.</p><blockquote><strong>Setup Directory:</strong></blockquote><p>Choose the directory where your code or files should be there. Inside the directory, run this command to create a Readme file which should describe your work:</p><pre>echo &quot;# Your Title&quot; &gt;&gt; README.md</pre><blockquote><strong>Git initializing</strong></blockquote><p>To initiate a new Git repository, navigate to your project directory and run:</p><pre>git init</pre><p>This command initializes a new repository, setting up the necessary structures for version control.</p><blockquote><strong>Adding and Staging Files:</strong></blockquote><pre>git add README.md</pre><p>After creating your file in the initialized directory, you can add and stage using this command.</p><blockquote><strong>Adding and Staging All Files:</strong></blockquote><pre>git add .</pre><p>By using dot (<strong>.</strong>) we can easily add and stage all the files.</p><blockquote><strong>Git Status:</strong></blockquote><pre>git status</pre><p>This command will help you to view the status of your local file adding and staging.</p><blockquote><strong>Committing Changes:</strong></blockquote><pre>git commit -m &quot;Enter your commit message here&quot;</pre><p>It’ll save all your code and be ready to push in the remote repo. In this command, you can give any commit message you want, like Initial commit . Which is useful for identifying all the things that are done in this commit.</p><blockquote><strong>Add and commit in shortened command:</strong></blockquote><p>It’ll add and commit all changes in a single step.</p><pre>git commit -am &quot;commit message&quot;</pre><blockquote><strong>Git Logging:</strong></blockquote><pre>git log</pre><p>It’s used to check the log of file insertion, modification, and deletion. Like a history of file commits.</p><blockquote><strong>Change the remote branch name:</strong></blockquote><p>By default the branch name will be master, we can change it by this command:</p><pre>git branch -M main</pre><p>In this command, -M is used to change the remote branch name and -m is used to change the local branch name.</p><p><strong>Adding the remote origin:</strong></p><pre>git remote add origin https://github.com/Ruban-07/test-blog.git</pre><p><strong>Checking the remote origin:</strong></p><pre>git remote -v</pre><p>After running this command, you’ll find your repo URL here. Once you confirm it, then you can push your files to your origin.</p><blockquote><strong>Pushing Changes to Origin:</strong></blockquote><pre>git push -u origin main</pre><p>This is used for the first push, to setting the local main as remote main.</p><p>The rest of the time you can push the code by this command:</p><pre>git push origin main</pre><p>After pushing the code, just refresh the repository to view your codes there.</p><blockquote><strong>Branches:</strong></blockquote><pre>git branch</pre><p>It’s used to check the current branch and to check what all the branches are available in your local.</p><blockquote><strong>Checkout to a new branch:</strong></blockquote><pre>git checkout -b &lt;new-branch&gt;</pre><blockquote><strong>Checkout to an existing branch:</strong></blockquote><pre>git checkout &lt;existing-branch&gt;</pre><blockquote><strong>Rename Branch Local:</strong></blockquote><pre>git branch -m new-branch-name</pre><blockquote>Rename Branch Remote:</blockquote><pre>git branch -M new-branch-name</pre><blockquote><strong>Delete Branch Local:</strong></blockquote><pre>git branch -d branch-name</pre><blockquote><strong>Delete Branch Remote:</strong></blockquote><pre>git branch -D branch-name</pre><blockquote><strong>Switch Branch:</strong></blockquote><pre>git switch -c branch-name</pre><p>It’ll move the changes from one branch to another.</p><blockquote><strong>Fetching Changes:</strong></blockquote><p>It’s very useful when you want to fetch a branch that is not available in your local. You can just fetch the branch and checkout at that branch easily.</p><p>Let’s imagine this life scenario, you and your friend code together in a repo, and your friend pushes a branch in the repo, which is not there in your local.</p><p>In that scenario, you can fetch the branch to the local by using this command:</p><pre>git fetch origin &lt;branch-name&gt;</pre><blockquote><strong>Pull Changes:</strong></blockquote><p>This is used to pull the remote changes to local.</p><p>If your friend pushes the code to the remote, then you can pull those changes by using this command:</p><pre>git pull origin &lt;branch-name&gt;</pre><blockquote><strong>Stash Changes:</strong></blockquote><ul><li>It is used when you need to checkout to another branch without committing and losing these changes.</li><li>It’ll stash the changes to local and we can pop back the changes when we want.</li></ul><blockquote><strong>Stash:</strong></blockquote><pre>git stash</pre><p>It’ll stash all the uncommitted files.</p><blockquote><strong>List the Stashes:</strong></blockquote><pre>git stash list</pre><p>It’ll list out all the stashes.</p><blockquote><strong>Pop Back:</strong></blockquote><pre>git stash pop stash@{1}</pre><p>It’ll pop back the stash with the ID you’ve mentioned in {}.</p><blockquote><strong>Drop:</strong></blockquote><pre>git stash drop</pre><p>This command will clear the last stash.</p><blockquote><strong>Drop Specific:</strong></blockquote><pre>git stash drop stash@{1}</pre><p>It’ll clear the stash with the ID you’ve mentioned in {}.</p><blockquote><strong>Clear Stashes:</strong></blockquote><pre>git stash clear</pre><p>It’ll clear all the stashes.</p><blockquote><strong>Merge the Changes(Resolving the Conflicts):</strong></blockquote><p>There is an option called Merge; it’ll be useful to merge two branches into a single branch. For that, run this command:</p><pre>git merge &lt;branch-name&gt;</pre><p>Running this command may result in conflicts, which will be resolved in these steps:</p><ol><li>Pull all the changes from the branch-1, by running this command:</li></ol><pre>git pull origin &lt;branch-1&gt;</pre><p>2. Now checkout at the main branch:</p><pre>git checkout main</pre><p>3. Next, checkout branch-2, which you want to merge with branch-1:</p><pre>git checkout &lt;branch-2&gt;</pre><p>4. Merge the two branches:</p><pre>git merge &lt;branch-1&gt;</pre><p>Now, you may get conflicts because branch-1 has some file changes that not there in branch-2, In this case,</p><p>There will be three options:</p><ol><li>Accept incoming changes.</li><li>Accept current changes.</li><li>Accept both changes.</li></ol><p>Now just compare those files and decide which one you want.</p><blockquote><strong>Cloning an repository to your local:</strong></blockquote><p>You can easily clone an existing repository to your local machine with this command:</p><pre>git clone &lt;repoURL&gt;</pre><pre>cd &lt;repo-name&gt;</pre><p>Now you have the remote code in your local.</p><blockquote><strong>Git Reset Changes:</strong></blockquote><ul><li>Thegit reset command is used to undo the changes in your working directory and get back to a specific commit while discarding all the commits made after that one.</li><li>For instance, imagine you made ten commits. Usinggit reset on the first commit will remove all nine commits, taking you back to the first commit stage.</li><li>You can use multiple options along with git reset, but these are the main ones. Each one is used depending on a specific situation:</li></ul><ol><li>git reset --soft</li><li>git reset --mixed, and</li><li>git reset --hard</li></ol><p><strong>Git Reset Soft:</strong></p><p>The — soft aims to change the HEAD (where the last commit is in your local machine) reference to a specific commit. For instance, if we realize that we forgot to add a file to the commit, we can move back using the — soft with respect to the following format:</p><blockquote><strong>To move back to the commit with a specific reference (n):</strong></blockquote><pre>git reset --soft HEAD~n</pre><blockquote><strong>To get back to the last commit:</strong></blockquote><pre>git reset --soft HEAD~1</pre><p>Also, there must be a commit ID for every commit, and you can also use that commit ID to reset.</p><blockquote><strong>Reset using commit ID:</strong></blockquote><pre>git reset --soft 521747298a3790fde1710f3aa2d03b55020575aa</pre><blockquote><strong>Git Reset Mixed:</strong></blockquote><p>This is the default argument for git reset. Running this command has two impacts:</p><ol><li>Uncommit all the changes and</li><li>Unstage them.</li></ol><p>Imagine that we accidentally added one file, and we want to remove it because that file is not finished yet.</p><p>Here is how to proceed:</p><ul><li>Unstage the files that were in the commit with git reset HEAD</li><li>Only add the files we need for the commit</li></ul><pre>git reset HEAD</pre><pre>git status</pre><pre>On branch master<br>Untracked files:<br>(use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)<br>file1.txt<br>file2.txt<br>file3.txt<br><br>nothing added to commit but untracked files present (use &quot;git add&quot; to track)</pre><blockquote><strong>Add file:</strong></blockquote><pre>git add file2.txt file3.txt<br><br>git commit -m &quot;Removed the file1.txt from the commit&quot;</pre><blockquote><strong>Git Reset Hard:</strong></blockquote><p>This option has the potential of being dangerous. So, be cautious when using it!</p><p>When using the hard reset on a specific commit, it forces the HEAD to get back to that commit and deletes everything else after that.</p><p>Before running the hard reset, let’s have a look at the content of the folder.</p><pre>git reset --hard</pre><p>It’s a command used to reset the current branch to a previous commit, forcefully discarding any local changes and modifications made to the files.</p><blockquote><strong>Git Revert:</strong></blockquote><p>Git revertis similar togit reset, but the approach is slightly different. Instead of removing all the commits in its path, the revert ONLY undoes a single commit by taking you back to the staged files before the commit.</p><p>So, instead of removing a commit, git revert inverts the changes introduced by the original commit by creating a new commit with the underlying inverse content. This is a safe way to revoke a commit because it prevents you from losing your history.</p><p>It is important to know that the revert will have no effect unless the commit hash or reference is specified.</p><p>Let’s explore a few common git revert options:</p><p>The --no-edit option allows the user to not change the message used for the commit you attend to revert, and this will make git revert file to master branch.</p><pre>git revert --no-edit &lt;commit ID&gt;</pre><p>To illustrate this scenario, let’s create two new files to be added.</p><pre>touch file1.txt file2.txt</pre><p>After creating those files, we need to add them to the modified version staging area.</p><pre>git add file1</pre><p>Before moving on, let’s look at the status:</p><pre>git status<br>Changes to be committed:<br>(use &quot;git rm --cached &lt;file&gt;...&quot; to unstage)<br>new file:   file2.txt<br>new file:   file1.txt</pre><p>We can observe that the two files have been added, now, we can commit the changes:</p><pre>git commit -m &quot;Added the monitoring script files&quot;<br>[master (root-commit) eae84e7] Added the monitoring script files<br>2 files changed, 0 insertions(+), 0 deletions(-)<br>create mode 100644 file2.txt<br>create mode 100644 file1.txt</pre><p>Now, let’s imagine that the previous commit was not intentional, and we want to get rid of it.</p><pre>git revert --no-edit eae84e7<br><br>[master c61ef6b] Revert &quot;Added the monitoring script files&quot;<br>Date: Sat Nov 12 20:14:17 2022 -0600<br>2 files changed, 0 insertions(+), 0 deletions(-)<br>delete mode 100644 file2.txt<br>delete mode 100644 file1.txt</pre><p>Let’s have a look at the log of the commits:</p><pre>git log<br><br>commit c61ef6b4e86f41f47c8c77de3b5fca3945a7c075 (HEAD -&gt; master)<br>Author: tester teido &lt;teido@gmail.com&gt;<br>Date:   Sat Nov 12 20:14:17 2022 -0600<br><br>  Revert &quot;Added the files&quot;<br> <br>  This reverts commit eae84e7669af733ee6c1b854f2fcd9acfea9d4a3.<br><br>commit eae84e7669af733ee6c1b854f2fcd9acfea9d4a3<br>Author: tester teido &lt;teido@gmail.com&gt;<br>Date:   Sat Nov 12 20:05:57 2022 -0600<br><br>  Added the files</pre><p>From the log, we can notice that a new commit has been created with the ID <em>c61ef6b4e86f41f47c8c77de3b5fca3945a7c075</em> to reverse the original commit with the ID <em>eae84e7669af733ee6c1b854f2fcd9acfea9d4a3</em>.</p><p><strong>When to use Git Revert vs Reset:</strong></p><blockquote><strong>Git Revert (Safe Play):</strong></blockquote><ul><li>Using git revert, you can go back to previous states while creating a new commit.</li><li>Go for this option if you want to undo changes on a public branch, for safety.</li></ul><blockquote><strong>Git Reset:</strong></blockquote><ul><li>With git reset, you can go back to the previous commits, but can’t create a new commit.</li><li>This option is better when undoing changes on a private branch.</li></ul><h3><strong>Git Extension:</strong></h3><p>In Visual Studio Code (VS Code), the Git extension is an integrated part of the editor, providing a seamless interface for working with Git repositories directly within the editor.</p><blockquote><strong>Creating an Repository and push the code using extension:</strong></blockquote><p><strong>Step 1:</strong> Install the Extension in VS Code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*AMnBhIqctXlDjyuFJYP9kg.png" /></figure><p>Make sure you have Git installed on your machine and the GitHub extension installed in Visual Studio Code.</p><p><strong>Step 2: </strong>Authenticate with GitHub.</p><ul><li>If you haven’t already, authenticate your VS Code with your GitHub account.</li><li>You can do this by clicking on the Source Control icon in the Activity Bar (on the side), and it will prompt you to sign in.</li></ul><p><strong>Step 3:</strong> Create a Repository.</p><ul><li>Go to your project directory which you want to push to GitHub. And open it in VS Code.</li><li>Open the Source control option.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/331/1*afCbTRS438hVajSVu_RtHg.png" /></figure><ul><li>In source control, click the option <strong>Publish to GitHub</strong>.</li><li>Then it’ll show a pop-up like this:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*ELs66jMMXNLJxD8wZzfGNQ.png" /></figure><ul><li>Type the branch name you want and select the type you want, public or private.</li><li>Once you select it, then the repo will be created in your GitHub and local.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aaSyk7Oz_7UEfLe-w8fOpQ.png" /></figure><h3><strong>Finale:</strong></h3><p>In this Dynamic world, we must be aware of the Version Control System — Git, so here is something I can pitch about it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*OFWs5wXpL5aedlbcH7Oosw.gif" /></figure><p>If any Suggestions or Corrections, you’re always welcome!!!</p><p>See you on the next journey👋👋👋</p><p>Thank you for reading my blog🫂</p><p>Until then, Signing off:</p><p><a href="https://www.linkedin.com/in/ruban-raghavendar-k/">Ruban</a>❤️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8673be9031a9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/yavar/git-version-control-system-8673be9031a9">Git — Version Control System</a> was originally published in <a href="https://medium.com/yavar">YavarTechWorks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript — Developer — Part 1]]></title>
            <link>https://medium.com/yavar/javascript-developer-part-1-c408a9f2e618?source=rss-890732543ff2------2</link>
            <guid isPermaLink="false">https://medium.com/p/c408a9f2e618</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[javascript-development]]></category>
            <category><![CDATA[web]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Ruban Raghavendar K]]></dc:creator>
            <pubDate>Wed, 13 Dec 2023 12:33:17 GMT</pubDate>
            <atom:updated>2024-05-07T04:54:03.889Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>J</strong>avaScript — Developer — Part_1</h3><p>Javascript Complete Roadmap Series...</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i8-u-V8LTTbQwTeUwLI_BQ.gif" /><figcaption>JS</figcaption></figure><blockquote><strong>Introduction:</strong></blockquote><p>JavaScript, often abbreviated JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. It lets us add interactivity to pages e.g. you might have seen sliders, alerts, click interactions, popups, etc on different websites — all of that is built using JavaScript. Apart from being used in the browser, it is also used in other non-browser environments as well such as Node.js for writing server-side code in JavaScript, Electron for writing desktop applications, React Native for mobile applications, and so on.</p><blockquote><strong>History of JavaScript:</strong></blockquote><p>JavaScript was initially created by <strong>Brendan Eich</strong> of <strong>NetScape</strong> and was first announced in a press release by Netscape in 1995. It has a bizarre history of naming; initially, it was named <strong>Mocha</strong> by the creator, which was later renamed <strong>LiveScript</strong>. In 1996, about a year later after the release, NetScape decided to rename it to <strong>JavaScript</strong> with hopes of capitalizing on the Java community (although JavaScript did not have any relationship with Java) and released Netscape 2.0 with the official support of JavaScript.</p><blockquote><strong>Javascript Versions:</strong></blockquote><p>JavaScript was invented by Brendan Eich, and in 1997 it became an ECMA standard. ECMAScript is the official language name. ECMAScript versions include ES1, ES2, ES3, ES5, and ES6.</p><blockquote><strong>How to run Javascript:</strong></blockquote><p>JavaScript can be run in the browser by including the external script file using the script tag, writing it within the HTML page using the script tag again, running it in the browser console or you can also use <strong>REPL</strong>.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;body&gt;<br><br>&lt;h2&gt;JavaScript in Body&lt;/h2&gt;<br><br>&lt;p id=&quot;demo&quot;&gt;&lt;/p&gt;<br><br>&lt;script&gt;<br>document.getElementById(&quot;demo&quot;).innerHTML = &quot;My First JavaScript&quot;;<br>&lt;/script&gt;<br><br>&lt;/body&gt;<br>&lt;/html&gt;</pre><blockquote><strong>Javascript Variables:</strong></blockquote><p>Most of the time, a JavaScript application needs to work with information. To store and represent this information in the JavaScript codebase, we use variables. A variable is a container for a value.</p><ol><li>An online shop — the information might include goods being sold and a shopping cart.</li><li>A chat application — the information might include users, messages, and much more.</li></ol><p>Variables are used to store this information.</p><blockquote><strong>Variable Declarations:</strong></blockquote><p>To use variables in JavaScript, we first need to create it i.e. declare a variable. To declare variables, we use one of the var, let, or const keywords.</p><blockquote><strong>[var] keyword:</strong></blockquote><p>The var statement declares a function-scoped or globally-scoped variable, optionally initializing it to a value.</p><pre>var x = 1;<br>console.log(x);</pre><blockquote><strong>[let] keyword:</strong></blockquote><p>The let declaration declares a block-scoped local variable, optionally initializing it to a value.</p><pre>let message;<br>message = &#39;Hello&#39;;</pre><blockquote><strong>[const] keyword:</strong></blockquote><p>Constants are block-scoped, much like variables declared using the let keyword. The value of a constant can’t be changed through reassignment (i.e. by using the assignment operator), and it can’t be redeclared (i.e. through a variable declaration). However, if a constant is an object or array its properties or items can be updated or removed.</p><p>Variables declared using const are called “constants”. They cannot be reassigned. An attempt to do so would cause an error:</p><pre>const myBirthday = &#39;18.04.1982&#39;;<br>myBirthday = &#39;01.01.2001&#39;; // error, can&#39;t reassign the constant!</pre><pre>// const colors using in our application<br>const COLOR_RED = &quot;#F00&quot;;<br>const COLOR_GREEN = &quot;#0F0&quot;;<br>const COLOR_BLUE = &quot;#00F&quot;;<br>const COLOR_ORANGE = &quot;#FF7F00&quot;;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*uwufAHSuIkzKI2WVAsMzvA.png" /><figcaption>Difference</figcaption></figure><blockquote><strong>Use Strict:</strong></blockquote><p>Normally, we need to define a variable before using it. But in the old times, it was technically possible to create a variable by a mere assignment of the value without using let. This still works now if we don’t put use strict in our scripts to maintain compatibility with old scripts.</p><pre>// note: no &quot;use strict&quot; in this example<br><br>num = 5; // the variable &quot;num&quot; is created if it didn&#39;t exist<br>alert(num); // 5</pre><p>This is a bad practice and would cause an error in strict mode:</p><pre>&quot;use strict&quot;;<br>num = 5; // error: num is not defined</pre><blockquote><strong>Hoisting:</strong></blockquote><p>Hoisting is a behavior in JavaScript where variable and function declarations are moved to the top of their containing scope during the compilation phase before the code is executed. This means that you can use variables and functions before they are declared in your code, even though they may appear to be used before their actual placement in the code.</p><ol><li>Variable Hoisting:</li></ol><pre>console.log(x); // Output: undefined<br>var x = 5;<br>console.log(x); // Output: 5</pre><p>In this example, the variable x is declared and assigned a value of 5 using the var keyword. Before the declaration, we try to log the value of x, and it outputs undefined. This is because the variable declaration var x; is hoisted to the top of the scope, but its assignment (x = 5;) stays in place. So, at the time of the first console.log(x), the variable x exists but hasn&#39;t been assigned a value yet, which results in undefined. After that, the assignment takes place, and the second console.log(x) outputs the correct value 5.</p><p>2. Function Hoisting:</p><pre>greet(); // Output: &quot;Hello!&quot;<br><br>function greet() {<br>  console.log(&quot;Hello!&quot;);<br>}</pre><p>In this example, we have a function declaration named greet. Even though the function call greet() appears before the function declaration in the code, it still works without any errors. This is because function declarations are hoisted to the top of the scope. The code is interpreted like this:</p><pre>function greet() {<br>  console.log(&quot;Hello!&quot;);<br>}<br><br>greet(); // Output: &quot;Hello!&quot;</pre><blockquote><strong>Naming Rules:</strong></blockquote><p>A variable name should accurately identify your variable. When you create good variable names, your JavaScript code becomes easier to understand and easier to work with. Properly naming variables is really important. JavaScript also has some rules when it comes to naming variables.</p><ul><li>Must start with a letter (a-z, A-Z) or an underscore (_) or a dollar sign ($).</li><li>Can be followed by letters, numbers, underscores, or dollar signs.</li><li>Cannot be a reserved keyword or a future reserved keyword. For example, you cannot use var, function, if, else, etc., as variable or function names.</li></ul><p>Examples of valid variable and function names:</p><pre>var age;<br>var _user;<br>var $price;<br>function getUserInfo() {}</pre><p>Camel Case:</p><ul><li>It is a common convention to use camel case for variable and function names.</li><li>Start with a lowercase letter and capitalize the first letter of each subsequent concatenated word.</li></ul><p>Examples of camel case names:</p><pre>var userName;<br>var itemCount;<br>function calculateTotalAmount() {}</pre><p>Constants:</p><ul><li>For constants, which are variables that should not be re-assigned, all letters should be in uppercase.</li><li>Use underscores to separate words.</li></ul><p>Examples of constant names:</p><pre>const PI = 3.14159;<br>const MAX_LENGTH = 100;</pre><p>Classes and Constructors:</p><ul><li>Class names should follow PascalCase, which means starting with an uppercase letter and capitalizing the first letter of each subsequent concatenated word.</li><li>Constructors for classes should typically use the same name as the class and start with an uppercase letter.</li></ul><p>Example of class and constructor names:</p><pre>class Person {<br>  constructor(name, age) {<br>    this.name = name;<br>    this.age = age;<br>  }<br>}</pre><blockquote><strong>Scopes:</strong></blockquote><p>In JavaScript, scopes determine the accessibility and visibility of variables and functions within different parts of your code. There are mainly three types of scopes:</p><p>Global Scope:</p><ul><li>Variables declared outside of any function or block have a global scope.</li><li>Global variables are accessible throughout the entire code, including inside functions and blocks.</li><li>Declaring variables in the global scope makes them available to all functions and blocks within the program.</li></ul><pre>var globalVar = &quot;I am a global variable&quot;;<br><br>function foo() {<br>  console.log(globalVar); // Output: &quot;I am a global variable&quot;<br>}<br><br>foo();</pre><p>Local Scope (Function Scope):</p><ul><li>Variables declared inside a function have local scope and are accessible only within that function.</li><li>Local variables are not accessible outside of the function where they are declared.</li><li>Each function invocation creates a new local scope with its own set of local variables.</li></ul><pre>function bar() {<br>  var localVar = &quot;I am a local variable&quot;;<br>  console.log(localVar); // Output: &quot;I am a local variable&quot;<br>}<br><br>bar();<br>console.log(localVar); // Throws an error: localVar is not defined</pre><p>Block Scope (Introduced with let and const):</p><ul><li>Variables declared with let and const have block scope, meaning they are accessible only within the block where they are declared.</li><li>A block is any code wrapped inside curly braces {} such as loops, conditional statements, and functions.</li><li>Block-scoped variables are not accessible outside of the block where they are defined.</li></ul><pre>if (true) {<br>  let blockVar = &quot;I am a block-scoped variable&quot;;<br>  console.log(blockVar); // Output: &quot;I am a block-scoped variable&quot;<br>}<br><br>console.log(blockVar); // Throws an error: blockVar is not defined</pre><p>It’s important to understand scope to avoid unintended variable collisions and to manage variable visibility effectively. Variables declared with var have function scope or global scope, depending on whether they are declared inside or outside a function, respectively. On the other hand, variables declared with let and const have block scope, providing better control over variable visibility and reducing common issues like variable hoisting.</p><blockquote><strong>Datatypes:</strong></blockquote><p>Data type refers to the type of data that a JavaScript variable can hold. There are seven primitive data types in JavaScript (Number, BigInt, String, Boolean, Null, Undefined and Symbol). Objects are non-primitives.</p><p>There are several data types that define the nature of values and how they are stored and manipulated. JavaScript is a dynamically-typed language, meaning you don’t need to explicitly specify the data type of a variable; the data type is automatically determined based on the value assigned to it. The main data types in JavaScript are:</p><ol><li>Primitive Data Types:</li></ol><ul><li>These are the basic building blocks of data in JavaScript and are immutable, meaning their values cannot be changed.</li></ul><p>a. Number: Represents both integer and floating-point numbers.</p><pre>var age = 30;<br>var pi = 3.14;</pre><p>b. String: Represents sequences of characters enclosed in single (‘’) or double (“”) quotes.</p><pre>var name = &quot;John Doe&quot;;<br>var message = &#39;Hello, World!&#39;;</pre><p>c. Boolean: Represents a logical value, either true or false.</p><pre>var isStudent = true;<br>var isLoggedIn = false;</pre><p>d. Null: Represents a deliberate absence of any object value.</p><pre>var emptyValue = null;</pre><p>e. Undefined: Represents a declared variable with no assigned value.</p><pre>var undefinedValue;</pre><p>f. Symbol (ES6): Represents a unique and immutable value that can be used as an identifier for object properties.</p><pre>var id = Symbol(&quot;unique id&quot;);</pre><p>g. BigInt is a data type introduced in ECMAScript 2020 (ES11) to represent arbitrarily large integers in JavaScript. Before BigInt, JavaScript represented all numbers using the Number type, which is a 64-bit floating-point format (double-precision) that can accurately represent integers up to 2^53 - 1. Any number greater than that would lose precision.</p><p>With BigInt, you can now work with integers that exceed the Number type&#39;s limit, allowing you to perform precise calculations on very large numbers.</p><pre>const bigNumber = 1234567890123456789012345678901234567890n;<br><br>// You can convert a Number to a BigInt using the BigInt() function.<br>const regularNumber = 1234567890123456789012345678901234567890;<br>const bigNumber = BigInt(regularNumber);<br><br>// BigInt values can be used in mathematical operations, and the results will also be of type BigInt.<br>const bigNum1 = 1234567890n;<br>const bigNum2 = 9876543210n;<br>const result = bigNum1 + bigNum2; // 11111111100n<br><br>// You can compare BigInt values using standard comparison operators (&lt;, &gt;, &lt;=, &gt;=, ==, ===, etc.).<br>const bigNum1 = 100n;<br>const bigNum2 = 200n;<br>console.log(bigNum1 &lt; bigNum2); // true</pre><p>2. Object Data Type:</p><ul><li>Objects are complex data types that can store multiple values and functions as properties.</li></ul><pre>var person = {<br>  name: &quot;John Doe&quot;,<br>  age: 30,<br>  isStudent: true<br>};</pre><p>3. Array Data Type:</p><ul><li>Arrays are special objects that store a collection of elements in an ordered list.</li></ul><pre>var numbers = [1, 2, 3, 4, 5];<br>var fruits = [&quot;apple&quot;, &quot;banana&quot;, &quot;orange&quot;];</pre><p>4. Function Data Type:</p><ul><li>Functions are a type of object that can be invoked to perform specific tasks.</li></ul><pre>function add(a, b) {<br>  return a + b;<br>}</pre><p>5. Date Data Type:</p><ul><li>The Date object is used for working with dates and times.</li></ul><pre>var currentDate = new Date();</pre><p>6. RegExp (Regular Expression) Data Type:</p><ul><li>Regular expressions are used to perform pattern matching in strings.</li></ul><pre>var pattern = /ab+c/;</pre><p>7. Map and Set (ES6):</p><ul><li>Map is a collection of key-value pairs, while Set is a collection of unique values.</li></ul><pre>var map = new Map();<br>var set = new Set();</pre><p>JavaScript is a versatile language with a flexible and dynamic type system that allows you to work with various data types and perform a wide range of operations. Understanding these data types is fundamental to writing effective JavaScript code.</p><p>Thank you so much for spending your time reading our blog patiently😍</p><p>Let’s see in the next part of this series, until then Signing off:</p><p>Ruban❤️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c408a9f2e618" width="1" height="1" alt=""><hr><p><a href="https://medium.com/yavar/javascript-developer-part-1-c408a9f2e618">JavaScript — Developer — Part 1</a> was originally published in <a href="https://medium.com/yavar">YavarTechWorks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android App Development: Part — 2]]></title>
            <link>https://medium.com/yavar/android-app-development-part-2-cc6a4258c3be?source=rss-890732543ff2------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc6a4258c3be</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Ruban Raghavendar K]]></dc:creator>
            <pubDate>Thu, 31 Aug 2023 03:28:33 GMT</pubDate>
            <atom:updated>2023-09-01T04:53:20.887Z</atom:updated>
            <content:encoded><![CDATA[<h3>Android App Development: Part — 2</h3><p>Using Kotlin</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*ulmAxp7Ijl91L4YYALMoNw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*chxyhQyWwO-YD5ff-fdtkw.gif" /></figure><p>Android development using Kotlin involves creating mobile applications for Android devices. Using the Android Studio IDE, you design user interfaces with XML layout files, and each screen is represented by an activity, which corresponds to a Kotlin class. Kotlin’s concise syntax and interoperability with existing Java code make it a popular choice.</p><p>Let’s continue…</p><blockquote><strong>Text View:</strong></blockquote><ul><li>TextView is a simple widget that is seen in every android application. This widget is used to display simple text within the android application. We can add custom styling to the text that we have to show.</li></ul><pre>    &lt;TextView<br>        android:layout_width=&quot;wrap_content&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:text=&quot;@string/app_name&quot;<br>        android:textColor=&quot;@color/design_default_color_error&quot;<br>        android:textSize=&quot;16sp&quot;<br>        android:textStyle=&quot;bold&quot;<br>        app:layout_constraintBottom_toBottomOf=&quot;parent&quot;<br>        app:layout_constraintEnd_toEndOf=&quot;parent&quot;<br>        app:layout_constraintStart_toStartOf=&quot;parent&quot;<br>        app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;</pre><ul><li>We can also use the design mode to change the styling of the text.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ORx7foFLSZ7udEcHqnqFAw.png" /></figure><ul><li>We should not use the text directly in the activity file, that’s not a good coding practice.</li><li>The best way is to define it strings.xml and call the names wherever we want.</li><li>If we use it like that, it shows the warning, like this:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*hspYNMBlSUcons4zjFLE9g.png" /></figure><ul><li>Here also Android Studio eases our work, we don’t need to go to the strings.xml and define the strings, by here we can define it to strings.xml, it is very simple.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/361/1*QZFi8Wya1QBK1CYXD3VhKQ.png" /></figure><ul><li>Just click on the Bulb icon or click on Alt + Enter to open the suggestions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*81qSh8oc3mV1Y7g2S1_H-A.png" /></figure><ul><li>Then select the “Extract string resource” option to extract the string to strings.xml.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*bXUdlh68Q_1WseBDJsIJ_Q.png" /></figure><ul><li>Then we need to type the name of the string, check the value of the string, and hit OK to define the string in strings.xml.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*qa0hi-TvWki1BxYVIxMBsg.png" /><figcaption>strings.xml</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*7lY6_zUvs_h6homBm2R69Q.png" /><figcaption>activity_main.xml</figcaption></figure><ul><li>Then automatically it’ll call the string here from the strings.xml.</li><li>Okay, let’s use some input fields, starting from text input.</li></ul><blockquote><strong>Layout Validation:</strong></blockquote><ul><li>In Android Studio, there is an amazing feature called Layout Validation, which is used to check how our application looks on other devices.</li><li>This panel is located in the right-end. There we can test by categories of different devices, different colors, different language locales, different font sizes and more.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*QpJEc7fQvz1TUFMMZ9Yk0g.png" /></figure><ul><li>Let’s explore some things in the MainActivity.kt.</li></ul><pre>package com.example.test_app_android<br><br>import androidx.appcompat.app.AppCompatActivity<br>import android.os.Bundle<br><br>class MainActivity : AppCompatActivity() {<br>    override fun onCreate(savedInstanceState: Bundle?) {<br>        super.onCreate(savedInstanceState)<br>        setContentView(R.layout.activity_main)<br>    }<br>}</pre><ul><li>This is our Kotlin file. MainActivity is the layout controller class of the activity_main.xml.</li><li>The activity_main is connected through the SetContentView() function.</li><li>In Android, onCreate() function is called when the activity is first created. This function is where we should do all the normal setup codes like creating views and binding data.</li><li>super.onCreate(savedInstanceState) is providing us with the bundle containing the activities previously frozen state.</li><li>While using view components, it should be created inside the onCreate() function before using it in the layout files.</li><li>For creating it in the onCreate(), the Kotlin provides a keyword called val to create a view components in MainActivity and it is a read-only value.</li><li>I’ve inserted an text, input edit text, and button, that I’m going to create it in the onCreate() function.</li></ul><pre>// val valueName = findViewById&lt;valueType&gt;(R.id.idName)<br><br>val welcomeGreeting = findViewById&lt;TextView&gt;(R.id.textHello)<br>val welcomeGreeting = findViewById&lt;TextView&gt;(R.id.textHello)<br>val myButton = findViewById&lt;Button&gt;(R.id.submitButton)</pre><blockquote><strong>On Click Listener:</strong></blockquote><ul><li>Whenever the user clicks a button, it should do some operations, that should be written inside this function called setOnClickListener{}.</li><li>Next, we’re going to display the user input name for the greetings.</li><li>In Kotlin or Java, if we need to display a string we need to use double quotes “”.</li><li>And for the string interpolation, we can use the dollar symbol $.</li></ul><pre>myButton.setOnClickListener{<br>  val enteredName = inputName.text.toString()<br>  val welcomeMessage = &quot;Welcome $enteredName&quot;<br>}</pre><ul><li>The message is ready, now let’s write a code to display it. To display it on the screen just assign the welcomeMessage to the TextView.</li></ul><pre>val welcomeGreeting = findViewById&lt;TextView&gt;(R.id.textHello)<br>myButton.setOnClickListener{<br>  val enteredName = inputName.text.toString()<br>  val welcomeMessage = &quot;Welcome $enteredName&quot;<br>  welcomeGreeting.text = welcomeMessage<br>}</pre><blockquote><strong>Refactoring:</strong></blockquote><ul><li>In our real life, we’ll supposed to handle the big project like enterprises level projects. On those projects we’ll use one view component at many places, incase we need to refactor it, it took a large amount of time to replace in the all places where we used it.</li><li>For that, Android Studio gives us a solution for refactoring in all places, let’s look at how it works…</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/1*6JdaSwEIay00cDTfWFoY6g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/1*W4-b0LaZSMza7nZl5SJ6mA.png" /></figure><pre>val inputName = findViewById&lt;EditText&gt;(R.id.etName)</pre><ul><li>Once we change here, it’ll change all the files at the project level.</li></ul><blockquote><strong>Clear Fields:</strong></blockquote><p>Let’s make this more user-friendly. If we type something in the text field and click on the submit button, the value is not cleared but should be cleared after the user clicks on the submit button. For that, there is a method called .clear.</p><pre>// inside the myButton.setOnClickListener{} <br>inputName.text.clear()</pre><blockquote><strong>Data Validation:</strong></blockquote><ul><li>Let’s look into some data validation parts if we hit the submit button without an name input(empty input), should not allow the user to submit the empty string. So we’re going to write a conditional statement.</li><li>If the input contains the empty string, then we should intimate the user to enter the name.</li><li>For that, Kotlin provides a Toast message function to display a toast message to the user.</li></ul><pre>// Toast.makeText(context, &quot;message to be displayed&quot;, duration)<br>Toast.makeText(this@MainActivity, &quot;Please enter the name!&quot;,Toast.LENGTH_SHORT).show()</pre><ul><li>The Toast.makeText() function has three parameters, such as context, message string, and duration.</li><li>In the context, we can able to provide two contexts, Application Context and Main Activity Context.</li><li>To use an Application Context, just write like applicationContext, but for using a Main Activity Context, write like this@MainActivity.</li><li>Both will work, but there is a difference between them. The applicationContext is an <strong>application-level</strong> context, but the this@MainActivity is the <strong>activity-level</strong> context, it’ll end when the activity ends, and the applicationContext will end when the application ends.</li><li>We can use it according to our use case. For now we can use this <strong>activity-level</strong>.</li><li>In the Duration, there are two values: <em>LENGTH_SHORT</em> and <em>LENGTH_LONG .</em>The short length duration will end soon but the long length will take time to end.</li></ul><blockquote><strong>Visibility:</strong></blockquote><ul><li>We can also control the visibility of the view components. Let me define a button.</li><li>Give an id for it and search for the attribute called visibility, select the value as invisible. Then the button will be invisible.</li><li>In code also the attribute will be added as invisble.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*hhc2Iz6Rya4ZgweCWwK4Rg.png" /></figure><pre>    &lt;Button<br>        android:id=&quot;@+id/btnOffers&quot;<br>        android:layout_width=&quot;wrap_content&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:text=&quot;Next&quot;<br>        android:textSize=&quot;24sp&quot;<br>        android:textStyle=&quot;bold&quot;<br>/////// Visibility Attribute ///////////////<br>        android:visibility=&quot;invisible&quot;<br>        app:layout_constraintBottom_toBottomOf=&quot;parent&quot;<br>        app:layout_constraintEnd_toEndOf=&quot;parent&quot;<br>        app:layout_constraintHorizontal_bias=&quot;0.862&quot;<br>        app:layout_constraintStart_toStartOf=&quot;parent&quot;<br>        app:layout_constraintTop_toTopOf=&quot;parent&quot;<br>        app:layout_constraintVertical_bias=&quot;0.935&quot; /&gt;</pre><ul><li>Let’s make it visible when the user enters a name and hits the Submit button.</li></ul><pre>// this user need to import visible view<br>import android.view.View.VISIBLE<br><br>// we can use this in the conditional statement<br>offerButton.visibility = VISIBLE</pre><blockquote><strong>Navigate:</strong></blockquote><ul><li>In Android, we can navigate from one screen to another using Indent, We need to provide two arguments to Indent, Current Context and Destination Activity.</li></ul><pre>offerButton.setOnClickListener {<br>  val indent = Intent(this, SecondActivity::class.java)<br>  startActivity(indent)<br>}</pre><ul><li>In this function, offerButton is the navigating button ID.</li><li>this the keyword indicates that “this context”, and “SecondActivity::class.java” indicates that the destination activity.</li><li>startActivity(indent) indicates that passing the indent to start the navigation activity.</li></ul><blockquote><strong>Passing a Data:</strong></blockquote><ul><li>We can pass the data from one screen to another screen by using a putExtra() method with the parameters name and value. In this the name is used to call it in the second activity.</li><li>For passing a name, there is a problem here, the name is stored and used inside the myButton function, It is defined by the val keyword, but the val is immutable.</li><li>Instead of val the keyword we can use var keyword for this scenario.</li></ul><pre>// define &amp; initiate as empty string<br>var enteredName = &quot;&quot;<br><br>// Assign a value for it<br>myButton.setOnClickListener {<br>  enteredName = inputName.text.toString()<br>}<br><br>// pass it in the navigating button using &#39;putExtra()&#39;<br>offerButton.setOnClickListener {<br>  indent.putExtra(&quot;USER&quot;,enteredName)<br>}<br></pre><ul><li>Next, go to the secondActivity file and get the data by getStringExtra() method with the name which is mentioned in the MainActivity.</li><li>In the secondActivity file, first insert a text view and give an appropriate ID for it. Then inside the onCreate():</li></ul><pre>val userName = intent.getStringExtra(&quot;USER&quot;)<br>val textView = findViewById&lt;TextView&gt;(R.id.tvOffer)<br>val message = &quot;$userName, you have free access for one month!!!&quot;<br>textView.text = message</pre><ul><li>Now the value will be displayed in the text view of the secondActivity.</li></ul><blockquote><strong>Kotlin Fundamentals:</strong></blockquote><p>Let’s see some Kotlin fundamentals and try them in <a href="https://play.kotlinlang.org/">Kotlin Playground</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3nds8kaXidPJFuparbTfDw.png" /><figcaption>Kotlin Playground</figcaption></figure><p>Remember the <a href="https://kotlinlang.org/docs/keyword-reference.html">Kotlin keyword</a>; it’s essential to our development. Spend time on it.</p><pre>fun main(){<br>    println(&quot;Welcome Ruban!&quot;)<br>}</pre><p>Let’s break down this simple function:</p><blockquote><strong>Fun Keyword:</strong></blockquote><p>In Kotlin, every time we use the fun keyword to declare a function, fun is meant by <strong>Function</strong>.</p><blockquote><strong>Main Function:</strong></blockquote><ul><li>The main function is the first function, which is called when we run the app.</li><li>Every Kotlin program needs a function named main because, from there only Kotlin starts executing the program.</li></ul><blockquote><strong>Parenthesis &amp; Braces:</strong></blockquote><ul><li>The parenthesis should be there, followed by the function name, we can also pass the parameter through it. We’ll go into detail later.</li><li>The function body should be surrounded by the curly braces.</li></ul><blockquote><strong>Print:</strong></blockquote><p>The println is a function from a co-libraries, we use it to print a text and move to the next line.</p><blockquote><strong>Comments:</strong></blockquote><ul><li>The comments are programmer-readable statements in the codes.</li><li>The comments are usually ignored by the compilers.</li><li>We add comments to make the source code easier to understand and provide information.</li><li>We can add both multi-line comments and single-line comments.</li></ul><pre>/**<br>  This is a multi-line comments:<br>  Welcome to my blog,<br>  Let&#39;s learn some new things<br> */<br><br>// This is a single-line comment</pre><p>Let’s write a basic program in Kotlin:</p><blockquote><strong>val &amp; var:</strong></blockquote><ul><li>The val is immutable and var is mutable.</li><li>If an value that we need to re-assign the value, then we need to go with var, if an value that we won’t change, there we need to use val keyword.</li></ul><blockquote><strong>Functions:</strong></blockquote><ul><li>Instead of writing multiple lines of code, we can split it into functions and call them wherever we want.</li><li>It’ll make our code more understandable and clear.</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fpl.kotl.in%2FlAl2_mTO9%3Ftheme%3Ddarcula&amp;display_name=Kotlin+Playground&amp;url=https%3A%2F%2Fpl.kotl.in%2FlAl2_mTO9%3Ftheme%3Ddarcula&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=kotl" width="800" height="300" frameborder="0" scrolling="no"><a href="https://medium.com/media/8fd7051cc3f54969ca47ed4eaf4246b1/href">https://medium.com/media/8fd7051cc3f54969ca47ed4eaf4246b1/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fpl.kotl.in%2F10uC71_tS%3Ftheme%3Ddarcula&amp;display_name=Kotlin+Playground&amp;url=https%3A%2F%2Fpl.kotl.in%2F10uC71_tS%3Ftheme%3Ddarcula&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=kotl" width="800" height="300" frameborder="0" scrolling="no"><a href="https://medium.com/media/1552b5a7e62857d81b874dd721d19f15/href">https://medium.com/media/1552b5a7e62857d81b874dd721d19f15/href</a></iframe><ul><li>In the above example, we’ve created one main function and one Int function which is used to calculate the sum of two numbers by the passing parameters of firstNumber &amp; secondNumber, we’re adding those two numbers and returning them.</li><li>We’re returning Int, so we need to mention the type of returning function.</li></ul><pre>fun calc(firstNumber:Int,secondNumber:Int):Int{ <br><br>  // Block of codes<br><br>}</pre><ul><li>Mentioning the type is the best practice for all places.</li></ul><p>Thank you so much for spending your time to reading our blog patiently😍</p><p>This is a continuing series for Android Development, so keep reading our blog 🤜🏻🤛🏻</p><p>Let’s see in the next part of this series, until then, Signing off:</p><p>Ruban❤️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc6a4258c3be" width="1" height="1" alt=""><hr><p><a href="https://medium.com/yavar/android-app-development-part-2-cc6a4258c3be">Android App Development: Part — 2</a> was originally published in <a href="https://medium.com/yavar">YavarTechWorks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android-App Development — Part_1]]></title>
            <link>https://medium.com/yavar/android-app-development-part-1-252f4ed7e2ba?source=rss-890732543ff2------2</link>
            <guid isPermaLink="false">https://medium.com/p/252f4ed7e2ba</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Ruban Raghavendar K]]></dc:creator>
            <pubDate>Sun, 27 Aug 2023 18:21:25 GMT</pubDate>
            <atom:updated>2023-08-28T05:40:55.325Z</atom:updated>
            <content:encoded><![CDATA[<h3>Android-App Development — Part_1</h3><p>Using Kotlin</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W9OXJS1rOd-DRdsjQ0AMPw.png" /></figure><p>Android development using Kotlin involves creating mobile applications for Android devices. Using the Android Studio IDE, you design user interfaces with XML layout files, and each screen is represented by an activity, which corresponds to a Kotlin class. Kotlin’s concise syntax and interoperability with existing Java code make it a popular choice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HTaSTWRF-84rSsCCJLNMPw.png" /></figure><blockquote><strong>Android:</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*q0J7rMMqNhKkHJm953kJZA.png" /></figure><p>Android was developed by the Open Handset Alliance, led by Google, and other companies. Android offers a unified approach to application development for mobile devices which means developers need only develop for Android, and their applications should be able to run on different devices powered by Android.</p><blockquote><strong>Kotlin:</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*Aovk6Bv5kgbfn6_MqbuHBA.png" /></figure><p>Kotlin is an open-source, statically typed programming language that supports both object-oriented and functional programming. Kotlin provides similar syntax and concepts from other languages, including C#, Java, and Scala, among many others. Kotlin does not aim to be unique — instead, it draws inspiration from decades of language development. It exists in variants that target the JVM (Kotlin/JVM), JavaScript (Kotlin/JS), and native code (Kotlin/Native).</p><p>Certain Android APIs, like Android KTX, are Kotlin-specific, but most are written in Java and can be called from either Java or Kotlin. Kotlin’s interoperability with Java is core to its growth. It means you can call into Java code from Kotlin and vice-versa, leveraging your existing Java libraries.</p><blockquote><strong>Java:</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*dOlD2CRS-B9qC7C1GsZ4XQ.png" /></figure><p>JAVA is a programming language that is used in Android App Development. It is class-based and object-oriented programming whose syntax is influenced by C++. The primary goals of JAVA are to be simple, object-oriented, robust, secure, and high-level.</p><blockquote><strong>Let’s Get — Started 🏁</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*9CfYt83M8Id6szmWDKpaQA.png" /></figure><p>The very first step is to install Android Studio on our machine. To install the studio, there are some system requirements, let’s look into it…</p><blockquote><strong>System Requirements:</strong></blockquote><p><strong>For WindowsOS:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*1oAxGrOFgoY1Q-03z5u5AQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kcOsJyYIoKbLw6a18Vfm9g.png" /></figure><p><strong>For MacOS:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*T2WLmn0GfeUjhkS3jY0JzA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y8dz6i84eGSBzR5mwIS6-A.png" /></figure><p><strong>For LinuxOS:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*elFbgewxjkzp4b1JksA53w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V0pFwuY1PpWJd0-rd6W5pA.png" /></figure><blockquote><strong>Installation:</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*Jll4MW3XdRrQc0hKuIjVrQ.png" /></figure><ul><li>To Install the Android Studio, Click the 👉🏻 <a href="https://developer.android.com/studio"><strong>Android Studio</strong></a> to download and install.</li><li>Once we click the link given above, we’ll be redirected to the Android Studio Official Download page, We need to click the <strong>Download Android Studio🔻 </strong>option, accept their Terms and Conditions, and download the Studio.</li></ul><blockquote><strong>Setup Studio:</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*vtwyP0cLeKpJ81Mpic7UMg.png" /></figure><p>Once we install Android Studio, then open it. For the very first time it took time to open, because the libraries and packages are need to by download, “<strong>the internet connections is required</strong>”.</p><p>After sometime, the studio will show three options:</p><ol><li>New Project</li><li>Open</li><li>Get from VCS</li></ol><p>From these select a new project and choose the device we need, we need to select: the “Phone and Tablet” option.</p><p>There are multiple Activity templates; from those, we need to select “Empty Activity”. And click “Next”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yh2eW8F5L_uf9o7owi5ksA.png" /></figure><p>Set the project name and project location, wherever we need put our project. And click finish to create project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YKj-MeOrBOTLEl31eQ80tA.png" /></figure><blockquote><strong>Folder Structure:</strong></blockquote><ul><li><strong>Manifests </strong>— Let’s Start with the “<strong>manifests</strong>” folder, the manifests folder container, and the AndroidManifest.XML file. This is a very important file. Every Android app has an “AndroidManifest.XML” file. This file contains some information, about how to run the app.</li><li>This XML file acts as an intermediary between the Android OS and our Application.</li><li>When the user taps on the app icon to launch the application, the Android operating system first reaches the AndroidManifest.XML file</li><li>By using the information in AndroidManifest.XML file, the system decides what to do next? and what activity to open first.</li><li>The Manifest file contains details about all the activities.</li><li>In that, there we’ve an intent filters, for example:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*nKK4tf5hKo1xyo5eggq4DA.png" /></figure><ul><li>This intent says that this is a Launch activity.</li><li>Using this information, Android OS decides to launch this main activity first.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*NvB9A6F0CeFXN9leBC5aGw.png" /></figure><blockquote><strong>Create Activity:</strong></blockquote><p>For creating an activity, go File → New → Activity → Empty Views Activity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wRfapioP6qGb9PfAiryyBg.png" /></figure><ul><li>After that, we need to give our activity and click finish.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6-0lfeaD-85TtPyNMgpiLw.png" /></figure><ul><li>And also it’s mainly used for setting permissions in our application, if our application uses any REST-APIs, then the internet is necessary, For that, we need to set the permissions here.</li></ul><pre>&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;</pre><ul><li><strong>Java </strong>— Look into Java a directory, the Java folder contains all the source code files we create during the development.</li><li>The Java folder contains three subfolders, the first one contains the source code files. The next two directories are to be used for test and Android test directories are to store test files.</li><li>We use this directory to create test cases, normal unit test cases.</li><li><strong>Java-Generated</strong> — We can see another Java folder, which is a generated one. This folder contains generated classes.</li><li>All the time, Android Studio will generate a lot of classes for us to make our life easier whenever we use supporting libraries like Chrome and Retrofit to save time making our work easier they generate a lot of files for us that generated files will be stored inside this generator java folder.</li><li>We may have a question, We’re using Kotlin but why there are Java files? Because Kotlin language has been created on top of Java language, on top of Java libraries. Kotlin is a more advanced and modern version of Java.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*6tD9vXDk3Nd3XehM8SwvKA.png" /></figure><ul><li><strong>Res </strong>— we have res a folder, this res folder contains all non-code resources. This folder does not contain Kotlin files but all the other related resource files of the app, such as XML layout files, String resources, and Bitmap Images.</li><li>This folder is divided into four subfolders named drawable, layout, mipmap, and values.</li><li><strong>Drawable </strong>— The folder called drawable contains all the different types of images we used for the development of the application, every time we add a new image file, we add it to the drawable folder. By default, we’ve two XML files. We can also add any formats to it such as .jpg, .png, .jpeg, and more.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*QP2bw7qMDB28zFYod3LODw.png" /></figure><ul><li>And then we have layout folder. The layout folder contains all the XML layout files.</li><li>For the mainactivity.kt file, the Kotlin class, we have a corresponding layout named activity main. So the layout file is stored in the layout folder.</li><li>The layout files create the view or a screen that contains all the components like buttons, text, views dropdown menus, and everything for the activities created in the Java folder.</li><li>These are called <strong>view controllers</strong>, the activity_main.xml is view, and the MainActivity.kt is a controller of that view.</li><li><strong>Minmap </strong>— The minmap contains icons in different sizes, like hdpi, mdpi, xhdpi, xxhdpi, xxxhdpi, anydpi.</li><li>In our market, there are different sizes of mobile devices, and for that these are the different sizes of icons.</li><li><strong>Values </strong>— The values contain the Strings, Colors, and Themes of our project in the XML format.</li><li>Whenever we use colors or strings in our app, we do not need to type the exact string or hex code there. Instead of that, we can use the names.</li></ul><pre>// colors.xml<br>&lt;resources&gt;<br>    &lt;color name=&quot;purple_200&quot;&gt;#FFBB86FC&lt;/color&gt;<br>&lt;/resources&gt;<br>when we&#39;re creating application, all the colors should be inside this colors.xml file.<br>whenever and wherever we need this, we just call the name to use it.<br><br><br>// strings.xml<br>&lt;resources&gt;<br>    &lt;string name=&quot;app_name&quot;&gt;My Application&lt;/string&gt;<br>&lt;/resources&gt;<br>when we&#39;re creating application, same like colors, all the strings should be inside this strings.xml file.<br>whenever and wherever we need this, we just call the name to use it.</pre><ul><li>In the future, if we need to change or rewrite something, we no need to change in all the places, we just change in these xml files.</li><li><strong>Themes</strong> —This folder contains the details about the theme of our application.</li><li>We can change the default primary and secondary colors and we can also insert our custom theme xml files.</li><li><strong>Gradle-Scripts </strong>—These are very important, gradle is an automated build system. So because of the gradle, we don’t have to do the configuration manually. We don’t have to download libraries put them in different folders and write our own configurations. Gradle automatically does all that stuff.</li><li>There are two build.gradle files, one is <strong>Project Level</strong> and another one is <strong>App Level</strong> gradle file. Most of the time we use these two files.</li><li>Especially in the App Level gradle file, whenever we use plugins or dependencies, we need to define it here.</li><li>In the Android studio, if we select an activity xml file, we can see three modes: 1. Code, Split, and Design. By the coding mode, we can see only the code alone, by the design mode we can only see the design of the code, by the split mode we can see both the code and designs.</li></ul><blockquote><strong>Run:</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*s7zOHERAHj2q7nWtnBeeHg.png" /></figure><ul><li>To run our application we’ve multiple ways, The best way to run our app is to click the ▶️ play button.</li><li>In the top menus, there is an Run option, in that, there is an option called Run App, this is another way to run our application.</li><li>Or by clicking Shift + F10 to run the app.</li><li>For the very first time, it took time to run, because the first time, it’ll build the app from scratch but the next time, it won’t take that much time.</li><li>We can run our application in an Android Emulator or we can our mobile device externally using the USB Debugging option.</li><li>I recommend using USB Debugging with our mobile device, it is more fastest debugging option.</li><li>In the layouts, the activity_main.xml contains some default codes for the “Hello World!” text.</li></ul><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;androidx.constraintlayout.widget.ConstraintLayout<br>    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    xmlns:tools=&quot;http://schemas.android.com/tools&quot;<br>    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;match_parent&quot;<br>    tools:context=&quot;.MainActivity&quot;&gt;<br><br>    &lt;TextView<br>        android:layout_width=&quot;wrap_content&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:text=&quot;Hello World!&quot;<br>        app:layout_constraintBottom_toBottomOf=&quot;parent&quot;<br>        app:layout_constraintEnd_toEndOf=&quot;parent&quot;<br>        app:layout_constraintHorizontal_bias=&quot;0.501&quot;<br>        app:layout_constraintStart_toStartOf=&quot;parent&quot;<br>        app:layout_constraintTop_toTopOf=&quot;parent&quot;<br>        app:layout_constraintVertical_bias=&quot;0.181&quot; /&gt;<br><br>&lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;</pre><ul><li>We can design the screen in two modes, 1. Code mode and Design mode. In the code mode, we need to type the xml code, but the Android Studio presents the design mode to ease our work.</li><li>While in design mode, it’ll look like this:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yX2SPpA6Z6jVS55lVkgLmg.png" /></figure><ul><li>On the right side of the design, we can change the attribute values to make our design.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/281/1*tV5LOHDHT7vw3RSxhysArQ.png" /></figure><ul><li>On the left side, there is a thing called Palette, which helps us to insert the various view components like buttons, ImageView, Switch, etc.</li></ul><p>Thank you so much for spending your time reading our blog patiently😍</p><p>Let’s see in the next part of this series, until then Signing off:</p><p>Ruban❤️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=252f4ed7e2ba" width="1" height="1" alt=""><hr><p><a href="https://medium.com/yavar/android-app-development-part-1-252f4ed7e2ba">Android-App Development — Part_1</a> was originally published in <a href="https://medium.com/yavar">YavarTechWorks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>