<?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>Forem: Guilherme Cabral</title>
    <description>The latest articles on Forem by Guilherme Cabral (@theoneguilherme).</description>
    <link>https://forem.com/theoneguilherme</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%2F111180%2F46844da8-bc04-494f-bcf8-6a17155e02b5.jpg</url>
      <title>Forem: Guilherme Cabral</title>
      <link>https://forem.com/theoneguilherme</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/theoneguilherme"/>
    <language>en</language>
    <item>
      <title>Building a cross-platform todo mobile app using Flutter: Pt. 2</title>
      <dc:creator>Guilherme Cabral</dc:creator>
      <pubDate>Tue, 30 Oct 2018 15:16:29 +0000</pubDate>
      <link>https://forem.com/runtime-revolution/building-a-cross-platform-todo-mobile-app-using-flutter-pt-2-2l0o</link>
      <guid>https://forem.com/runtime-revolution/building-a-cross-platform-todo-mobile-app-using-flutter-pt-2-2l0o</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8iL4wB-l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2Aw7Zz6iKz6BKWrUaYwYcI8Q.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8iL4wB-l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2Aw7Zz6iKz6BKWrUaYwYcI8Q.jpeg" alt="Photo by Randall Ruiz on Unsplash"&gt;&lt;/a&gt;&lt;/p&gt;
Photo by Randall Ruiz on Unsplash



&lt;p&gt;In the &lt;a href="https://dev.to/theoneguilherme/building-a-cross-platform-todo-mobile-app-using-flutter-5e3m"&gt;first part of this series (which you should totally take a look at)&lt;/a&gt;, we set up our workspace to build apps with Flutter. In this part, we will take a more in-depth tour on how we can build stuff with it, and even create ourselves a pretty basic to-do app.&lt;/p&gt;

&lt;p&gt;As you may remember, we were looking at the entry-point of every Dart application, the &lt;code&gt;main.dart&lt;/code&gt; file. This file builds a simple counter app with a button that increments a variable, which then gets printed on the screen. That’s pretty useless, isn’t it? Let’s build something better. Let’s build a to-do app.&lt;/p&gt;

&lt;p&gt;Before starting, I think we should delete the code from the example app I mentioned above and start from scratch. To do that, make your &lt;code&gt;main.dart&lt;/code&gt; file look like this one:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;There are some things you should focus on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;void main() =&amp;gt; runApp(new MyApp());&lt;/code&gt; is the entry-point of the application&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;the &lt;code&gt;MyApp&lt;/code&gt; class, that holds the root of the widget tree&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;MaterialApp()&lt;/code&gt; is a widget provided by the library imported in the first line of the file. It builds a Material Design app.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;the &lt;code&gt;HomePage&lt;/code&gt; class, a widget that has a State instance of the class &lt;code&gt;_HomePageState&lt;/code&gt;, which will return more than a &lt;code&gt;Container()&lt;/code&gt; soon enough.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are lots of details about this, and we’ll cover them as we go.&lt;/p&gt;

&lt;p&gt;To-do lists have to-do items, right? So we need to describe Items using a simple class. To do so, we’ll make a folder called &lt;code&gt;models&lt;/code&gt; and inside we’ll create a file called &lt;code&gt;item.dart&lt;/code&gt; that looks like this:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Now that we have the model, let’s work on presenting our tasks by using some widgets! By importing Flutter’s Material library, we have access to a bunch of different pre-designed widgets to build our interface.&lt;/p&gt;

