import 'dart:async'; import 'package:http/http.dart' as http; class NetUtils { static Future get(String url, {Map? params}) async { if (params != null && params.isNotEmpty) { StringBuffer sb = StringBuffer("?"); params.forEach((key, value) { sb.write("$key" + "=" + "$value" + "&"); }); String paramStr = sb.toString(); paramStr = paramStr.substring(0, paramStr.length - 1); url += paramStr; } http.Response res = await http.get(Uri.parse(url)); return res.body; } static Future post(String url, {Map? params}) async { http.Response res = await http.post(Uri.parse(url), body: params); return res.body; } }