Introduction xxiPart I: The Foundations of Flutter ProgrammingChapter 1: Introducing Flutter and Getting Started 3Introducing Flutter 4Defining Widgets and Elements 5Understanding Widget Lifecycle Events 5The StatelessWidget Lifecycle 6The StatefulWidget Lifecycle 6Understanding the Widget Tree and the Element Tree 8Stateless Widget and Element Trees 9Stateful Widget and Element Trees 10Installing the Flutter SDK 13Installing on macOS 13System Requirements 13Get the Flutter SDK 13Check for Dependencies 14iOS Setup: Install Xcode 14Android Setup: Install Android Studio 14Set Up the Android Emulator 15Installing on Windows 15System Requirements 15Get the Flutter SDK 16Check for Dependencies 16Install Android Studio 16Set Up the Android Emulator 17Installing on Linux 17System Requirements 17Get the Flutter SDK 18Check for Dependencies 19Install Android Studio 19Set Up the Android Emulator 19Configuring the Android Studio Editor 20Summary 20Chapter 2: Creating a Hello World App 25Setting Up the Project 25Using Hot Reload 30Using Themes to Style Your App 33Using a Global App Theme 33Using a Theme for Part of an App 35Understanding Stateless and Stateful Widgets 37Using External Packages 38Searching for Packages 39Using Packages 40Summary 41Chapter 3: Learning Dart Basics 43Why Use Dart? 43Commenting Code 44Running the main() Entry Point 45Referencing Variables 45Declaring Variables 46Numbers 47Strings 47Booleans 47Lists 47Maps 48Runes 48Using Operators 49Using Flow Statements 51if and else 51ternary operator 52for Loops 52while and do-while 53while and break 54continue 54switch and case 55Using Functions 55Import Packages 57Using Classes 57Class Inheritance 60Class Mixins 60Implementing Asynchronous Programming 61Summary 62Chapter 4: Creating a Starter Project Template 65Creating and Organizing Folders and Files 65Structuring Widgets 69Summary 74Chapter 5: Understanding the Widget Tree 77Introduction to Widgets 77Building the Full Widget Tree 79Building a Shallow Widget Tree 85Refactoring with a Constant 86Refactoring with a Method 86Refactoring with a Widget Class 91Summary 99Part II: Intermediate Flutter: Fleshing Out an AppChapter 6: Using Common Widgets 103Using Basic Widgets 103SafeArea 107Container 108Text 112RichText 112Column 114Row 115Column and Row Nesting 115Buttons 119FloatingActionButton 119FlatButton 121RaisedButton 121IconButton 122PopupMenuButton 123ButtonBar 126Using Images and Icons 130AssetBundle 130Image 131Icon 132Using Decorators 135Using the Form Widget to Validate Text Fields 139Checking Orientation 143Summary 149Chapter 7: Adding Animation to an App 151Using AnimatedContainer 152Using AnimatedCrossFade 155Using AnimatedOpacity 160Using AnimationController 164Using Staggered Animations 170Summary 175Chapter 8: Creating an App's Navigation 177Using the Navigator 178Using the Named Navigator Route 188Using Hero Animation 188Using the BottomNavigationBar 193Using the BottomAppBar 199Using the TabBar and TabBarView 203Using the Drawer and ListView 207Summary 217Chapter 9: Creating Scrolling Lists and Effects 221Using the Card 222Using the ListView and ListTile 223Using the GridView 230Using the GridView.count 230Using the GridView.extent 232Using the GridView.builder 233Using the Stack 237Customizing the CustomScrollView with Slivers 243Summary 250Chapter 10: Building Layouts 253A High-Level View of the Layout 253Weather Section Layout 256Tags Layout 256Footer Images Layout 257Final Layout 257Creating the Layout 257Summary 265Chapter 11: Applying Interactivity 267Setting Up GestureDetector: The Basics 267Implementing the Draggable and Dragtarget Widgets 275Using the GestureDetector for Moving and Scaling 278Using the InkWell and InkResponse Gestures 289Using the Dismissible Widget 296Summary 303Chapter 12: Writing Platform-Native Code 307Understanding Platform Channels 307Implementing the Client Platform Channel App 309Implementing the iOS Host Platform Channel 313Implementing the Android Host Platform Channel 318Summary 322Part III: Creating Production-Ready AppsChapter 13: Saving Data with Local Persistence 327Understanding the JSON Format 328Using Database Classes to Write, Read, and Serialize JSON 330Formatting Dates 331Sorting a List of Dates 332Retrieving Data with the FutureBuilder 333Building the Journal App 335Adding the Journal Database Classes 339Adding the Journal Entry Page 344Finishing the Journal Home Page 359Summary 371Chapter 14: Adding The Firebase and Firestore Backend 375What are Firebase and Cloud Firestore? 376Structuring and Data Modeling Cloud Firestore 377Viewing Firebase Authentication Capabilities 380Viewing Cloud Firestore Security Rules 381Configuring the Firebase Project 383Adding a Cloud Firestore Database and Implementing Security 391Building the Client Journal App 395Adding Authentication and Cloud Firestore Packages to the Client App 395Adding Basic Layout to the Client App 403Adding Classes to the Client App 406Summary 409Chapter 15: Adding State Management to the Firestore Client App 411Implementing State Management 412Implementing an Abstract Class 414Implementing the InheritedWidget 415Implementing the Model Class 416Implementing the Service Class 417Implementing the BLoC Pattern 417Implementing StreamController, Streams, Sinks, and StreamBuilder 419Building State Management 421Adding the Journal Model Class 422Adding the Service Classes 424Adding the Validators Class 430Adding the BLoC Pattern 432Adding the AuthenticationBloc 432Adding the AuthenticationBlocProvider 435Adding the LoginBloc 436Adding the HomeBloc 441Adding the HomeBlocProvider 443Adding the JournalEditBloc 444Adding the JournalEditBlocProvider 447Summary 449Chapter 16: Adding Blocs to Firestore Client App Pages 453Adding the Login Page 454Modifying the Main Page 460Modifying the Home Page 465Adding the Edit Journal Page 472Summary 484Index 489
About the authorMarco L. Napoli is the CEO of Pixolini Inc. and an experienced mobile, web and desktop app developer. He has a strong proven record in developing visually elegant and simple to use systems. His work and published apps can be seen at pixolini.com.