0%

Book Description

A step-by-step guide to learning Flutter and Dart 2 for creating Android and iOS mobile applications

Key Features

  • Get up to speed with the basics of Dart programming and delve into Flutter development
  • Understand native SDK and third-party libraries for building Android and iOS applications using Flutter
  • Package and deploy your Flutter apps to achieve native-like performance

Book Description

Google Flutter is a cross-platform mobile platform that makes it easier to write secure and high-performance native apps for iOS and Android.

This book begins by introducing you to the Flutter framework and basics of Dart. You'll learn to set up the development environment to get started with your Flutter project. The book will guide you through designing the user interface and user input functions for your app. As you progress, you'll explore the navigator widget to manage your app routes and understand how to add transitions between screens. You'll then get to grips with developing your own plugin and discover how to structure good plugin code. The book will help you display a map from the Flutter app, add markers and interactions to it, and use the Google Places API. You'll build on your knowledge by not only adding tests to create a bug-free app, but also preparing it for deployment on Apple's App Store and Google Play. In later chapters, you'll learn to improve the user experience with advanced features such as map integrations, platform-specific code with native programming languages, and personalized animation options for designing intuitive UIs.

By the end of this book, you'll be well-versed with Dart programming and have the skills to develop your own mobile apps or build a career as a Dart and Flutter app developer.

What you will learn

  • Understand the fundamentals of the Dart programming language
  • Explore the core concepts of the Flutter UI and how it compiles for multiple platforms
  • Develop Flutter plugins and widgets and understand how to structure good plugin code
  • Style your apps with widgets and learn the difference between stateful and stateless widgets
  • Add animation to your UI using Flutter's AnimatedBuilder component
  • Integrate your native code into your Flutter codebase for native app performance

Who this book is for

This book is for developers looking to learn Google's revolutionary framework, Flutter from scratch. No knowledge of Flutter or Dart is required. However, basic programming language knowledge will be helpful.