&lt;p&gt;We need some to-do items to display. First we need to import the Item model we created earlier:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'package:todo/models/item.dart';
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;And then we place our tasks inside our &lt;code&gt;_HomePageState&lt;/code&gt; class, like this:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class _HomePageState extends State&amp;lt;HomePage&amp;gt; {

  List&amp;lt;Item&amp;gt; items = [
    Item('Take a shower'),
    Item('Go shopping'),
    Item('Feed the cat'),
  ];

  ...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now that we have items to show, let’s grow our widget tree to display them by changing our build method to this:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@override
Widget build(BuildContext context) {
  return new Scaffold(
    appBar: new AppBar(
      title: new Text('Awesome Todo'),
    ),
    body: new Container(
      child: new ListView.builder(
        itemCount: items.length,
        itemBuilder: (context, index) {
          return ListTile(
            title: Text(
              '${items[index].title}',
            ),
            trailing: new IconButton(
              icon: new Icon(Icons.delete),
              onPressed: null,
            ),
          );
        },
      ),
    ),
  );
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If you’re using Visual Studio Code or IntelliJ IDEA, and have already installed the respective Flutter plugin, you can start the app from the editor by pressing F5 on VS Code or clicking the green play button on IntelliJ IDEA (you also have &lt;em&gt;hot-reload-on-save&lt;/em&gt; awesomeness). Run the app, and your device or simulator should look like the image below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8nEc3IR4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2A5fc_9fzc9VB2yNRD1WPOOA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8nEc3IR4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2A5fc_9fzc9VB2yNRD1WPOOA.png" alt="Ew, who can’t remember to take a shower?"&gt;&lt;/a&gt;&lt;/p&gt;
Ew, who can’t remember to take a shower?



&lt;p&gt;Let’s go over the widgets we used. The &lt;code&gt;Scaffold&lt;/code&gt; is the basic structure for our app. It holds, among other things, the &lt;code&gt;AppBar&lt;/code&gt; which we see on the top, and a &lt;code&gt;Container&lt;/code&gt; as our body. It could also hold a drawer menu or other things. The &lt;code&gt;Container&lt;/code&gt; on the body is the parent of a &lt;code&gt;ListView.builder()&lt;/code&gt;. We could have just used &lt;code&gt;ListView(children: items)&lt;/code&gt; and everything would be fine. I chose to go with &lt;code&gt;ListView.builder()&lt;/code&gt; because this way it &lt;em&gt;automagically&lt;/em&gt; renders its children (&lt;code&gt;ListTile&lt;/code&gt; in this case) as they are scrolled through, similar to an infinite scroll.&lt;/p&gt;

&lt;p&gt;We’ll need to add to-do items to our awesome list. Let’s start by adding a &lt;code&gt;FloatingActionButton&lt;/code&gt; to our app! We’ll add it to our &lt;code&gt;Scaffold&lt;/code&gt;, and this should be the result:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@override
Widget build(BuildContext context) {
  return new Scaffold(
    appBar: new AppBar(
      title: new Text('Awesome Todo'),
    ),
    body: new Container(
      child: new ListView.builder(
        itemCount: items.length,
        itemBuilder: (context, index) {
          return ListTile(
            title: Text(
              '${items[index].title}',
            ),
            trailing: new IconButton(
              icon: new Icon(Icons.delete),
              onPressed: null,
            ),
          );
        },
      ),
    ),
    floatingActionButton: new FloatingActionButton(
      onPressed: null,
      tooltip: 'Increment',
      child: new Icon(Icons.add),
    ),
  );
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kZUq7EEs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2AXTQpctyhofeYyxalAVoP2A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kZUq7EEs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2AXTQpctyhofeYyxalAVoP2A.png" alt="Look at it, so pretty."&gt;&lt;/a&gt;&lt;/p&gt;
Look at it, so pretty.



&lt;p&gt;And now we have a great Floating Action Button on our app!&lt;/p&gt;

&lt;p&gt;It is pretty, but dumb: right now, the button does nothing. Neither do the trash cans on the items. Let’s create the methods that will handle those interactions and update our &lt;code&gt;FloatingActionButton&lt;/code&gt; and &lt;code&gt;ListTile&lt;/code&gt; widgets.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;_onAddItemPressed() {

}

_onDeleteItem(item) {

}

floatingActionButton: new FloatingActionButton(
  onPressed: () {
    _onAddItemPressed();
  },
  tooltip: 'Increment',
  child: new Icon(Icons.add),
),

...

trailing: new IconButton(
  icon: new Icon(Icons.delete),
  onPressed: () {
    _onDeleteItem(index);
  },
),
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;To delete the Item from the list, we’ll just have to add this to the method we created above:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;_onDeleteItem(item) {
  items.removeAt(item);
  setState(() {});
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;To add new items, I wanted to make things prettier and a little more fun. We’ll have a drawer coming from the bottom of the screen. That drawer will have a &lt;code&gt;TextField&lt;/code&gt; that the user can fill and submit a task to the list. To do this, we are going to use a &lt;code&gt;BottomSheet&lt;/code&gt;, more specifially, the &lt;code&gt;Persistant&lt;/code&gt; kind. &lt;code&gt;PersistantBottomSheets&lt;/code&gt; are context-aware, which means that opening them counts as navigating to another route of our app and that can be closed by pressing back in the app or in the device¹ (if running on an Android phone). To do so, we’ll need to set a key on our Scaffold widget. First, we’ll create it:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;final GlobalKey&amp;lt;ScaffoldState&amp;gt; _scaffoldKey = new GlobalKey&amp;lt;ScaffoldState&amp;gt;();
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Set it on our Scaffold widget:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@override
Widget build(BuildContext context) {
  return new Scaffold(
    key: _scaffoldKey,
    ...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;and now we can use it to open the &lt;code&gt;PersistantBottomSheet&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;_onAddItemPressed() {
  _scaffoldKey.currentState.showBottomSheet&amp;lt;Null&amp;gt;((BuildContext context) {
    return new Container(
      decoration:
          new BoxDecoration(color: Colors.blueGrey),
      child: new Padding(
        padding: const EdgeInsets.fromLTRB(32.0, 50.0, 32.0, 32.0),
      ),
    );
  });
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This will show a sliding drawer coming from the bottom, with a &lt;code&gt;Container&lt;/code&gt;, that has styles from a &lt;code&gt;BoxDecoration&lt;/code&gt; widget, and has a &lt;code&gt;Padding&lt;/code&gt; widget as a child (remember when I said that everything is a widget?).&lt;/p&gt;

&lt;p&gt;If you go to your device and hit the Floating Button, you’ll see it rise to a small grey box to the left. That’s our &lt;code&gt;Padding&lt;/code&gt; widget, being empty. Nothing to worry about, as we’re going to insert our &lt;code&gt;TextField&lt;/code&gt; there. To achieve this, we’ll need a &lt;code&gt;TextEditingController&lt;/code&gt; to handle our &lt;code&gt;TextField&lt;/code&gt; and we’ll set it right after our &lt;code&gt;_scaffoldKey&lt;/code&gt; :&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;final TextEditingController _textEditingController =
new TextEditingController();
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;and give our &lt;code&gt;Padding&lt;/code&gt; widget a child.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;child: new Padding(
  padding: const EdgeInsets.fromLTRB(32.0, 50.0, 32.0, 32.0),
  child: new TextField(
    controller: _textEditingController,
    decoration: InputDecoration(
      hintText: 'Please enter a task',
    ),
    onSubmitted: _onSubmit,
  ),
),
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Right now it won’t build because we are using the _onSubmit function on the &lt;code&gt;TextField&lt;/code&gt; and we haven’t created it yet. It’s pretty similar to our _onDeleteItem function:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;_onSubmit(String s) {
  if (s.isNotEmpty) {
    items.add(Item(s));
    _textEditingController.clear();
    setState(() {});
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Try it, you should now be able to add new tasks and delete old ones.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9jjSmJ9f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2Am6v8_XYtE43BrGmAR2lRug.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9jjSmJ9f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2Am6v8_XYtE43BrGmAR2lRug.gif" alt="Note to self: make more and better GIFs next time."&gt;&lt;/a&gt;&lt;/p&gt;
Note to self: make more and better GIFs next time.



&lt;p&gt;And that’s it! With 100 lines of code we built a cross platform to-do app. You can check the whole code &lt;a href="https://github.com/guivazcabral/flutter_todo"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The next step is making the data persistent by storing the items in the device’s storage. Stay tuned for the third part of this series!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;¹ You can also close the &lt;code&gt;PersistantModalSheet&lt;/code&gt; by dragging it down.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I love building products and I found my place to do so at &lt;a href="http://www.runtime-revolution.com/"&gt;Runtime Revolution&lt;/a&gt;. If you are interested in who we are and what we do, make sure to reach out!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>mobile</category>
    </item>
    <item>
      <title>Building a cross-platform todo mobile app using Flutter</title>
      <dc:creator>Guilherme Cabral</dc:creator>
      <pubDate>Tue, 30 Oct 2018 14:59:07 +0000</pubDate>
      <link>https://forem.com/runtime-revolution/building-a-cross-platform-todo-mobile-app-using-flutter-5e3m</link>
      <guid>https://forem.com/runtime-revolution/building-a-cross-platform-todo-mobile-app-using-flutter-5e3m</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--c4kE5qee--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/yfuqrhx5j462q3ieyv6d.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--c4kE5qee--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/yfuqrhx5j462q3ieyv6d.jpeg" alt="Photo by Andrea Reiman on Unsplash"&gt;&lt;/a&gt;&lt;/p&gt;
Photo by Andrea Reiman on Unsplash



&lt;p&gt;I’ve been playing with this tool for some time, but not enough to have a thorough understanding of it. So, as I’m writing this post, I’ll actually be learning along with it. This post is about a framework that can be used to build mobile apps for iOS and Android using a single codebase. “Is it React Native?” — you ask. No, it is not.&lt;/p&gt;

&lt;h2&gt;
  
  
  Flutter
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;verb.&lt;br&gt;
(of a bird or other winged creature) fly unsteadily or hover by flapping the wings quickly and lightly.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://flutter.io/"&gt;Flutter&lt;/a&gt; is a tool made by Google to build Android and iOS apps sharing the same codebase. It is a brand new tool (at the time of writing, it was in Release Preview 2), built to compete with &lt;a href="https://facebook.github.io/react-native/"&gt;React-Native&lt;/a&gt;, &lt;a href="https://visualstudio.microsoft.com/xamarin/"&gt;Xamarin&lt;/a&gt; and other tools.&lt;/p&gt;

&lt;p&gt;Is it better than any of those competitors? I actually don’t know. My experience with those tools is close to non-existent. But, as a huge fan of &lt;em&gt;hipster-driven development&lt;/em&gt; methodologies, I had to try this.&lt;/p&gt;

&lt;p&gt;I came across Flutter for the first time by accident: I was scrolling through my YouTube feed and, as a subscriber to the &lt;a href="https://www.youtube.com/user/GoogleDevelopers"&gt;Google Developers’&lt;/a&gt; YouTube channel, there was this 1 minute video suggestion that I clicked by accident. The video was about a specific feature of Flutter I can’t recall. What I do remember is that I was instantly amazed by how simple it was to build Material Design apps for Android. Only later did I found out it was actually doable for iOS as well, in a &lt;a href="https://www.youtube.com/watch?v=w2TcYP8qiRI"&gt;video¹ of a keynote on DartConf&lt;/a&gt;. And so I became a pain-in-the-ass-evangelist for Flutter.&lt;/p&gt;

&lt;p&gt;Flutter and applications built with Flutter are written in &lt;a href="https://www.dartlang.org/"&gt;Dart&lt;/a&gt;, a programming language made by Google too. They say Dart will look familiar if you are used to JavaScript. I don’t really agree with that, but what do I know?&lt;/p&gt;

&lt;p&gt;Well, enough chit-chat. Cue the drum roll and let’s start.&lt;/p&gt;

&lt;p&gt;First we need to install Flutter on our machine. That’s easy:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://storage.googleapis.com/flutter_infra/releases/beta/macos/flutter_macos_v0.9.4-beta.zip"&gt;Download the Flutter SDK&lt;/a&gt; and extract it to a folder of your choice.&lt;/p&gt;

&lt;p&gt;Next we’ll need to make the flutter binary accessible. We should add its parent folder to our &lt;code&gt;$PATH&lt;/code&gt; variable but, if you’re lazy like me, you can add a &lt;em&gt;symbolic link (symlink)²&lt;/em&gt; to your &lt;code&gt;/usr/local/bin&lt;/code&gt; folder by running:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ln -s /path/to/extracted/folder/bin/flutter /usr/local/bin/flutter
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And that’s it! You have just created a &lt;em&gt;symlink&lt;/em&gt; to the Flutter binary in your &lt;code&gt;/usr/local/bin&lt;/code&gt; folder. Placing a binary in that folder will make it available everywhere by calling just its name.&lt;/p&gt;

&lt;p&gt;Now, if you run flutter doctor on a terminal, Flutter will check if you have the required dependencies for it to work. It will tell you to install Android Studio and XCode, and other stuff. You should follow the &lt;a href="https://flutter.io/setup-macos/#platform-setup"&gt;platform guide&lt;/a&gt; to install everything. It will also look for IntelliJ IDEA/Android Studio or Visual Studio Code and, if you use any of them, it will recommend installing plugins for them (take a look at the guide to &lt;a href="https://flutter.io/get-started/editor/#androidstudio"&gt;configure your preferred editor&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;We are now ready to try Flutter! In a terminal, run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ flutter create todo
$ cd todo
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now, open a Simulator or connect a device and run &lt;code&gt;flutter doctor&lt;/code&gt; to check if it’s detected and ready to use. If so, run&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ flutter run
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;and &lt;em&gt;voilà&lt;/em&gt;, there you have a Flutter app running. By default, the flutter create command generates a boilerplate app with a floating button that increments a value show in the center of the screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qGaE7u2g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2AaEegE8iHOq6HNxpKhFr84Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qGaE7u2g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2AaEegE8iHOq6HNxpKhFr84Q.png" alt="Flutter boilerplate counter app running on iPhone XS Simulator."&gt;&lt;/a&gt;&lt;/p&gt;
Flutter boilerplate counter app running on iPhone XS Simulator.



&lt;p&gt;Now would be a good time to take a look at our application code. Dart works with an entry-point, i.e., everything starts on the &lt;code&gt;main()&lt;/code&gt; function present in this &lt;code&gt;lib/main.dart&lt;/code&gt; file. Open and check it out. It should look something like this:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;The code is filled with comments and they explain well what everything is and what it does. I do feel there’s one comment missing from the top of the file:&lt;/p&gt;

&lt;blockquote&gt;
&lt;h1&gt;
  
  
  In Flutter, everything is a widget.
&lt;/h1&gt;
&lt;/blockquote&gt;

&lt;p&gt;There are two types of Widgets: &lt;em&gt;Stateful&lt;/em&gt; and &lt;em&gt;Stateless&lt;/em&gt;. The first type are widgets that hold state, and the other kind don’t (duh) and both can have one or more widgets as children — a Flutter app is structured as a widget tree.&lt;/p&gt;

&lt;p&gt;In the second part of this blogpost series, we’ll build a to-do app using both &lt;em&gt;Stateful&lt;/em&gt; and &lt;em&gt;Stateless&lt;/em&gt; widgets³. I hope you’ll stick around.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;¹ This video may be outdated and some of the code it shows may not work as expected.&lt;br&gt;
² Adding directories to your $PATH is more useful when you want to have access to a bunch of binaries that are in the same directory.&lt;br&gt;
³ There are popular state-management libraries for Flutter like Redux, but they are an overkill solution for a simple project like a to-do app. We’ll take a look at them another time.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I love building products and I found my place to do so at &lt;a href="http://www.runtime-revolution.com/"&gt;Runtime Revolution&lt;/a&gt;. If you are interested in who we are and what we do, make sure to reach out!&lt;/em&gt;&lt;/p&gt;

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