Fix a couple of strong mode issues. (#14070)
* JSON.decode produces Map<String, dynamic> and List<dynamic> objects. If a more tight type is required then object needs to be converted explicitly (see dart-lang/sdk#31876); * Completer<dynamic> produces Future<dynamic>. In Dart 2 it is runtime error to assign Future<dynamic> to variable of type Future<T>;
This commit is contained in:
parent
e11cf5c94c
commit
6e38b42919
@ -214,7 +214,11 @@ class AssetImage extends AssetBundleImageProvider {
|
|||||||
if (json == null)
|
if (json == null)
|
||||||
return null;
|
return null;
|
||||||
// TODO(ianh): JSON decoding really shouldn't be on the main thread.
|
// TODO(ianh): JSON decoding really shouldn't be on the main thread.
|
||||||
final Map<String, List<String>> parsedManifest = JSON.decode(json);
|
final Map<String, dynamic> parsedJson = JSON.decode(json);
|
||||||
|
final Iterable<String> keys = parsedJson.keys;
|
||||||
|
final Map<String, List<String>> parsedManifest =
|
||||||
|
new Map<String, List<String>>.fromIterables(keys,
|
||||||
|
keys.map((String key) => new List<String>.from(parsedJson[key])));
|
||||||
// TODO(ianh): convert that data structure to the right types.
|
// TODO(ianh): convert that data structure to the right types.
|
||||||
return new SynchronousFuture<Map<String, List<String>>>(parsedManifest);
|
return new SynchronousFuture<Map<String, List<String>>>(parsedManifest);
|
||||||
}
|
}
|
||||||
|
@ -179,10 +179,10 @@ abstract class CachingAssetBundle extends AssetBundle {
|
|||||||
assert(parser != null);
|
assert(parser != null);
|
||||||
if (_structuredDataCache.containsKey(key))
|
if (_structuredDataCache.containsKey(key))
|
||||||
return _structuredDataCache[key];
|
return _structuredDataCache[key];
|
||||||
Completer<dynamic> completer;
|
Completer<T> completer;
|
||||||
Future<dynamic> result;
|
Future<T> result;
|
||||||
loadString(key, cache: false).then<T>(parser).then<Null>((T value) {
|
loadString(key, cache: false).then<T>(parser).then<Null>((T value) {
|
||||||
result = new SynchronousFuture<dynamic>(value);
|
result = new SynchronousFuture<T>(value);
|
||||||
_structuredDataCache[key] = result;
|
_structuredDataCache[key] = result;
|
||||||
if (completer != null) {
|
if (completer != null) {
|
||||||
// We already returned from the loadStructuredData function, which means
|
// We already returned from the loadStructuredData function, which means
|
||||||
@ -198,7 +198,7 @@ abstract class CachingAssetBundle extends AssetBundle {
|
|||||||
}
|
}
|
||||||
// The code above hasn't yet run its "then" handler yet. Let's prepare a
|
// The code above hasn't yet run its "then" handler yet. Let's prepare a
|
||||||
// completer for it to use when it does run.
|
// completer for it to use when it does run.
|
||||||
completer = new Completer<dynamic>();
|
completer = new Completer<T>();
|
||||||
_structuredDataCache[key] = completer.future;
|
_structuredDataCache[key] = completer.future;
|
||||||
return completer.future;
|
return completer.future;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user