mirror of
https://github.com/rive-app/rive-flutter.git
synced 2025-07-15 06:30:53 +08:00
Revving format to 2 with smaller string encoding.
This commit is contained in:
example
assets
blue_artboard.rivcolors_juice.rivcubic_work.rivdraworderanimation_3.rivjet_fighter.rivping_pong.rivtape_deck.rivteeny_tiny.rivweb_&_desktop_2.riv
lib
lib/src
core/field_types
rive_core/runtime
utilities/binary_buffer
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
example/assets/teeny_tiny.riv
Normal file
BIN
example/assets/teeny_tiny.riv
Normal file
Binary file not shown.
Binary file not shown.
@ -44,7 +44,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
|
||||
// Load the animation file from the bundle, note that you could also
|
||||
// download this. The RiveFile just expects a list of bytes.
|
||||
rootBundle.load('assets/colors_juice.riv').then(
|
||||
rootBundle.load('assets/teeny_tiny.riv').then(
|
||||
(data) async {
|
||||
var file = RiveFile();
|
||||
// Load the RiveFile from the binary data.
|
||||
@ -56,7 +56,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
// Add a controller to play back a known animation on the main/default
|
||||
// artboard.We store a reference to it so we can toggle playback.
|
||||
artboard.addController(
|
||||
_controller = SimpleAnimation('walk'),
|
||||
_controller = SimpleAnimation('idle'),
|
||||
);
|
||||
setState(() => _riveArtboard = artboard);
|
||||
}
|
||||
|
@ -3,7 +3,8 @@ import 'package:rive/src/utilities/binary_buffer/binary_reader.dart';
|
||||
|
||||
class CoreStringType extends CoreFieldType<String> {
|
||||
@override
|
||||
String deserialize(BinaryReader reader) => reader.readString();
|
||||
String deserialize(BinaryReader reader) =>
|
||||
reader.readString(explicitLength: false);
|
||||
|
||||
@override
|
||||
String lerp(String from, String to, double f) => from;
|
||||
|
@ -4,7 +4,7 @@ import 'package:rive/src/utilities/binary_buffer/binary_reader.dart';
|
||||
import 'exceptions/rive_format_error_exception.dart';
|
||||
|
||||
class RuntimeHeader {
|
||||
static const int majorVersion = 1;
|
||||
static const int majorVersion = 2;
|
||||
static const int minorVersion = 0;
|
||||
static const String fingerprint = 'RIVE';
|
||||
final int ownerId;
|
||||
|
@ -115,8 +115,8 @@ class BinaryReader {
|
||||
/// Read a string encoded into the stream. Strings are encoded with a varuint
|
||||
/// integer length written first followed by length number of utf8 encoded
|
||||
/// bytes.
|
||||
String readString() {
|
||||
int length = readVarUint();
|
||||
String readString({bool explicitLength = true}) {
|
||||
int length = explicitLength ? readVarUint() : buffer.lengthInBytes;
|
||||
String value = _utf8Decoder.convert(Uint8List.view(
|
||||
buffer.buffer, buffer.offsetInBytes + _readIndex, length));
|
||||
_readIndex += length;
|
||||
|
@ -151,9 +151,11 @@ class BinaryWriter {
|
||||
/// Encode a string into the buffer. Strings are encoded with a varuint
|
||||
/// integer length written first followed by length number of utf8 encoded
|
||||
/// bytes.
|
||||
void writeString(String value) {
|
||||
void writeString(String value, {bool explicitLength = true}) {
|
||||
var list = _utf8Encoder.convert(value);
|
||||
writeVarUint(list.length);
|
||||
if (explicitLength) {
|
||||
writeVarUint(list.length);
|
||||
}
|
||||
write(list);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user