Downloading the example code for this ebook: You can download the example code files for this ebook on GitHub at the following link: https://github.com/PacktPublishing/Flutter-for-Beginners. If you require support please email: [email protected]

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Flutter for Beginners
  3. Dedication
  4. About Packt
    1. Why subscribe?
    2. Packt.com
  5. Contributors
    1. About the author
    2. About the reviewer
    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. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  7. Section 1: Introduction to Dart
  8. An Introduction to Dart
    1. Getting started with Dart
      1. The evolution of Dart
      2. How Dart works
        1. Dart VM and JavaScript compilation
      3. Hands-on Dart
        1. DartPad
        2. Dart development tools
        3. Hello world
    2. Understanding why Flutter uses Dart
      1. Adding productivity
        1. Compiling Flutter apps and hot reload
      2. Easy learning
      3. Maturity
    3. Introducing the structure of the Dart language
      1. Dart operators
        1. Arithmetic operators
        2. Increment and decrement operators
        3. Equality and relational operators
        4. Type checking and casting
        5. Logical operators
        6. Bits manipulation
        7. Null-safe and null-aware operators
      2. Dart types and variables
        1. final and const
        2. Built-in types
          1. Numbers
          2. BigInt
          3. Booleans
          4. Collections
          5. Strings
          6. String interpolation
          7. Literals
        3. Type inference – bringing dynamism to the show 
      3. Control flows and looping
      4. Functions
        1. Function parameters
      5. Data structures, collections, and generics
        1. Generics
          1. When and why to use generics
          2. Generics and Dart literals
    4. Introduction to OOP in Dart
      1. Dart OOP features
        1. Objects and classes
        2. Encapsulation
        3. Inheritance and composition
        4. Abstraction
        5. Polymorphism
    5. Summary
    6. Further reading
  9. Intermediate Dart Programming
    1. Dart classes and constructors
      1. The enum type
      2. The cascade notation
      3. Constructors
        1. Named constructors
        2. Factory constructors
      4. Field accessors – getters and setters
      5. Static fields and methods
      6. Class inheritance
        1. The toString() method
    2. Interfaces, abstract classes, and mixins
      1. Abstract classes
      2. Interfaces
      3. Mixins – adding behavior to a class
      4. Callable classes, top-level functions, and variables
        1. Callable classes
        2. Top-level functions and variables
    3. Understanding Dart libraries and packages
      1. Importing and using a library
        1. Importing show and hide
        2. Importing prefixes to libraries
        3. Importing path variants
      2. Creating Dart libraries
        1. Library member privacy
        2. The library definition
          1. A single-file library
          2. Splitting libraries into multiple files
          3. A multiple-file library – the export statement
      3. Dart packages
        1. Application packages versus library packages
      4. Package structures
      5. Stagehand – the Dart project generator
      6. The pubspec file
      7. Package dependencies – pub
        1. Specifying dependencies
          1. The version constraint
          2. The source constraint
    4. Introducing async programming with Futures and Isolates
      1. Dart Futures
      2. Dart Isolates
    5. Introducing unit testing with Dart
      1. The Dart test package
      2. Writing unit tests
    6. Summary
  10. An Introduction to Flutter
    1. Comparisons with other mobile app development frameworks
      1. The problems Flutter wants to solve
      2. Differences between existing frameworks
        1. High performance
        2. Full control of the UI
        3. Dart
        4. Being backed by Google
          1. Fuchsia OS and Flutter
        5. Open source framework
        6. Developer resources and tooling
    2. Flutter compilation (Dart)
      1. Development compilation
      2. Release compilation
      3. Supported platforms
    3. Flutter rendering
      1. Web-based technologies
      2. Framework and OEM widgets
      3. Flutter – rendering by itself
    4. Widgets introduction
      1. Composability
      2. Immutability
      3. Everything is a widget
        1. The widget tree
    5. Hello Flutter
      1. pubspec file 
      2. Running the generated project
        1. lib/main.dart file
        2. Flutter run
    6. Summary
  11. Section 2: The Flutter User Interface - Everything is a Widget
  12. Widgets: Building Layouts in Flutter
    1. Stateful versus stateless widgets
      1. Stateless widgets
      2. Stateful widgets
      3. Stateful and stateless widgets in code
        1. Stateless widget in code
        2. Stateful widgets in code
      4. Inherited widgets
      5. Widget key property
    2. Built-in widgets
      1. Basic widgets
        1. The Text widget
        2. The Image widget
        3. Material Design and iOS Cupertino widgets
          1. Buttons
          2. Scaffold
          3. Dialogs
          4. Text fields
          5. Selection widgets
          6. Date and time pickers
          7. Other components
    3. Understanding built-in layout widgets
      1. Containers
      2. Styling and positioning
      3. Other widgets (gestures, animations, and transformations)
    4. Creating a UI with widgets (favor manager app)
      1. The app screens
        1. The app code
        2. Favors app home screen
          1. The layout code
        3. The request favor screen
          1. The layout code
    5. Creating custom widgets
    6. Summary
  13. Handling User Input and Gestures
    1. Handling user gestures
      1. Pointers
      2. Gestures
        1. Tap
        2. Double tap
        3. Press and hold
        4. Drag, pan, and scale
          1. Horizontal drag
          2. Vertical drag
          3. Pan
          4. Scale
      3. Gestures in material widgets
    2. Input widgets
      1. FormField and TextField
        1. Using a controller
        2. Accessing FormField state
      2. Form
        1. Accessing Form state
          1. Using a key
          2. Using InheritedWidget
    3. Validating Input (Forms)
      1. Validating user input
    4. Custom input and FormField
      1. Creating custom inputs
      2. Custom input widget example
        1. Creating an Input widget
        2. Turn the widget into a FormField widget
    5. Putting it all together
      1. Favors screen
        1. Tap gestures on the favor tab
        2. Tap gestures on FavorCards
          1. Making FavorsPage a StatefulWidget
          2. Refuse action handling
          3. Do action handling
        3. Tap on Request a favor button
      2. The Requesting a favor screen
        1. The close button
        2. The SAVE button
          1. Validating input using the Form widget
    6. Summary
  14. Theming and Styling
    1. Theme widgets
      1. Theme widget 
        1. ThemeData
          1. Brightness
      2. Theming in practice
      3. Platform class
    2. Material Design
      1. MaterialApp widget
      2. Scaffold widget
      3. Custom theme
    3. iOS Cupertino
      1. CupertinoApp
      2. Cupertino in practice
    4. Using custom fonts
      1. Importing fonts to the Flutter project
      2. Overriding the default font in the app
    5. Dynamic styling with MediaQuery and LayoutBuilder
      1. LayoutBuilder
      2. MediaQuery
        1. MediaQuery example
      3. Additional responsive classes
    6. Summary
  15. Routing: Navigating between Screens
    1. Understanding the Navigator widget
      1. Navigator 
      2. Overlay
        1. Navigation stack/history
      3. Route 
        1. RouteSettings
      4. MaterialPageRoute and CupertinoPageRoute
      5. Putting it all together
      6. The WidgetsApp way
    2. Named routes
      1. Moving to named routes
        1. Arguments
      2. Retrieving results from Route
    3. Screen transitions
      1. PageRouteBuilder 
        1. Custom transitions in practice
    4. Hero animations
      1. The Hero widget
      2. Implementing Hero transitions
    5. Summary
  16. Section 3: Developing Fully Featured Apps
  17. Firebase Plugins
    1. Firebase overview
      1. Setting up Firebase
      2. Connecting the Flutter app to Firebase
        1. Configuring an Android app
        2. Configuring iOS app
        3. FlutterFire
          1. Adding the FlutterFire dependency to the Flutter project
    2. Firebase authentication 
      1. Enabling Authentication services in Firebase
      2. Authentication screen
      3. Logging in with Firebase
        1. Sending verification code
        2. Verifying the SMS code
        3. Updating the profile and login status
    3. NoSQL database with Cloud Firestore
      1. Enabling Cloud Firestore on Firebase
      2. Cloud Firestore and Flutter
      3. Loading favors from Firestore
      4. Updating favors on Firebase
      5. Saving a favor on Firebase
    4. Cloud Storage with Firebase Storage
      1. Introduction to Firebase Storage
      2. Adding Flutter Storage dependencies
      3. Uploading files to Firebase
    5. Ads with Firebase AdMob
      1. AdMob account
      2. Creating an AdMob account
      3. AdMob in Flutter
        1. Side note on Android
        2. Side note on iOS
      4. Showing ads in Flutter
    6. ML with Firebase ML Kit
      1. Adding ML Kit to Flutter
      2. Using the label detector in Flutter
    7. Summary
  18. Developing Your Own Flutter Plugin
    1. Creating a package/plugin project
      1. Flutter packages versus Dart packages
      2. Starting a Dart package project
      3. Starting a Flutter plugin package
    2. A plugin project structure
      1. MethodChannel
      2. Implementing the Android plugin
      3. Implementing the iOS plugin
      4. The Dart API
      5. An example of plugin package
      6. Using the plugin  
    3. Adding documentation to the package
      1. Documentation files
      2. Library documentation
      3. Generating documentation
    4. Publishing a package
    5. Plugin project development recommendations
    6. Summary
  19. Accessing Device Features from the Flutter App
    1. Launching a URL from the app
      1. Displaying a link
        1. The flutter_linkify plugin
      2. Launching a URL
        1. The url_launcher plugin
    2. Managing app permissions
      1. Managing permissions on Flutter
        1. Using the permission_handler plugin
    3. Importing a contact from the phone
      1. Importing a contact with contact_picker 
      2. Contact permission with permission_handler
        1. Contact permission on Android
        2. Contact permission on iOS
        3. Checking and requesting permission in Flutter (permission_handler)
    4. Integrating the phone's camera
      1. Taking pictures with image_picker
      2. Camera permission with permission_handler
        1. Camera permission on Android
        2. Camera permission on iOS
        3. Requesting camera permission in Flutter (permission_handler)
    5. Summary
  20. Platform Views and Map Integration
    1. Displaying a map
      1. Platform views
        1. Enabling platform views on iOS
      2. Creating a platform view widget
        1. Creating an Android view
        2. Creating an iOS view
        3. Usage of a platform view widget
      3. Getting started with the google_maps_flutter plugin
      4. Displaying a map with the google_maps_flutter plugin
        1. Enabling the Maps API on Google Cloud Console
        2. Google Maps API integration on Android
        3. Google Maps API integration on iOS
        4. Displaying a map on Flutter
    2. Adding markers to the map
      1. The Marker class
      2. Adding markers in the GoogleMap widget
    3. Adding map interactions
      1. Adding markers dynamically
      2. GoogleMapController
      3. Getting GoogleMapController
      4. Animating a map camera to a location
    4. Using the Google Places API
      1. Enabling the Google Places API
      2. Getting started with the google_maps_webservice plugin
      3. Getting a place address using the google_maps_webservice plugin
    5. Summary
  21. Section 4: Advanced Flutter - Resources to Complex Apps
  22. Testing, Debugging, and Deployment
    1. Flutter testing – unit and widget testing
      1. Widget tests
        1. The flutter_test package
          1. The testWidgets function
        2. Widget test example
    2. Debugging Flutter apps
      1. Observatory
      2. Additional debugging features
      3. DevTools
    3. Profiling Flutter apps
      1. The Observatory profiler
      2. Profile mode
        1. Performance overlay
    4. Inspecting the Flutter widget tree
      1. Widget inspector
        1. The Flutter inspector in DevTools
    5. Preparing apps for deployment
      1. Release mode
      2. Releasing apps for Android
        1. AndroidManifest and build.gradle
          1. AndroidManifest – permissions
          2. AndroidManifest – meta tags
          3. AndroidManifest – application name and icon 
          4. build.gradle – application ID and versions
          5. build.gradle – signing the app
      3. Releasing apps for iOS
        1. App Store Connect
        2. Xcode 
          1. Xcode – application details and Bundle ID
          2. Xcode – AdMob
          3. Xcode – signing the app
    6. Summary
  23. Improving User Experience
    1. Accessibility in Flutter and adding translations to apps
      1. Flutter's support for accessibility
      2. Flutter internationalization
        1. The intl package
        2. The intl_translation package
        3. The flutter_localizations package
      3. Adding localizations to a Flutter app
        1. Dependencies
        2. The AppLocalization class
        3. Generating .arb files with intl_translation
        4. Using translated resources
    2. Communication between native and Flutter with platform channels
      1. Platform channel
      2. Message codecs
    3. Creating background processes
      1. The Flutter compute() function
        1. SendPort and ReceivePort
          1. IsolateNameServer
      2. A compute() example
      3. Full background process
      4. Init the calculation
        1. The background isolate
    4. Adding Android-specific code to run Dart code in the background
      1. The HandsOnBackgroundProcessPlugin class
      2. The BackgroundProcessService class
        1. The PluginRegistrantCallback property
    5. Adding iOS-specific code to run Dart code in the background
      1. The SwiftHandsOnBackgroundProcessPlugin class
    6. Summary
  24. Widget Graphic Manipulations
    1. Transforming widgets with the Transform class
      1. The Transform widget
        1. Understanding the Matrix4 class
    2. Exploring the types of transformations
      1. Rotate transformation
      2. Scale transformation
      3. Translate transformation
      4. Composed transformations
    3. Applying transformations to your widgets
      1. Rotating widgets
      2. Scaling widgets
      3. Translating widgets
      4. Applying multiple transformations 
    4. Using custom painters and canvas
      1. The Canvas class
        1. Canvas transformations
        2. Canvas ClipRect
        3. Methods
        4. The Paint object
      2. The CustomPaint widget
        1. CustomPaint construction details
      3. The CustomPainter object
        1. The paint method
        2. The shouldRepaint method
      4. A practical example
        1. Defining a widget
        2. Defining CustomPainter
          1. Overriding the shouldRepaint method
          2. Overriding the paint method
      5. The radial chart variant
        1. Defining a widget
        2. Defining CustomPainter
    5. Summary
  25. Animations
    1. Introducing Animations
      1. The Animation<T> class
        1. AnimationController
          1. TickerProvider and Ticker
        2. CurvedAnimation
        3. Tween
    2. Using animations
      1. Rotate animation
      2. Scale animation
      3. Translate animation
      4. Multiple transformations and custom Tween
        1. Custom Tween
    3. Using AnimatedBuilder
      1. The AnimatedBuilder class
      2. Revisiting our animation 
    4. Using AnimatedWidget
      1. The AnimatedWidget class
      2. Rewriting the animation with AnimatedWidget 
    5. Summary
  26. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think
3.145.108.9