Farewell, local fork of the http package. (#8642)

This commit is contained in:
Ian Hickson
2017-03-07 18:08:36 -08:00
committed by GitHub
parent 90774c188a
commit 68fb3e4868
28 changed files with 48 additions and 1787 deletions

View File

@@ -10,7 +10,8 @@
import 'dart:convert';
import 'dart:math' as math;
import 'package:flutter/http.dart' as http;
import 'package:flutter/services.dart';
import 'package:http/http.dart' as http;
final math.Random _rng = new math.Random();
@@ -60,19 +61,22 @@ String _urlToFetch(int chunk) {
}
class StockDataFetcher {
int _nextChunk = 0;
StockDataFetcher(this.callback) {
_httpClient = createHttpClient();
_fetchNextChunk();
}
final StockDataCallback callback;
http.Client _httpClient;
static bool actuallyFetchData = true;
StockDataFetcher(this.callback) {
_fetchNextChunk();
}
int _nextChunk = 0;
void _fetchNextChunk() {
if (!actuallyFetchData)
return;
http.get(_urlToFetch(_nextChunk++)).then<Null>((http.Response response) {
_httpClient.get(_urlToFetch(_nextChunk++)).then<Null>((http.Response response) {
final String json = response.body;
if (json == null) {
print("Failed to load stock data chunk ${_nextChunk - 1}");

View File

@@ -3,6 +3,7 @@ dependencies:
flutter:
sdk: flutter
intl: '>=0.14.0 <0.15.0'
http: '>=0.11.3+11'
dev_dependencies:
flutter_test: