-
Notifications
You must be signed in to change notification settings - Fork 229
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description
Animations that were previously going out of bounds of the artboard are now clipped inside the artboard
Steps To Reproduce
Steps to reproduce the behavior:
- Use the .riv file
- The animation will clip inside the artboard
- Use this code
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:rive/rive.dart';
import 'package:youtrust/widgets/hooks/async_scope.dart';
/// A hook widget that displays a Rive animation with caching to prevent
/// restarting on rebuild. Use this for tab icons and other widgets
/// that should maintain their animation state across rebuilds.
class CachedRiveAnimation extends HookWidget {
const CachedRiveAnimation({
required this.assetPath,
this.artboard,
this.stateMachine,
this.fit = Fit.contain, // I tried cover and this did not work as well
this.alignment = Alignment.center,
this.placeHolder,
super.key,
});
final String assetPath;
final String? artboard;
final String? stateMachine;
final Fit fit;
final Alignment alignment;
final Widget? placeHolder;
@override
Widget build(BuildContext context) {
final scope = useAsyncScope();
final fileLoader = useMemoized(
() => FileLoader.fromAsset(
assetPath,
riveFactory: Factory.rive,
),
[assetPath],
);
final state = useState<RiveState>(RiveLoading());
final controller = useState<RiveWidgetController?>(null);
useEffect(
() {
scope.run(() async {
try {
final file = await fileLoader.file();
final newController = RiveWidgetController(
file,
artboardSelector: artboard != null
? ArtboardNamed(artboard!)
: const ArtboardDefault(),
stateMachineSelector: stateMachine != null
? StateMachineNamed(stateMachine!)
: const StateMachineDefault(),
);
controller.value = newController;
state.value = RiveLoaded(
file: file,
controller: newController,
viewModelInstance: null,
);
} on Exception catch (e, stackTrace) {
state.value = RiveFailed(e, stackTrace);
}
});
return () {
controller.value?.dispose();
};
},
[fileLoader, artboard, stateMachine],
);
return switch (state.value) {
RiveLoaded(controller: final controller) => RiveWidget(
controller: controller,
fit: fit,
alignment: alignment,
),
RiveLoading() => placeHolder ?? const SizedBox.shrink(),
RiveFailed() => placeHolder ?? const SizedBox.shrink(),
};
}
}
Source .riv/.rev file
Expected behavior
After migrating from 0.13.x to 0.14.0 it became clipped inside the artboard
Screenshots
Device & Versions (please complete the following information)
- Device: iPhone 14 Pro
- OS: iOS 26.2
- Flutter Version: Copy-paste the output of
flutter --version
Flutter 3.35.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision ac4e799d23 (3 months ago) • 2025-09-26 12:05:09 -0700
Engine • hash 0274ead41f6265309f36e9d74bc8c559becd5345 (revision d3d45dcf25) (2 months ago) •
2025-09-26 16:45:18.000Z
Tools • Dart 3.9.2 • DevTools 2.48.0
Additional context
On 0.13.x it worked all fine
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working