Book Image

Flutter Cookbook

By : Simone Alessandria, Brian Kayfitz
4 (1)
Book Image

Flutter Cookbook

4 (1)
By: Simone Alessandria, Brian Kayfitz

Overview of this book

“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.
Table of Contents (17 chapters)
About Packt

How it works...

You can think of a stream as a one-way pipe, with two ends. One end of the pipe only allows you to insert data, and the other end is where data gets out.

In Flutter, you can do the following:

  • You can use a stream controller to control a stream.
  • A stream controller has a sink property to insert new data.
  • The stream property of StreamController is a way out of StreamController.

You can see a diagram of this concept in the following diagram:

In the app you have built in this recipe, the first step involved the creation of a stream controller, and you did that in the NumberStream class, with the help of the following command:

StreamController<int> controller = StreamController<int>();

As you can see, a stream controller is generic, and you can choose its type (in this case, int) depending on the needs of your app.

The next step was adding data to the stream controller, leveraging its sink property, and we did that with the following...