i want to convert this java code for android app to flutter (dart) to connect localhost
public class HttpHandler {
private static final String TAG = HttpHandler.class.getSimpleName();
public HttpHandler(){
}
public String makeServiceCall(String keyword,String para,String data) {
Log.d("enter url","enter in httpclass");
String reqUrl1="http://192.168.1.16:8082/gotrade_merchant/callservice?keyword="+keyword+ "¶=" +para+ "&data=" +data+"";
// String reqUrl1 = "http://192.168.1.10//gotrademob/gosellsy/goTrade/fetch?keyword="+keyword+ "¶=" +para+ "&data=" +data+"";
// String reqUrl1 = "http://192.168.1.18:8080//gotrademob/gosellsy/goTrade/fetch?keyword="+keyword+ "¶=" +para+ "&data=" +data+"";
String reqUrl = reqUrl1.replace(" ", "%20").replace("#", "");
Log.d("reqUrl>>",""+reqUrl);
String response="null";
try{
URL url=new URL(reqUrl);
HttpURLConnection conn=(HttpURLConnection)url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
conn.setRequestProperty("Content-Language", "en-US");
conn.setUseCaches (false);
conn.setDoInput(true);
conn.setDoOutput(true);
// DataOutputStream wr = new DataOutputStream (conn.getOutputStream ());
// wr.writeBytes (reqUrl1);
// wr.flush ();
// wr.close ();
InputStream in= new BufferedInputStream(conn.getInputStream());
Log.d("in",""+in);
response = convertStreamToString(in);
}
catch (MalformedURLException e) {
Log.e(TAG, "MalformedURLException: " + e.getMessage());
} catch (ProtocolException e) {
Log.e(TAG, "ProtocolException: " + e.getMessage());
} catch (IOException e) {
Log.e(TAG, "IOException: " + e.getMessage());
}
catch (Exception e){
Log.e(TAG, "Exception: " + e.getMessage());
}
Log.d("response>>>",""+response);
return response;
}
private String convertStreamToString(InputStream is){
BufferedReader reader= new BufferedReader(new InputStreamReader(is));
StringBuilder sb=new StringBuilder();
String line;
try{
while((line= reader.readLine())!=null){
sb.append(line).append('\n');
}
} catch (IOException e) {
e.printStackTrace();
}
finally {
try{
is.close();
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return sb.toString();
}
}