Remove redundant fetch functions and avoid crashing when no headers are set

This commit is contained in:
Collin Jackson
2015-11-16 18:30:29 -08:00
parent 3350c0c3e4
commit b07d55d1b3
5 changed files with 9 additions and 31 deletions

View File

@@ -10,7 +10,7 @@
import 'dart:convert';
import 'dart:math' as math;
import 'package:flutter/services.dart';
import 'package:flutter/http.dart' as http;
final math.Random _rng = new math.Random();
@@ -83,8 +83,8 @@ class StockDataFetcher {
if (!actuallyFetchData)
return;
fetchBody(_urlToFetch(_nextChunk++)).then((Response response) {
String json = response.bodyAsString();
http.get(_urlToFetch(_nextChunk++)).then((http.Response response) {
String json = response.body;
if (json == null) {
print("Failed to load stock data chunk ${_nextChunk - 1}");
return;