Frank Zammetti
Practical Flutter Improve your Mobile Development with Googles Latest Open-Source SDK
Frank Zammetti
Pottstown, PA, USA
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the books product page, located at www.apress.com/9781484249710 . For more detailed information, please visit http://www.apress.com/source-code .
ISBN 978-1-4842-4971-0 e-ISBN 978-1-4842-4972-7
https://doi.org/10.1007/978-1-4842-4972-7
Frank Zammetti 2019
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
Id like to dedicate this book to butterflies, which flutter in the wind.
No, wait, thats too easy.
Id like to dedicate this book to gamblers who, the British people might say, make a flutter on the horses.
Yes, thats actually a real usage of the word flutter, but that too is too easy.
No, Id like to dedicate this book to all the unknowns the human race has yet to discover and, in some cases, create. I am a pessimist by nature, but I fight that nature each and every day because I also recognize that the universe is a wondrous place and, despite what the evening news tells us, the human race is capable of great beauty and wondrous creation.
And, with my stated goal of being immortal, because death just isnt me its been done before, so Im just gonna go ahead and skip it I look forward to seeing it all!
Introduction
Creating mobile apps that look, feel, and function like native apps and are also cross-platform is a tricky proposition, even after all these years of developers working to achieve that goal. You can write native code for each platform and do your best to make them as similar as possible, and thats certainly a good way to get native performance and capabilities into your app. But, effectively, that means writing your app multiple times. Clients tend not to like having to pay for that sort of thing!
Instead, you can take the HTML route and have a single code base that works everywhere. But then, you will often be left out in the cold in terms of native device capabilities, not to mention performance frequently being subpar (there are some options that minimize these concerns to be sure, but theyre still there no matter how good those options do).
Ive been doing this exact thing for two decades now (seriously!), so Ive seen it all, many times over. So, when I see a possible unicorn on the horizon, Im skeptical for sure. But, when you get closer and see that the unicorn is indeed real, well, its not really a unicorn anymore, is it? Its reality, and a wondrous reality at that.
And so, I present to you the unicorn that is the wondrous reality: Flutter!
Thanks to the talented engineers at Google, Flutter is a platform that provides a means for you to write a single code base (more or less) that works on Android and iOS equally well while delivering native performance and native capabilities. Built with modern tools and development techniques, Flutter opens up the world of mobile development to programmers that is, dare I say it, even fun to use!
In this book, youll learn Flutter by building two real apps, not just grossly simplified, dumbed-down, and contrived examples (although there are a few of those early on, as concepts are introduced). No, the apps well build together will be practical apps that you could use for real if you want, not just simple tech demos, and along the way youll see many aspects that went into their development, including in some cases the problems I faced in putting it together and the solutions I came up with. In doing so, youll get solid, hands-on experience with using Flutter in a real-world way a way that will prepare you for building your own apps later.
Youll also learn some things tangential to building the app including building a server with Node.js and WebSockets. You can consider those nice little bonuses to the real star of the show in Flutter.
On top of that, youll get a bonus third app thats drastically different from the first two: a game! Yes, well build a game together using Flutter, if for no other reason than to highlight some additional capabilities of Flutter that the first two apps wont necessarily touch on and will give you a chance to see Flutter from a different angle, expanding your horizons for whats possible. A game may not be quite as practical in a sense, but games sure are fun to make, and a little fun never hurt anyone!
By the end, youll have a good handle on what Flutter offers, and youll be in an excellent position to go off and create the Next Big Thing(tm) app with it.
If you were a computer enthusiast in the 1980s, then youre probably familiar with typing in 20 small-print magazine pages of machine code to play a game or run an app for balancing your checkbook (yes, we really did that and, entirely tangentially, there were even radio stations that would broadcast the code, similar to how a modern takes data and creates sounds from it to transmit over a phone line, which you could record and then run through a program that would spit out the code for you!). You certainly could do that with this book, type it all in by hand, but that would be a painful amount of typing!
So, before you get started, I suggest you head over to the Apress web site, search for this book, and grab the source code bundle from there. That should give you everything you need to follow along without having to type your fingers raw!
That said, dont forget that the best way to learn anything is by doing, so definitely get in there and hack at the example code and apps and see what happens when you make changes. As you finish reading the chapters associated with each app, maybe get in there and try and add a feature or two (and, Ill even make some suggestions along the way for doing just that to give you some direction). I think before long youll realize that because of the power Flutter provides, small changes can make significant differences in what winds up on the screen.