Skip to content

Commit

Permalink
Use package http (#234)
Browse files Browse the repository at this point in the history
* Use package http

* delete test
  • Loading branch information
dnfield authored Feb 20, 2024
1 parent 5bc6a02 commit 02389b1
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 94 deletions.
4 changes: 4 additions & 0 deletions packages/vector_graphics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 1.1.11

- Use package:http to drop dependency on dart:html.

## 1.1.10+1

- Add missing save before clip.
Expand Down
24 changes: 0 additions & 24 deletions packages/vector_graphics/lib/src/_http_io.dart

This file was deleted.

21 changes: 0 additions & 21 deletions packages/vector_graphics/lib/src/_http_web.dart

This file was deleted.

5 changes: 0 additions & 5 deletions packages/vector_graphics/lib/src/http.dart

This file was deleted.

11 changes: 7 additions & 4 deletions packages/vector_graphics/lib/src/loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';

import 'http.dart';
import 'package:http/http.dart' as http;

/// An interface that can be implemented to support decoding vector graphic
/// binary assets from different byte sources.
Expand Down Expand Up @@ -145,17 +144,21 @@ class NetworkBytesLoader extends BytesLoader {
const NetworkBytesLoader(
this.url, {
this.headers,
});
http.Client? httpClient,
}) : _httpClient = httpClient;

/// The HTTP headers to use for the network request.
final Map<String, String>? headers;

/// The [Uri] of the resource to request.
final Uri url;

final http.Client? _httpClient;

@override
Future<ByteData> loadBytes(BuildContext? context) async {
final Uint8List bytes = await httpGet(url, headers: headers);
final http.Client client = _httpClient ?? http.Client();
final Uint8List bytes = (await client.get(url, headers: headers)).bodyBytes;
return bytes.buffer.asByteData();
}

Expand Down
7 changes: 4 additions & 3 deletions packages/vector_graphics/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: vector_graphics
description: A vector graphics rendering package for Flutter.
version: 1.1.10+1
version: 1.1.11
homepage: https://github.com/dnfield/vector_graphics

environment:
Expand All @@ -10,13 +10,14 @@ environment:
dependencies:
flutter:
sdk: flutter
vector_graphics_codec: 1.1.10+1
http: ^1.2.1
vector_graphics_codec: 1.1.11

dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^1.0.0
vector_graphics_compiler: 1.1.10+1
vector_graphics_compiler: 1.1.11

# Comment out before publishing
dependency_overrides:
Expand Down
33 changes: 0 additions & 33 deletions packages/vector_graphics/test/vector_graphics_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -502,39 +502,6 @@ void main() {
expect(exception.toString(), contains(loader.toString()));
});

testWidgets(
'(WebOnly) creates OpacityLayer, TransformLayer, and ColorFilterLayer to draw picture',
(WidgetTester tester) async {
final TestAssetBundle testBundle = TestAssetBundle();

await tester.pumpWidget(
DefaultAssetBundle(
bundle: testBundle,
child: const Directionality(
textDirection: TextDirection.ltr,
child: VectorGraphic(
loader: AssetBytesLoader('foo.svg'),
colorFilter: ColorFilter.mode(Colors.red, BlendMode.srcIn),
opacity: AlwaysStoppedAnimation<double>(0.5),
),
),
),
);
await tester.pumpAndSettle();

expect(tester.layers.last, isA<PictureLayer>());
expect(
tester.layers[tester.layers.length - 2],
isA<ColorFilterLayer>().having(
(ColorFilterLayer layer) => layer.colorFilter,
'colorFilter',
const ColorFilter.mode(Colors.red, BlendMode.srcIn)));
expect(
tester.layers[tester.layers.length - 3],
isA<OpacityLayer>()
.having((OpacityLayer layer) => layer.alpha, 'alpha', 128));
}, skip: !kIsWeb);

testWidgets(
'Construct vector graphic with drawPicture strategy',
(WidgetTester tester) async {
Expand Down
4 changes: 4 additions & 0 deletions packages/vector_graphics_codec/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 1.1.11

- Use package:http to drop dependency on dart:html.

## 1.1.10+1

- Add missing save before clip.
Expand Down
2 changes: 1 addition & 1 deletion packages/vector_graphics_codec/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: vector_graphics_codec
description: An encoding library for `package:vector_graphics`
version: 1.1.10+1
version: 1.1.11
homepage: https://github.com/dnfield/vector_graphics

environment:
Expand Down
4 changes: 4 additions & 0 deletions packages/vector_graphics_compiler/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 1.1.11

- Use package:http to drop dependency on dart:html.

## 1.1.10+1

- Add missing save before clip.
Expand Down
6 changes: 3 additions & 3 deletions packages/vector_graphics_compiler/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: vector_graphics_compiler
description: A compiler for `package:vector_graphics`.
version: 1.1.10+1
version: 1.1.11
homepage: https://github.com/dnfield/vector_graphics

executables:
Expand All @@ -14,7 +14,7 @@ dependencies:
meta: ^1.7.0
path_parsing: ^1.0.1
xml: ^6.3.0
vector_graphics_codec: 1.1.10+1
vector_graphics_codec: 1.1.11
path: ^1.8.0

dev_dependencies:
Expand All @@ -25,7 +25,7 @@ dev_dependencies:
sdk: flutter
flutter_test:
sdk: flutter
vector_graphics: 1.1.10+1
vector_graphics: 1.1.11

# Comment out before publishing
dependency_overrides:
Expand Down

0 comments on commit 02389b1

Please sign in to comment.