Flutter For Dummies by Barry Burd

Title page image

Flutter® For Dummies®

To view this book's Cheat Sheet, simply go to www.dummies.com and search for “Flutter For Dummies Cheat Sheet” in the Search box.

Introduction

On December 5, 2018, at an annual developers’ event in London, Google announced the release of Flutter 1.0. Between December 5 and the end of December, the number of page visits to the official flutter.io website jumped from 2.3 million to 4.7 million. In the following year, the number of posts about Flutter on the Stack Overflow developers’ website increased by 70 percent, exceeding the count of posts about React Native — the most popular alternative to Flutter.

Companies such as Capital One, Alibaba, Groupon, and Philips Hue use Flutter to develop mobile apps. The official app for the musical Hamilton is written using Flutter. Google’s next mobile operating system, code-named Fuchsia, is based on Flutter. An estimated 200 million users run apps written in Flutter. More than 250,000 developers write Flutter code, and the Google Play Store has over 3,000 Flutter apps.

Are you interested in developing Flutter apps? If so, you’re in good company.

How to Use This Book

You can attack this book in either of two ways: Go from cover to cover or poke around from one chapter to another. You can even do both. Start at the beginning and then jump to a section that particularly interests you. This book was designed so that the basic topics come first, and the more-involved topics follow them. But you may already be comfortable with some basics, or you may have specific goals that don’t require you to know about certain topics.

In general, my advice is this:

  • If you already know something, don’t bother reading about it.
  • If you’re curious, don’t be afraid to skip ahead. You can always sneak a peek at an earlier chapter, if you need to do so.

Conventions Used in This Book

Almost every technically themed book starts with a little typeface legend, and Flutter For Dummies is no exception. What follows is a brief explanation of the typefaces used in this book:

  • New terms are set in italics.
  • If you need to type something that’s mixed in with the regular text, the characters you type appear in bold. For example: “Type MyNewProject in the text field.”
  • You also see this computerese font. I use computerese for Flutter code, filenames, onscreen messages, and other such text. Also, if something you need to type is really long, it appears in computerese font on its own line (or lines).
  • You may need to change certain characters when you type them on your own computer keyboard. For instance, I may ask you to type

    final String anyname;

  • which means that you type final String, and then a name that you make up on your own, and then a semicolon. Words you need to replace with your own words are set in italicized computerese.

What You Don’t Have to Read

Pick the first chapter or section that has material you don’t already know, and start reading there. Of course, you may hate making decisions as much as I do. If so, here are some guidelines you can follow:

  • If you already know what kind of an animal Flutter is and you don’t care what happens behind the scenes when a Flutter app runs: Skip Chapter 1 and go straight to Chapter 2. Believe me — I won’t mind.
  • If you already know how to get a Flutter app running: Skip Part 1 and start with Part 2.
  • If you’ve already tinkered with some simple Flutter apps: Skim over Chapter 1, and then go to Part 3. Chapter 1 pulls together the bits and pieces that you’ve read about Flutter, and Part 3 takes you beyond the very basics.
  • If you have experience writing Flutter apps: Come to my house and help me write Flutter For Dummies, 2nd Edition.

If you want to skip the sidebars and the paragraphs with Technical Stuff icons, please do. In fact, if you want to skip anything at all, feel free.

Foolish Assumptions

In this book, I make a few assumptions about you, the reader. If one of these assumptions is incorrect, you’re probably okay. If all these assumptions are incorrect … well, buy the book anyway:

  • I assume that you have access to a computer. Access to a smartphone is helpful but not absolutely necessary. All the software you need in order to test Flutter apps on a laptop or desktop computer is freely available. You simply download, install, and get going.
  • I assume that you can navigate your computer’s common menus and dialog boxes. You don’t have to be a Windows or Macintosh power user, but you should be able to start a program, find a file, put a file into a certain directory — that sort of thing. Much of the time, when you follow the instructions in this book, you’re typing code on the keyboard, not pointing-and-clicking the mouse.

    On those occasions when you need to drag-and-drop, cut-and-paste, or plug-and-play, I guide you carefully through the steps. But your computer may be configured in any of several billion ways, and my instructions may not quite fit your special situation. When you reach one of these platform-specific tasks, try following the steps in this book. If the steps don’t quite fit, consult a book with instructions tailored to your system. If you can’t find such a book, send me an email. (My address appears later in the introduction.)

  • I assume that you can think logically. That’s all there is to application development — thinking logically. If you can think logically, you’ve got it made. If you don’t believe that you can think logically, read on. You may be pleasantly surprised.
  • I make very few assumptions about your computer programming experience (or your lack of such experience). In writing this book, I’ve tried to do the impossible: make the book interesting for experienced programmers yet accessible to people with little or no programming experience. This means that I don’t assume any particular programming background on your part. If you’ve never written any code, that’s okay.

    On the other hand, if you’ve done some coding (maybe in Java, Python, or C++), you’ll discover some interesting plot twists in Dart — the language that’s used to develop Flutter apps. The creators of Dart took the best ideas from object-oriented programming and functional programming, streamlined them, reworked them, and reorganized them into a simple yet powerful way of thinking about problems. You’ll enjoy programming in Dart.

