requestAccount method

Asks the user to select an account and give your application access to it.

Implementation

Future<CredentialsWithKnownAddress> requestAccount() {
  return rawRequest('eth_requestAccounts').then((res) {
    var accounts = res as List<dynamic>; // Cast to a List
    if (accounts.isNotEmpty) {
      return MetaMaskCredentials(
          accounts.first as String, this); // Use the first account
    } else {
      throw StateError('No accounts returned from MetaMask.');
    }
  });
}