Replace univeral_io dependency with http

This commit is contained in:
matt Sullivan
2021-06-10 14:55:17 -07:00
parent e152506e9e
commit 9db1dbfe85
2 changed files with 24 additions and 20 deletions

View File

@ -4,7 +4,7 @@ import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:rive/rive.dart';
import 'package:rive/src/rive_core/artboard.dart';
import 'package:universal_io/io.dart';
import 'package:http/http.dart' as http;
enum _Source {
asset,
@ -22,6 +22,7 @@ class RiveAnimation extends StatefulWidget {
final List<String> stateMachines;
final BoxFit? fit;
final Alignment? alignment;
/// Widget displayed while the rive is loading.
final Widget? placeHolder;
@ -83,24 +84,27 @@ class _RiveAnimationState extends State<RiveAnimation> {
/// Loads a Rive file from an HTTP source and configures artboard, animation,
/// and controller.
void _loadNetwork() {
final client = HttpClient();
final contents = <int>[];
Future<void> _loadNetwork() async {
final res = await http.get(Uri.parse(widget.name));
final data = ByteData.view(res.bodyBytes.buffer);
_init(data);
// final client = HttpClient();
// final contents = <int>[];
client
.getUrl(Uri.parse(widget.name))
.then(
(req) async => req.close(),
)
.then(
(res) => res.listen(
contents.addAll,
onDone: () {
final data = ByteData.view(Uint8List.fromList(contents).buffer);
_init(data);
},
),
);
// client
// .getUrl(Uri.parse(widget.name))
// .then(
// (req) async => req.close(),
// )
// .then(
// (res) => res.listen(
// contents.addAll,
// onDone: () {
// final data = ByteData.view(Uint8List.fromList(contents).buffer);
// _init(data);
// },
// ),
// );
}
/// Initializes the artboard, animation, and controller

View File

@ -1,6 +1,6 @@
name: rive
description: Rive 2 Flutter Runtime. This package provides runtime functionality for playing back and interacting with animations built with the Rive editor available at https://rive.app.
version: 0.7.15
version: 0.7.16
repository: https://github.com/rive-app/rive-flutter
homepage: https://rive.app
@ -12,8 +12,8 @@ dependencies:
flutter:
sdk: flutter
graphs: ^2.0.0
http: ^0.13.3
meta: ^1.3.0
universal_io: ^2.0.4
dev_dependencies:
flutter_test: