Flutter compass is giving very laggy performance on real device with transform.rotate. Is there any better animation for this purpose to smoothen out the rotation of compass widget.
My code is as below
class _AnimationRotationState extends State<AnimationRotation>
with SingleTickerProviderStateMixin {
final double angleMinus = pi / 4.1;
double _changing = 0.0;
Stream<QiblahDirection> qiblahStream = FlutterQiblah.qiblahStream;
@override
void initState() {
super.initState();
_qiblahStream();
}
void _qiblahStream() {
qiblahStream.listen((event) {
setState(() {
var value = event.qiblah;
_changing = -2 * pi * (value / 360);
});
});
}
@override
void dispose() {
// qiblahStream.
super.dispose();
}
@override
Widget build(BuildContext context) {
return Stack(clipBehavior: Clip.hardEdge, children: [
Transform.rotate(
angle: _changing,
child: Transform.rotate(
angle: 0.00,
child: Image.asset("assets/compass.png"),
),
),