Flutter Projects

Book description

Learn Flutter and the Dart programming language by building impressive real-world mobile applications for Android and iOS

Key Features

  • Learn cross-platform mobile development with Flutter and Dart by building 11 real-world apps
  • Create wide array of mobile projects such as 2D game, productivity timer, movie browsing app, and more
  • Practical projects demonstrating Flutter development techniques with tips, tricks, and best practices

Book Description

Flutter is a modern reactive mobile framework that removes a lot of the complexity found in building native mobile apps for iOS and Android. With Flutter, developers can now build fast and native mobile apps from a single codebase.

This book is packed with 11 projects that will help you build your own mobile applications using Flutter. It begins with an introduction to Dart programming and explains how it can be used with the Flutter SDK to customize mobile apps. Each chapter contains instructions on how to build an independent app from scratch, and each project focuses on important Flutter features.From building Flutter Widgets and applying animations to using databases (SQLite and sembast) and Firebase, you'll build on your knowledge through the chapters. As you progress, you'll learn how to connect to remote services, integrate maps, and even use Flare to create apps and games in Flutter. Gradually, you'll be able to create apps and games that are ready to be published on the Google Play Store and the App Store. In the concluding chapters, you'll learn how to use the BLoC pattern and various best practices related to creating enterprise apps with Flutter.

By the end of this book, you will have the skills you need to write and deliver fully functional mobile apps using Flutter.

What you will learn

  • Design reusable mobile architectures that can be applied to apps at any scale
  • Get up to speed with error handling and debugging for mobile application development
  • Apply the principle of 'composition over inheritance' to break down complex problems into many simple problems
  • Update your code and see the results immediately using Flutter's hot reload
  • Identify and prevent bugs from reappearing with Flutter's developer tools
  • Manage an app's state with Streams and the BLoC pattern
  • Build a simple web application using Flutter Web

Who this book is for

This book is for mobile developers and software developers who want to learn Flutter to build state-of-the-art mobile apps. Although prior experience with Dart programming or Flutter is not required, knowledge of object-oriented programming (OOP), data structures and software design patterns will be beneficial.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Flutter Projects
  3. Dedication
  4. About Packt
    1. Why subscribe?
  5. Contributors
    1. About the author
    2. About the reviewers
    3. Packt is searching for authors like you
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Conventions used
    4. Get in touch
      1. Reviews
  7. Hello Flutter!
    1. Technical requirements
    2. Understanding the Dart language basics
      1. Hello Dart
      2. Area calculator
      3. For loops and strings
      4. The Arrow syntax and the ternary operator
      5. While loops, lists, and generics
        1. foreach()
        2. map()
        3. where()
      6. Classes and objects
      7. Using getters and setters
      8. Constructors
        1. This keyword
    3. Creating your first Flutter app
      1. Running your first Hello World app
      2. Using MaterialApp and Scaffold
      3. Formatting Text and Using Columns
      4. Showing images and using buttons
      5. Showing an AlertDialog box
      6. Using padding
      7. Using SingleChildScrollView
    4. Summary
    5. Questions
    6. Further reading
  8. Miles or Kilometers? Using Stateful Widgets
    1. Technical requirements
    2. Project overview
    3. Understanding state and stateful widgets
    4. Creating the measure converter project
      1. Using stateful widgets
      2. Reading user input from TextField
      3. Creating a DropdownButton widget
      4. Updating a DropdownButton widget
      5. Completing the UI of the app
      6. Adding the business logic
    5. Summary
    6. Questions
    7. Further reading
  9. My Time - Listening to a Stream of Data
    1. Technical requirements
    2. Building the timer home page layout
      1. Installing the percent_indicator Package in your app
    3. Using a stream and asynchronous programming in Flutter
      1. Showing the time in the main screen: StreamBuilder
      2. Enabling the buttons
    4. Navigating to the settings route
    5. Building the Settings screen layout
      1. Using the GridView.Count() constructor
        1. Adding custom SettingButtons to the widgets.dart file
    6. Using shared_preferences to read and write app data
    7. Summary
    8. Questions
    9. Further reading
  10. Pong Game - 2D Animations and Gestures
    1. Technical requirements
    2. Building the UI of the app
      1. Creating the ball
      2. Creating the bat
      3. Creating the grid
    3. Using animations
    4. Adding the game logic
    5. Using GestureDetector
    6. Checking the bat position
    7. Adding randomness to the game
    8. Adding the score and completing the game
    9. Summary
    10. Questions
    11. Further reading
  11. Let's Go to the Movies - Getting Data from the Web
    1. Technical requirements
    2. Project overview
    3. Connecting to a web service and retrieving data with HTTP
      1. Creating the app and connecting to the API with the HTTP library
    4. Parsing JSON data and transforming it into model objects
      1. Adding the Movie model class
    5. Adding a ListView to show data
      1. Showing a trailing icon in a ListTile
    6. Showing the detail screen and passing data through screens
    7. Adding the search feature
    8. Summary
    9. Questions
    10. Further reading
  12. Store That Data - Using Sq(F)Lite To Store Data in a Local Database
    1. Technical requirements
    2. Essential theory and context
    3. Project overview
    4. Using sqflite databases
      1. Creating an sqflite database
      2. Testing the database
    5. Creating the model classes
    6. Showing database data to the user
      1. Inserting and editing data
      2. Deleting elements
      3. Challenge – completing the Items Screen functionality
      4. Challenge solution – completing the Items Screen functionality
        1. Step 1
        2. Step 2
        3. Step 3
        4. Step 4
        5. Step 5
        6. Step 6
    7. Summary
    8. Questions
    9. Further reading
  13. Firing Up the App - Integrating Firebase into a Flutter App
    1. Technical requirements
    2. Introducing Firebase
    3. Project overview
    4. Adding Firebase to your Flutter project
      1. Creating a Firestore database
      2. Integrating Firebase into a Flutter app
        1. Configuring your Android app
        2. Configuring your iOS app
        3. Testing Firebase integration with your app
      3. The EventDetail model class
      4. Creating the Event Detail screen
    5. Adding authentication to your app
      1. Adding the login/signup screen
      2. Adding the authentication logic
      3. Introducing Firebase rules
    6. Writing data to Firebase: Adding the favorite feature
      1. Showing and deleting favorites
    7. Summary
    8. Questions
    9. Further reading
  14. The Treasure Mapp - Integrating Maps and Using Your Device Camera
    1. Technical requirements
    2. Geolocation and camera – a powerful duo
    3. Integrating Google Maps into Flutter
      1. Showing a map with Google Maps
        1. Using geolocation to find the current position
        2. Adding a marker to the map
      2. Creating the place model and helper classes
      3. Inserting new places on the map
      4. Editing and deleting existing places
    4. Using the device camera
      1. Saving and retrieving pictures as local files
    5. Summary
    6. Questions
    7. Further reading
  15. Let's Play Dice: Knockout - Creating an Animation with Flare
    1. Technical requirements
    2. Project overview
    3. What's Flare?
    4. Creating objects with Flare
      1. Creating new objects in Flare
    5. Animating objects with Flare
      1. Creating the Roll animation
    6. Integrating Flare into a Flutter app
      1. Creating the Dice class
      2. Creating the Single Dice screen
      3. Creating the Knockout game
    7. Summary
    8. Questions
    9. Further reading
  16. ToDo App - Leveraging the BLoC Pattern and Sembast
    1. Technical requirements
    2. Project overview
    3. Using sembast to store data
      1. Sembast: dealing with data
        1. Opening a sembast database
        2. Creating CRUD methods with sembast
        3. Using sembast
    4. The BLoC pattern
      1. Using the BLoC pattern
        1. The BLoC guideline step by step
          1. 1. Creating the BLoC class
          2. 2. Declaring the data that will change
          3. 3. Setting the StreamControllers
          4. 4. Creating the getters for streams and sinks
          5. 5. Adding the logic of the BLoC
          6. 6. Creating the constructor
          7. 7. Setting the dispose() method
      2. Using BLoCs and Streams to update the UI
      3. The HomePage screen user interface
      4. The TodoScreen user interface
    5. Summary
    6. Questions
    7. Further reading
  17. Building a Flutter Web App
    1. Technical requirements
    2. Essential theory and context
    3. Project overview
    4. Building a Flutter app that runs on a browser
      1. Connecting to the Google Books API web service
      2. Creating the Book model class
      3. Using the HTTP service to retrieve books
    5. Creating a responsive UI
      1. Responsive widgets: ListView or Table?
        1. Creating the Table for larger devices
        2. Creating the ListView for smaller devices
    6. Using shared_preferences to save data in Android, iOS, and the web
      1. Completing the UI of the app
    7. Publishing a Flutter app to a web server
    8. Summary
    9. Questions
    10. Further reading
  18. Appendix
    1. Setting up your environment to build Flutter projects
      1. Installing Flutter on a Windows PC
        1. Installing Git
        2. Installing the Flutter Software Development Kit (SDK)
        3. Installing Android Studio
        4. Connecting an Android physical device
        5. Configuring Android Studio
        6. Installing and configuring VS Code
      2. Installing Flutter on a Mac
        1. Installing the Flutter SDK
        2. Installing Xcode
  19. Assessment
    1. Assessment
      1. Chapter 1
      2. Chapter 2
      3. Chapter 3
      4. Chapter 4
      5. Chapter 5
      6. Chapter 6
      7. Chapter 7
      8. Chapter 8
      9. Chapter 9
      10. Chapter 10
      11. Chapter 11
  20. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Flutter Projects
  • Author(s): Simone Alessandria
  • Release date: April 2020
  • Publisher(s): Packt Publishing
  • ISBN: 9781838647773