Flutter® For Dummies®
Published by: John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030-5774, www.wiley.com
Copyright © 2020 by John Wiley & Sons, Inc., Hoboken, New Jersey
Published simultaneously in Canada
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without the prior written permission of the Publisher. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions
.
Trademarks: Wiley, For Dummies, the Dummies Man logo, Dummies.com, Making Everything Easier, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and may not be used without written permission. Flutter is a registered trademark of Google, LLC. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc. is not associated with any product or vendor mentioned in this book.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ.
For general information on our other products and services, please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002. For technical support, please visit https://hub.wiley.com/community/support/dummies
.
Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com
. For more information about Wiley products, visit www.wiley.com
.
Library of Congress Control Number: 2020935615
ISBN: 978-1-119-61258-2; 978-1-119-61261-2 (ebk); 978-1-119-61262-9 (ebk)
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.
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:
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:
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).final String anyname;
italicized computerese
.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 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.
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 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 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.
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 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.)
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.
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.
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.
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.)
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:
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.
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.
Enough with the introduction! Onward to Flutter… .
Part 1
IN THIS PART …
Working through the nuts-and-bolts of mobile app development
Prepping your development computer
Running sample programs