这是我的代码
class TitleGreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
double height = MediaQuery.of(context).size.height;
print('title green buile');
return Positioned(
key: UniqueKey(),
top: 0.0,
child: GestureDetector(
onTap: () {
Provider.of<MoveDetailsDesVisibility>(context)
.setViisibility(1, context);
},
child: AnimatedContainer(
key: UniqueKey(),
duration: Duration(seconds: 0),
padding: EdgeInsets.only(
top: Provider.of<MoveDetailsDesVisibility>(context)
.des2visibility
? (1 / 4) * height + 225
: (1 / 4) * height + 115),
height: Provider.of<MoveDetailsDesVisibility>(context)
.des2visibility
? (1 / 4) * height + 260
: (1 / 4) * height + 150,
//150
width: (3 / 4) * width - 11.5,
decoration: BoxDecoration(
color: Color(0xFF24DC25),
borderRadius:
BorderRadius.only(bottomLeft: Radius.circular(30))),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
SizedBox(
width: 5,
),
Transform.rotate(
key: UniqueKey(),
angle: Provider.of<MoveDetailsDesVisibility>(context)
.des2visibility?-80:0,
child:
Image.asset(
'assets/icons/faNote.png',
fit: BoxFit.cover,
width: 20,
height: 20,
)),
SizedBox(
width: 9,
),
Text(
'توضیحات مربی',
style: TextStyle(
color: Colors.white,
fontSize: 14,
fontWeight: FontWeight.bold),
)
],
),
],
),
)));
}
}
在此代码中,当我更新提供程序并更改提供程序的值时,在此代码中调用了此窗口小部件类,并调用了build方法,但是这种编码检查“ des2visibility”的值是否为false或true时不要调用,并且图像窗口小部件在整个过程中不进行转换构建在错误位置的小部件的一部分,我与使用者进行了测试,并获取了整个小部件的键值,但不起作用
答案 0 :(得分:0)
这是一个无状态的小部件,应使用有状态的小部件Titlegreen