Flutter for Beginners - Third Edition

Book description

Follow this step-by-step illustrated guide to launch your own Flutter apps and gain hands-on experience

Key Features

  • Get up to speed with the basics of Dart programming and delve into Flutter development
  • Learn about Flutter widgets, plugins, and animations to create a high-quality, user-friendly app
  • Package and deploy your Flutter apps to achieve native-like performance
  • Purchase of the print or Kindle book includes a free PDF eBook

Book Description

There have been many attempts at creating frameworks that are truly cross-platform, but most struggle to create a native-like experience at high-performance levels. Flutter achieves this with an elegant design and a wealth of third-party plugins, solidifying its status as the future of mobile app development. If you are a mobile developer who wants to create rich and expressive native apps with the latest Google Flutter framework, this book is for you.

You’ll start with the basics of cross-platform development frameworks, specifically Flutter. You’ll then explore the Dart programming language which is the foundation of the Flutter framework. Next, you’ll get a feel for Flutter and how to create your first app, followed by an exploration of the various popular plugins that supplement the Flutter framework. Finally, you’ll explore testing and app release, including some common glitches that you may experience.

By the end of this book, you’ll be well-equipped to create and release a basic Flutter app along with gaining a solid understanding of the Flutter framework and Dart language.

What you will learn

  • Understand the Flutter framework and cross-platform development
  • Acclimate the fundamentals of the Dart programming language
  • Explore Flutter widgets, the core widget library, and stateful and stateless widgets
  • Discover the complete development lifecycle, including testing and debugging
  • Get familiar with both the mobile and web app release processes
  • Dig deeper into more advanced Flutter concepts like animation
  • Explore common Flutter plugins ad how to use them
  • Discover the Flutter community and how to stay up-to-date

Who this book is for

If you are an existing mobile developer seeking a better way to develop cross-platform apps, an existing software developer looking to explore mobile app development, or someone investigating mobile apps and simply wants to know what the Flutter fuss is about, this is the book for you. Prior knowledge of Flutter and Dart is not required.

