Adding the authentication logic

We'll place the authentication logic in a new class. This class will contain four methods:

  • A method to log in
  • A method to sign up
  • A method to log out
  • A method to retrieve the current user

Let's begin adding our login, as follows:

  1. Create a new folder in the lib folder of our app and call it shared. Inside the shared folder, let's also create a new file called authentication.dart.
  2. In this file, we'll import the firebase_auth package and async.dart.
  3. Next, we'll create a new class called Authentication, as follows:
import 'dart:async';import 'package:firebase_auth/firebase_auth.dart';class Authentication {}
  1. In the Authentication class, we'll declare an instance of FirebaseAuth, which is the object that enables ...

Get Flutter Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.