Unverified Commit 9c471a94 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

ImageProvider.toString uses double.toStringAsFixed (#131348)

This provides consistency for web vs VM (and is more consistent with how we do doubles everywhere else in toStrings).
parent f5f36ec0
......@@ -185,5 +185,5 @@ class NetworkImage extends image_provider.ImageProvider<image_provider.NetworkIm
int get hashCode => Object.hash(url, scale);
@override
String toString() => '${objectRuntimeType(this, 'NetworkImage')}("$url", scale: $scale)';
String toString() => '${objectRuntimeType(this, 'NetworkImage')}("$url", scale: ${scale.toStringAsFixed(1)})';
}
......@@ -215,6 +215,5 @@ class NetworkImage
int get hashCode => Object.hash(url, scale);
@override
String toString() =>
'${objectRuntimeType(this, 'NetworkImage')}("$url", scale: $scale)';
String toString() => '${objectRuntimeType(this, 'NetworkImage')}("$url", scale: ${scale.toStringAsFixed(1)})';
}
......@@ -1618,7 +1618,7 @@ class FileImage extends ImageProvider<FileImage> {
int get hashCode => Object.hash(file.path, scale);
@override
String toString() => '${objectRuntimeType(this, 'FileImage')}("${file.path}", scale: $scale)';
String toString() => '${objectRuntimeType(this, 'FileImage')}("${file.path}", scale: ${scale.toStringAsFixed(1)})';
}
/// Decodes the given [Uint8List] buffer as an image, associating it with the
......@@ -1722,7 +1722,7 @@ class MemoryImage extends ImageProvider<MemoryImage> {
int get hashCode => Object.hash(bytes.hashCode, scale);
@override
String toString() => '${objectRuntimeType(this, 'MemoryImage')}(${describeIdentity(bytes)}, scale: $scale)';
String toString() => '${objectRuntimeType(this, 'MemoryImage')}(${describeIdentity(bytes)}, scale: ${scale.toStringAsFixed(1)})';
}
/// Fetches an image from an [AssetBundle], associating it with the given scale.
......@@ -1863,7 +1863,7 @@ class ExactAssetImage extends AssetBundleImageProvider {
int get hashCode => Object.hash(keyName, scale, bundle);
@override
String toString() => '${objectRuntimeType(this, 'ExactAssetImage')}(name: "$keyName", scale: $scale, bundle: $bundle)';
String toString() => '${objectRuntimeType(this, 'ExactAssetImage')}(name: "$keyName", scale: ${scale.toStringAsFixed(1)}, bundle: $bundle)';
}
// A completer used when resolving an image fails sync.
......
......@@ -159,6 +159,12 @@ void main() {
expect(imageCache.statusForKey(provider).untracked, false);
expect(imageCache.pendingImageCount, 1);
}, skip: kIsWeb); // [intended] The web cannot load files.
test('ImageProvider toStrings', () async {
expect(const NetworkImage('test', scale: 1.21).toString(), 'NetworkImage("test", scale: 1.2)');
expect(const ExactAssetImage('test', scale: 1.21).toString(), 'ExactAssetImage(name: "test", scale: 1.2, bundle: null)');
expect(MemoryImage(Uint8List(0), scale: 1.21).toString(), equalsIgnoringHashCodes('MemoryImage(Uint8List#00000, scale: 1.2)'));
});
}
class FakeCodec implements Codec {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment