0

I want to use AnimatedSize, in child of AnimatedPositioned but i get the exception.

this is my code :

AnimatedPositioned( duration: Duration(seconds: 2), curve: Curves.fastLinearToSlowEaseIn, top: isProfileSelected ? 100 : 0, child: Transform.translate( offset: Offset(isProfileSelected ? MediaQuery.of(context).size.width / 2 - 53 :MediaQuery.of(context).size.width / 2 - 38, 90 / 2), child: AnimatedSize( curve: Curves.fastOutSlowIn, child: isProfileSelected ? SizedBox( width: 106.0, child: circleAvatar(106, 106), ) : SizedBox( width: 76.0, child: circleAvatar(76, 76), ), ), ), ), 
3
  • try adding a duration to AnimatedSize Commented Nov 22, 2020 at 17:59
  • can you add the the exception that your are getting? Commented Nov 22, 2020 at 17:59
  • This exception (The following assertion was thrown building Positioned(top: 100.0): 'package:flutter/src/rendering/animated_size.dart': Failed assertion: line 86 pos 15: 'vsync != null': is not true.) Commented Nov 23, 2020 at 7:30

1 Answer 1

1

add this to your class state

class _MyWidgetState extends State<_MyWidget> with SingleTickerProviderStateMixin { ............. AnimatedPositioned( duration: Duration(seconds: 2), curve: Curves.fastLinearToSlowEaseIn, top: isProfileSelected ? 100 : 0, child: Transform.translate( offset: Offset(isProfileSelected ? MediaQuery.of(context).size.width / 2 - 53 :MediaQuery.of(context).size.width / 2 - 38, 90 / 2), child: AnimatedSize( vsync: this, //This must be required duration: Duration(milliseconds: 200), //Duration is also required curve: Curves.fastOutSlowIn, child: isProfileSelected ? SizedBox( width: 106.0, child: circleAvatar(106, 106), ) : SizedBox( width: 76.0, child: circleAvatar(76, 76), ), ), ), ), ...................... 

}

Sign up to request clarification or add additional context in comments.

1 Comment

The named parameter 'vsync' isn't defined. This is wrong. Or maybe too old, but vsync is not a property of AnimatedSize nor it is part of AnimatedPositioned.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.