Update code according to linter rules

This commit is contained in:
Oystein Kristoffer Tveit 2020-06-26 17:45:56 +02:00
parent 3f7576e1a9
commit f5a9b602bf
2 changed files with 8 additions and 13 deletions

View File

@ -42,17 +42,12 @@ Future<ExampleResults> searchForExamples(String phrase) async {
/// instead of (no results).
Future<PhrasePageScrapeResult> scrapeForPhrase(String phrase) async {
final uri = uriForPhraseScrape(phrase);
try {
final response = await http.get(uri);
return parsePhrasePageData(response.body, phrase);
} catch (err) {
// if (response.statusCode == 404) {
// return PhrasePageScrapeResult(
// query: phrase,
// found: false,
// );
// }
rethrow;
final response = await http.get(uri);
if (response.statusCode == 404) {
return PhrasePageScrapeResult(
query: phrase,
found: false,
);
}
return parsePhrasePageData(response.body, phrase);
}

View File

@ -113,7 +113,7 @@ ExampleResults parseExamplePageData(String pageHtml, String phrase) {
final document = parse(pageHtml);
final divs = document.querySelectorAll('.sentence_content');
final results = divs.map((div) => _parseExampleDiv(div)).toList();
final results = divs.map(_parseExampleDiv).toList();
return ExampleResults(
query: phrase,