requestAllAccounts method

Future<List<String>> requestAllAccounts()

Asks the user for permission and retrieves all accounts that the user has authorized.

Implementation

Future<List<String>> requestAllAccounts() {
  return rawRequest('eth_requestAccounts').then((res) {
    var accounts = res as List<dynamic>; // Cast to a List
    if (accounts.isNotEmpty) {
      // Map the dynamic list to a strongly-typed List<String>
      return accounts.cast<String>();
    } else {
      throw StateError('No accounts returned from MetaMask.');
    }
  });
}