Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Flutter Cookbook, Second Edition
Flutter Cookbook, Second Edition

Flutter Cookbook, Second Edition: 100+ step-by-step recipes for building cross-platform, professional-grade apps with Flutter 3.10.x and Dart 3.x , Second Edition

eBook
€17.99 €26.99
Paperback
€33.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Flutter Cookbook, Second Edition

Flutter Cookbook, Second Edition: 100+ real-world recipes to build cross-platform applications with Flutter 3.3 powered by Dart 2.16

Welcome to Packt Early Access. We’re giving you an exclusive preview of this book before it goes on sale. It can take many months to write a book, but our authors have cutting-edge information to share with you today. Early Access gives you an insight into the latest developments by making chapter drafts available. The chapters may be a little rough around the edges right now, but our authors will update them over time.

You can dip in and out of this book or follow along from start to finish; Early Access is designed to be flexible. We hope you enjoy getting to know more about the process of writing a Packt book.

  1. Chapter 1: Getting Started with Flutter: Setting up your environment and choosing an IDE
  2. Chapter 2: Dart: A programming language you probably already know
  3. Chapter 3: Building Layouts, Hot Reload and Hot Restart...

Why Flutter?

Flutter is an open-source framework to build apps, created by Google. Before investing time and effort in learning a new framework, there is a critical question we need to answer: Is Flutter worth learning and using?

While the answer to this question probably depends on your needs and expectations, there are several reasons that make Flutter a great framework to learn and use. Some of them include:

  • Cross-platform: With Flutter, you can build apps for iOS and Android, web, desktop, and IoT devices with a single code base.
  • Fast development: Flutter includes several features that help speed up your development workflow. Among the most important, it’s worth mentioning hot reload, hot restart, and sound null safety support.
  • User interface: Flutter provides a rich set of widgets to create beautiful, high-performance apps.
  • Open source: Flutter and Dart (the programming language you use in Flutter) are open source and supported by Google...

Technical requirements

Flutter requires a 64-bit operating system. In particular:

Building mobile applications can be a taxing task for your computer. While the minimum hardware requirements to develop a Flutter app are relatively low, your developing experience will be greatly enhanced with the following specs:

  • 8 GB of random-access memory (RAM). 16 gigabytes (GB) is preferred, especially when using a virtual device (emulator or simulator).
  • At least 50 GB of available hard...

Installing Flutter: a high-level overview

You can start developing Flutter apps without any installation or configuration. You can quickly create prototypes and simple apps and share your code with fellow developers with an online tool called DartPad, available here: https://dartpad.dev. It is an online open-source tool that runs on any browser.

However, if you are serious about programming with Flutter, there will come a time when you need to develop your apps locally and, therefore, will need to configure your system.

Configuring your Flutter development environment is rather easy. You can divide the process into three parts:

  1. First, you must install the Flutter software development kit (SDK). Currently, you can build Flutter apps from Windows, macOS, Linux, and ChromeOS.
  2. Then, depending on your target platform, you have to install a specific platform SDK: Android, iOS, and/or desktop. You can also develop for the web, without installing any specific SDK...

Installing the Flutter SDK

Before you can build anything, you need to download the Flutter SDK.

On the main Flutter website at https://docs.flutter.dev/get-started/install, you’ll find the prebuilt packages for Windows, macOS, Linux, or ChromeOS—the currently supported platforms to create Flutter apps.

Figure 1.1: The Flutter installation page

Once you select your operating system, whatever your choice, you will find a section called Get the Flutter SDK. Here, you will find a compressed file (.zip for Windows and macOS, and .tar.gz for Linux and ChromeOS).

You should then create a directory for the Flutter SDK, and extract the contents of the compressed file into that directory; for instance, this could be c:\dev\flutter on a Windows machine or ~/development on other platforms.

There is another tool, called FVM (Flutter Version Management), that allows managing multiple versions of Flutter SDKs on your development machine.

If...

How to use Git to manage the Flutter SDK

An alternative way to install the Flutter SDK is using Git.

Since Flutter is open source and hosted on GitHub, if you clone the main Flutter repository, you’ll already have everything you need. As an added bonus, you can easily change to different versions of the Flutter SDK when needed.

The packages that are available to download on Flutter’s website are snapshots from the Git repository. Flutter uses Git internally to manage its versions, channels, and upgrades.

Installing Git

First, you need to make sure you have Git installed on your computer. Git is installed by default on most Mac and Linux machines. For Windows, you can download and install Git here: https://git-scm.com/download/win.

You can also download a Git client to make working with repositories a bit easier. Tools such as Sourcetree (https://www.sourcetreeapp.com) or GitHub Desktop (https://desktop.github.com) can simplify working with Git....

Setting up the command line and saving path variables

Now that you have installed the Flutter SDK, there are a few more steps needed to make the software accessible on your computer. Unlike apps with user interfaces (UIs), Flutter is primarily a command-line tool. Let’s quickly learn how to set up the command line on macOS, Windows, and Linux in the following sections.

macOS command-line setup

To use Flutter on macOS, you need to save the location of the Flutter executable to your system’s environment variables.

Newer Macs use the Z shell (also known as zsh). This is basically an improved version of the older Bash, with several additional features.

When using zsh, you can add a line to your zshrc file, which is a text file that contains the zsh configuration. If the file does not exist yet, you can create a new file as follows:

  1. Open the zshrc file with the following command in your Terminal:
    nano $HOME/.zshrc
    
  2. ...

Confirming your environment is correct with Flutter Doctor

Flutter comes with a tool called Flutter Doctor. This tool provides a list of everything that needs to be done to make sure that Flutter can run correctly. You are going to use Flutter Doctor as a guide during the installation process. This tool is also invaluable in checking whether your system is up to date.

In your Terminal window, type the following command:

flutter doctor

Flutter Doctor will tell you whether your platform SDKs are configured properly and whether Flutter can see any devices, including physical mobile devices, simulators and emulators, your desktop, and the web browser.

Configuring the iOS SDK

The iOS SDK is provided by a single application: Xcode. Xcode is one behemoth of an application; it controls all the official ways in which you will interact with Apple’s platforms and is only available for macOS. As large as Xcode is, there are a few pieces of software that are missing. Two of these are community tools: CocoaPods and Homebrew. These are package managers, or programs that install other programs. You can use both of these tools to build iOS apps.

Downloading Xcode

The iOS SDK comes bundled with Apple’s IDE, Xcode. The best place to get Xcode is through the Apple App Store:

  1. Press Command + Space to open Spotlight and then type in app store:
    Graphical user interface, text, application, email  Description automatically generated

    Figure 1.6: App Store results in Spotlight

    As an alternative, you can just click on the menu in the top-left corner of your screen and select App Store, but keyboard shortcuts are much more fun.

  1. After the App Store opens, search for Xcode and select...

Configuring the Android SDK setup

Just like with Xcode, Android Studio and the Android SDK come hand in hand, which should make this process fairly easy. But also like Xcode, Android Studio is just the starting point. There are a bunch of tiny tools that you’ll need to get everything up and running.

Installing Android Studio

Follow these steps to install Android Studio:

  1. You can download Android Studio at https://developer.android.com/studio.

    The website will autodetect your operating system and only show the appropriate download link:

    Graphical user interface, text, application, chat or text message  Description automatically generated

    Figure 1.10: Android Studio download page

    After Android Studio is installed, you’ll need to download your target Android SDK(s). From the Android Studio menu, select Preferences and then type android into the search field:

    Figure 1.11: Android Studio SDKs screen

    While it may be tempting to grab the most recent version of the Android SDK, you might want to choose the second most recent...

Which IDE/editor should you choose?

A developer’s IDE is a very personal choice, and developers may engage in heated battles over the best tool to use.

Ultimately, the choice is dependent on which tool you are most productive and more capable in. If you find yourself fighting with the tool rather than just writing code, then it might not be the right choice. As with most things, it’s more important to make choices based on what best fits your personal and unique style, rather than follow any prescribed doctrine.

You can develop Flutter apps with any editor, including Notepad and the Flutter CLI, but Flutter provides official plugins for four popular IDEs:

  • Android Studio
  • Visual Studio Code (VS Code)
  • IntelliJ IDEA
  • Emacs

Let’s compare and configure all four and find out which one might be right for you.

Android Studio

Android Studio is a mature and stable IDE. Since 2014, Android Studio has been promoted as...

Picking the right channel

One final item we need to cover before diving into building apps is the concept of channels. Flutter segments its development streams into channels, which is really just a fancy name for Git branches. Each channel represents a different level of stability for the Flutter framework. Flutter developers will release the latest features to the master channel first. As these features stabilize, they will get promoted to the beta channel, and then to the stable channel.

In previous Flutter versions, there was also a dev channel, between master and beta, but this was removed. The Flutter versioning policy will probably be updated in the near future, so please have a look at the Flutter build release page at https://github.com/flutter/flutter/wiki/Flutter-build-release-channels for the latest versioning updates.

Most of the time, you will probably want to stick to the stable channel. This will make sure that your code mostly runs without any...

Summary

By now, you should have a working Flutter environment set up. It is recommended that you rerun Flutter Doctor from time to time to check the status of your environment. The Doctor will also let you know when a new version of Flutter is available, which—depending on your channel—happens every few weeks or months. Flutter is still a relatively young framework and growing fast, so you should always keep your environment up to date.

The Flutter team is also very receptive to helping you with any technical issues you might encounter. If you run into an issue that hasn’t been documented yet, you can always reach out to the Flutter team directly on GitHub at https://github.com/flutter/flutter/issues.

Learning about the command line will become an invaluable skill. This can range from setting up and configuring your environment to writing build scripts, which we will do later in this book when we automate building and publishing the apps to the stores...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Thoroughly updated to cover the latest features in Flutter 3.10.x and Dart 3.x
  • Practical recipes to publish responsive, multi-platform apps from a single database
  • Covers not just the ‘hows’ but the ‘whys’ of Flutter’s features with examples

Description

Are you ready to tap into the immense potential of Flutter? With over 1,000 new mobile apps published every day on the Apple and Google Play stores, Flutter is transforming the landscape of app development. It's time for you to join the revolution. Introducing the second edition of Flutter Cookbook, a step-by-step guide designed exclusively for you. Whether you're a seasoned developer or just starting your coding journey, this book is your ultimate companion. Dive into the latest features of Flutter 3.10 and unlock the secrets to building professional-grade, cross-platform applications. With our recipe-based approach, we'll not only show you how to implement Flutter's features but also explain why they work. Through practical examples and real-world execution, you'll gain a deeper understanding of Flutter's inner workings. From crafting stunning UI/UX with widgets to leveraging hot reload and restart techniques, we'll equip you with best practices and invaluable knowledge. As you progress, you'll learn to efficiently manage data, add interactivity and animations, and integrate essential Flutter plugins like maps, camera, voice recognition and more. And let's not forget the dedicated chapter on implementing MLkit powered by TensorFlow Lite. We'll guide you through building custom machine learning solutions, expanding the capabilities of your apps. By the time you reach the end of this comprehensive Flutter book, you'll have the skills and confidence to write and deliver fully functional apps.

Who is this book for?

Developers who are familiar with the OOP language and prefer learning-by-doing will get the most out of this book. If you have some experience building apps on Flutter or have been playing around with the framework for some time now and have set eyes on developing mobile apps using Dart, then this book is for you.

What you will learn

  • Familiarize yourself with Dart fundamentals and set up your development environment
  • Efficiently track and eliminate code errors with proper tools
  • Create various screens using multiple widgets to effectively manage data
  • Craft interactive and responsive apps by incorporating routing, page navigation, and input field text reading
  • Design and implement a reusable architecture suitable for any app
  • Maintain control of your codebase through automated testing and developer tooling
  • Develop engaging animations using the necessary tools
  • Enhance your apps with ML features using Firebase MLKit and TensorFlow Lite
  • Successfully publish your app on the Google Play Store and the Apple App Store

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : May 31, 2023
Length: 712 pages
Edition : 2nd
Language : English
ISBN-13 : 9781803232638
Category :
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : May 31, 2023
Length: 712 pages
Edition : 2nd
Language : English
ISBN-13 : 9781803232638
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 103.97
50 Algorithms Every Programmer Should Know
€37.99
Flutter Cookbook, Second Edition
€33.99
Flutter for Beginners
€31.99
Total 103.97 Stars icon

Table of Contents

18 Chapters
Getting Started with Flutter Chevron down icon Chevron up icon
Creating Your First Flutter App Chevron down icon Chevron up icon
Dart: A Language You Already Know Chevron down icon Chevron up icon
Introduction to Widgets Chevron down icon Chevron up icon
Mastering Layout and Taming the Widget Tree Chevron down icon Chevron up icon
Adding Interactivity and Navigation to Your App Chevron down icon Chevron up icon
Basic State Management Chevron down icon Chevron up icon
The Future is Now: Introduction to Asynchronous Programming Chevron down icon Chevron up icon
Data Persistence and Communicating with the Internet Chevron down icon Chevron up icon
Advanced State Management with Streams Chevron down icon Chevron up icon
Using Flutter Packages Chevron down icon Chevron up icon
Adding Animations to Your App Chevron down icon Chevron up icon
Using Firebase Chevron down icon Chevron up icon
Firebase Machine Learning Chevron down icon Chevron up icon
Flutter Web and Desktop Chevron down icon Chevron up icon
Distributing Your Mobile App Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.6
(39 Ratings)
5 star 82.1%
4 star 10.3%
3 star 0%
2 star 2.6%
1 star 5.1%
Filter icon Filter
Top Reviews

Filter reviews by




Giovanny Sep 14, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I have learned so much with this book
Subscriber review Packt
Giovanny Sep 13, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I have learned so much with this book. It's between my favorites books now
Subscriber review Packt
병옥 김 Jan 28, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Feefo Verified review Feefo
Alberto Acosta Nov 08, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
It is undoubtedly the best technical book publisher on the planet. And their approach to collaboration with their readers couldn't be better. I can't say enough about how grateful I am to PackPub for giving me access to the most advanced technologies year after year, year after year.
Feefo Verified review Feefo
Akash Matlani Jul 13, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Very Useful & Detail Described.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.