authenticateCustomer method

  1. @override
Future<bool> authenticateCustomer({
  1. required String email,
  2. required String password,
})
override

Authenticate customer with email and password.

Attempts to log in a customer using their email and password credentials. Upon successful authentication, the customer token is stored for subsequent requests.

email the customer's email address password the customer's password

Returns true if authentication was successful, false otherwise.

Implementation

@override
Future<bool> authenticateCustomer({
  required String email,
  required String password,
}) async {
  try {
    final result = await methodChannel.invokeMethod<bool>(
      'authenticateCustomer',
      {'email': email, 'password': password},
    );

    if (result == true) {
      // Get token after successful authentication
      _customerToken = await methodChannel.invokeMethod<String>(
        'getCustomerToken',
      );
    }

    return result ?? false;
  } catch (e) {
    _error = e.toString();
    return false;
  }
}