How This Book Is Organized

This book is divided into subsections, which are grouped into sections, which come together to make chapters, which are lumped, finally, into four parts (like one of those Russian matryoshka dolls). The parts of the book are described here.

Part 1, “Getting Ready”

Part 1 covers all the nuts-and-bolts. It introduces you to the major ideas behind mobile app development and walks you through the installation of the necessary software products.

The instructions in these chapters cover both Windows and Macintosh computers. They cover many computer configurations with all kinds of software already installed. But adding new software is always tricky, and you might have a few hurdles to overcome. If you do, check the end of this chapter for ways to reach me (the author) and get some quick advice. (Yes, I answer emails, tweets, Facebook posts, and notes sent by carrier pigeons.)

Part 2, “Flutter: A Burd’s-Eye View”

Chapters 3 and 4 cover Flutter’s basic building blocks. These chapters describe some simple Flutter apps and introduce Dart programming language fundamentals.

If you’ve created apps specifically for Android or iOS, some of the material in Part 2 may be familiar to you. If so, you can skip sections or read this stuff quickly. But don’t read too quickly. Flutter is different from most other development frameworks, and Flutter’s differences are worth noting.

Part 3, “Details, Details”

If you’ve tasted some Flutter and want more, you can find what you need in Part 3 of this book. This part’s chapters cover the building blocks of a solid, useful app — tasks like responding to user input, laying out your app’s components, navigating from page to page, getting data from the Internet, and more.

Part 4, “The Part of Tens”

In The Part of Tens, which is a little Flutter candy store, you can find lists — lists of tips for avoiding mistakes, tracking down resources, and finding all kinds of interesting goodies.

More on the web!

You’ve read the Flutter For Dummies book, seen the Flutter For Dummies movie, worn the Flutter For Dummies T-shirt, and eaten the Flutter For Dummies candy. What more is there to do?

That’s easy. Just visit this book’s website: www.allmycode.com/Flutter. There, you can find updates, comments, additional information, and answers to commonly asked questions from readers. You can also find a small chat application for sending me quick questions when I’m online. (When I’m not online, you can contact me in other ways. See the end of this chapter for more info.)

Icons Used in This Book

If you could watch me write this book, you’d see me sitting at my computer, talking to myself. I say each sentence in my head. Most of the sentences I mutter several times. When I have an extra thought, a side comment, or something else that doesn’t belong in the regular stream, I twist my head a little bit. That way, whoever’s listening to me (usually, nobody) knows that I’m off on a momentary tangent.

Of course, in print, you can’t see me twisting my head. I need some other way to set a side thought in a corner by itself. I do it with icons. When you see a Tip icon or a Remember icon, you know that I’m taking a quick detour.

Here’s a list of icons that I use in this book:

Tip A tip is an extra piece of information — helpful advice that the other books may forget to tell you.

Warning Everyone makes mistakes. Heaven knows that I’ve made a few in my time. Anyway, when I think people are especially prone to make a mistake, I mark the text with a Warning icon.

Remember You can think of the word Remember in two different contexts. One context is, “Remember to do this good thing in your code, and remember not to do that bad thing in your code.” Another context is, “When you find yourself not doing this good thing or doing that bad thing, remember that you can read about it in the section containing this icon.” Personally, I prefer the latter context because it recognizes that everyone forgets stuff. When you forget something, simply go back and look it up.

crossreference “If you don’t remember what such-and-such means, see blah-blah-blah,” or “For more information, read blahbity-blah-blah.”

On the web This icon calls attention to useful material that you can find online. (You don’t have to wait long to see one of these icons. I use one at the end of this introduction!)

Technical stuff Occasionally, I run across a technical tidbit. The tidbit may help you understand what the people behind the scenes (the people who created Java) were thinking. You don’t have to read it, but you may find it useful. You may also find the tidbit helpful if you plan to read other (geekier) books about Flutter.

Beyond the Book

In addition to what you’re reading right now, this book comes with a free access-anywhere Cheat Sheet containing code that you can copy-and-paste into your own Flutter program. To get this Cheat Sheet, simply go to www.dummies.com and type Flutter For Dummies Cheat Sheet in the Search box.

Where to Go from Here

If you’ve gotten this far, you’re ready to start reading about Flutter app development. Think of me (the author) as your guide, your host, your personal assistant. I do everything I can to keep things interesting and, most importantly, to help you understand.

On the web If you like what you read, send me a note. My email address, which I created just for comments and questions about this book, is flutter@allmycode.com. If email and chat aren’t your favorites, you can reach me instead on Twitter (@allmycode) and on Facebook (/allmycode). And don’t forget — for the latest updates, visit this book’s website. The site’s direct address is www.allmycode.com/flutter. Alternatively, you can visit www.allmycode.com and find links to all my books’ web pages.

Enough with the introduction! Onward to Flutter… .

Part 1

Getting Ready

IN THIS PART …

Working through the nuts-and-bolts of mobile app development

Prepping your development computer

Running sample programs