Skip to content

Commit

Permalink
Cache by default
Browse files Browse the repository at this point in the history
  • Loading branch information
dnfield committed Nov 28, 2018
1 parent cf38f25 commit 99feec0
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# CHANGES

## 0.7.0+1

- By default, `SvgPicture.asset` will now cache the asset. We already cached the
final picture, but the caching included any color filtering provided on the
image. This is problematic if the color is animated. See
https://github.com/dnfield/flutter_svg/issues/33

## 0.7.0

- **BREAKING** Correct erroneous `width` and `height` processing on the root element.
- **BREAKING** Correct erroneous `width` and `height` processing on the root
element.
- Previously, `width` and `height` were treated as synonyms for the width and
height of the `viewBox`. This is not correct, and resulted in meaningful
rendering errors in some scenarios compared to Chrome. Fixing this makes the
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.7.0"
version: "0.7.0+1"
meta:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions lib/avd.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ class AvdPicture extends SvgPicture {
: this(
ExactAssetPicture(
allowDrawingOutsideViewBox == true
? avdByteDecoderOutsideViewBox
: avdByteDecoder,
? avdStringDecoderOutsideViewBox
: avdStringDecoder,
assetName,
bundle: bundle,
package: package,
Expand Down
9 changes: 4 additions & 5 deletions lib/src/picture_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ abstract class AssetBundlePictureProvider
/// const constructors so that they can be used in const expressions.
const AssetBundlePictureProvider(this.decoder) : assert(decoder != null);

final PictureInfoDecoder<Uint8List> decoder;
final PictureInfoDecoder<String> decoder;

/// Converts a key into an [PictureStreamCompleter], and begins fetching the
/// picture using [_loadAsync].
Expand All @@ -416,13 +416,12 @@ abstract class AssetBundlePictureProvider
/// This function is used by [load].
@protected
Future<PictureInfo> _loadAsync(AssetBundlePictureKey key) async {
final ByteData data = await key.bundle.load(key.name);
final String data = await key.bundle.loadString(key.name);
if (data == null) {
throw 'Unable to read data';
}

return await decoder(
data.buffer.asUint8List(), key.colorFilter, key.toString());
return await decoder(data, key.colorFilter, key.toString());
}
}

Expand Down Expand Up @@ -760,7 +759,7 @@ class ExactAssetPicture extends AssetBundlePictureProvider {
/// included in a package. See the documentation for the [ExactAssetPicture] class
/// itself for details.
const ExactAssetPicture(
PictureInfoDecoder<Uint8List> decoder,
PictureInfoDecoder<String> decoder,
this.assetName, {
this.bundle,
this.package,
Expand Down
4 changes: 2 additions & 2 deletions lib/svg.dart
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ class SvgPicture extends StatefulWidget {
BlendMode colorBlendMode = BlendMode.srcIn,
}) : pictureProvider = ExactAssetPicture(
allowDrawingOutsideViewBox == true
? svgByteDecoderOutsideViewBox
: svgByteDecoder,
? svgStringDecoderOutsideViewBox
: svgStringDecoder,
assetName,
bundle: bundle,
package: package,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: flutter_svg
description: An SVG rendering and widget library for Flutter, which allows painting and displaying Scalable Vector Graphics 1.1 files.
author: Dan Field <dfield@gmail.com>
homepage: https://github.com/dnfield/flutter_svg
version: 0.7.0
version: 0.7.0+1

dependencies:
path_drawing: ^0.4.0
Expand Down

0 comments on commit 99feec0

Please sign in to comment.