During the splash screen, when user is auto signed in, after a short while, his avatar pops up.
Has this modify the size of the container, the Center
widget repositions the whole thing right away where I would have preferred a quick but smooth animation.
I wrote a minimal code to reproduce the situation:
class MyWidget extends StatefulWidget {
@override State<MyWidget> createState()=>_MyWidgetState();
}
class _MyWidgetState extends State<MyWidget> {
/// Whether to show the additional container?
bool _showContainer = false;
@override
Widget build(BuildContext context) {
return Center(child:
ListView(
shrinkWrap:true,
children:[
Text(
'Hello, World!',
style: Theme.of(context).textTheme.headlineMedium,
),
if(_showContainer)
Container(
color: Colors.pink,
width: 100,
height: 300,
child: const Text("How to make the apparition smooth and animated"),
),
ElevatedButton(
onPressed: ()=>setState(()=>_showContainer=true),
child: const Text("SHOW CONTAINER"),
),
]),
);
}
}
By clicking on the button, you make the additional container appears. But to make the re-entering smooth and animated?
The dart pad for convenience: https://dartpad.dev/?id=db58260305bd6080d514f8b736e4ccd3
2
Answers
Can you try this
Use
AnimatedSize
Widget