<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ludovic Taffin</title>
    <description>The latest articles on DEV Community by Ludovic Taffin (@drumor).</description>
    <link>https://dev.to/drumor</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F119814%2Fbde30fb1-2dbf-4a15-8c04-042a67c56cc0.png</url>
      <title>DEV Community: Ludovic Taffin</title>
      <link>https://dev.to/drumor</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/drumor"/>
    <language>en</language>
    <item>
      <title>Deploy Flask app on Heroku with Github</title>
      <dc:creator>Ludovic Taffin</dc:creator>
      <pubDate>Thu, 06 May 2021 14:42:40 +0000</pubDate>
      <link>https://dev.to/drumor/deploy-flask-app-on-heroku-with-github-1o1e</link>
      <guid>https://dev.to/drumor/deploy-flask-app-on-heroku-with-github-1o1e</guid>
      <description>&lt;p&gt;Hello guys,&lt;/p&gt;

&lt;p&gt;Heroku is an awesome resource if you want to set up a web app.&lt;br&gt;
I recently needed it for a personal project and here is some simple step i had to follow to set up this correctly.&lt;/p&gt;
&lt;h2&gt;
  
  
  All starts with an awesome GitHub project
&lt;/h2&gt;

&lt;p&gt;Let's imagine you have develop and awesome flask app in a private GitHub repository:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F445q1rbf6qv10biqsg8r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F445q1rbf6qv10biqsg8r.png" alt="Some GitHub repository"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;My code is sooo complicated (&lt;code&gt;run.py&lt;/code&gt;) :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkxp9096ac29pa9ji7389.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkxp9096ac29pa9ji7389.png" alt="My awesome code"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And the result is awesome:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Hello, World!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This result is incredible and i have to share the result with the world to let anyone use this!&lt;br&gt;
I'll then deploy it first on a free resource to see my result online.&lt;/p&gt;
&lt;h2&gt;
  
  
  Deploy on Heroku.
&lt;/h2&gt;

&lt;p&gt;For this i'll use Heroku! After creating an account, i'll create my first app.&lt;br&gt;
I set up a name and a region and then discover my dashboard.&lt;br&gt;
You can see and configure a lot of things but we will focus on deploy tab.&lt;br&gt;
I will first select GitHub for deployment method.&lt;br&gt;
After a connection to GitHub profile, you can select the repository (public or private) to deploy by entering the name.&lt;/p&gt;

&lt;p&gt;I can now define an automatic or manual deploy. I'll go for a manual, as I didn't set CI. I just have to select the branch and hit deploy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Spoiler, as it is, the deployment will fail.&lt;/strong&gt;&lt;br&gt;
Heroku needs some extra information to make this awesome project work.&lt;/p&gt;
&lt;h2&gt;
  
  
  Some extra needs
&lt;/h2&gt;

&lt;p&gt;First, a list of requirements for the project. Those are listed in my &lt;code&gt;requirements.txt&lt;/code&gt;. For my tiny project i only need:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;flask
jinja2
gunicorn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, a runtime definition (defined in &lt;code&gt;runtime.txt&lt;/code&gt;). Here are supported version of Python in Heroku :&lt;br&gt;
&lt;a href="https://devcenter.heroku.com/articles/python-support#supported-runtimes" rel="noopener noreferrer"&gt;Here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So i defined my runtime simply as follow&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;python-3.9.4&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Finally, Heroku web applications require a &lt;code&gt;Procfile&lt;/code&gt;. This file is used to explicitly declare application’s process types and entry points. It is located in the root of the repository.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;web: gunicorn wsgi:app&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;(related to my &lt;code&gt;wsgi.py&lt;/code&gt; file)&lt;/p&gt;

&lt;p&gt;This Procfile requires Gunicorn, the production web server. That's why I set Gunicorn in my requirements file.&lt;/p&gt;

&lt;p&gt;We can now deploy the wonderful app and enjoy it at the dedicated URL provide by Heroku.&lt;/p&gt;

