isConnected method
Returns true
if the provider is connected to the current chain, and false
otherwise.
Note that this method has nothing to do with the user's accounts.
You may often encounter the word connected
in reference to whether a web3 site can access the user's accounts. In the provider interface, however, connected
and disconnected
refer to whether the provider can make RPC requests to the current chain.
// To check if provider is connected to current chain
ethereum!.isConnected() // true
// To check if provider is connected to current chain and connected to user accounts i.e. ready to use
ethereum!.isConnected() && (await getAccounts()).isNotEmpty; // true
Implementation
bool isConnected() => impl.isConnected();