import 'dart:async'; import 'package:flutter/material.dart'; enum Status { NotLoggedIn, NotRegistered, LoggedIn, Registered, Authenticating, Registering, LoggedOut } class AuthProvider with ChangeNotifier { Status _loggedInStatus = Status.NotLoggedIn; Status _registeredInStatus = Status.NotRegistered; Status get loggedInStatus => _loggedInStatus; Status get registeredInStatus => _registeredInStatus; Future login(String email, int pinCode) async { var result; final Map loginData = { 'user': {'email': email, 'pinCode': pinCode} }; _loggedInStatus = Status.Authenticating; notifyListeners(); Timer(Duration(seconds: 30), () { _loggedInStatus = Status.LoggedIn; notifyListeners(); result = {'status': true, 'message': 'Successful'}; return result; }); } Future> register( String email, String password, String passwordConfirmation) async { final Map registrationData = { 'user': { 'email': email, 'password': password, 'password_confirmation': passwordConfirmation } }; return {'status': true, 'message': 'Successfully registered'}; } }