<?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[tagmalogic - Medium]]></title>
        <description><![CDATA[Where journey meets the destination — magic tech! - Medium]]></description>
        <link>https://medium.com/tagmalogic?source=rss----2c12838630c0---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>tagmalogic - Medium</title>
            <link>https://medium.com/tagmalogic?source=rss----2c12838630c0---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 07:44:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/tagmalogic" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Flutter — quick start]]></title>
            <link>https://medium.com/tagmalogic/flutter-quick-start-9595a676062a?source=rss----2c12838630c0---4</link>
            <guid isPermaLink="false">https://medium.com/p/9595a676062a</guid>
            <category><![CDATA[mobile-development]]></category>
            <category><![CDATA[getting-started]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Tagmalogic]]></dc:creator>
            <pubDate>Sun, 26 Jul 2020 11:11:25 GMT</pubDate>
            <atom:updated>2020-07-26T11:11:25.185Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flutter — quick start</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*RBqj985qfReOp0OUbGj3Eg.png" /><figcaption>Flutter Tech &amp; Coffee — Quick Start</figcaption></figure><h3>Introduction</h3><p>Hey everyone, I’ll not go into what Flutter is and why we love it but rather focus on giving you the a quick set of steps and resources on how to get started with it.</p><h3>Installation</h3><p>While Flutter development can happen across multiple platforms, I’ll focus on macOS in this tutorial. Nevertheless please find the official resources for installing Flutter based on your platform, <a href="https://flutter.dev/docs/get-started/install">here</a>.</p><p>Please note that due to variations in development platforms if you face any challenge in covering any point below please revisit at the end of the rest of installations/setups.</p><p><strong><em>Download the latest stable </em></strong><a href="https://flutter.dev/docs/development/tools/sdk/releases?tab=macos"><strong><em>Flutter SDK</em></strong></a> for your platform, as of now <a href="https://storage.googleapis.com/flutter_infra/releases/stable/macos/flutter_macos_1.17.5-stable.zip">1.17.5</a> is the latest for macOS, and unzip it in your software kits folder and then add it to the PATH. For instance:</p><pre>cd {path your software kits folder}<br>unzip ~/Downloads/flutter_macos_1.17.5-stable.zip<br>export PATH<strong>=</strong>&quot;$PATH:`pwd`/flutter/bin&quot;</pre><p>The above will set the Flutter path for current terminal session. For a permanent solution see this <a href="https://flutter.dev/docs/development/ui/widgets">link</a> and do the steps appropriate for you. Here is how I do it to add it to the .bash_profile . I use vi as an editor, but you can choose your preferred one.</p><pre>vi $HOME/.bash_profile</pre><pre>&lt;then make sure I have this line added&gt;</pre><pre>export PATH=&quot;$PATH:{path your software kits folder}&quot;</pre><pre>&lt;then refresh your terminal&gt;</pre><pre>source $HOME/.bash_profile</pre><p>Run echo $PATH to check that Flutter is added to the path and then which flutter that should return the location of your Flutter installation.</p><p>Now, run<strong>flutter doctor</strong> and this will basically point the next steps you need to undertake, as simple as that :).</p><p>You might need to install other <strong>dependencies</strong> for Android (like Android SDK and Android Studio) or iOS and macOS (like XCode), and I’d advise you follow those steps, as they are customised for your system. On macOS you will need to have all Android or iOS steps to be able to deliver a Flutter application.</p><p>Generally, I’d advice you to perform the following steps (if you did not do it already):</p><ul><li><strong>install or update your Xcode</strong> from Mac App Store. Just search for it or go <a href="https://apps.apple.com/us/app/xcode/id497799835?mt=12">here</a>. Be advised that updating your macOS version might be required… Then open Xcode and install additional components if prompted for. Check additional advice <a href="https://flutter.dev/docs/get-started/install/macos#install-xcode">here</a>.</li><li><strong>start the iOS simulator</strong> withopen -a Simulator . Check additional advice <a href="https://flutter.dev/docs/get-started/install/macos#set-up-the-ios-simulator">here</a>.</li></ul><blockquote>At this stage you should be able to go to your development folder and run flutter create default_project , this will <strong>create a basic project for you</strong>, and then cd default_project and with<strong>flutter run</strong> you will eventually see your default application starting on the iOS Simulator.<strong> Should you want to run on a physical device</strong> you will need to connect one to you development platform and perform a set of settings in Xcode as mentioned <a href="https://flutter.dev/docs/get-started/install/macos#deploy-to-ios-devices">here</a>. See below how I signed in.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LEAVj-LcYAbbmOag2J6uXw.png" /></figure><ul><li><strong>install or update your Android Studio</strong>. Search it up or go <a href="https://developer.android.com/studio">here</a>. One piece of advice is to go and check in Preferences &gt; Plugin that Flutter and Dart plugins are installed, if not, install them and restart the IDE.</li></ul><blockquote>At this stage, if you still have the iOS Simulator up and your physical device connected, and if you open the created Flutter project in Android Studio, or if you create new Flutter project in Android Studio (File &gt; New &gt; New Flutter Project…) you will be able to launch the project on one of the available devices like below, click on the run button (the green triangle). Make sure that the physical device is unlocked if you choose it.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*kKVfUxMChOqeN6MPL7UkNA.png" /></figure><blockquote>In Android Studio you can define additional <strong>Android Emulators</strong> from AVD Manager and then start them. They should then be available in the devices to run your project against. Obviously this are using Android OS.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AhKcxbrGxXJ7qVmk7XNGow.png" /></figure><ul><li><strong>install also VS Code </strong>from <a href="https://code.visualstudio.com/download">here</a> and follow the instructions <a href="https://flutter.dev/docs/get-started/editor?tab=vscode">here</a>, should you want to use it as your development platform.</li></ul><p>Do run flutter doctor as there might be other dependencies that your system needs. Just install everything that is still pointed out.</p><p>Once flutter doctor shows not more issues, then you are good to go to the next steps.</p><h3>Default Flutter project &amp; run it.</h3><p>Well, at this stage you have already the default Flutter project :) — Flutter Demo — set up on your development environment. You created it either with flutter create default_project or with create new Flutter project in Android Studio (File &gt; New &gt; New Flutter Project…).</p><p>We also have minimally covered above how to run from Android Studio your project on iOS simulator or Android emulator. Even more, we touched on how you can simply run on real devices.</p><h3>Explore ahead and visit official documentation</h3><p>Now you can go ahead and explore the main.dart file in your project. It is not the purpose of this getting started tutorial to explore the Flutter code, but just get you started with the development environment and the demo project.</p><p>As Flutter makes extensive use of widgets I’d advise you to review in the <a href="https://flutter.dev/docs/development/ui/widgets">official widgets documentation page</a> the widgets used in the demo project like: StatelessWidget, StatefulWidget, Scaffold, AppBar, Text and so on.</p><blockquote>I hope this quick intro to Flutter was useful and stay tuned as more advanced tutorials will keep coming. Don’t hesitate to like, share and comment :)</blockquote><blockquote>See you!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9595a676062a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tagmalogic/flutter-quick-start-9595a676062a">Flutter — quick start</a> was originally published in <a href="https://medium.com/tagmalogic">tagmalogic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WebdriverIO — Open multiple browser tabs]]></title>
            <link>https://medium.com/tagmalogic/webdriverio-open-multiple-browser-tabs-1882fbfc7e89?source=rss----2c12838630c0---4</link>
            <guid isPermaLink="false">https://medium.com/p/1882fbfc7e89</guid>
            <category><![CDATA[tagmalogic]]></category>
            <category><![CDATA[webdriverio]]></category>
            <category><![CDATA[webdriver]]></category>
            <dc:creator><![CDATA[Tagmalogic]]></dc:creator>
            <pubDate>Sat, 30 May 2020 21:00:00 GMT</pubDate>
            <atom:updated>2020-05-30T21:11:12.257Z</atom:updated>
            <content:encoded><![CDATA[<h3>WebdriverIO — Open multiple browser tabs</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*GNm6YWVXvrNHH8f2y-wPhg.png" /><figcaption>WebdriverIO — multiple browser tabs</figcaption></figure><p>In this article I assume you are familiar with WebdriverIO, at least at a basic level and you know how to put a test together and run it.</p><p>One need that you might have, at times, is to deal with multiple browser tabs or windows and perform different verifications there.</p><p>This is where <strong>browser.newWindow </strong>can come to the rescue… with one caveat though… there seems to be some limitations and it opens only one additional browser tab (or window). If you need only two browser tabs/windows that’s fine but what if you need more than two browser tabs/windows?</p><p>So, this code below will end up having only two open browser tabs… well, the second tab that initially opens webdriver.io will be reloaded with yahoo.comand this sucks, right?</p><pre>browser.url(https://medium.com/%E2%80%9Chttps://google.com&quot;);<br>browser.newWindow(&quot;https://webdriver.io&quot;);<br>browser.newWindow(&quot;https://yahoo.com&quot;);</pre><p>There is a way though to sort this out :), just use some JavaScript insertion to open additional browser tabs with <strong>window.open()</strong>. The command below will open additional tabs for you.</p><pre>browser.execute((url) =&gt; {</pre><pre>window.open(url);</pre><pre>}, &quot;http://yahoo.com&quot;);</pre><p>Now, if we put it all together and want, let say, to open for different tabs, with two seconds waiting interval between them and the switch to the newly open tabs, here is the code below, you can just copy/paste in your spec file and try it out.</p><pre>describe(&quot;tabs&quot;, () =&gt; {<br>  it(&quot;multiple browser tabs / windows&quot;, () =&gt; {<br>    // open url<br>    browser.url(https://medium.com/&quot;%3Ca%20href=%22/service/https://google.com/%22%3Ehttps://google.com%3C/a%3E&quot;);<br>    browser.pause(2000);</pre><pre><strong>browser.newWindow(&quot;</strong><a href="https://webdriver.io/"><strong>https://webdriver.io</strong></a><strong>&quot;);</strong><br>    browser.pause(2000);</pre><pre><strong>browser.execute((url) =&gt; {<br>      window.open(url);<br>    }, &quot;</strong><a href="http://yahoo.com/"><strong>http://yahoo.com</strong></a><strong>&quot;);</strong><br>    browser.pause(2000);</pre><pre><strong>browser.execute((url) =&gt; {<br>      window.open(url);<br>    }, &quot;</strong><a href="http://twitter.com/"><strong>http://twitter.com</strong></a><strong>&quot;);</strong><br>    browser.pause(2000);</pre><pre>browser.switchWindow(&quot;google.com&quot;);<br>    browser.pause(2000);</pre><pre>browser.<strong>switchWindow</strong>(&quot;webdriver.io&quot;);<br>    browser.pause(2000);</pre><pre>browser.<strong>switchWindow</strong>(&quot;yahoo.com&quot;);<br>    browser.pause(2000);</pre><pre>browser.<strong>switchWindow</strong>(&quot;twitter.com&quot;);<br>    browser.pause(2000);<br>  });<br>});</pre><p>There is one thing to note though, each browser might have implemented window.open() slightly different. For instance, open new tabs rather than windows or the other way around. You might need to do additional research regarding your browser if it does not behave as you expected as sometimes this can be worked out in the browser setting.</p><p>This was tested in WebdriverIO v6.</p><p>I hope this was helpful!</p><p>See ya!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1882fbfc7e89" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tagmalogic/webdriverio-open-multiple-browser-tabs-1882fbfc7e89">WebdriverIO — Open multiple browser tabs</a> was originally published in <a href="https://medium.com/tagmalogic">tagmalogic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WebdriverIO — getting started]]></title>
            <link>https://medium.com/tagmalogic/webdriverio-getting-started-906c2729111e?source=rss----2c12838630c0---4</link>
            <guid isPermaLink="false">https://medium.com/p/906c2729111e</guid>
            <category><![CDATA[webdriver]]></category>
            <category><![CDATA[webdriverio]]></category>
            <category><![CDATA[automation]]></category>
            <dc:creator><![CDATA[Tagmalogic]]></dc:creator>
            <pubDate>Thu, 28 May 2020 23:14:23 GMT</pubDate>
            <atom:updated>2020-06-12T23:17:29.480Z</atom:updated>
            <content:encoded><![CDATA[<h3>WebdriverIO — getting started</h3><h3>test automation… super quick and slick!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*I0c2pdc7CXjCcjBFUTD-6g.png" /><figcaption>WebdriverIO — Getting Started</figcaption></figure><p>Well, once you are here, I guess you should be having at least a basic idea of what WebdriverIO is… a test automation framework.</p><blockquote>On top of that I’d say… it is super awesome.</blockquote><p>This is not going to be an in depth article about WebdriverIO but just a flavour on how you can get started really quickly with it.</p><p>In the mix we’ll see mocha for organising tests, chai for assertions, node.js for handling JavaScript libraries as well as Docker for spinning up our demo application — in this case a test WordPress instance.</p><h4><strong>Let’s get things prepared</strong></h4><p>So, make sure you have node.js and some tools that come with it installed. You can install it from <a href="https://nodejs.org/en/">here</a>. I’d say, take the recommended LTS version. Run, in your terminal, node -v , npm -v , npx -v . If all these return version numbers, you’re fine to go.</p><p>In your terminal, create your own folder, like… wdio-test for instance, and navigate to it, then create a new node package there.</p><pre>mkdir wdio-test<br>cd wdio-test<br>npm init -y</pre><p>Note the package.json file created.</p><p>Now, let’s install Webdriver.IO and configure it with defaults.</p><pre>npm i --save-dev @wdio/cli<br>npx wdio config -y</pre><p>At this stage, besides WebdriverIO, we have already installed mocha and other essential packages. Let’s also install chai assertion library, from which we’ll be using the expect module in our test. WebdriverIO has also anexpect library but for the purposes of this tutorial I’ll be using chai .</p><pre>npm i --save-dev chai</pre><p>Have a look in package.json and you should see all packages installed in devDependencies section.</p><pre>...</pre><pre>&quot;devDependencies&quot;: {<br>    &quot;<a href="http://twitter.com/wdio/cli">@wdio/cli</a>&quot;: &quot;^6.1.15&quot;,<br>    &quot;<a href="http://twitter.com/wdio/local-runner">@wdio/local-runner</a>&quot;: &quot;^6.1.14&quot;,<br>    &quot;<a href="http://twitter.com/wdio/mocha-framework">@wdio/mocha-framework</a>&quot;: &quot;^6.1.14&quot;,<br>    &quot;<a href="http://twitter.com/wdio/spec-reporter">@wdio/spec-reporter</a>&quot;: &quot;^6.1.14&quot;,<br>    &quot;<a href="http://twitter.com/wdio/sync">@wdio/sync</a>&quot;: &quot;^6.1.14&quot;,<br>    &quot;chai&quot;: &quot;^4.2.0&quot;,<br>    &quot;chromedriver&quot;: &quot;^83.0.0&quot;,<br>    &quot;wdio-chromedriver-service&quot;: &quot;^6.0.3&quot;<br>  }</pre><pre>...</pre><p>Our tests files (the specs) will sit in test/specs folder… so let’s create it.</p><pre>mkdir test<br>cd test<br>mkdir specs<br>cd ..</pre><h4>Get the tested application running</h4><p>First of all, move back to your folder wdio-test .</p><p>You can try out and tests on any web application and beyond but I’ve prepared for you a WordPress instance on Docker, that you can spin up locally, so you have the total control of your test environment</p><p>Follow the steps <a href="https://medium.com/tagmalogic/wordpress-with-docker-b9bf102fbcc">here</a> to get your WordPress with Docker test instance up and running on your computer.</p><h4>What scenario we’ll test?</h4><p>Well, we’ll test, using WebdriverIO, a very basic scenario… just Login to WordPress. In fact we’ll do the following:</p><ul><li>open the browser to and navigate to the URL to login in our test app</li><li>check that the login page is displayed correctly</li><li>feed in the login details</li><li>perform login</li><li>check that the login was performed successfully</li><li>perform logout</li></ul><h4>Selectors</h4><p>We’ll be identifying elements to interact with by their XPath, in this tutorial.</p><p>So navigate to <a href="http://localhost:8000/wp-admin">http://localhost:8000/wp-admin</a> (if you are logged in already in WordPress, perform a logout first).</p><p>Right click on the “Log In” button and select Inspect, as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/1*CZIo2bvlqHmCgYHKQVt_fQ.png" /><figcaption>Identify Elements</figcaption></figure><p>Now, let’s see the “Log In” button attributes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*WzsfrzqAWHiOQas5RQYckg.png" /></figure><p>As you can see, there is an attribute id=&quot;wp-submit&quot; , this is how we are going to identify this element. The XPath in this case is:</p><pre>//input[@id=&#39;wp-submit&#39;]</pre><p>We are going to do the same for the “Username” and “Password” as well as on a couple of elements that are shown in the WordPress Dashboard after login.</p><p>Now, make sure you moved back to your wdio-test folder and then create a new file inside the specs folder. On Mac for instance, will go like touch ./test/specs/wdio-get-started.js . You can as well use a text editor, as well.</p><p>Put the following code in wdio-get-started.js with your favourite editor.</p><pre>const expect = require(&quot;chai&quot;).expect;<br>describe(&quot;Test Scenario&quot;, () =&gt; {<br>  it(&quot;Navigate to WordPress&quot;, () =&gt; {<br>    browser.url(https://medium.com/&quot;%3Ca%20href=%22/service/http://localhost:8000/wp-admin%22%3Ehttp://localhost:8000/wp-admin%3C/a%3E&quot;);<br>    $(&quot;//input[<a href="http://twitter.com/id">@id</a>=&#39;wp-submit&#39;]&quot;).waitForDisplayed(5000);<br>  });<br>  it(&quot;Feed in details and initiate login&quot;, () =&gt; {<br>    $(&quot;//input[<a href="http://twitter.com/id">@id</a>=&#39;user_login&#39;]&quot;).setValue(&quot;magicman&quot;);<br>    $(&quot;//input[<a href="http://twitter.com/id">@id</a>=&#39;user_pass&#39;]&quot;).setValue(&quot;passwordWP&quot;);<br>    $(&quot;//input[<a href="http://twitter.com/id">@id</a>=&#39;wp-submit&#39;]&quot;).click();<br>  });<br>  it(&quot;Perform assertions&quot;, () =&gt; {<br>    $(&quot;//h1[text()=&#39;Dashboard&#39;]&quot;);<br>    expect($(&quot;//p[<a href="http://twitter.com/class">@class</a>=&#39;about-description&#39;]&quot;).getText()).to.equal(<br>      &quot;We’ve assembled some links to get you started:&quot;<br>    );<br>  });<br>  it(&quot;Logout&quot;, () =&gt; {<br>    $(&quot;//span[<a href="http://twitter.com/class">@class</a>=&#39;display-name&#39;]&quot;).moveTo();<br>    $(&quot;//a[text()=&#39;Log Out&#39;]&quot;).waitForDisplayed(5000);<br>    $(&quot;//a[text()=&#39;Log Out&#39;]&quot;).click();<br>    $(&quot;//p[contains(text(), &#39;You are now logged out.&#39;)]&quot;);<br>  });<br>});</pre><p>Go through it and note how we identify elements with$ which under the hood calling browser.findElement method. Also, note the use of waitForDisplayed methods that wait for elements to be displayed for the specified number of milliseconds. Also, note the mocha syntax, with describe block containing the scenario and it blocks containing individual test cases with theirs steps.</p><p>Now, you can run it with npx wdio wdio.conf.js and the run video will look something like below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m_5pu-W7P-JeQ69y0_2PlQ.gif" /><figcaption>WebdriverIO — run video</figcaption></figure><p>Once execution is complete you’ll see results as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w26Qcif3sM2bbZ4p1dUzhA.png" /></figure><p>I hope this tutorial was of use for you. Once again this was intended to be a very high level example of getting started with a basic WebdriverIO test scenario and for that reason we did not go into more detailed explanations but that will be covered in follow up tutorials.</p><p>See you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=906c2729111e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tagmalogic/webdriverio-getting-started-906c2729111e">WebdriverIO — getting started</a> was originally published in <a href="https://medium.com/tagmalogic">tagmalogic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WordPress with Docker]]></title>
            <link>https://medium.com/tagmalogic/wordpress-with-docker-b9bf102fbcc?source=rss----2c12838630c0---4</link>
            <guid isPermaLink="false">https://medium.com/p/b9bf102fbcc</guid>
            <category><![CDATA[wordpress]]></category>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Tagmalogic]]></dc:creator>
            <pubDate>Mon, 25 May 2020 23:11:21 GMT</pubDate>
            <atom:updated>2020-05-26T06:52:57.976Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*l4WJxzu5AtL20joMsD7TAA.png" /><figcaption>WordPress with Docker</figcaption></figure><p>Hey, here are a few steps to get your local installation of WordPress on Docker. Need to say that this article is not for production use and is rather a quick start point on which you can build later on based on your needs. But for learning… should be just what you need, I hope.</p><p>Even more, my intention here is to get you quickly set up and not deep dive in explaining all the concepts and components used.</p><p>Oh, one more thing, this article was put together using WordPress 5.2.2 but should be fairly similar for most versions.</p><h4>Docker</h4><p>First of all you will need to have Docker and Docker Compose installed locally, on your computer. You can do it from <a href="https://docs.docker.com/get-docker/">here</a>. Once done, check in your terminal that the installation was successful with:</p><pre>docker --version</pre><pre>docker-compose --version</pre><p>When running the above commands, you should see a version displayed.</p><p>Now, create a new file called, docker-compose.yml and add the following code to it:</p><pre>version: &quot;3.3&quot;</pre><pre>services:</pre><pre>db:</pre><pre>image: <strong>tagmalogic/simplewebappmysql:1.0</strong></pre><pre>volumes:</pre><pre>- db_data:/var/lib/mysql</pre><pre>restart: always</pre><pre>environment:</pre><pre>MYSQL_ROOT_PASSWORD: somewordpress</pre><pre>MYSQL_DATABASE: wordpress</pre><pre>MYSQL_USER: wordpress</pre><pre>MYSQL_PASSWORD: wordpress</pre><pre>wordpress:</pre><pre>depends_on:</pre><pre>- db</pre><pre>image: <strong>tagmalogic/simplewebappwp:1.0</strong></pre><pre>ports:</pre><pre>- &quot;8000:80&quot;</pre><pre>restart: always</pre><pre>environment:</pre><pre>WORDPRESS_DB_HOST: db:3306</pre><pre>WORDPRESS_DB_USER: wordpress</pre><pre>WORDPRESS_DB_PASSWORD: wordpress</pre><pre>WORDPRESS_DB_NAME: wordpress</pre><pre>volumes:</pre><pre>db_data: {}</pre><p>This will spin up, on your local machine, a Wordpress instance that is available on port 8000. Should this port be already used by other application you can go ahead and adjust it, change it in docker-compose.yml file to a port suitable for you.</p><p>In fact there are two images that we’ve build containers from. One image for the database (<strong>tagmalogic/simplewebappmysql:1.0</strong>) and one for WordPress itself (<strong>tagmalogic/simplewebappwp:1.0</strong>).</p><p>Now, run in your terminal windowdocker-compose up -d and then navigate to http://localhost:8000 . You will be prompted to progress with the Wordpress installation.</p><h4>Wordpress installation</h4><p>Choose your “language” and click continue. I’ll choose English (United States)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*Jz7G185O4CnQfcWd6aVADw.png" /><figcaption>Install WordPress — choose language</figcaption></figure><p>Insert the details in the form below…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*mlDBx6YUD3NBarA_ZZ7zbQ.png" /><figcaption>Install WordPress — install details</figcaption></figure><p>I’ll be using the following:</p><ul><li><strong>Site Tilt</strong>e — <em>WordPress Test Site</em></li><li><strong>Username</strong> — <em>magicman</em></li><li><strong>Password</strong> — <em>passwordWP</em> (well obviously, this is just a test site but don’t use such a weak password)</li><li>Check confirm use of weak password if you see this option</li><li><strong>Your Email </strong>— <em>notreallymine@notarealdomain.notarealdomain</em></li></ul><p>… hit Install WordPress.</p><p>After a short while you should be directed to the login page as below. Go ahead and login with the username and password you choose above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/363/1*Bx9MW5Pfa9ByGvyj8zTT5g.png" /><figcaption>WordPress — Login</figcaption></figure><p>Here you are, you are shown the WordPress Dashboard :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4oO_3zcIQMB_qzSu3PCVHg.png" /><figcaption>WordPress — Dashboard</figcaption></figure><p>I hope this quick tutorial was of help for you!</p><p>See you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9bf102fbcc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tagmalogic/wordpress-with-docker-b9bf102fbcc">WordPress with Docker</a> was originally published in <a href="https://medium.com/tagmalogic">tagmalogic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implement vibration with Flutter]]></title>
            <link>https://medium.com/tagmalogic/implement-vibration-with-flutter-c0a7d2d4007?source=rss----2c12838630c0---4</link>
            <guid isPermaLink="false">https://medium.com/p/c0a7d2d4007</guid>
            <category><![CDATA[haptic-feedback]]></category>
            <category><![CDATA[vibration]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Tagmalogic]]></dc:creator>
            <pubDate>Sun, 19 Jan 2020 15:38:51 GMT</pubDate>
            <atom:updated>2020-01-19T15:38:31.226Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*JRlHyCC-49K_WyEbbd9LYA.png" /><figcaption>Vibration in Flutter</figcaption></figure><p>This is meant to be a real quick guide on how to implement vibrations on iOS and Android mobile devices, using Flutter.</p><p>Before we jump into it… expect that vibrations will work in a different way on Android vs iOS. So, <strong><em>test the heck out of it</em></strong> before rolling out your app.</p><h4>How will the demo app look like?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*pTt-I3YEezVcK4wnG7leJQ.png" /><figcaption>Flutter — Vibrate example app</figcaption></figure><h4>Here is what you need to do</h4><p>Just go ahead and create a new Flutter project and replace the code in main.dart with the following:</p><pre>import &#39;package:flutter/material.dart&#39;;<br><strong>import &#39;package:flutter/services.dart&#39;;</strong> // we need this for the vibrations<br><strong>import &#39;dart:io&#39;;</strong> // we need this for the sleep method<br><br>void main() =&gt; runApp(MyApp());<br><br>class MyApp extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      title: &#39;Vibrate Demo&#39;,<br>      theme: ThemeData(<br>        primarySwatch: Colors.<em>blue</em>,<br>      ),<br>      home: VibrateHomepage(),<br>    );<br>  }<br>}<br><br>class VibrateHomepage extends StatefulWidget {<br>  VibrateHomepage({Key key}) : super(key: key);<br><br>  @override<br>  _VibrateHomepageState createState() =&gt; _VibrateHomepageState();<br>}<br><br>class _VibrateHomepageState extends State&lt;VibrateHomepage&gt; {<br><strong>  _PatternVibrate() {<br>    HapticFeedback.<em>mediumImpact</em>();<br><br>    sleep(<br>      const Duration(milliseconds: 200),<br>    );<br><br>    HapticFeedback.<em>mediumImpact</em>();<br><br>    sleep(<br>      const Duration(milliseconds: 500),<br>    );<br><br>    HapticFeedback.<em>mediumImpact</em>();<br><br>    sleep(<br>      const Duration(milliseconds: 200),<br>    );<br>    HapticFeedback.<em>mediumImpact</em>();<br>  }</strong><br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      body: Center(<br>        child: Column(<br>          crossAxisAlignment: CrossAxisAlignment.stretch,<br>          mainAxisAlignment: MainAxisAlignment.center,<br>          children: &lt;Widget&gt;[<br>            Expanded(<br>              child: FlatButton(<br>                child: Text(&#39;HapticFeedback.vibrate()&#39;),<br>                onPressed: () {<br>                  <strong>HapticFeedback.<em>vibrate</em>();</strong><br>                },<br>                color: Colors.<em>deepPurple</em>[100],<br>              ),<br>            ),<br>            Expanded(<br>              child: FlatButton(<br>                child: Text(&#39;HapticFeedback.selectionClick()&#39;),<br>                onPressed: () {<br>                  <strong>HapticFeedback.<em>selectionClick</em>();</strong><br>                },<br>                color: Colors.<em>deepPurple</em>[200],<br>              ),<br>            ),<br>            Expanded(<br>              child: FlatButton(<br>                child: Text(&#39;HapticFeedback.lightImpact()&#39;),<br>                onPressed: () {<br>                  <strong>HapticFeedback.<em>lightImpact</em>();</strong><br>                },<br>                color: Colors.<em>deepPurple</em>[300],<br>              ),<br>            ),<br>            Expanded(<br>              child: FlatButton(<br>                child: Text(&#39;HapticFeedback.mediumImpact()&#39;),<br>                onPressed: () {<br>                  <strong>HapticFeedback.<em>mediumImpact</em>();</strong><br>                },<br>                color: Colors.<em>deepPurple</em>[400],<br>              ),<br>            ),<br>            Expanded(<br>              child: FlatButton(<br>                child: Text(&#39;HapticFeedback.heavyImpact()&#39;),<br>                onPressed: () {<br>                  <strong>HapticFeedback.<em>heavyImpact</em>();</strong><br>                },<br>                color: Colors.<em>deepPurple</em>[500],<br>              ),<br>            ),<br>            Expanded(<br>              child: FlatButton(<br>                child: Text(&#39;Pattern - heart beat&#39;),<br>                onPressed: () {<br>                  <strong>_PatternVibrate();</strong><br>                },<br>                color: Colors.<em>deepPurple</em>[600],<br>              ),<br>            )<br>          ],<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>Now, let’s review what we have added in the code above related to our purpose… vibration.</p><p>We need this package import &#39;package:flutter/services.dart&#39;; as it will add the class HapticFeedback to our code base, with its methods <em>vibrate , </em><em>lightImpact, </em><em>mediumImpact, </em><em>heavyImpact </em>and<em> </em><em>selectionClick , </em>each one of them with a different vibration intensity. I’ll not go deeper here but rather advice you to run the application at the end of tutorial and try all vibrations.</p><p>I’ve imported import ‘dart:io’; to avail of the the sleep method so we can create advanced vibration patterns. _PatternVibrate() function is creating an advanced pattern, similar to a heart beat… or at least I tried :)</p><p>Then, we have for each FlatButton widget an onPressed function that is calling HapticFeedback.<em>vibrate</em>();, HapticFeedback.<em>selectionClick</em>();, HapticFeedback.<em>lightImpact</em>();, HapticFeedback.<em>mediumImpact</em>(); and HapticFeedback.<em>heavyImpact</em>(); Each one of them is triggering a different type of vibration. Also, we have the last FlatButton widget calling our _PatternVibrate() function.</p><h4>Update AndroidManifest.xml on Android.</h4><p>To have the application working in Android you will need to add &lt;uses-permission android:name=&quot;android.permission.VIBRATE&quot; /&gt; to all the AndroidManifest.xml files inside the &lt;manifest&gt; tag — arguably you might not really not need to add to all of them but for peace of mind, I’d say for this tutorial, add to all of them. You can find the AndroidManifest.xml files in {project root}/app/src/debug, {project root}/app/src/main and {project root}/app/src/profile. Also, on your Android device, you will need on enable Haptic Vibrations. In my case I did it in Settings -&gt; Sounds and vibration -&gt; Vibrations feedback and I an on Android 8. On your device might be different though.</p><p><strong>NOTE:</strong> On older versions of iOS and Android you might not have all the vibrations available and also enabling vibration feedback might be done via different steps. I do not cover this here. The example here is tested on iOS 13 and Android 8.</p><p>Also, I’ve found out that while, all vibrations covered above work on iOS, some of them did not work at all on Android (at least on Android 8) so be advised once again to test out your application. Here is what did <strong>not</strong> work for me at all on Android: HapticFeedback.<em>selectionClick</em>(); and HapticFeedback.<em>heavyImpact</em>(); hopefully this will get working in the next Flutter versions.</p><h4>Run you application and enjoy!</h4><p>Now go ahead, hook you your device(s) and run the application. All you need to do, once the application is launched on your device, and you did the settings above, is to click all the buttons and observe the vibration pattern.</p><p>I hope you enjoyed the reading and that it was useful for you.</p><p>Do not hesitate to leave comments bellow on what you liked or you did not like so much, what you want to see more or just … clap and share if you found this article useful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0a7d2d4007" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tagmalogic/implement-vibration-with-flutter-c0a7d2d4007">Implement vibration with Flutter</a> was originally published in <a href="https://medium.com/tagmalogic">tagmalogic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Widgets sizes relative to screen size in Flutter using MediaQuery]]></title>
            <link>https://medium.com/tagmalogic/widgets-sizes-relative-to-screen-size-in-flutter-using-mediaquery-3f283afc64d6?source=rss----2c12838630c0---4</link>
            <guid isPermaLink="false">https://medium.com/p/3f283afc64d6</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[media-queries]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Tagmalogic]]></dc:creator>
            <pubDate>Sat, 04 Jan 2020 21:09:33 GMT</pubDate>
            <atom:updated>2020-01-04T21:09:33.044Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*ZomVcH0opQYWfQaS0uuSxA.png" /><figcaption>Dynamic widget size in Flutter — MediaQuery</figcaption></figure><p>OK, have you ever felt like banging your head into a wall when you had your mobile app almost ready and gave a final check on how it looks on different devices with different screen sizes? Well, I felt like that recently :)</p><p>Luckily there is a relatively quick fix for this problem in Flutter. We can retrieve the screen size (width or height) and calculate for each widget what ratio shall have relative to the device size. Obviously, this will result in different values for different devices with different screen sizes. And that’s the whole point. The beauty of it is that we just need to retrieve the screen size and then decide what ratio of that size we what for each of our widgets to use, the rest is done automatically for us.</p><h3>A bit of logic for safety reasons … before coding</h3><p>We will be using MediaQuery.of(context).size to retrieve the device screen size. Before jumping to some simple code examples we need to understand what the size means in this context. It is not the actual physical resolution in pixels but rather it expresses <em>logical</em> pixels. But that’s exactly what we need. MediaQuery uses a devicePixelRatio property. Basically, if you want to tell the exact physical pixel value of your screen width you will need to do something like this: MediaQuery.of(context).size.width * MediaQuery.of(context).devicePixelRatio . In reality we don’t need to do such calculations in most of the cases as the size properties of Flutter widgets use the <em>logical</em> pixels.</p><p>Now, all you need to know really is that you can retrieve the width of the screen with MediaQuery.of(context).size.width and the height of the screen with MediaQuery.of(context).size.height. If you want to get a Size object with both dimensions you can get with with just MediaQuery.of(context).size.</p><p>Very important is to use import ‘package:flutter/material.dart’; to be able to use MediaQuery, too.</p><h3>Retrieving the meaningful height can be tricky</h3><p>To avoid another head bang onto the wall there is a bit of a trick for the height value that we need to know. The height includes the AppBar and status bar heights, too. Should you look to deduct those from the total height you can retrieve their values. The constant kToolbarHeight has the height value of the AppBar (if you are using the default AppBar height) and with MediaQuery.<em>of</em>(context).padding.top you can retrieve the height of the status bar. Then the actual meaningful screen height will be: MediaQuery.of(context).size.height — MediaQuery.<em>of</em>(context).padding.top — kToolbarHeight . Furthermore, if you use a BottomNavigation bar, the default height is stored in kBottomNavigationBarHeight constant. Naturally, in that case, the screen height will be: MediaQuery.of(context).size.height — MediaQuery.<em>of</em>(context).padding.top — kToolbarHeight — kBottomNavigationBarHeight . Really, all depends on your use case.</p><h3>Let’s see some code now…</h3><p>Go ahead and create a new Flutter project. Create a new file called sizes_helpers.dart in the lib folder of the project, besides the main.dart file. Add the following code in your new file:</p><pre>import &#39;package:flutter/material.dart&#39;;<br><br>Size <strong>displaySize</strong>(BuildContext context) {<br>  debugPrint(&#39;Size = &#39; + MediaQuery.<em>of</em>(context).size.toString());<br>  return <strong>MediaQuery.<em>of</em>(context).size;</strong><br>}<br><br>double <strong>displayHeight</strong>(BuildContext context) {<br>  debugPrint(&#39;Height = &#39; + displaySize(context).height.toString());<br>  return <strong>displaySize(context).height;</strong><br>}<br><br>double <strong>displayWidth</strong>(BuildContext context) {<br>  debugPrint(&#39;Width = &#39; + displaySize(context).width.toString());<br>  return <strong>displaySize(context).width;</strong><br>}</pre><p>I’ve added a number of debugPrint statements so you can check your logs during execution to see what are the actual values for size, width and height. Keep in mind that those are <em>logical</em> pixels not physical ones.</p><p>Add the following code in the main.dart file:</p><pre>import &#39;package:flutter/material.dart&#39;;<br><strong>import &#39;package:sizes/sizes_helpers.dart&#39;;<br></strong><br>void main() =&gt; runApp(MyApp());<br><br>class MyApp extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      title: &#39;Sizes... sizes&#39;,<br>      theme: ThemeData(<br>        primarySwatch: Colors.<em>blue</em>,<br>      ),<br>      home: MyHomePage(title: &#39;Sizes... sizes&#39;),<br>    );<br>  }<br>}<br><br>class MyHomePage extends StatefulWidget {<br>  MyHomePage({Key key, this.title}) : super(key: key);<br><br>  final String title;<br><br>  @override<br>  _MyHomePageState createState() =&gt; _MyHomePageState();<br>}<br><br>class _MyHomePageState extends State&lt;MyHomePage&gt; {<br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(<br>        title: Text(widget.title),<br>      ),<br>      body: Center(<br>        child: Column(<br>          mainAxisAlignment: MainAxisAlignment.center,<br>          children: &lt;Widget&gt;[<br>            Container(<br>              color: Colors.<em>red</em>,<br><strong>              width: displayWidth(context) * 0.25,<br></strong>              child: Text(<br>                &#39;Box width 25% of screen width and text size 3% of screen width&#39;,<br>                textAlign: TextAlign.center,<br>                <strong>style: TextStyle(fontSize: displayWidth(context) * 0.03),</strong><br>              ),<br>            ),<br>            Container(<br>              color: Colors.<em>green</em>,<br>              <strong>width: displayWidth(context) * 0.5,</strong><br>              child: Text(<br>                &#39;Box width 50% of screen width and text size 6% of screen width&#39;,<br>                textAlign: TextAlign.center,<br>                <strong>style: TextStyle(fontSize: displayWidth(context) * 0.06),</strong><br>              ),<br>            ),<br>            Container(<br>              color: Colors.<em>blue</em>,<br>              <strong>width: displayWidth(context),</strong><br>              child: Text(<br>                &#39;Box width equal to screen width and text size 10% of screen width&#39;,<br>                textAlign: TextAlign.center,<br>                <strong>style: TextStyle(fontSize: displayWidth(context) * 0.1),</strong><br>              ),<br>            ),<br>          ],<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>Although the code is simple and easy to understand please note:</p><ul><li>we imported the newly created file: import ‘package:sizes/sizes_helpers.dart’;</li><li>we’ve set the width of the Container widgets as a fraction of the total screen width, i.e. width: displayWidth(context) * 0.25</li><li>we set the size of the Text widget in the TextStyle widget once again as a fraction of the total screen width, i.e. style: TextStyle(fontSize: displayWidth(context) * 0.03)</li></ul><p>Now, go ahead and run your application and you should see something like this…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*L_Rv-UtpEp9uM_4Ja0a9Jg.png" /></figure><p>Now let’s see an example on how to calculate the height of the screen deducting the status bar height and the AppBar height.</p><p>Replace the code in main.dart file with the following code:</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:sizes/sizes_helpers.dart&#39;;<br><br>void main() =&gt; runApp(MyApp());<br><br>class MyApp extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      title: &#39;Sizes... sizes&#39;,<br>      theme: ThemeData(<br>        primarySwatch: Colors.<em>blue</em>,<br>      ),<br>      home: MyHomePage(title: &#39;Sizes... sizes&#39;),<br>    );<br>  }<br>}<br><br>class MyHomePage extends StatefulWidget {<br>  MyHomePage({Key key, this.title}) : super(key: key);<br><br>  final String title;<br><br>  @override<br>  _MyHomePageState createState() =&gt; _MyHomePageState();<br>}<br><br>class _MyHomePageState extends State&lt;MyHomePage&gt; {<br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(<br>        title: Text(widget.title),<br>      ),<br>      body: Center(<br>        child: Column(<br>          mainAxisAlignment: MainAxisAlignment.center,<br>          children: &lt;Widget&gt;[<br>            Container(<br>              color: Colors.<em>red</em>,<br>              width: displayWidth(context) * 0.5,<br>              <strong>height: displayHeight(context) -<br>                  MediaQuery.<em>of</em>(context).padding.top -<br>                  kToolbarHeight,</strong><br>              child: Text(<br>                &#39;Box width 50% of screen width and text size 6% of screen width and full screen height minus status bar height and AppBar height&#39;,<br>                textAlign: TextAlign.center,<br>                style: TextStyle(fontSize: displayWidth(context) * 0.06),<br>              ),<br>            ),<br>          ],<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>Before running the code note how we calculate the height property for the Container widget: height: displayHeight(context) -<br> MediaQuery.<em>of</em>(context).padding.top -<br> kToolbarHeight .</p><p>Go ahead now and execute your code and you should see something like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*BXMyvhNwWFRZfbUJw-WnLA.png" /></figure><p>I hope you enjoyed the reading and that it was useful for you.</p><p>Do not hesitate to leave comments bellow on what you liked, you did not like so much, what you want to see more or just … clap and share if you found this article useful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f283afc64d6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tagmalogic/widgets-sizes-relative-to-screen-size-in-flutter-using-mediaquery-3f283afc64d6">Widgets sizes relative to screen size in Flutter using MediaQuery</a> was originally published in <a href="https://medium.com/tagmalogic">tagmalogic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter — Navigate with style — basic example with BottomNavigationBar]]></title>
            <link>https://medium.com/tagmalogic/flutter-navigate-with-style-basic-example-with-bottomnavigationbar-2df19e9cf5c8?source=rss----2c12838630c0---4</link>
            <guid isPermaLink="false">https://medium.com/p/2df19e9cf5c8</guid>
            <category><![CDATA[mobile-development]]></category>
            <category><![CDATA[bottomnavigationbar]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-tech-coffe]]></category>
            <dc:creator><![CDATA[Mihai Vilcu]]></dc:creator>
            <pubDate>Sat, 30 Nov 2019 20:38:51 GMT</pubDate>
            <atom:updated>2019-11-30T21:33:27.115Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flutter — BottomNavigationBar example — Navigate with style !</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*zhcZtgLx7a3qCIG3TBrqjA.png" /><figcaption>BottomNavigationBar with Flutter</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*DCPrCStZ1po22EhE8hoYEQ.png" /><figcaption>Example of Flutter BottomNavigationBar</figcaption></figure><p>Hi there! Once you are here I assume you have at least a basic understanding on how Flutter works and would like to see how we can quickly add a BottomNavigationBar to our app.</p><p>So, let’s get down to business, we’ll not cover all basics about Flutter. If you have no previous knowledge about Flutter, you can start at the official <a href="https://flutter.dev/docs">Flutter Documentation</a> page.</p><p><strong>What is a BottomNavigationBar?</strong></p><p>Well, as the name says, it is a bar at the bottom of your app the makes navigation to various views easy. The recommended number of views by Flutter team is between three and five. Also, it is recommended to use it in conjunction with aScaffold widget, and we will do just that.</p><p><strong>What we’re building?</strong></p><p>We will build a basic application that has three view: <strong>Home</strong>, <strong>Settings</strong> and <strong>Contact</strong>. We will not care too much about styling or other visual appearance elements, not even about having a beautiful application structure but really keeping it focused on how the BottomNavigationBar can be implemented quickly. In the end will look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/278/1*Zcx8x2e8efvdjJkvaDFTfw.gif" /><figcaption>Example BottomNavigationBar app</figcaption></figure><p><strong>Let’s get started…</strong></p><p>Firstly we’ll create three pages for the three views that will be shown when we click items of the bottom navigation bar. Let’s just call them page_one.dart, page_two.dart and page_three.dart. Then we will add the BottomNavigationBar code in the main.dart file.</p><p>The three pages, will have some very similar basic content:</p><p>page_one.dart:</p><pre>import &#39;package:flutter/material.dart&#39;;<br><br>class PageOne extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return Column(<br>      mainAxisAlignment: MainAxisAlignment.center,<br>      children: &lt;Widget&gt;[<br>        Card(<br>          child: Row(<br>            mainAxisAlignment: MainAxisAlignment.spaceBetween,<br>            children: &lt;Widget&gt;[<br><strong>              Icon(<br>                Icons.<em>home</em>,<br>                size: 50.0,<br>              ),<br>              Text(<br>                &#39;Home Page&#39;,<br>                style: TextStyle(fontSize: 50.0),<br>              ),</strong><br>            ],<br>          ),<br>        )<br>      ],<br>    );<br>  }<br>}</pre><p>page_two.dart:</p><pre>import &#39;package:flutter/material.dart&#39;;<br><br>class PageTwo extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return Column(<br>      mainAxisAlignment: MainAxisAlignment.center,<br>      children: &lt;Widget&gt;[<br>        Card(<br>          child: Row(<br>            mainAxisAlignment: MainAxisAlignment.spaceBetween,<br>            children: &lt;Widget&gt;[<br><strong>              Icon(<br>                Icons.<em>settings</em>,<br>                size: 50.0,<br>              ),<br>              Text(<br>                &#39;Settings&#39;,<br>                style: TextStyle(fontSize: 50.0),<br>              ),</strong><br>            ],<br>          ),<br>        )<br>      ],<br>    );<br>  }<br>}</pre><p>page_three.dart:</p><pre>import &#39;package:flutter/material.dart&#39;;<br><br>class PageThree extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return Column(<br>      mainAxisAlignment: MainAxisAlignment.center,<br>      children: &lt;Widget&gt;[<br>        Card(<br>          child: Row(<br>            mainAxisAlignment: MainAxisAlignment.spaceBetween,<br>            children: &lt;Widget&gt;[<br><strong>              Icon(<br>                Icons.<em>call</em>,<br>                size: 50.0,<br>              ),<br>              Text(<br>                &#39;Contact&#39;,<br>                style: TextStyle(fontSize: 50.0),<br>              ),</strong><br>            ],<br>          ),<br>        )<br>      ],<br>    );<br>  }<br>}</pre><p>As you can see, each of the three pages, that will be our views, has a different Icon and Text widgets, besides that, they are just the same.</p><p>The main.dart file will keep the whole logic of spinning through the views.</p><p>main.dart:</p><pre><strong>import &#39;package:flutter/material.dart&#39;;<br>import &#39;page_one.dart&#39;;<br>import &#39;page_two.dart&#39;;<br>import &#39;page_three.dart&#39;;</strong><br><br>void main() =&gt; runApp(MyApp());<br><br>class MyApp extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      theme: ThemeData(<br>        primarySwatch: Colors.<em>blue</em>,<br>//<br>      ),<br>      home: MyHomePage(title: &#39;Flutter Demo Home Page&#39;),<br>    );<br>  }<br>}<br><br>class MyHomePage extends StatefulWidget {<br>  MyHomePage({Key key, this.title}) : super(key: key);<br><br>  final String title;<br><br>  @override<br>  _MyHomePageState createState() =&gt; _MyHomePageState();<br>}<br><br>class _MyHomePageState extends State&lt;MyHomePage&gt; {<br><br><strong>  static List&lt;Widget&gt; <em>_myPages </em>= &lt;Widget&gt;[PageOne(), PageTwo(), PageThree()];</strong><br><br><strong>  int _selectedIndex = 0;<br><br>  void _onItemTapped(int index) {<br>    setState(() {<br>      _selectedIndex = index;<br>    });<br>  }</strong><br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(<br>        title: Text(widget.title),<br>      ),<br>      <strong>body: <em>_myPages</em>[_selectedIndex],</strong><br>  <strong>    bottomNavigationBar: BottomNavigationBar(<br>        type: BottomNavigationBarType.fixed,<br>        items: const &lt;BottomNavigationBarItem&gt;[<br>          BottomNavigationBarItem(<br>            icon: Icon(<br>              Icons.</strong><strong><em>home</em></strong><strong>,<br>            ),<br>            title: Text(&#39;Home&#39;),<br>          ),<br>          BottomNavigationBarItem(<br>            icon: Icon(<br>              Icons.</strong><strong><em>settings</em></strong><strong>,<br>            ),<br>            title: Text(<br>              &#39;Settings&#39;,<br>            ),<br>          ),<br>          BottomNavigationBarItem(<br>            icon: Icon(Icons.</strong><strong><em>call</em></strong><strong>),<br>            title: Text(&#39;Contact&#39;),<br>          ),<br>        ],<br>        currentIndex: _selectedIndex,<br>        onTap: _onItemTapped,<br>      ),</strong><br>    );<br>  }<br>}</pre><p><strong>Let’s understand </strong><strong>main.dart logic:</strong></p><p>First of all see the import of the three view files.</p><pre>import ‘page_one.dart’;<br>import ‘page_two.dart’;<br>import ‘page_three.dart’;</pre><p>Then, note that for convenience we created a list with all the views so we can access them later on based on the index number of the bottom bar item pressed.</p><pre>static List&lt;Widget&gt; <em>_myPages </em>= &lt;Widget&gt;[PageOne(), PageTwo(), PageThree()];</pre><p>Now, we have a variable _selectedIndex holding the selected view number, or the item, in the bottom navigation bar, that is selected. 0 means that the first item is selected.</p><pre>int _selectedIndex = 0;</pre><p>Then we created a function _onItemTapped that will be called when an item is pressed together with the position number. This is needed to call setState to re-build the widget state with the _selectedIndex variable new value, so with a different view, as explained further below.</p><pre>void _onItemTapped(int index) {<br>  setState(() {<br>    _selectedIndex = index;<br>  });<br>}</pre><p>Now, in the bottomNavigationBar section of the Scaffold widget we added the BottomNavigationBar widget itself. This one contains several BottomNavigationBarItem widgets that in turn contain icons and texts widgets.</p><p>In this article we are addressing only type: BottomNavigationBarType.fixe. If you are feeling adventurous go ahead and play around with type: BottomNavigationBarType.shifting, too.</p><p>With currentIndex: _selectedIndex we set the current view based on the _selectedIndex variable value.</p><p>Finally, we call the earlier defined function when we press anyone of the items onTap: _onItemTapped.</p><pre>bottomNavigationBar: BottomNavigationBar(<br>  type: BottomNavigationBarType.fixed,<br>  items: const &lt;BottomNavigationBarItem&gt;[<br>    BottomNavigationBarItem(<br>      icon: Icon(<br>        Icons.<em>home</em>,<br>      ),<br>      title: Text(&#39;Home&#39;),<br>    ),<br>    BottomNavigationBarItem(<br>      icon: Icon(<br>        Icons.<em>settings</em>,<br>      ),<br>      title: Text(<br>        &#39;Settings&#39;,<br>      ),<br>    ),<br>    BottomNavigationBarItem(<br>      icon: Icon(Icons.<em>call</em>),<br>      title: Text(&#39;Contact&#39;),<br>    ),<br>  ],<br>  currentIndex: _selectedIndex,<br>  onTap: _onItemTapped,<br>)</pre><p><strong>Put them all together and hit run!</strong></p><p>Now, add the four dart files from above (page_one.dart, page_two.dart, page_three.dart and main.dart) in your Flutter project and give them a run.</p><p>I hope you managed to get it running.</p><p>Do not hesitate to leave comments bellow on what you liked, you did not like so much, what you want to see more or just … clap if you found this article useful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2df19e9cf5c8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tagmalogic/flutter-navigate-with-style-basic-example-with-bottomnavigationbar-2df19e9cf5c8">Flutter — Navigate with style — basic example with BottomNavigationBar</a> was originally published in <a href="https://medium.com/tagmalogic">tagmalogic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>