&lt;p&gt;My repositroy is available &lt;a href="https://github.com/Drumor/heroku_python_example" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>flask</category>
      <category>heroku</category>
      <category>deploy</category>
      <category>github</category>
    </item>
    <item>
      <title>Brute force - let's have a look</title>
      <dc:creator>Ludovic Taffin</dc:creator>
      <pubDate>Mon, 15 Feb 2021 16:13:35 +0000</pubDate>
      <link>https://dev.to/drumor/brute-force-let-s-have-a-look-2ff6</link>
      <guid>https://dev.to/drumor/brute-force-let-s-have-a-look-2ff6</guid>
      <description>&lt;p&gt;Originally posted  &lt;a href="https://drumor.dev/posts/brute-force/"&gt;here&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;I recently issue the problem of a lost password on one of my own rar file. I so decided to attempt some of my most common password... None works... I was near of a simple deletion of my file and a lot of cry... Then i tried to brute force this...&lt;/p&gt;

&lt;h2&gt;
  
  
  What is brute force ?
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;In cryptography, a brute-force attack consists of an attacker submitting many passwords or passphrases with the hope of eventually guessing a combination correctly.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Thank you wikipedia! To be as concrete as possible, you take an amount of strings and you try each one. It's like having a lot of keys on a key-ring and trying one by one to open a door... Boring!&lt;/p&gt;

&lt;h2&gt;
  
  
  Limits
&lt;/h2&gt;

&lt;p&gt;It's quite a simple try/guess and hope (like i did with common passwords)... So it's not complicated but is time consuming... Let's have a look on how much attempts it could theoretically take...  &lt;/p&gt;

&lt;p&gt;Theoretically, it can be expressed that way :&lt;/p&gt;

&lt;p&gt;

&lt;/p&gt;
&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;A=NM
A = N^M
&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathdefault"&gt;A&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathdefault"&gt;N&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mathdefault mtight"&gt;M&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;where N is the size of the used &lt;em&gt;alphabet&lt;/em&gt; and M is the size of the &lt;em&gt;password&lt;/em&gt; (number of characters).&lt;/p&gt;

&lt;p&gt;So if u use an alphabet of 26 characters (like the lowercase common alphabet) on a password of 10 chars, the maximum number of attemps will be :&lt;/p&gt;


&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;A=2610
A = 26^{10}
&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathdefault"&gt;A&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord"&gt;2&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord"&gt;6&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;span class="mord mtight"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;


&lt;p&gt;So A = 141.167.095.653.376 attemps... This is, of course, the worst case scenario possible...On Average, this will take the half number of attempts to find a lowercase password base on the classical alphabet... Still huge...&lt;/p&gt;

&lt;h2&gt;
  
  
  Brute force a rar file with python - a tiny example
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Attention, i don't encourage you to try this on production environment... Brute forcing is attacking a system which is illegal...&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here is a tiny snippet that let you test a brute force over a rar file:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/usr/bin/env python3

alphabet = "abcdefghijklmnopqrstuvwxyz"
path = "path/to/file"
for a in range(1,len(alphabet)+1):
    for b in itertools.product(alphabet,repeat=a):
        pass="".join(b)
        kf=os.popen("unrar t -y -p%s %s | grep 'All OK'"%(pass,path))
        if "All OK" in kf:
            print("Success:" + pass)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The code is easy no? Of course i simplify this as much as possible... We should, of course, verify that the file exist for example... This snippet can easily be improved... But it's not the purpose here.... &lt;/p&gt;

&lt;h2&gt;
  
  
  How to increase security over brute force?
&lt;/h2&gt;

&lt;p&gt;Well this is quite obvious, a brute force attack take time, so you need to increase the max number of attempts to discourage the attacker. This can simply done by increasing the N and the M so, the size of the alphabet and the size of the password. N will increase if u use uppercase,lowercase,number, special characters. M will increase if your password become as long as possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Improve performances
&lt;/h2&gt;

