getArticleContent method Null safety

Future<String> getArticleContent(
  1. String url
)

getArticleContent gets the actual articles content unless status code is not 200

Implementation

Future<String> getArticleContent(String url) async {
  var response = await http.get(Uri.parse(url));
  var code = response.statusCode;
  if (code != 200) {
    return "";
  }
  var doc = parse(response.body);
  var p = doc.getElementsByTagName("p");
  var description = "";
  for (var para in p) {
    description += para.text;
  }

  return description;
}