I am getting error while connecting with ethereum node.
- this line ==> print(client.getBlockNumber()); returns error
E/flutter (22015): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: SocketException: Failed host lookup: 'localhost:8545' (OS Error: No address associated with hostname, errno = 7)
import 'package:flutter/material.dart';
import 'package:http/http.dart';
import 'package:web3dart/web3dart.dart';
import 'dart:async';
const String url =
'https://mainnet.infura.io'; // i am also running geth on local http://localhost:8545
class HomeScreen extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _HomeScreenState();
}
}
class _HomeScreenState extends State<HomeScreen> {
@override
void initState() {
main();
super.initState();
}
main() {
final httpClient =new Client();
final client =new Web3Client(url, httpClient);
print(client.getBlockNumber());
}
}