&lt;p&gt;As making a password is a human being thing (except if you use generate password only), most of the time used passwords have a union match with common words from languages. You'll then gain time by using words from dictionary in place of generated words.&lt;/p&gt;

&lt;p&gt;For example, English vocabulary count more or less 470000 words ( &lt;a href="https://en.wikipedia.org/wiki/List_of_dictionaries_by_number_of_words"&gt;wikipedia&lt;/a&gt; you da best! ) which is (if you only use the 26 lowercase letters for alphabet) a big improvement. Better the &lt;a href="https://en.wikipedia.org/wiki/List_of_the_most_common_passwords"&gt;list&lt;/a&gt;  of common passwords is certainly a good dictionary to gain time.&lt;/p&gt;

</description>
      <category>security</category>
      <category>password</category>
      <category>crypto</category>
    </item>
    <item>
      <title>Flutter - Layouts understanding</title>
      <dc:creator>Ludovic Taffin</dc:creator>
      <pubDate>Fri, 12 Feb 2021 17:03:23 +0000</pubDate>
      <link>https://dev.to/drumor/flutter-layouts-understanding-3ebe</link>
      <guid>https://dev.to/drumor/flutter-layouts-understanding-3ebe</guid>
      <description>&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;This post was originally post  &lt;a href="https://drumor.dev/posts/flutter-layouts/"&gt;here&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Now that we understand how widgets works, it's now time to start building awesome layouts!&lt;br&gt;
As everything is widget(s) in Flutter, the layout model is also a widget. Text, Image,... Everything you see in an app is widgets for Flutter. We are so going to build layouts with widgets into widgets into widgets....&lt;/p&gt;

&lt;h2&gt;
  
  
  Everything is widget
&lt;/h2&gt;

&lt;p&gt;Here’s a diagram of the widget tree:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Aju2yAJy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://flutter.dev/assets/ui/layout/sample-flutter-layout-46c76f6ab08f94fa4204469dbcf6548a968052af102ae5a1ae3c78bc24e0d915.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Aju2yAJy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://flutter.dev/assets/ui/layout/sample-flutter-layout-46c76f6ab08f94fa4204469dbcf6548a968052af102ae5a1ae3c78bc24e0d915.png" alt="a widget tree"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can here find a widget we have already seen : Text. This is the leaf of this tree as it looks like the final touch of this layout. We can simply understand that we'll mainly end our layouts with the text part.&lt;/p&gt;

&lt;p&gt;Start from the top, the layout is defined within a &lt;a href="https://api.flutter.dev/flutter/widgets/Container-class.html"&gt;&lt;code&gt;Container&lt;/code&gt;&lt;/a&gt;. That is a widget class that allows you to customize its child widget. Use a &lt;code&gt;Container&lt;/code&gt; when you want to add padding, margins, borders, or background color, to name some of its capabilities.&lt;/p&gt;

&lt;p&gt;A &lt;code&gt;row&lt;/code&gt; is set into the container to add padding to this one. The rest is a three &lt;code&gt;columns&lt;/code&gt; structure where we have an &lt;code&gt;Icon&lt;/code&gt; widget and a text just under (Set by the container).&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Widgets
&lt;/h2&gt;

&lt;p&gt;Flutter comes with a lot of predefined widgets. You can found them in &lt;a href="https://flutter.dev/docs/development/ui/widgets"&gt;the widget catalog&lt;/a&gt;. They are well split into different categories to let you find what you need the easy way. Pay attention that you can also retrieve what you want within the &lt;a href="https://api.flutter.dev/flutter"&gt;API&lt;/a&gt;. The widget pages in the API docs often make suggestions about similar widgets that might better suit your needs.&lt;/p&gt;

&lt;p&gt;Let's talk about two must have widgets:&lt;/p&gt;

&lt;h3&gt;
  
  
  Container
&lt;/h3&gt;

