states_rebuilder
states_rebuilder copied to clipboard
implicit animation is skipped if parent widget calls setState
video:
https://user-images.githubusercontent.com/48729942/163563833-59af7c20-6549-4a14-b6d1-6cae9a9cf24a.mp4
import 'package:flutter/material.dart';
import 'package:states_rebuilder/states_rebuilder.dart';
class DemoScreen extends StatefulWidget {
const DemoScreen({
Key? key,
}) : super(key: key);
@override
State<DemoScreen> createState() => _DemoScreenState();
}
class _DemoScreenState extends State<DemoScreen> {
double height = 100;
void toggleHeight() {
height = height == 100 ? 50 : 100;
setState(() {});
}
@override
Widget build(BuildContext context) {
final animation = RM.injectAnimation(
duration: const Duration(seconds: 1),
curve: Curves.linear,
);
return Scaffold(
body: ListView(
children: [
SizedBox(height: 40),
TextButton(
child: Text('toggle'),
onPressed: toggleHeight,
),
TextButton(
child: Text('setState(() {});'),
onPressed: () {
print('setState(() {});');
setState(() {});
},
),
OnAnimationBuilder(
listenTo: animation,
builder: (animate) {
final height = animate(this.height)!;
return Container(
height: height,
width: 50,
color: Colors.blue,
);
},
),
],
),
);
}
}
Hi @altynbek132 Do not define injectAnimation inside the build method.
@GIfatahTH did not help
@altynbek132 So Sorry for my lateness; This is a bug and it is fixed.
Check version 6.1.0 the bug is fixed.