<?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 Jecky Modi on Medium]]></title>
        <description><![CDATA[Stories by Jecky Modi on Medium]]></description>
        <link>https://medium.com/@modijecky?source=rss-681a17c5235d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*c8_Mc71r3KMhy6JV0BQ0qQ.jpeg</url>
            <title>Stories by Jecky Modi on Medium</title>
            <link>https://medium.com/@modijecky?source=rss-681a17c5235d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 19:04:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@modijecky/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[@frozen in swift]]></title>
            <link>https://medium.com/@modijecky/frozen-in-swift-d8601a416108?source=rss-681a17c5235d------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8601a416108</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[attributes]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Jecky Modi]]></dc:creator>
            <pubDate>Thu, 18 Jan 2024 15:15:21 GMT</pubDate>
            <atom:updated>2024-01-18T15:15:21.417Z</atom:updated>
            <content:encoded><![CDATA[<p>There are multiple attributes available in swift but one which is small one but very useful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*GWL6QiP4XVXEwMnihkJHwg.jpeg" /></figure><p>As per keyword, It applies to structures or enums to restrict the kind of changes you can make to the type. it’s used to denote an enum that will not receive additional values in future.</p><p>Frozen Structs. To opt out of this flexibility, a struct may be marked @frozen . This promises that <strong>no stored properties will be added to or removed from the struct, even non-ABI-public ones, and allows the compiler to optimize as such</strong>. These stored properties also must not have any observing accessors.</p><p>For example, 2D Axis have only 2 axis Horizontal and vertical</p><blockquote>@frozen public enum Axis2D{<br> case vertical<br> case horizontal<br>}</blockquote><p>We know that apart from this 2 axis, there won’t be 3rd case for that.</p><blockquote>Whenever you use this enum in switch-case, You need to define code for both cases and compiler will be happy.</blockquote><p>Happy coding!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8601a416108" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prefetching in iOS]]></title>
            <link>https://medium.com/@modijecky/prefetching-in-ios-2375b43cdf6b?source=rss-681a17c5235d------2</link>
            <guid isPermaLink="false">https://medium.com/p/2375b43cdf6b</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[collectionview]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[prefetch]]></category>
            <category><![CDATA[tableviews]]></category>
            <dc:creator><![CDATA[Jecky Modi]]></dc:creator>
            <pubDate>Sun, 08 May 2022 06:36:29 GMT</pubDate>
            <atom:updated>2022-05-08T06:40:05.900Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*dTzAwm5sKoJOkv91wCa1uw.png" /></figure><p>Evert wonder why Social media scroll is so smooth and data are always there when we scroll or it doesn’t take time to load those.</p><p>Well, Here I am with a small but a useful feature of <strong>prefetching</strong> in iOS.</p><p>Let’s get started…</p><p>We can prefetch data using <strong>tableview</strong> ad <strong>collectionview</strong> both but for that we need to register delegate as we are registering <strong>dataSource</strong> delegate.</p><pre>tableView.prefetchDataSource = self  </pre><pre>OR</pre><pre>collectionView.prefetchDataSource = self</pre><p>Let’s take an example of <strong>tableView.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*2MCB3sAGjxB6LAlGSv1Z0w.png" /></figure><p>Now, We already register delegate, we need to use it’s methods by providing <strong>UITableViewDataSourcePrefetching</strong>in tableView methods.</p><p>There’s two function in the UITableViewDataSourcePrefetching protocol :</p><pre>protocol <strong>UITableViewDataSourcePrefetching</strong> {</pre><pre><strong>// This is called when the rows are near to the visible area</strong><br>  public func tableView(_ tableView: UITableView, prefetchRowsAt indexPaths: [IndexPath])<br>  <br>  <strong>// This is called when the rows move further away from visible area, exa: user scroll in an opposite direction<br>  // Cancel Unnecessary Fetches</strong></pre><pre>  optional public func tableView(_ tableView: UITableView, cancelPrefetchingForRowsAt indexPaths: [IndexPath])<br>}</pre><p>Let’s take an example of <strong>collectionView.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RZOjeJVU8taVwxHauwA1hA.png" /></figure><p>Now, We already register delegate, we need to use it’s methods by providing <strong>UICollectionViewDataSourcePrefetching</strong> tableView methods.</p><p>There’s two function in the <strong>UICollectionViewDataSourcePrefetching</strong> protocol :</p><pre>protocol <strong>UICollectionViewDataSourcePrefetching</strong> {</pre><pre><strong>  // This is called when the rows are near to the visible area</strong><br>  public collectionView(_ collectionView: UICollectionView, prefetchItemsAt indexPaths: [IndexPath])<br>  <br>  <strong>// This is called when the rows move further away from visible area, exa: user scroll in an opposite direction<br>  // Cancel Unnecessary Fetches</strong></pre><pre>optional public collectionView(_ collectionView: UICollectionView, cancelPrefetchingForItemsAt indexPaths: [IndexPath])<br>}</pre><h3><strong>How prefetching works</strong></h3><p>Here are just observations exactly how many rows outside of visible area will be prefetched.</p><ol><li>prefetchRowsAtmethod doesn’t get called for rows which are visible on screen initially without scrolling.</li><li>Right after initial visible rows became visible, prefetchRowsAt will be called, and the indexPaths variable contain around 10 rows nearest to the visible area.</li><li>Depending on the scrolling speed, the indexPaths in prefetch method will contain different amount of rows. On normal scrolling speed, usually it will contain 1 row. If you scroll at a fast speed, it will contain multiple rows.</li></ol><p><strong>When you get used to it, you will find it very useful in multiple places.</strong></p><h3>That’s it!</h3><p>Comment if you want an example of prefetching using <strong>tableView</strong> and <strong>collectionView</strong> both.</p><p>I hope you find it useful. Your clap is giving me encouragement to create these type of stories and also Make sure you follow me on <a href="https://medium.com/@modijecky"><strong>Medium</strong></a> not to miss anything.</p><p>Also, let’s connect on <a href="https://www.linkedin.com/in/jecky-m-691b3ba1/"><strong>Linkedin</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2375b43cdf6b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[@autoclosure in Swift]]></title>
            <link>https://medium.com/@modijecky/autoclosure-in-swift-ed1d3da5748b?source=rss-681a17c5235d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed1d3da5748b</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[autoclosure]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[closure]]></category>
            <category><![CDATA[basics-of-programming]]></category>
            <dc:creator><![CDATA[Jecky Modi]]></dc:creator>
            <pubDate>Sat, 26 Feb 2022 06:22:58 GMT</pubDate>
            <atom:updated>2022-02-26T06:45:30.508Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*tEOiHflrJVXzl8a1sgI8-A.png" /></figure><p>Here, I am with a basic but a useful attribute called <strong>@autoclosure. <br></strong>Let’s deep dive into this attribute.</p><h4><strong>What’s use of @autoclosure?</strong></h4><p>As it’s name suggest, it creates a closure from an argument passed to a function.</p><p>On the implementation level, Everything looks same but here we optimize our code and slightly a performance improvement.</p><h4><strong>Let’s take an Example</strong></h4><p>Here, We created a normal function which check a condition and we are passing condition as in closure, but here we use extra curly braces to pass that condition.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4f43e4767f6463130c3ef5ca772bd8ac/href">https://medium.com/media/4f43e4767f6463130c3ef5ca772bd8ac/href</a></iframe><p>If we omit the braces, we are passing in an expression and that’s an error:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/63ae7134a7ddfd240b7ff443086ca9c0/href">https://medium.com/media/63ae7134a7ddfd240b7ff443086ca9c0/href</a></iframe><p>Here, <strong>@autoclosure </strong>comes in handy. If you use this attribute in closures you can directly pass it as an argument and it will create a closure for that argument.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/38a6b1e65610b60c860fdfd03039e8ef/href">https://medium.com/media/38a6b1e65610b60c860fdfd03039e8ef/href</a></iframe><p><strong>So when the caller writes an expression like </strong><strong>2 &gt; 1, it&#39;s automatically wrapped into a closure to become </strong><strong>{2 &gt; 1}. So it works with just an expression without the need to wrap it in a closure.</strong></p><p>When you get used to it, you will find it very useful in multiple places.</p><h3>That’s it!</h3><p>I hope you find it useful. Your clap is giving me encouragement to create these type of stories and also Make sure you follow me on <a href="https://medium.com/@modijecky"><strong>Medium</strong></a> not to miss anything.</p><p>Also, let’s connect on <a href="https://www.linkedin.com/in/jecky-m-691b3ba1/"><strong>Linkedin</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed1d3da5748b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift: Dynamic Member Lookup]]></title>
            <link>https://medium.com/@modijecky/swift-dynamic-member-lookup-cd0c9cbde33a?source=rss-681a17c5235d------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd0c9cbde33a</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[attributes]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Jecky Modi]]></dc:creator>
            <pubDate>Sun, 09 Jan 2022 09:33:21 GMT</pubDate>
            <atom:updated>2022-01-09T09:54:07.506Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/404/1*xVNDeIwSrxEGITcispAXJA.png" /></figure><p>Swift is a type safe language, In addition swift 5.5 introduces a new attribute called<strong> @dynamicmemberlookup.</strong></p><p>This attribute to a class, structure, enumeration, or protocol to enable members to be looked up by name at runtime. So it will not give any errors at compile time rather it <strong>returns default value</strong> if value is not found.</p><p><strong>Dynamic member lookup by member name can be used to create a wrapper type around data that can’t be type checked at compile time</strong></p><p>It’s same thing like you are accessing property for some class, struct or enum. For Example,</p><pre>let<strong> </strong>user<strong> = User()<br></strong>user<strong>.id<br></strong>user<strong>.name</strong></pre><h3>Use Dynamic Member Lookup</h3><p>As it’s an attribute you can just declare with giving a type @<strong>dynamicMemberLookup </strong>and provide an implementation for the <strong>subscript</strong>(dynamicMember:) method.</p><h3><strong>Dynamic Member Lookup with String Argument</strong></h3><p>as an example, we are taking user struct which has data of dictionary<strong><br></strong>Here is the Example,</p><pre>@<strong>dynamicMemberLookup</strong><br><strong>struct</strong> User {<br>    <strong>subscript</strong>(dynamicMember userData: String) -&gt; String {<br>        let properties = [&quot;id&quot;: &quot;us1236&quot;, &quot;name&quot;: &quot;Medium&quot;]<br>        return properties[userData, <strong>default</strong>: &quot;not found&quot;]<br>    }<br>}</pre><p>Now you can access properties same as you access of enums, structs</p><pre>let<strong> </strong>user<strong> = User()</strong></pre><pre>user.<strong>id               //Prints </strong>&#39;us1236<strong>&#39;<br></strong>user.<strong>name             //Prints &#39;</strong>Medium<strong>&#39;</strong></pre><pre><strong>//Accessing data which is not declared in dictionary<br></strong>user.<strong>fullname         //Prints &#39;not found&#39; as default value</strong></pre><p>What’s going on, Let’s discuss</p><ol><li>Dynamic member lookup attribute enables looking for the member info <strong>User</strong></li><li><strong>subscript</strong>(dynamicMember userData: String) is responsible for finding the expected info for the request</li></ol><h3><strong>Dynamic member lookup by key path</strong></h3><p>Let’s take an example</p><pre>struct <strong>Address</strong>{<br>   let houseNo : <strong>String</strong><br>   let street : <strong>String</strong><br>   let city : <strong>String</strong><br>}</pre><pre>struct <strong>User</strong>{<br>   let name<strong> : String<br>   </strong>let address : <strong>Address<br></strong>}</pre><pre>let address = <strong>Address</strong>(houseNo: &quot;37&quot;, street: &quot;9/4, 2nd street&quot;, city: &quot;New york&quot;)<br>let user = <strong>User</strong>(name: &quot;Nick&quot;, address: address)<br>print(user.address.houseNo) <strong>// Prints &quot;37&quot;</strong></pre><p>It will print ‘houseNo’ but for that you need to traverse through <strong>User-&gt;Address-&gt;houseNo, </strong>but what if you need to access <strong>user.houseNo </strong>directly?</p><p>This is where using keypaths with dynamic member lookup comes in handy.</p><p>Let’s make it simple, So here we create <strong>generic</strong> subscript that <strong>exposes properties of Address</strong></p><pre>@<strong>dynamicMemberLookup</strong><br>struct <strong>User</strong>{<br>   let name<strong> : String<br>   </strong>let address : <strong>Address</strong></pre><pre>subscript&lt;T&gt;(dynamicMember keyPath: KeyPath&lt;<strong>Address</strong>, T&gt;) -&gt; T {<br>        return address[keyPath: keyPath]<br>    }<br>}</pre><p>Now you can lookup the field you want from <strong>Address</strong></p><pre>user.<strong>houseNo</strong>         //<strong>Prints &#39;37&#39;</strong><br>user.<strong>street</strong>          //<strong>Prints &#39;</strong>9/4, 2nd street<strong>&#39;</strong><br>user.<strong>city</strong>            //<strong>Prints &#39;New york&#39;</strong></pre><h3>That’s it!</h3><p>I hope you find it useful. Your clap is giving me encouragement to create these type of stories and also Make sure you follow me on <a href="https://medium.com/@modijecky"><strong>Medium</strong></a> not to miss anything.</p><p>Also, let’s connect on <a href="https://www.linkedin.com/in/jecky-m-691b3ba1/"><strong>Linkedin</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd0c9cbde33a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Checking dynamic variables whether has some value or null]]></title>
            <link>https://medium.com/@modijecky/checking-empty-variables-fb4bc17474ba?source=rss-681a17c5235d------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb4bc17474ba</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[nullcheck]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutterdev]]></category>
            <category><![CDATA[flutterdevelopmentcompany]]></category>
            <dc:creator><![CDATA[Jecky Modi]]></dc:creator>
            <pubDate>Sat, 30 Oct 2021 08:05:04 GMT</pubDate>
            <atom:updated>2021-10-30T08:08:05.109Z</atom:updated>
            <content:encoded><![CDATA[<p>In Flutter, If we don’t put enough condition to check variable is empty or null then it will throw exception and it’s so frustrating.</p><h4>What are you using to check whether</h4><ul><li>String is empty (string != null or string != “”)</li><li>Array is empty (array != null || array.length != 0)</li><li>dictionary is empty (dict.isEmpty) or (dict.isNotEmpty)</li><li>bool is empty (bool != null)</li><li>int, float, num, double (value != null)</li></ul><p>It’s totally headache to check all type of variables and it’s also time cosuming.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F1xkMucz3jc5AGB4elL%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Freaction-1xkMucz3jc5AGB4elL&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2F1xkMucz3jc5AGB4elL%2Fgiphy.gif%3Fcid%3D790b761122e207f1cb871e9939a48ab6e54532789f7fc3db%26rid%3Dgiphy.gif%26ct%3Dg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="310" frameborder="0" scrolling="no"><a href="https://medium.com/media/75eead131fd7b7267660325888f40ce4/href">https://medium.com/media/75eead131fd7b7267660325888f40ce4/href</a></iframe><p>What’s the simple solution for checking any dynamic variable whether it’s empty or has some value ?</p><p>Here is the common solution for all dynamic variables.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4e8d329fc97a920d5747c600fd8b3bc0/href">https://medium.com/media/4e8d329fc97a920d5747c600fd8b3bc0/href</a></iframe><p>Happy coding, <br>Thank you.</p><p>#flutter #flutterdevelopment<br>#happycoding</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb4bc17474ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Smooth paging animation using Provider in PageController in Flutter]]></title>
            <link>https://medium.com/@modijecky/smooth-paging-animation-using-provider-in-pagecontroller-in-flutter-68d4e6e17d09?source=rss-681a17c5235d------2</link>
            <guid isPermaLink="false">https://medium.com/p/68d4e6e17d09</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[animation]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[provider]]></category>
            <dc:creator><![CDATA[Jecky Modi]]></dc:creator>
            <pubDate>Sat, 23 Oct 2021 08:39:55 GMT</pubDate>
            <atom:updated>2021-10-23T08:57:36.780Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Flutter</strong>, A cross platform mobile application development platform is currently trending in world wide market in mobile apps.</p><h4>What is PageController ?</h4><p>There are lots of widgets in Flutter but in which most common is <strong>pagecontroller</strong>. A page controller lets you manipulate which page is visible in a <a href="https://api.flutter.dev/flutter/widgets/PageView-class.html">PageView</a>. It consists of different <strong>pageviews</strong> in it.</p><p><strong>What is Provider ?</strong></p><p><em>Provider</em> is a Flutter architecture that provides the current data model to the place where we currently need it. It contains some data and notifies observers when a change occurs.</p><p>In Flutter SDK, this type is called a <strong><em>ChangeNotifier</em></strong>. For the object of type <strong><em>ChangeNotifier</em></strong> to be available to other widgets, we need <strong><em>ChangeNotifierProvider</em></strong>.</p><p>It provides observed objects for all of its descendants. The object which is able to receive current data is <em>Consumer</em>, which has a <strong><em>ChangeNotifier</em></strong> instance in the parameter of its <em>build</em> function that can be used to feed subsequent views with data.</p><p>So in this demo we will talk about animating between pages of <strong>pagecontroller</strong> using custom buttons. Here what we are going to achieve using custom buttons.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*menzTuZhO-HCd-ENvMy1Hg.png" /><figcaption>Account page with Linked and Delinked accounts</figcaption></figure><p>So in above screenshot “Linked account” and “Delinked account” are custom button created and based on those button click we change page of page controller.</p><p>So here is the common PageController code :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cad15b3296ea89abeaf1eec4d39981d1/href">https://medium.com/media/cad15b3296ea89abeaf1eec4d39981d1/href</a></iframe><p>Here in above Gist file you can see that on button click we need to set state of page and reload whole widget.</p><p><strong>What if we don’t need to do that ? We can change page of pagecontroller without using setState</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3oKIPl97G9KsnxS3XG%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Freactionseditor-interesting-hmm-3oKIPl97G9KsnxS3XG&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2F3oKIPl97G9KsnxS3XG%2Fgiphy.gif%3Fcid%3D790b76112906b9567c2c15af69254471d615c6e096d38fc6%26rid%3Dgiphy.gif%26ct%3Dg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="186" frameborder="0" scrolling="no"><a href="https://medium.com/media/e2e60f3f4f4a923a411ac37ef7a81c1f/href">https://medium.com/media/e2e60f3f4f4a923a411ac37ef7a81c1f/href</a></iframe><p>So here <strong>Provider</strong> comes in Picture. We will create class with <strong>ChangeNotifier</strong> of <strong>Provider.</strong></p><p>Here is the class of Provider :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ee79a3c1fefc824077d719481221e954/href">https://medium.com/media/ee79a3c1fefc824077d719481221e954/href</a></iframe><p>So in this provider file, We create a private variable <strong>_currentPage </strong>and create getter-setter of this variable.</p><p>At the end of setter you notice <strong>notifyListeners() </strong>is there, So whenever value of that variable update, it will notify widget that this value is updated and it will update that widget too.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F26BRBKqUiq586bRVm%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Famericasgottalent-agt-americas-got-talent-26BRBKqUiq586bRVm&amp;image=https%3A%2F%2Fmedia2.giphy.com%2Fmedia%2F26BRBKqUiq586bRVm%2Fgiphy.gif%3Fcid%3D790b76113a99e45d9d11b348055331282c32283733215b6f%26rid%3Dgiphy.gif%26ct%3Dg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="240" frameborder="0" scrolling="no"><a href="https://medium.com/media/6da27c9644d182946e23d3575d2cde55/href">https://medium.com/media/6da27c9644d182946e23d3575d2cde55/href</a></iframe><p>but there is a catch here, You need to register your provider class into main.dart file otherwise it will throw error. You can register as many providers as you want.</p><blockquote><strong>ChangeNotifierProvider(create: (_) =&gt; PageNotifier())</strong></blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e98b4c63a2dd465fbac3d0fceef87c36/href">https://medium.com/media/e98b4c63a2dd465fbac3d0fceef87c36/href</a></iframe><p>By registering this provider, you are now ready to use it anywhere in current implementation. To getting notified by <strong>NotifyListener, </strong>you need to use <strong>Consumer </strong>to be embedded in particular widget tree as follows :</p><blockquote><strong>Consumer&lt;PageNotifier&gt;( builder: (context, provider, snapshot) { return child; } );</strong></blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f95146dd4ba3125f01baf6f957915b9e/href">https://medium.com/media/f95146dd4ba3125f01baf6f957915b9e/href</a></iframe><p>So it will notify, when you change value of <strong>_currentPage </strong>and it will automatically update the current index of <strong>pagecontroller</strong>. Remember you need to change index of <strong>PageController</strong> when you change value of <strong>_currentPage </strong>as follow<strong> :</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ad1283c3296550bf5347cb9e78ca5c2/href">https://medium.com/media/1ad1283c3296550bf5347cb9e78ca5c2/href</a></iframe><p>So, Provider is one of the best pattern to achieve state management in flutter. There are different type of Provider Notifiers, you can find those in provider pacakge <a href="https://pub.dev/packages/provider"><strong>https://pub.dev/packages/provider</strong></a><strong>.</strong></p><p>Here is the full demo :<br><a href="https://www.dropbox.com/s/c4nsrozym1vuqq5/demo_provider.zip?dl=0">https://www.dropbox.com/s/c4nsrozym1vuqq5/demo_provider.zip?dl=0</a></p><p>Thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68d4e6e17d09" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google map circle radius In Out Animation]]></title>
            <link>https://medium.com/@modijecky/google-map-circle-radius-in-out-animation-68d798a0d9ca?source=rss-681a17c5235d------2</link>
            <guid isPermaLink="false">https://medium.com/p/68d798a0d9ca</guid>
            <category><![CDATA[animation]]></category>
            <category><![CDATA[google-maps]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Jecky Modi]]></dc:creator>
            <pubDate>Tue, 05 Nov 2019 03:34:11 GMT</pubDate>
            <atom:updated>2019-11-05T03:34:11.548Z</atom:updated>
            <content:encoded><![CDATA[<p>This title is too obvious that everyone has worked on it and knows the animation very well. Well, I am not talking about heart beat animation of circle radius, I am talking about In an Out animation. So, Let’ start….</p><p>What we want to achieve as per the below gif.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2u_ZPpECCr3tF1OJLpCM9w.gif" /><figcaption>Animation Google map radius In Out</figcaption></figure><p>So, How can we do like that?</p><p>As per my last story, I shared you how to do pin drop animation on google map, Here is the link of that. <a href="https://medium.com/@modijecky/google-map-pin-drop-animation-a6888758b61c">https://medium.com/@modijecky/google-map-pin-drop-animation-a6888758b61c</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FMn3qYLjj7KiejarSI1%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fyearsandyears-years-and-Mn3qYLjj7KiejarSI1&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FMn3qYLjj7KiejarSI1%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="186" frameborder="0" scrolling="no"><a href="https://medium.com/media/760c64945f9a5c42a1e62478d7993d03/href">https://medium.com/media/760c64945f9a5c42a1e62478d7993d03/href</a></iframe><p><strong>Now the Logic behind this animation is We draw circle on google map by increasing its radius step by step using timer and remove the older ones.</strong></p><p>So, Now you have the core logic, Now ready to implement it ??</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FZgURe4CWXu8gBEpwYy%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fcbc-schittscreek-schitts-creek-ZgURe4CWXu8gBEpwYy&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2FZgURe4CWXu8gBEpwYy%2Fgiphy-downsized-large.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/c1ab8d61eaabaca6e99307c6074c3798/href">https://medium.com/media/c1ab8d61eaabaca6e99307c6074c3798/href</a></iframe><h3>Let’s Start</h3><h4>First, We need a current location and set radius of for example, 5000 meters. So…</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*LQtowaijsxnZslf73BAagg.png" /></figure><p>This will set out current location, Now for the radius</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*k_FviRNyC3yYHaJD0mBWIw.png" /></figure><p>You have one question that what is <strong>bounds() </strong>here. So here is the explanation for that</p><p>Now, We have to fit that radius of google map within our Screen ratio. So there is extension of google map which calculates bounds of given coordinates using radius</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*dtS3IUh4QWFRyKdHoKuwkA.png" /></figure><h3>Now the Core part <strong>ANIMATION</strong></h3><p>So we are using timer here for animation So each time timer method calls we can increase or decrease radius</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*7upba4qNAen2z_L7K1qc9w.png" /></figure><p>Timer Method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*5Z1TVBv_yOirPgJShu70bQ.png" /></figure><p>Now you think what is <strong>circleAnimation ==.out</strong> and <strong>.in </strong>is?<br>So it is enum to identify whether my circle animation is In or Out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*fVsjMZuwrHLby3zhzSHWGA.png" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FxT9KVB3T08uqxrzEqs%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Ffilmeditor-movie-mean-girls-xT9KVB3T08uqxrzEqs&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FxT9KVB3T08uqxrzEqs%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc3ce88bc7f1eedc73d4fb00a725452a/href">https://medium.com/media/dc3ce88bc7f1eedc73d4fb00a725452a/href</a></iframe><p>Now you have questions like what is meaning of appending array with <strong>GMSCircle </strong>object.<br>Also what is purpose of code when you remove object from array.</p><p>So at first we talk about core logic that we need to remove older radius to remove it from google map. These last lines contains that logic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*GeCn6IgTTEiqA5we5YATmw.png" /></figure><p>It removes the older circle radius from google map.</p><h4><strong>That’s it, We have successfully achieved out outcome.</strong></h4><p>Here is the full source code.<br><a href="https://gist.github.com/jeckymodi/86f4a41cbfcf95ea60d541b99286e86b">https://gist.github.com/jeckymodi/86f4a41cbfcf95ea60d541b99286e86b</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68d798a0d9ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google Map Pin Drop Animation]]></title>
            <link>https://medium.com/@modijecky/google-map-pin-drop-animation-a6888758b61c?source=rss-681a17c5235d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6888758b61c</guid>
            <category><![CDATA[marker-animation]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[google-maps]]></category>
            <category><![CDATA[animation]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Jecky Modi]]></dc:creator>
            <pubDate>Sun, 27 Oct 2019 17:40:59 GMT</pubDate>
            <atom:updated>2019-10-30T10:32:15.870Z</atom:updated>
            <content:encoded><![CDATA[<p>Day by day we meet new challenges and we first think that this is not going to possible in any ways but then there is a time when we think of that challenge and ready to face it.</p><p>So as per same I have a new project in which there is a pin drop animation in google map. So I go through different sites like <strong>stackoverflow</strong>, <strong>github</strong>, <strong>reddit</strong> and <strong>medium</strong> too. But I didn’t get my answer.</p><p>So At last I told to project manager that google map is not providing any kind of this feature So we need to replace this animation with a popout animation provided by google map default.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Ful0l9GGc1aZZ2Mruzo%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fsnl-saturday-night-live-season-44-ul0l9GGc1aZZ2Mruzo&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Ful0l9GGc1aZZ2Mruzo%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="242" frameborder="0" scrolling="no"><a href="https://medium.com/media/a72c7365725872291dc7ee64da6fadce/href">https://medium.com/media/a72c7365725872291dc7ee64da6fadce/href</a></iframe><p>So one day I was free and thinking about that animation if it is possible or not. So I took my laptop in our <strong>office’s game zone</strong>, with a <strong>CCD coffee</strong> and try to think to implement that feature.</p><p>Now I have the challenge So i figure out how to start it.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3oKIPl97G9KsnxS3XG%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Freactionseditor-interesting-hmm-3oKIPl97G9KsnxS3XG&amp;image=https%3A%2F%2Fmedia2.giphy.com%2Fmedia%2F3oKIPl97G9KsnxS3XG%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="186" frameborder="0" scrolling="no"><a href="https://medium.com/media/80cea15ac1f55c23d658d22cad351bc1/href">https://medium.com/media/80cea15ac1f55c23d658d22cad351bc1/href</a></iframe><p>First I thought how to convert my pin points with my view points.</p><p>So now we are using google map functionality widely, We are using <strong>projection</strong> of google map which convert google map marker <strong>coordinates</strong> with view <strong>CGPoints.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*8OHsAF-e4i-hUYW1egks2g.png" /></figure><p>I am taking Syndey, Australia coordinates as example.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fd2eNXDl6ZkpOIqfhG6%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fromy-d2eNXDl6ZkpOIqfhG6&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fd2eNXDl6ZkpOIqfhG6%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="239" frameborder="0" scrolling="no"><a href="https://medium.com/media/0ce23ee2b697eaefe2398d8704b09cd6/href">https://medium.com/media/0ce23ee2b697eaefe2398d8704b09cd6/href</a></iframe><p>Now we have our view CGPoints, We can do whatever we can.<br>So first of all we can imagine where we have to drop our pin, So for example, If we have to drop pin from our screen top then we can do it.</p><p>We are taking a small drop of 200 pixels.</p><p>So now the core logic of this animation.</p><ol><li>We have coordinates of our marker in our screen. So we can add a subview with same coordinates excluding y axis.</li><li>Create a view with 200 minus y axis and add into our UIView and take same imageview as of pin icon, add it into that subview as follow.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*_XmYuIWqPeb95C26Jh0xow.png" /></figure><p><strong>Now you think why there is 22 pixels minus from x axis, We will talk this later.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*faoyAK-lWZBszME4QxUfaA.png" /><figcaption>You have this kind of view right now</figcaption></figure><p>4. We can animate this view to our desired coordinates. Just animate to that coordinates and remove that view from superview and add google marker into map. So we can use uiview animation for this as follow</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*1myymQp4i-N15cflayDL_A.png" /></figure><p><strong>Same question here why there are 22 pixel minus from x and y axis.</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F5Y8y2ql1vF1J6qAHXW%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fnbcmanifest-nbc-season1-manifest-5Y8y2ql1vF1J6qAHXW&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F5Y8y2ql1vF1J6qAHXW%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/395381940d46e564eef94b32e7d8c6e8/href">https://medium.com/media/395381940d46e564eef94b32e7d8c6e8/href</a></iframe><p>So as per our logic we create UIView and add it as subview. Assume that size of pin is 44*44</p><p>So for example, We found out pin coordinates as (300, 200), that is center of our pin so if we create uiview of same coordinates that is not at perfect position, It is right side of our marker. So for that we are deducting that pixels from x and y axis. Our desired output as follow</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*JjAnx6GpNNR7mPuao3iPag.gif" /></figure><p>Here is the full source code for this. Happy Coding!!!</p><p><a href="https://gist.github.com/jeckymodi/c06c5e056460b3035f4f2bf2febff26e">https://gist.github.com/jeckymodi/c06c5e056460b3035f4f2bf2febff26e</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6888758b61c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>