&lt;p&gt;This widget can contain other widgets. They are defined as children in the tree structure. Those widgets allow to define several properties such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;alignment&lt;/li&gt;
&lt;li&gt;constraints (for size constraints)&lt;/li&gt;
&lt;li&gt;padding (for space padding)&lt;/li&gt;
&lt;li&gt;decoration&lt;/li&gt;
&lt;li&gt;transform (for geometrical transformation)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is the constructor:&lt;br&gt;
&lt;code&gt;Container({Key key, AlignmentGeometry alignment, EdgeInsetsGeometry padding, Color color, Decoration decoration, Decoration foregroundDecoration, double width, double height, BoxConstraints constraints, EdgeInsetsGeometry margin, Matrix4 transform, Widget child, Clip clipBehavior: Clip.none})&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Row &amp;amp; Column
&lt;/h3&gt;

&lt;p&gt;I present here both Row and Column as they do quite the same job except for the orientation.&lt;/p&gt;

&lt;p&gt;Row organizes its children horizontally and Column do the same but vertically. They both define a mainAxisAlignment and a crossAxisAlignment that define how the children must be displayed on the main axis and on the cross axis of the widget. For a row main axis is horizontal and vertical for the cross axis as previously said. And of course, it's the opposite for the Column widget.&lt;/p&gt;

&lt;p&gt;Here is the column constructor :&lt;br&gt;
 &lt;code&gt;Column({Key key, MainAxisAlignment mainAxisAlignment: MainAxisAlignment.start, MainAxisSize mainAxisSize: MainAxisSize.max, CrossAxisAlignment crossAxisAlignment: CrossAxisAlignment.center, TextDirection textDirection, VerticalDirection verticalDirection: VerticalDirection.down, TextBaseline textBaseline, List&amp;lt;Widget&amp;gt; children: const &amp;lt;Widget&amp;gt;[]})&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and the row constructor:&lt;br&gt;
&lt;code&gt;Row({Key key, MainAxisAlignment mainAxisAlignment: MainAxisAlignment.start, MainAxisSize mainAxisSize: MainAxisSize.max, CrossAxisAlignment crossAxisAlignment: CrossAxisAlignment.center, TextDirection textDirection, VerticalDirection verticalDirection: VerticalDirection.down, TextBaseline textBaseline: TextBaseline.alphabetic, List&amp;lt;Widget&amp;gt; children: const &amp;lt;Widget&amp;gt;[]})&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Constraints
&lt;/h2&gt;

&lt;p&gt;To fully understand Flutter’s layout system, you need to learn how Flutter positions and sizes the components in a layout. This is going to be our next article!&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dev</category>
      <category>mobile</category>
      <category>layouts</category>
    </item>
    <item>
      <title>Flutter - Widgets</title>
      <dc:creator>Ludovic Taffin</dc:creator>
      <pubDate>Fri, 06 Nov 2020 16:23:14 +0000</pubDate>
      <link>https://dev.to/drumor/flutter-walkthrough-widgets-1ppp</link>
      <guid>https://dev.to/drumor/flutter-walkthrough-widgets-1ppp</guid>
      <description>&lt;p&gt;&lt;em&gt;Post originally posted here : &lt;a href="https://drumor.dev/posts/flutter-widgets/" rel="noopener noreferrer"&gt;https://drumor.dev/posts/flutter-widgets/&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;Flutter is based on the widget concept. Today we are talking about this.&lt;/p&gt;

&lt;p&gt;Basic idea is : &lt;em&gt;Create interface only with widgets&lt;/em&gt;.&lt;br&gt;
Widgets so define how the interface looks like. They describe this with their states and their configuration. When a widget's state changes, the widget rebuilds his description. The framework makes a diff from the initial description and the current description to determine the minimal changes to apply.&lt;br&gt;
let's know have a comprehension of the widgets in the hello world project :&lt;/p&gt;

&lt;h2&gt;
  
  
  Flutter - Hello World!
&lt;/h2&gt;

