Book description
Discover how to build, scale, and debug native iOS and Android applications from a single codebase using the Dart programming language - a hands-on approach
Key Features
- Work through practical recipes for building mobile applications with Flutter
- Quickly build and iterate on your user interface (UI) with hot reload
- Fix bugs and prevent them from reappearing using Flutter's developer tools and test suites
Book Description
"Anyone interested in developing Flutter applications for Android or iOS should have a copy of this book on their desk." - Amazon 5* Review
Lauded as the 'Flutter bible' for new and experienced mobile app developers, this recipe-based guide will teach you the best practices for robust app development, as well as how to solve cross-platform development issues.
From setting up and customizing your development environment to error handling and debugging, The Flutter Cookbook covers the how-tos as well as the principles behind them.
As you progress, the recipes in this book will get you up to speed with the main tasks involved in app development, such as user interface and user experience (UI/UX) design, API design, and creating animations. Later chapters will focus on routing, retrieving data from web services, and persisting data locally. A dedicated section also covers Firebase and its machine learning capabilities.
The last chapter is specifically designed to help you create apps for the web and desktop (Windows, Mac, and Linux).
Throughout the book, you'll also find recipes that cover the most important features needed to build a cross-platform application, along with insights into running a single codebase on different platforms.
By the end of this Flutter book, you'll be writing and delivering fully functional apps with confidence.
What you will learn
- Use Dart programming to customize your Flutter applications
- Discover how to develop and think like a Dart programmer
- Leverage Firebase Machine Learning capabilities to create intelligent apps
- Create reusable architecture that can be applied to any type of app
- Use web services and persist data locally
- Debug and solve problems before users can see them
- Use asynchronous programming with Future and Stream
- Manage the app state with Streams and the BLoC pattern
Who this book is for
If you're familiar with the basic concepts of programming and have your eyes set on developing mobile apps using Dart, then this book is for you. As a beginner, you'll benefit from the clear and concise step-by-step recipes, while a more experienced programmer will learn best practices and find useful tips. You'll get the most out of this book if you have experience coding in either JavaScript, Swift, Kotlin, Java, Objective-C, or C#.
Table of contents
- Title Page
- Copyright and Credits
- Dedication
- Contributors
- Preface
-
Getting Started with Flutter
- Technical requirements
- How to use Git to manage the Flutter SDK
- Installing Git
- How to do it...
- See also
- Setting up the command line and saving path variables
- macOS command-line setup
- Windows command-line setup
- Confirming your environment is correct with Flutter Doctor
- Configuring the iOS SDK
- Downloading Xcode
- CocoaPods
- Xcode command-line tools
- Homebrew
- Checking in with the Doctor
- Configuring the Android SDK setup
- Installing Android Studio
- Creating an Android emulator
- Which IDE/editor should you choose?
- Android Studio
- VS Code
- IntelliJ IDEA
- Picking the right channel
- How to create a Flutter app
- How to do it...
- How to choose a platform language for your app
- Where do you place your code?
- Hot reload – refresh your app without recompiling
- Summary
-
Dart: A Language You Already Know
- Technical requirements
- Declaring variables – var versus final versus const
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Strings and string interpolation
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- How to write functions
- Getting ready
- How to do it...
- How it works...
- How to use functions as variables with closures
- Getting ready
- How to do it...
- How it works...
- Creating classes and using the class constructor shorthand
- Getting ready
- How to do it...
- How it works...
- The building blocks of OOP
- See also
- How to group and manipulate data with collections
- Getting ready
- How to do it...
- How it works...
- Subscript syntax
- There's more...
- See also
- Writing less code with higher-order functions
- Getting ready
- How to do it...
- How it works...
- Mapping
- Sorting
- Filtering
- Reducing
- Flattening
- There's more...
- First-class functions
- Iterables and chaining higher-order functions
- See also
- How to take advantage of the cascade operator
- Getting ready
- How to do it...
- How it works...
- See also
- Understanding Dart Null Safety
- Getting ready
- How to do it...
- How it works...
- See also
-
Introduction to Widgets
- Technical requirements
- Creating immutable widgets
- How to do it...
- How it works...
- Using a Scaffold
- Getting ready
- How to do it...
- How it works...
- Using the Container widget
- Getting ready
- How to do it...
- How it works...
- Printing stylish text on the screen
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Importing fonts and images into your app
- Getting ready
- How to do it...
- How it works...
- See also
-
Mastering Layout and Taming the Widget Tree
- Placing widgets one after another
- Getting ready
- How to do it...
- How it works...
- Proportional spacing with the Flexible and Expanded widgets
- Getting ready
- How to do it...
- How it works...
- See also
- Drawing shapes with CustomPaint
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Nesting complex widget trees
- Getting ready
- How to do it...
- How it works...
- See also
- Refactoring widget trees to improve legibility
- Getting ready
- How to do it...
- How it works...
- See also
- Applying global themes
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
-
Adding Interactivity and Navigation to Your App
- Adding state to your app
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Interacting with buttons
- Getting ready
- How to do it...
- How it works...
- Making it scroll
- Getting ready
- How to do it...
- How it works...
- There's more...
- Handling large datasets with list builders
- How to do it...
- How it works...
- There's more...
- Working with TextFields
- Getting ready
- How to do it...
- How it works...
- See also
- Navigating to the next screen
- How to do it...
- How it works...
- Invoking navigation routes by name
- How to do it...
- How it works...
- Showing dialogs on the screen
- How to do it...
- How it works...
- There's more...
- Presenting bottom sheets
- How to do it...
- How it works...
- See also
-
Basic State Management
- Technical requirements
- Model-view separation
- Getting ready
- How to do it...
- How it works...
- See also
- Managing the data layer with InheritedWidget
- Getting ready
- How to do it...
- How it works...
- See also
- Making the app state visible across multiple screens
- Getting ready
- How to do it...
- How it works...
- Designing an n-tier architecture, part 1 – controllers
- Getting ready
- How to do it...
- How it works...
- See also
- Designing an n-tier architecture, part 2 – repositories
- Getting ready
- How to do it...
- How it works...
- Designing an n-tier architecture, part 3 – services
- How to do it...
- How it works...
- There's more...
- See also
-
The Future is Now: Introduction to Asynchronous Programming
- Technical requirements
- Using a Future
- Getting ready
- How to do it...
- How it works...
- See also
- Using async/await to remove callbacks
- Getting ready
- How to do it...
- How it works...
- See also
- Completing Futures
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Firing multiple Futures at the same time
- Getting ready
- How to do it...
- How it works...
- See also
- Resolving errors in asynchronous code
- Getting ready
- How to do it...
- Dealing with errors using the then() callback:
- Dealing with errors using async/await
- How it works...
- See also
- Using Futures with StatefulWidgets
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Using the FutureBuilder to let Flutter manage your Futures
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Turning navigation routes into asynchronous functions
- Getting ready
- How to do it...
- How it works...
- Getting the results from a dialog
- Getting ready
- How to do it...
- How it works...
- See also
-
Data Persistence and Communicating with the Internet
- Technical requirements
- Converting Dart models into JSON
- Getting ready
- How to do it...
- How it works...
- Reading the JSON file
- Transforming the JSON string into a list of Map objects
- Transforming the Map objects into Pizza objects
- There's more...
- See also
- Handling JSON schemas that are incompatible with your models
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Catching common JSON errors
- Getting ready
- How to do it...
- How it works...
- See also
- Saving data simply with SharedPreferences
- Getting ready
- How to do it...
- How it works...
- See also
- Accessing the filesystem, part 1 – path_provider
- Getting ready
- How to do it...
- How it works...
- See also
- Accessing the filesystem, part 2 – working with directories
- Getting ready
- How to do it...
- How it works...
- See also
- Using secure storage to store data
- Getting ready
- How to do it...
- How it works...
- See also
- Designing an HTTP client and getting data
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- POST-ing data
- Getting ready
- How to do it...
- How it works...
- PUT-ting data
- Getting ready
- How to do it...
- How it works...
- DELETE-ing data
- Getting ready
- How to do it...
- How it works...
-
Advanced State Management with Streams
- Technical requirements
- How to use Dart streams
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Using stream controllers and sinks
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Injecting data transform into streams
- Getting ready
- How to do it...
- How it works...
- See also
- Subscribing to stream events
- Getting ready
- How to do it...
- How it works...
- See also
- Allowing multiple stream subscriptions
- Getting ready
- How to do it...
- How it works...
- See also
- Using StreamBuilder to create reactive user interfaces
- Getting ready
- How to do it...
- How it works...
- See also
- Using the BLoC pattern
- Getting ready
- How to do it...
- How it works...
- See also
-
Using Flutter Packages
- Technical requirements
- Importing packages and dependencies
- Getting ready
- How to do it...
- How it works...
- See also
- Creating your own package (part 1)
- Getting ready
- How to do it...
- How it works...
- See also
- Creating your own package (part 2)
- Getting ready
- How to do it...
- How it works...
- See also
- Creating your own package (part 3)
- Getting ready
- How to do it...
- How it works...
- See also
- Adding Google Maps to your app
- Getting ready
- How to do it...
- How it works...
- See also
- Using location services
- Getting ready
- How to do it...
- How it works...
- See also
- Adding markers to a map
- Getting ready
- How to do it...
- How it works...
- There's more...
-
Adding Animations to Your App
- Creating basic container animations
- Getting ready
- How to do it...
- How it works...
- See also
- Designing animations part 1 – using the AnimationController
- Getting ready
- How to do it...
- How it works...
- See also
- Designing animations part 2 – adding multiple animations
- Getting ready
- How to do it...
- How it works...
- Designing animations part 3 – using curves
- Getting ready
- How to do it...
- How it works...
- See also
- Optimizing animations
- Getting ready
- How to do it...
- How it works...
- See also
- Using Hero animations
- Getting ready
- How to do it...
- How it works...
- See also
- Using premade animation transitions
- Getting ready
- How to do it...
- How it works...
- See also
- Using the AnimatedList widget
- Getting ready
- How to do it...
- How it works...
- See also
- Implementing swiping with the Dismissible widget
- Getting ready
- How to do it...
- How it works...
- See also
- Using the animations Flutter package
- Getting ready
- How to do it...
- How it works...
- See also
-
Using Firebase
- Configuring a Firebase app
- Getting ready
- How to do it...
- Android configuration
- iOS configuration
- Adding Firebase dependencies
- How it works...
- See also
- Creating a login form
- Getting ready
- How to do it...
- How it works...
- See also
- Adding Google Sign-in
- Getting ready
- How to do it...
- How it works...
- See also
- Integrating Firebase Analytics
- Getting ready
- How it works...
- How it works...
- See also
- Using Firebase Cloud Firestore
- Getting ready
- How to do it...
- How it works...
- See also
- Sending Push Notifications with Firebase Cloud Messaging (FCM)
- Getting ready
- How to do it...
- How it works...
- See also
- Storing files in the cloud
- Getting ready
- How to do it...
- How it works...
-
Machine Learning with Firebase ML Kit
- Using the device camera
- Getting ready
- How to do it...
- How it works...
- See also
- Recognizing text from an image
- Getting ready
- How to do it...
- How it works...
- See also
- Reading a barcode
- Getting ready
- How to do it...
- How it works...
- See also
- Image labeling
- Getting ready
- How to do it...
- How it works...
- See also
- Building a face detector and detecting facial gestures
- Getting ready
- How to do it...
- How it works...
- See also
- Identifying a language
- Getting ready
- How to do it...
- How it works...
- See also
- Using TensorFlow Lite
- Getting ready
- How to do it...
- How it works...
- See also
-
Distributing Your Mobile App
- Technical requirements
- Registering your iOS app on App Store Connect
- Getting ready
- How to do it...
- How it works...
- See also
- Registering your Android app on Google Play
- Getting ready
- How to do it...
- How it works...
- See also
- Installing and configuring fastlane
- Getting ready
- How to do it...
- Installing fastlane on Windows
- Installing fastlane on a Mac
- Configuring fastlane for Android
- Installing fastlane for iOS
- See also
- Generating iOS code signing certificates and provisioning profiles
- Getting ready
- How to do it...
- How it works...
- See also
- Generating Android release certificates
- Getting ready
- How to do it...
- How it works...
- See also
- Auto-incrementing your Android build number
- Getting ready
- How to do it...
- How it works...
- See also
- Configuring your app metadata
- Getting ready
- How to do it...
- Adding Android metadata
- Adding metadata for iOS
- How it works...
- See also
- Adding icons to your app
- Getting ready
- How to do it...
- How it works...
- See also
- Publishing a beta version of your app in the Google Play Store
- Getting ready
- How to do it...
- How it works...
- See also
- Using TestFlight to publish a beta version of your iOS app
- Getting ready
- How to do it...
- How it works...
- See also...
- Publishing your app to the stores
- Getting ready
- How to do it...
- Moving your app to production in the Play Store
- Moving your app to production in the App Store
- How it works...
- See also...
-
Flutter Web and Desktop
- Creating a responsive app leveraging Flutter Web
- Getting ready
- How to do it...
- How it works...
- See also...
- Running your app on macOS
- Getting ready
- How to do it...
- How it works...
- See also
- Running your app on Windows
- Getting ready...
- How to do it...
- How it works...
- See also...
- Deploying a Flutter website
- Getting ready
- How to do it...
- How it works...
- See also...
- Responding to mouse events in Flutter Desktop
- Getting ready
- How to do it
- How it works...
- See also
- Interacting with desktop menus
- Getting ready...
- How to do it...
- How it works...
- See also...
- About Packt
Product information
- Title: Flutter Cookbook
- Author(s):
- Release date: June 2021
- Publisher(s): Packt Publishing
- ISBN: 9781838823382
You might also like
book
Flutter Cookbook - Second Edition
Write, test and publish your web, desktop, and embedded apps with this most up-to-date book on …
book
Flutter and Dart Cookbook
Learn the essentials of working with Flutter and Dart to build full stack applications that meet …
book
Programming Flutter
Work in Flutter, a framework designed from the ground up for dual platform development, with support …
book
Flutter for Beginners - Second Edition
Develop the real-world experience you need to build and launch your own Flutter apps with this …