When I press the arrow button on the left using the animation container, I want it to slide down, but the picture is loaded before and it gives an error. How do I synchronize the picture with the container?
here I gave the animated container in the picture. To grow in the picture at the same time as the growth rate of the container, but it did not happen. I tried using the Animation control but didn't understand exactly how to use it in the Animation container.
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import '../models/question_model.dart';
import 'package:date_format/date_format.dart';
class ActiveQuestion extends StatefulWidget {
final Question question;
ActiveQuestion({Key key, this.question}) : super(key: key);
@override
_ActiveQuestionState createState() => _ActiveQuestionState();
}
class _ActiveQuestionState extends State<ActiveQuestion> with SingleTickerProviderStateMixin{
bool tapped = false;
double _margin = 15;
double _height = 120;
Color _color = Colors.white;
@override
Widget build(BuildContext context) {
return AnimatedContainer(
duration: Duration(milliseconds: 100),
margin: EdgeInsets.all(_margin),
width: double.infinity,
height: _height,
decoration: BoxDecoration(
color: _color,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.black,width: 3.0)
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (!tapped)
Flexible(
flex: 1,
child: IconButton(
icon: Icon(Icons.arrow_downward),
onPressed: () {
setState(() {
_height +=250;
tapped = tapped ? false : true;
});
},
),
),
if (tapped)
Flexible(
flex: 1,
child: IconButton(
icon: Icon(Icons.arrow_upward),
onPressed: () {
setState(() {
_height -=250;
tapped = tapped ? false : true;
});
},
),
),
Flexible(
flex: 4,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(child: Text(widget.question.title,style: GoogleFonts.rokkitt(fontSize: 20),)),
],
),
SizedBox(height: 10,),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Icon(Icons.comment),
Text(widget.question.answerCount.toString(),style: GoogleFonts.rokkitt(fontSize: 18),),
],
),
Text("@" + widget.question.name,style: GoogleFonts.rokkitt(fontSize: 18),),
Text('${formatDate(DateTime.parse(widget.question.time),[dd,'.',mm,".",yy," ",HH,":",nn])} ',style: GoogleFonts.rokkitt(fontSize: 18),),
],
),
],
),
),
],
),
if(tapped)
Divider(thickness: 1,),
if (tapped)
AnimatedContainer(
width: double.infinity,
height: _height,
duration: Duration(milliseconds: 1000),
child: SizedBox(
child: Image(
fit: BoxFit.fitWidth,
image: NetworkImage(widget.question.questPath,),
),
),
)
],
),
);
}
}