&lt;p&gt;Let's have a look at this snippet :&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    import 'package:flutter/material.dart';

    void main() {
      runApp(
        Center(
          child: Text(
            'Hello, world!',
            textDirection: TextDirection.ltr,
          ),
        ),
      );
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This project contains two widgets : Text and Center. We can easily understand that Text is the child of Center. Here is the result :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F2m87o33zamv3prm7g76i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F2m87o33zamv3prm7g76i.png" alt="Our First Hello World"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Except the 'hello world' text, Text widget takes a property textDirection. This property defines the direction of the text. In our case is gonna be from Left To Right (ltr). We could also define it from Right To Left (rtl)... Even if it has less interest for English text (The result would be '!Hello, World').&lt;br&gt;
The &lt;code&gt;runApp()&lt;/code&gt; function takes our center widget and makes it the root of the widget tree.&lt;/p&gt;

&lt;h2&gt;
  
  
  Widgets
&lt;/h2&gt;

&lt;p&gt;Key principle of the Flutter Framework, Widgets are bricks of you app's wall. Most of them comes from the standard library (like Text,Card,Icon,...) but you can also make your own by extending &lt;code&gt;StatelessWidget&lt;/code&gt; and &lt;code&gt;StatefulWidget&lt;/code&gt;. Widgets are organized as a hierarchic tree.&lt;/p&gt;

&lt;h2&gt;
  
  
  StatefulWidget versus StatelessWidget
&lt;/h2&gt;

&lt;p&gt;The widgets we define are based on one of the two super classes &lt;code&gt;StatelessWidget&lt;/code&gt; and &lt;code&gt;StatefulWidget&lt;/code&gt;. Those two classes are abstract class so they have abstract method that need to be implemented by their children.&lt;/p&gt;

&lt;h3&gt;
  
  
  StatelessWidget
&lt;/h3&gt;

&lt;p&gt;This is the most basic type of widget. This has no integrated state  and only have static properties.&lt;br&gt;
This class comes with one abstract method &lt;code&gt;build(context)&lt;/code&gt; that returns the widget to the user interface. This method is called by the framework when the widget is inserted in the Widget tree of the inserted context (passed as a parameter of build method).&lt;/p&gt;

&lt;h3&gt;
  
  
  StatefulWidget
&lt;/h3&gt;

&lt;p&gt;Those are the opposite of StatelessWidget. Those kind of widget have an integrated state. When a state change is detected, the framework rebuild them. Their state is represented by an object of type &lt;code&gt;State&amp;lt;T extends StatefulWidget&amp;gt;&lt;/code&gt; and is read by the framework when the widget is build. This may,obviously,change during his lifetime. This abstract class comes with a method &lt;code&gt;createState&lt;/code&gt; that creates a State object (another abstract class) and represent the state of the widget. The state class also comes with an abstract method &lt;code&gt;build&lt;/code&gt; (like the StatelessWidget).&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>mobile</category>
    </item>
    <item>
      <title>Flutter - Understand your first app</title>
      <dc:creator>Ludovic Taffin</dc:creator>
      <pubDate>Sun, 01 Nov 2020 14:04:30 +0000</pubDate>
      <link>https://dev.to/drumor/flutter-walkthrough-understand-your-first-app-fn0</link>
      <guid>https://dev.to/drumor/flutter-walkthrough-understand-your-first-app-fn0</guid>
      <description>&lt;p&gt;&lt;em&gt;The original post is here : &lt;a href="https://drumor.dev/posts/flutter-first-app-analyze/"&gt;https://drumor.dev/posts/flutter-first-app-analyze/&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Hello,&lt;br&gt;
So I recently restart my learning of Flutter. After the installation of flutter with Android Studio (see &lt;a href="https://flutter.dev/docs/get-started/install"&gt;doc&lt;/a&gt;), I create my first default project. Let see how does that works.&lt;/p&gt;

&lt;p&gt;Most of the Dart code you'll use and edit is in the lib folder. Another important part of a flutter project is pubspec.yaml file.&lt;/p&gt;

&lt;h2&gt;
  
  
  lib/Main.dart
&lt;/h2&gt;

&lt;p&gt;All the app is here. It starts with this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;void main() {  
 runApp(MyApp());  
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;As you can use the narrow notation , you could also write the main as this :&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;void main() =&amp;gt; runApp(new MyApp());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This looks like a classical main code. It runs the app that is defined after:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class MyApp extends StatelessWidget {  

 // This widget is the root of your application.  
  @override  
  Widget build(BuildContext context) {  
  return MaterialApp(  
          title: 'Flutter Demo',  
          theme: ThemeData(
              // This is the theme of your application.
              //
              // Try running your application with "flutter run".
              // You'll see the application has a blue toolbar.
              // Then, without quitting the app, try
              // changing the primarySwatch below to Colors.green and then invoke
              // "hot reload" (press "r" in the console where you ran "flutter run",
              // or simply save your changes to "hot reload" in a Flutter IDE).
              // Notice that the counter didn't reset back to zero; the application
              // is not restarted.  
              primarySwatch: Colors.blue,  
          ),  
          home: MyHomePage(title: 'Flutter Demo Home Page'),  
          );  
  }  
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;So the app is defined and extend StatelessWidget. In Flutter, almost everything is a Widget. In this case it's a widget without state. So it keeps no data.&lt;br&gt;
A build method is defined which is a sort of constructor of MyApp object. All widget have a build method. The method describes how to display the widget in terms of other, lower level widgets.&lt;br&gt;
This example creates a Material app. &lt;a href="https://material.io/guidelines"&gt;Material&lt;/a&gt; is a visual design language that is standard on mobile and the web. Flutter offers a rich set of Material widgets.&lt;br&gt;
A title, a theme and a home page are defined.&lt;/p&gt;

&lt;p&gt;Let's now have a see on the MyHomePage object:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

  @override
  _MyHomePageState createState() =&amp;gt; new _MyHomePageState();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;MyHomePage is a stateful widget. This means that, during the lifetime of the widget, a state that might change is maintained. Implementing a stateful widget requires at least two classes: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;a &lt;code&gt;StatefulWidget&lt;/code&gt; class that creates an instance of&lt;/li&gt;
&lt;li&gt;a &lt;code&gt;State&lt;/code&gt; class. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The &lt;code&gt;StatefulWidget&lt;/code&gt; class is, itself, immutable and can be thrown away and regenerated, but the &lt;code&gt;State&lt;/code&gt; class persists over the lifetime of the widget.&lt;/p&gt;

&lt;p&gt;Here is the State class _MyHomePageState :&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class _MyHomePageState extends State&amp;lt;MyHomePage&amp;gt; {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      // This call to setState tells the Flutter framework that something has
      // changed in this State, which causes it to rerun the build method below
      // so that the display can reflect the updated values. If we changed
      // _counter without calling setState(), then the build method would not be
      // called again, and so nothing would appear to happen.
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    //
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.
    return new Scaffold(
      appBar: new AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: new Text(widget.title),
      ),
      body: new Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: new Column(
          // Column is also layout widget. It takes a list of children and
          // arranges them vertically. By default, it sizes itself to fit its
          // children horizontally, and tries to be as tall as its parent.
          //
          // Invoke "debug paint" (press "p" in the console where you ran
          // "flutter run", or select "Toggle Debug Paint" from the Flutter tool
          // window in IntelliJ) to see the wireframe for each widget.
          //
          // Column has various properties to control how it sizes itself and
          // how it positions its children. Here we use mainAxisAlignment to
          // center the children vertically; the main axis here is the vertical
          // axis because Columns are vertical (the cross axis would be
          // horizontal).
          mainAxisAlignment: MainAxisAlignment.center,
          children: &amp;lt;Widget&amp;gt;[
            new Text(
              'You have pushed the button this many times:',
            ),
            new Text(
              '$_counter',
              style: Theme.of(context).textTheme.display1,
            ),
          ],
        ),
      ),
      floatingActionButton: new FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: new Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We discover some interesting elements :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;First we have a private (the _ indicates this ) variable counter thatwill store the count of hit:&lt;/p&gt;

&lt;p&gt;int _counter = 0;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Secondly, we get a private method, called &lt;code&gt;_incrementCounter&lt;/code&gt;, that ... increment the counter (Incredible! Right?!) by calling the &lt;code&gt;setState&lt;/code&gt; method from Flutter framework. This method call (by default) the build method defined after.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;And last but not least, the &lt;code&gt;build&lt;/code&gt; method that "simply" return a Scaffold widget. A scaffold widget is a layout where we have a top bar (Blue because the theme defined use the color blue), and a body. Here, the body is defined as a center layout that content a child Column and a floating button. The column widget is also a layout and represents a column (No way!!). It takes a list of children that are display one under the other (like a stack). In our case, there is two elements in the column, a default text and the display of the counter.&lt;br&gt;
The floating button is simply a button floating on the bottom right of the screen. This button has a OnPressed callback that runs _incrementCounter  when the button is pressed.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pubspec.yaml
&lt;/h2&gt;

&lt;p&gt;This is the configuration file of a flutter project. This lets you configure the name and description of the project, the SDK used, the dependencies of the project and others specifications. We will see later that if you wanna use assets (like pictures) in your project, you'll have to define it in this file.&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>mobile</category>
    </item>
    <item>
      <title>A complete walkthrough to Flutter mastering!</title>
      <dc:creator>Ludovic Taffin</dc:creator>
      <pubDate>Fri, 23 Oct 2020 15:53:56 +0000</pubDate>
      <link>https://dev.to/drumor/a-complete-walkthrough-to-flutter-mastering-40ol</link>
      <guid>https://dev.to/drumor/a-complete-walkthrough-to-flutter-mastering-40ol</guid>
      <description>&lt;p&gt;Hello Dev Community,&lt;/p&gt;

&lt;p&gt;First post for me in here (originally post here &lt;a href="https://drumor.dev/posts/learn-flutter/"&gt;https://drumor.dev/posts/learn-flutter/&lt;/a&gt;)! I'm so excited starting this new adventure on Dev.to!&lt;/p&gt;

&lt;p&gt;So I decided that today is THE day! The day I start (or restart) learning Flutter.&lt;br&gt;
For those who don't know what is flutter, here is a quick &lt;a href="https://www.youtube.com/watch?v=fq4N0hgOWzU"&gt;video&lt;/a&gt; from Google.&lt;/p&gt;

&lt;p&gt;I previously talk about this on my blog as an introduction on it &lt;a href="https://drumor.dev/posts/flutter-discover/"&gt;here&lt;/a&gt;.&lt;br&gt;
I sadly had less time to discover this technology but i'm sure this is the future of mobile development. &lt;/p&gt;

&lt;p&gt;I'm so now back in this business and i will then start learning Flutter with some resources :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://flutter.dev/docs"&gt;https://flutter.dev/docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.freecodecamp.org/news/how-to-learn-flutter-in-2020/"&gt;https://www.freecodecamp.org/news/how-to-learn-flutter-in-2020/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/flutter-community/i-want-to-learn-flutter-how-to-start-ffb4145f9b26"&gt;https://medium.com/flutter-community/i-want-to-learn-flutter-how-to-start-ffb4145f9b26&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This should give me a good base. I will then have a look to good open source project by checking GitHub :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/iampawan/FlutterExampleApps"&gt;https://github.com/iampawan/FlutterExampleApps&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Solido/awesome-flutter"&gt;https://github.com/Solido/awesome-flutter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/nisrulz/flutter-examples"&gt;https://github.com/nisrulz/flutter-examples&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/mitesh77/Best-Flutter-UI-Templates"&gt;https://github.com/mitesh77/Best-Flutter-UI-Templates&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This will give me a solid learning evolution but there is also a lot of work.&lt;br&gt;
Once i'll have a complete look on this, i'll realize a complete project that i'll explain in here. Stay tune!&lt;/p&gt;

&lt;p&gt;Do you have any website for learning flutter that i definitely should see? Let's comment then!&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>mobile</category>
    </item>
  </channel>
</rss>
