From 9db1dbfe8556c80a4386baca0ea6d2ac852621b6 Mon Sep 17 00:00:00 2001 From: matt Sullivan Date: Thu, 10 Jun 2021 14:55:17 -0700 Subject: [PATCH] Replace univeral_io dependency with http --- lib/src/widgets/rive_animation.dart | 40 ++++++++++++++++------------- pubspec.yaml | 4 +-- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/lib/src/widgets/rive_animation.dart b/lib/src/widgets/rive_animation.dart index 071fe3d..9075c3e 100644 --- a/lib/src/widgets/rive_animation.dart +++ b/lib/src/widgets/rive_animation.dart @@ -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 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 { /// Loads a Rive file from an HTTP source and configures artboard, animation, /// and controller. - void _loadNetwork() { - final client = HttpClient(); - final contents = []; + Future _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 = []; - 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 diff --git a/pubspec.yaml b/pubspec.yaml index 265f335..63df537 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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: