mirror of
https://github.com/rive-app/rive-flutter.git
synced 2025-11-09 01:16:42 +08:00
We'll need to decide on the Enum case for getting the `Type`. Long term it might be better to just not have this to avoid breaking changes. If we decide to remove that, or how it is currently in the PR with the extended conditions, it's a breaking change. The changes to `LocalAssetLoader` aren't breaking though, I realise now. I also removed deprecated things. Diffs= 1a8b3c7cc feat!: add audio out-of-band (#7037) 99d28e1ac Xxxx randomization updates part 2 (#7097) a0004fa72 Xxxx support random transitions (#7094) edac19b06 support randomizing transitions (#7082) Co-authored-by: Gordon <pggordonhayes@gmail.com>
49 lines
1.2 KiB
Dart
49 lines
1.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:rive/rive.dart';
|
|
|
|
class RiveAudioOutOfBandExample extends StatefulWidget {
|
|
const RiveAudioOutOfBandExample({super.key});
|
|
|
|
@override
|
|
State<RiveAudioOutOfBandExample> createState() =>
|
|
_RiveAudioOutOfBandExampleState();
|
|
}
|
|
|
|
class _RiveAudioOutOfBandExampleState extends State<RiveAudioOutOfBandExample> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_loadRiveFile();
|
|
}
|
|
|
|
RiveFile? _riveAudioAssetFile;
|
|
|
|
Future<void> _loadRiveFile() async {
|
|
final riveFile = await RiveFile.asset(
|
|
'assets/ping_pong_audio_demo.riv',
|
|
assetLoader: LocalAssetLoader(audioPath: 'assets/audio'),
|
|
);
|
|
setState(() {
|
|
_riveAudioAssetFile = riveFile;
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (_riveAudioAssetFile == null) {
|
|
return const Center(child: CircularProgressIndicator());
|
|
}
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Rive Audio [Out-of-Band]'),
|
|
),
|
|
body: RiveAnimation.direct(
|
|
_riveAudioAssetFile!,
|
|
stateMachines: const ['State Machine 1'],
|
|
fit: BoxFit.cover,
|
|
),
|
|
);
|
|
}
|
|
}
|