Table of contents

  1. Flutter for Beginners
  2. Foreword
  3. Contributors
  4. About the authors
  5. About the reviewers
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Conventions used
    6. Get in touch
    7. Share your thoughts
    8. Download a free PDF copy of this book
  7. Part 1:Learning the Core Concepts
  8. Chapter 1: What Is Flutter and Why Should I Use It?
    1. Technical requirements
    2. What is Flutter?
      1. Backed by Google
      2. Fuchsia OS and Flutter
      3. Dart
      4. One code base to rule them all
      5. Open source framework
    3. Hello Flutter – a first glimpse of Flutter
      1. Installing Flutter
      2. Development environment
      3. Hello world!
    4. Widgets, widgets, everywhere
      1. Flutter rendering
      2. Flutter – rendering by itself
      3. Composability
      4. Immutability
      5. Everything is a widget
    5. Building and running Flutter
      1. Debug mode
      2. Release mode
      3. Profile mode
      4. Supported platforms
      5. The pubspec.yaml file
      6. Running the generated project
    6. Summary
    7. Questions
    8. Further reading
  9. Chapter 2: An Introduction to Dart
    1. Technical requirements
    2. Getting started with Dart
      1. The evolution of Dart
      2. How to run Dart
      3. Introducing the structure of the Dart language
      4. Hands-on with Dart
    3. Variables and data types
      1. Variable declaration
      2. Null safety
      3. Built-in types
      4. final and const
      5. dynamic and using ‘as’
      6. Dart operators
    4. Control flows and looping
      1. if/else
      2. while and do-while loops
      3. for loops
      4. break and continue
      5. switch
      6. Hands-on, continued
    5. Functions and methods
      1. Function parameters
    6. Summary
    7. Questions
    8. Further reading
  10. Chapter 3: Flutter versus Other Frameworks
    1. Native development
      1. Developer skillset
      2. Project management
      3. Defect reports
      4. Performance
      5. Platform features
      6. Hot reload
      7. User experience
      8. App size
      9. New platforms
      10. Retired platforms
      11. Development resources
      12. Overview
    2. Cross-platform frameworks
      1. React Native
      2. Xamarin
      3. Cordova
      4. Framework popularity
    3. The Flutter community
      1. Events
      2. News and discussion
      3. Resources
    4. Flutter strengths and weaknesses
      1. Strengths
      2. Weaknesses
    5. Live Flutter apps
    6. Summary
    7. Questions
    8. Further reading
  11. Chapter 4: Dart Classes and Constructs
    1. Object orientation in Dart
      1. Objects and classes
      2. Other OOP artifacts
      3. Encapsulation
      4. Inheritance and composition
      5. Abstraction
      6. Polymorphism
      7. Functions as objects
    2. Understanding classes in Dart
      1. Class structure
      2. Constructors
      3. Class inheritance
      4. Abstract classes
      5. Interfaces
      6. Mixins
      7. Files and imports
    3. The enum type
    4. Using generics
      1. When and why to use generics
    5. Asynchronous programming
      1. Dart Futures
      2. Dart Isolates
    6. Summary
    7. Questions
    8. Further reading
  12. Part 2:Building a Basic Flutter App
  13. Chapter 5: Building Your User Interface through Widgets
    1. Technical requirements
    2. Stateful/stateless widgets
      1. Stateless widgets
      2. Stateful widgets
      3. Inherited widgets
      4. The widget key property
    3. Built-in widgets
      1. Display widgets
      2. User interaction widgets
      3. Layouts
      4. Advanced widgets (gestures, animations, and transformations)
    4. Summary
    5. Questions
    6. Further reading
  14. Chapter 6: Handling User Input and Gestures
    1. Technical requirements
    2. Handling user gestures
      1. Pointers
      2. Gestures
      3. GestureDetector
      4. Gestures in Material widgets
    3. A deeper look at the stateful widget life cycle
      1. Key life cycle states
      2. Mounted
    4. Input widgets and forms
      1. Getting input through the onChanged callback
      2. Getting input through a controller
      3. Form and FormField
      4. Accessing FormField’s state
      5. Form
    5. Custom input and FormField
      1. Creating custom inputs
      2. Custom input widget example
    6. Summary
    7. Questions
    8. Further reading
  15. Chapter 7: Let’s Get Graphical!
    1. Technical requirements
    2. Make me pretty
      1. Using colors
      2. Text style
      3. Container decoration
      4. Buttons
    3. The Scaffold widget
      1. Drawer
      2. Snackbar
      3. And there’s much more…
    4. Creating elegant content lists
    5. Understanding image types in Flutter
      1. Out-of-the-box support
      2. SVG
      3. Lottie files
    6. Slivers
      1. Lists with navigation
      2. SliverAppBar
    7. Summary
    8. Questions
    9. Further reading
  16. Chapter 8: Routing – Navigating between Screens
    1. Technical requirements
    2. Understanding the Navigator widget
      1. Navigator 1.0 and 2.0
      2. Navigator
      3. Navigator 1.0
      4. Navigator 2.0
    3. Screen transitions
      1. PageRouteBuilder
      2. Custom transitions in practice
    4. Passing data between screens
      1. Passing state in widget parameters
      2. InheritedWidget
      3. BLoC
      4. Redux
      5. Other options
    5. Summary
    6. Questions
    7. Further reading
  17. Part 3:Turning a Simple App into an Awesome App
  18. Chapter 9: Flutter Plugins – Get Great Functionality for Free!
    1. Technical requirements
    2. What is a plugin?
      1. Benefits
      2. Drawbacks
    3. Where can I find plugins?
    4. How do I add a plugin to my project?
      1. The pubspec.yaml file
      2. flutter pub
      3. Using a plugin in your code
    5. How do plugins work on iOS and Android?
      1. MethodChannel
      2. CocoaPods
      3. Gradle
    6. Common issues
      1. Plugin breaking change
      2. Plugin not working
      3. PR not merged
      4. Inconsistent dependencies
      5. MissingPluginException
    7. Summary
    8. Questions
    9. Further reading
  19. Chapter 10: Popular Third-Party Plugins
    1. Technical requirements
    2. Exploring Firebase plugins
      1. Firebase registration
      2. Connecting the Flutter app to Firebase
      3. FlutterFire plugins
      4. Firebase initialization
      5. Authentication
      6. Realtime Database
      7. Firestore
      8. Analytics and Crashlytics
      9. Cloud Storage
      10. AdMob
      11. Cloud Functions
      12. ML with Google ML Kit
      13. Messaging
    3. Understanding Google Maps and Places
    4. Exploring mobile device features
      1. Camera and QR codes
      2. Opening web pages
      3. Local storage
      4. Video
      5. Payment providers
      6. In-app purchases
      7. Opening files
    5. Plugins to help with your app support
      1. App version
      2. Device information
    6. Summary
    7. Questions
    8. Further reading
  20. Chapter 11: Using Widget Manipulations and Animations
    1. Technical requirements
    2. Transforming widgets with the Transform class
      1. The Transform widget
      2. Understanding the Matrix4 class
      3. Exploring the types of transformations
    3. Introducing animations
      1. The Animation<T> class
      2. AnimationController
      3. CurvedAnimation
      4. Tween
    4. Using animations
      1. Rotate animation
      2. Scale animation
      3. Translate animation
    5. Using AnimatedBuilder
      1. The AnimatedBuilder class
      2. Revisiting our animation
    6. Implicitly animated widgets
      1. AnimatedContainer
      2. AnimatedFoo
    7. Summary
    8. Questions
    9. Further reading
  21. Part 4:Testing and Releasing Your App
  22. Chapter 12: Testing and Debugging
    1. Technical requirements
    2. Unit testing
      1. The Dart test package
      2. Writing unit tests
      3. Unit test mocking
    3. Widget testing
      1. The WidgetTester class
      2. Widget test example
      3. Running a widget test
    4. Debugging your app
      1. Debugging in the IDE
      2. Additional debugging features
    5. DevTools
      1. The widget inspector
      2. Profile mode
    6. Summary
    7. Questions
    8. Further reading
  23. Chapter 13: Releasing Your App to the World
    1. Technical requirements
    2. Preparing your app for deployment
      1. Preparing the stores
      2. Preparing for the web
    3. Releasing your app on Android
      1. AndroidManifest and build.gradle
      2. Building and uploading your appbundle
    4. Releasing your app on iOS
      1. App Store Connect
      2. Xcode
      3. Building and uploading
    5. Releasing your app on the web
      1. Firebase hosting
      2. PWA support
    6. Tracking app usage and crashes
      1. Crashlytics
      2. Google Analytics
    7. Summary
    8. Questions
    9. Further reading
  24. Index
    1. Why subscribe?
  25. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share your thoughts
    3. Download a free PDF copy of this book

Product information

  • Title: Flutter for Beginners - Third Edition
  • Author(s): Thomas Bailey, Alessandro Biessek
  • Release date: October 2023
  • Publisher(s): Packt Publishing
  • ISBN: 9781837630387