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

View File

@ -1,6 +1,6 @@
name: rive 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. 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 repository: https://github.com/rive-app/rive-flutter
homepage: https://rive.app homepage: https://rive.app
@ -12,8 +12,8 @@ dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
graphs: ^2.0.0 graphs: ^2.0.0
http: ^0.13.3
meta: ^1.3.0 meta: ^1.3.0
universal_io: ^2.0.4
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: